Skip to content

Commit f90d568

Browse files
authored
feat(step-generation): py command for blowout in waste chute (#17837)
1 parent fa3180d commit f90d568

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import { describe, it, expect, vi } from 'vitest'
2+
import { WASTE_CHUTE_CUTOUT } from '@opentrons/shared-data'
23
import {
4+
DEFAULT_PIPETTE,
35
getInitialRobotStateStandard,
46
getSuccessResult,
57
makeContext,
68
} from '../fixtures'
79
import { blowOutInWasteChute } from '../commandCreators/compound'
8-
import type { InvariantContext, PipetteEntities, RobotState } from '../types'
10+
import type { InvariantContext, RobotState } from '../types'
911

1012
vi.mock('../getNextRobotStateAndWarnings/dispenseUpdateLiquidState')
1113

12-
const mockId = 'mockId'
13-
const mockPipEntities: PipetteEntities = {
14-
[mockId]: {
15-
name: 'p50_single_flex',
16-
id: mockId,
17-
spec: { channels: 1 },
18-
},
19-
} as any
20-
14+
const wasteChuteId = 'wasteChuteId'
2115
const invariantContext: InvariantContext = {
2216
...makeContext(),
23-
pipetteEntities: mockPipEntities,
17+
additionalEquipmentEntities: {
18+
[wasteChuteId]: {
19+
id: wasteChuteId,
20+
name: 'wasteChute',
21+
pythonName: 'mock_waste_chute_1',
22+
location: WASTE_CHUTE_CUTOUT,
23+
},
24+
},
2425
}
2526
const prevRobotState: RobotState = getInitialRobotStateStandard(
2627
invariantContext
@@ -30,8 +31,9 @@ describe('blowOutInWasteChute', () => {
3031
it('returns correct commands for blowing out in waste chute', () => {
3132
const result = blowOutInWasteChute(
3233
{
33-
pipetteId: mockId,
34+
pipetteId: DEFAULT_PIPETTE,
3435
flowRate: 10,
36+
wasteChuteId,
3537
},
3638
invariantContext,
3739
prevRobotState
@@ -41,7 +43,7 @@ describe('blowOutInWasteChute', () => {
4143
commandType: 'moveToAddressableArea',
4244
key: expect.any(String),
4345
params: {
44-
pipetteId: mockId,
46+
pipetteId: DEFAULT_PIPETTE,
4547
addressableAreaName: '1ChannelWasteChute',
4648
offset: { x: 0, y: 0, z: 0 },
4749
},
@@ -50,10 +52,15 @@ describe('blowOutInWasteChute', () => {
5052
commandType: 'blowOutInPlace',
5153
key: expect.any(String),
5254
params: {
53-
pipetteId: mockId,
55+
pipetteId: DEFAULT_PIPETTE,
5456
flowRate: 10,
5557
},
5658
},
5759
])
60+
expect(getSuccessResult(result).python).toBe(
61+
`
62+
mockPythonName.flow_rate.blow_out = 10
63+
mockPythonName.blow_out(mock_waste_chute_1)`.trim()
64+
)
5865
})
5966
})

step-generation/src/__tests__/blowoutUtil.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe('blowoutUtil', () => {
9494
expect(curryCommandCreator).toHaveBeenCalledWith(blowOutInWasteChute, {
9595
pipetteId: blowoutArgs.pipette,
9696
flowRate: 2.3,
97+
wasteChuteId,
9798
})
9899
})
99100
it('blowoutUtil curries blowout with dest plate params', () => {

step-generation/src/commandCreators/compound/blowOutInWasteChute.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,33 @@ import type { CommandCreator, CurriedCommandCreator } from '../../types'
1010
interface BlowOutInWasteChuteArgs {
1111
pipetteId: string
1212
flowRate: number
13+
wasteChuteId: string
1314
}
1415

1516
export const blowOutInWasteChute: CommandCreator<BlowOutInWasteChuteArgs> = (
1617
args,
1718
invariantContext,
1819
prevRobotState
1920
) => {
20-
const { pipetteId, flowRate } = args
21-
const pipetteChannels =
22-
invariantContext.pipetteEntities[pipetteId].spec.channels
21+
const { pipetteId, flowRate, wasteChuteId } = args
22+
const { pipetteEntities, additionalEquipmentEntities } = invariantContext
23+
const pipetteChannels = pipetteEntities[pipetteId].spec.channels
2324
const addressableAreaName = getWasteChuteAddressableAreaNamePip(
2425
pipetteChannels
2526
)
27+
const pipettePythonName = pipetteEntities[pipetteId].pythonName
28+
const wasteChutePythonName =
29+
additionalEquipmentEntities[wasteChuteId].pythonName
2630

27-
const commandCreators: CurriedCommandCreator[] = [
31+
const pythonCommandCreator: CurriedCommandCreator = () => ({
32+
commands: [],
33+
python:
34+
// The Python blow_out() does not take a flow rate argument, so we have to
35+
// reconfigure the pipette's default blow out rate instead:
36+
`${pipettePythonName}.flow_rate.blow_out = ${flowRate}\n` +
37+
`${pipettePythonName}.blow_out(${wasteChutePythonName})`,
38+
})
39+
const commandCreators = [
2840
curryCommandCreator(moveToAddressableArea, {
2941
pipetteId,
3042
addressableAreaName,
@@ -34,6 +46,7 @@ export const blowOutInWasteChute: CommandCreator<BlowOutInWasteChuteArgs> = (
3446
pipetteId,
3547
flowRate,
3648
}),
49+
pythonCommandCreator,
3750
]
3851

3952
return reduceCommandCreators(

step-generation/src/utils/misc.ts

+4
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,14 @@ export const blowoutUtil = (args: {
379379
}),
380380
]
381381
} else if (trashOrLabware === 'wasteChute') {
382+
const wasteChute = Object.values(additionalEquipmentEntities).find(
383+
ae => ae.name === 'wasteChute'
384+
)
382385
return [
383386
curryCommandCreator(blowOutInWasteChute, {
384387
pipetteId: pipette,
385388
flowRate,
389+
wasteChuteId: wasteChute?.id as string,
386390
}),
387391
]
388392
} else {

0 commit comments

Comments
 (0)