Skip to content

Commit

Permalink
fix(step-generation): modify curried command order for heater-shaker (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader authored May 22, 2023
1 parent c3f2240 commit acbf638
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 10 deletions.
82 changes: 81 additions & 1 deletion step-generation/src/__tests__/heaterShaker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
} from '@opentrons/shared-data'
import { heaterShaker } from '../commandCreators'
import { getModuleState } from '../robotStateSelectors'
import { getInitialRobotStateStandard, makeContext } from '../fixtures'
import { getErrorResult, getSuccessResult } from '../fixtures/commandFixtures'

import type { InvariantContext, RobotState, HeaterShakerArgs } from '../types'
import { getInitialRobotStateStandard, makeContext } from '../fixtures'

jest.mock('../robotStateSelectors')

Expand Down Expand Up @@ -163,4 +163,84 @@ describe('heaterShaker compound command creator', () => {
},
])
})
it('should not call deactivateShaker when it is not shaking but call activate temperature when setting target temp', () => {
heaterShakerArgs = {
...heaterShakerArgs,
rpm: null,
targetTemperature: 80,
}

const state = getInitialRobotStateStandard(invariantContext)

robotState = {
...state,
modules: {
...state.modules,
[HEATER_SHAKER_ID]: {
slot: HEATER_SHAKER_SLOT,
moduleState: {
type: 'heaterShakerModuleType',
targetSpeed: null,
},
} as any,
},
}

const result = heaterShaker(heaterShakerArgs, invariantContext, robotState)

expect(getSuccessResult(result).commands).toEqual([
{
commandType: 'heaterShaker/closeLabwareLatch',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
{
commandType: 'heaterShaker/setTargetTemperature',
key: expect.any(String),
params: {
celsius: 80,
moduleId: 'heaterShakerId',
},
},
])
})
it('should call to open latch last', () => {
heaterShakerArgs = {
...heaterShakerArgs,
latchOpen: true,
}

const state = getInitialRobotStateStandard(invariantContext)

robotState = {
...state,
modules: {
...state.modules,
[HEATER_SHAKER_ID]: {
slot: HEATER_SHAKER_SLOT,
} as any,
},
}

const result = heaterShaker(heaterShakerArgs, invariantContext, robotState)

expect(getSuccessResult(result).commands).toEqual([
{
commandType: 'heaterShaker/deactivateHeater',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
{
commandType: 'heaterShaker/openLabwareLatch',
key: expect.any(String),
params: {
moduleId: 'heaterShakerId',
},
},
])
})
})
24 changes: 15 additions & 9 deletions step-generation/src/commandCreators/compound/heaterShaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ export const heaterShaker: CommandCreator<HeaterShakerArgs> = (

const commandCreators: CurriedCommandCreator[] = []

if (args.latchOpen) {
commandCreators.push(
curryCommandCreator(heaterShakerOpenLatch, {
moduleId: args.module,
})
)
} else {
if (!args.latchOpen) {
commandCreators.push(
curryCommandCreator(heaterShakerCloseLatch, {
moduleId: args.module,
Expand All @@ -64,13 +58,17 @@ export const heaterShaker: CommandCreator<HeaterShakerArgs> = (
)
}

if (args.rpm === null) {
if (
args.rpm === null &&
'targetSpeed' in heaterShakerState &&
heaterShakerState.targetSpeed !== null
) {
commandCreators.push(
curryCommandCreator(heaterShakerStopShake, {
moduleId: args.module,
})
)
} else {
} else if (args.rpm !== null) {
commandCreators.push(
curryCommandCreator(heaterShakerSetTargetShakeSpeed, {
moduleId: args.module,
Expand All @@ -80,6 +78,14 @@ 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

0 comments on commit acbf638

Please sign in to comment.