Skip to content

Commit

Permalink
refactor(step-generation): openLatch should emit last in heaterShaker… (
Browse files Browse the repository at this point in the history
#14525)

… compound command

closes RQA-2361, RESC-195
  • Loading branch information
jerader authored Feb 21, 2024
1 parent 6079339 commit a80df7a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 9 deletions.
69 changes: 68 additions & 1 deletion step-generation/src/__tests__/heaterShaker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('heaterShaker compound command creator', () => {
},
])
})
it('should NOT delay and deactivate the heater shaker when a user specificies a timer tthat is 0 seconds', () => {
it('should NOT delay and deactivate the heater shaker when a user specificies a timer that is 0 seconds', () => {
heaterShakerArgs = {
...heaterShakerArgs,
rpm: 444,
Expand Down Expand Up @@ -163,6 +163,73 @@ describe('heaterShaker compound command creator', () => {
},
])
})
it('should delay and emit open latch last if open latch is specified', () => {
heaterShakerArgs = {
module: HEATER_SHAKER_ID,
rpm: null,
commandCreatorFnName: 'heaterShaker',
targetTemperature: null,
latchOpen: true,
timerMinutes: null,
timerSeconds: null,
}

heaterShakerArgs = {
...heaterShakerArgs,
rpm: 444,
targetTemperature: 80,
timerSeconds: 20,
timerMinutes: 0,
}
const result = heaterShaker(heaterShakerArgs, invariantContext, robotState)

expect(getSuccessResult(result).commands).toEqual([
{
commandType: 'heaterShaker/setTargetTemperature',
key: expect.any(String),
params: {
celsius: 80,
moduleId: 'heaterShakerId',
},
},
{
commandType: 'heaterShaker/setAndWaitForShakeSpeed',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
rpm: 444,
},
},
{
commandType: 'waitForDuration',
key: expect.any(String),
params: {
seconds: 20,
},
},
{
commandType: 'heaterShaker/deactivateShaker',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
{
commandType: 'heaterShaker/deactivateHeater',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
{
commandType: 'heaterShaker/openLabwareLatch',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
])
})
it('should not call deactivateShaker when it is not shaking but call activate temperature when setting target temp', () => {
heaterShakerArgs = {
...heaterShakerArgs,
Expand Down
16 changes: 8 additions & 8 deletions step-generation/src/commandCreators/compound/heaterShaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,6 @@ export const heaterShaker: CommandCreator<HeaterShakerArgs> = (
)
}

if (args.latchOpen) {
commandCreators.push(
curryCommandCreator(heaterShakerOpenLatch, {
moduleId: args.module,
})
)
}

if (
(args.timerMinutes != null && args.timerMinutes !== 0) ||
(args.timerSeconds != null && args.timerSeconds !== 0)
Expand Down Expand Up @@ -113,6 +105,14 @@ export const heaterShaker: CommandCreator<HeaterShakerArgs> = (
)
}

if (args.latchOpen) {
commandCreators.push(
curryCommandCreator(heaterShakerOpenLatch, {
moduleId: args.module,
})
)
}

return reduceCommandCreators(
commandCreators,
invariantContext,
Expand Down

0 comments on commit a80df7a

Please sign in to comment.