Skip to content

Commit cf17a9a

Browse files
authored
feat(step-generation): wire up vacuum step generation (#21319)
This PR builds command creators for all vacuum module actions except profiles (not yet added to PE). It also adds all state updater functions for the various emitted commands: open vent, close vent, set pump pressure, set pump power, and stop pump. The behavior should be as follows: - Initially, the vacuum vent is open, and the pump is off - Setting the pump state (power/pressure) _without_ a duration should hold that pump state indefinitely until explicitly turned off in a new step - Setting the pump state _with_ a duration should turn the pump off at the end of the duration. The vent may remain open or closed independently of this Closes EXEC-2563, Closes EXEC-2561
1 parent 67b8a44 commit cf17a9a

16 files changed

Lines changed: 889 additions & 53 deletions

File tree

protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/VacuumTools/VacuumModuleState.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ export function VacuumModuleState(props: VacuumModuleStateProps): JSX.Element {
2525
pumpText =
2626
vacuumState.modeType === VACUUM_MODE_POWER
2727
? t('vacuum.previous_state.pump.power', {
28-
power: vacuumState.currentPower,
28+
power: vacuumState.targetPower,
2929
})
3030
: t('vacuum.previous_state.pump.pressure', {
31-
pressure: vacuumState.currentPressure,
31+
pressure: vacuumState.targetPressure,
3232
})
3333
}
3434
return (

protocol-designer/src/steplist/formLevel/stepFormToArgs/vacuumFormToArgs.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,14 @@ const getPumpEndSettings = (args: {
8787
pumpDurationCheckbox: HydratedVacuumFormData['pumpDurationCheckbox']
8888
pumpDurationTime: HydratedVacuumFormData['pumpDurationTime']
8989
endingHoldVentCheckbox: HydratedVacuumFormData['endingHoldVentCheckbox']
90-
}): Partial<VacuumPumpAdvancedArgs> => {
90+
}): VacuumPumpAdvancedArgs | null => {
9191
const { pumpDurationCheckbox, pumpDurationTime, endingHoldVentCheckbox } =
9292
args
9393
if (!(pumpDurationCheckbox === true && pumpDurationTime != null)) {
94-
return {}
94+
return null
9595
}
9696
const duration = getTimeSecondsFromString(pumpDurationTime)
97-
return {
98-
duration,
99-
ventAfter: endingHoldVentCheckbox === true,
100-
}
97+
return { duration, ventAfter: endingHoldVentCheckbox === true }
10198
}
10299

103100
export const vacuumFormToArgs = (

step-generation/src/commandCreators/atomic/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ export { setTemperature } from './setTemperature'
3535
export { touchTip } from './touchTip'
3636
export { vacuumOpenVent } from './vacuumOpenVent'
3737
export { vacuumCloseVent } from './vacuumCloseVent'
38+
export { vacuumSetPumpPressure } from './vacuumSetPumpPressure'
39+
export { vacuumSetPumpPower } from './vacuumSetPumpPower'
3840
export { vacuumStopPump } from './vacuumStopPump'
3941
export { waitForTemperature } from './waitForTemperature'
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import * as errorCreators from '../../errorCreators'
2+
import { uuid } from '../../utils'
3+
14
import type { CommandCreator, VacuumCloseVentArgs } from '../../types'
25

36
// TODO: (nd, 2026-04-20) command creator implementation
@@ -6,8 +9,25 @@ export const vacuumCloseVent: CommandCreator<VacuumCloseVentArgs> = (
69
invariantContext,
710
prevRobotState
811
) => {
12+
const { moduleId } = args
13+
const module = invariantContext.moduleEntities[moduleId]
14+
15+
if (module == null) {
16+
return {
17+
errors: [errorCreators.missingModuleError()],
18+
}
19+
}
20+
21+
// TODO: (nd, 2026-04-20) implement Python emission
922
return {
10-
commands: [],
11-
python: '',
23+
commands: [
24+
{
25+
commandType: 'vacuumModule/closeVent',
26+
key: uuid(),
27+
params: {
28+
moduleId,
29+
},
30+
},
31+
],
1232
}
1333
}
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
import type { CommandCreator, VacuumOpenVentArgs } from '../../types'
1+
import * as errorCreators from '../../errorCreators'
2+
import { uuid } from '../../utils'
3+
4+
import type { VacuumModuleOpenVentCreateCommand } from '@opentrons/shared-data'
5+
import type { CommandCreator } from '../../types'
26

37
// TODO: (nd, 2026-04-20) command creator implementation
4-
export const vacuumOpenVent: CommandCreator<VacuumOpenVentArgs> = (
5-
args,
6-
invariantContext,
7-
prevRobotState
8-
) => {
8+
export const vacuumOpenVent: CommandCreator<
9+
VacuumModuleOpenVentCreateCommand['params']
10+
> = (args, invariantContext, prevRobotState) => {
11+
const { moduleId } = args
12+
const module = invariantContext.moduleEntities[moduleId]
13+
14+
if (module == null) {
15+
return {
16+
errors: [errorCreators.missingModuleError()],
17+
}
18+
}
19+
20+
// TODO: (nd, 2026-04-20) implement Python emission
921
return {
10-
commands: [],
11-
python: '',
22+
commands: [
23+
{
24+
commandType: 'vacuumModule/openVent',
25+
key: uuid(),
26+
params: {
27+
moduleId,
28+
},
29+
},
30+
],
1231
}
1332
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as errorCreators from '../../errorCreators'
2+
import { uuid } from '../../utils'
3+
4+
import type { CommandCreator, VacuumPumpPowerArgs } from '../../types'
5+
6+
// TODO: (nd, 2026-04-20) command creator implementation
7+
export const vacuumSetPumpPower: CommandCreator<VacuumPumpPowerArgs> = (
8+
args,
9+
invariantContext,
10+
prevRobotState
11+
) => {
12+
const { moduleId, powerPercent, duration, ventAfter } = args
13+
const module = invariantContext.moduleEntities[moduleId]
14+
15+
if (module == null) {
16+
return {
17+
errors: [errorCreators.missingModuleError()],
18+
}
19+
}
20+
21+
const holdArgs =
22+
duration != null
23+
? {
24+
duration,
25+
// defaults to true per PE command
26+
ventAfter: ventAfter ?? true,
27+
}
28+
: {}
29+
30+
// TODO: (nd, 2026-04-20) implement Python emission
31+
return {
32+
commands: [
33+
{
34+
commandType: 'vacuumModule/startSetVacuumPower',
35+
key: uuid(),
36+
params: {
37+
moduleId,
38+
percentPower: powerPercent,
39+
...holdArgs,
40+
},
41+
},
42+
],
43+
}
44+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as errorCreators from '../../errorCreators'
2+
import { uuid } from '../../utils'
3+
4+
import type { CommandCreator, VacuumPumpPressureArgs } from '../../types'
5+
6+
// TODO: (nd, 2026-04-20) command creator implementation
7+
export const vacuumSetPumpPressure: CommandCreator<VacuumPumpPressureArgs> = (
8+
args,
9+
invariantContext,
10+
prevRobotState
11+
) => {
12+
const { moduleId, gaugePressure, duration, ventAfter } = args
13+
const module = invariantContext.moduleEntities[moduleId]
14+
15+
if (module == null) {
16+
return {
17+
errors: [errorCreators.missingModuleError()],
18+
}
19+
}
20+
21+
const holdArgs =
22+
duration != null
23+
? {
24+
duration,
25+
// defaults to true per PE command
26+
ventAfter: ventAfter ?? true,
27+
}
28+
: {}
29+
30+
// TODO: (nd, 2026-04-20) implement Python emission
31+
return {
32+
commands: [
33+
{
34+
commandType: 'vacuumModule/startSetVacuumPressure',
35+
key: uuid(),
36+
params: {
37+
moduleId,
38+
gaugePressure,
39+
...holdArgs,
40+
// making this explicit for ease of use with statte upd
41+
},
42+
},
43+
],
44+
}
45+
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ export { replaceTip } from './replaceTip'
1717
export { thermocyclerProfileStep } from './thermocyclerProfileStep'
1818
export { thermocyclerStateStep } from './thermocyclerStateStep'
1919
export { transfer } from './transfer'
20-
export { vacuumSetPumpPower } from './vacuumSetPumpPower'
21-
export { vacuumSetPumpPressure } from './vacuumSetPumpPressure'
2220
export { vacuumSetPumpProfile } from './vacuumSetPumpProfile'
2321
export { waitForModuleTask } from './waitForModuleTask'

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

Lines changed: 0 additions & 13 deletions
This file was deleted.

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

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)