Skip to content

Commit ff69de7

Browse files
authored
feat(protocol-designer): update mixFormToArgs with new delay fields (#6575)
Closes #6348 * add new delay fields to mixFormToArgs * add test coverage to mixFormToArgs * refactor: make Flow types for inexact step-generation's Args types exact, and fix tests for command creators called with superfluous fields
1 parent 75a7545 commit ff69de7

File tree

14 files changed

+315
-105
lines changed

14 files changed

+315
-105
lines changed

protocol-designer/benchmarks/timelineGeneration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ bench(`commandCreatorsTimeline: mix ${times} times`, b => {
3939
dispenseOffsetFromBottomMm: 2,
4040
aspirateFlowRateUlSec: 5,
4141
dispenseFlowRateUlSec: 6,
42+
aspirateDelay: null,
43+
dispenseDelay: null,
4244
}),
4345
]
4446

protocol-designer/src/step-generation/__fixtures__/commandFixtures.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const DISPENSE_OFFSET_FROM_BOTTOM_MM = 3.2
5252
export const BLOWOUT_OFFSET_FROM_TOP_MM = 3.3
5353
const TOUCH_TIP_OFFSET_FROM_BOTTOM_MM = 3.4
5454

55-
type FlowRateAndOffsetParams = {|
55+
type FlowRateAndOffsetParamsTransferlike = {|
5656
aspirateFlowRateUlSec: number,
5757
dispenseFlowRateUlSec: number,
5858
blowoutFlowRateUlSec: number,
@@ -61,9 +61,8 @@ type FlowRateAndOffsetParams = {|
6161
blowoutOffsetFromTopMm: number,
6262
touchTipAfterAspirateOffsetMmFromBottom: number,
6363
touchTipAfterDispenseOffsetMmFromBottom: number,
64-
touchTipMmFromBottom: number,
6564
|}
66-
export const getFlowRateAndOffsetParams = (): FlowRateAndOffsetParams => ({
65+
export const getFlowRateAndOffsetParamsTransferLike = (): FlowRateAndOffsetParamsTransferlike => ({
6766
aspirateFlowRateUlSec: ASPIRATE_FLOW_RATE,
6867
dispenseFlowRateUlSec: DISPENSE_FLOW_RATE,
6968
blowoutFlowRateUlSec: BLOWOUT_FLOW_RATE,
@@ -74,6 +73,24 @@ export const getFlowRateAndOffsetParams = (): FlowRateAndOffsetParams => ({
7473
// for consolidate/distribute/transfer only
7574
touchTipAfterAspirateOffsetMmFromBottom: TOUCH_TIP_OFFSET_FROM_BOTTOM_MM,
7675
touchTipAfterDispenseOffsetMmFromBottom: TOUCH_TIP_OFFSET_FROM_BOTTOM_MM,
76+
})
77+
78+
type FlowRateAndOffsetParamsMix = {|
79+
aspirateFlowRateUlSec: number,
80+
dispenseFlowRateUlSec: number,
81+
blowoutFlowRateUlSec: number,
82+
aspirateOffsetFromBottomMm: number,
83+
dispenseOffsetFromBottomMm: number,
84+
blowoutOffsetFromTopMm: number,
85+
touchTipMmFromBottom: number,
86+
|}
87+
export const getFlowRateAndOffsetParamsMix = (): FlowRateAndOffsetParamsMix => ({
88+
aspirateFlowRateUlSec: ASPIRATE_FLOW_RATE,
89+
dispenseFlowRateUlSec: DISPENSE_FLOW_RATE,
90+
blowoutFlowRateUlSec: BLOWOUT_FLOW_RATE,
91+
aspirateOffsetFromBottomMm: ASPIRATE_OFFSET_FROM_BOTTOM_MM,
92+
dispenseOffsetFromBottomMm: DISPENSE_OFFSET_FROM_BOTTOM_MM,
93+
blowoutOffsetFromTopMm: BLOWOUT_OFFSET_FROM_TOP_MM,
7794

7895
// for mix only
7996
touchTipMmFromBottom: TOUCH_TIP_OFFSET_FROM_BOTTOM_MM,

protocol-designer/src/step-generation/__tests__/consolidate.test.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
dropTipHelper,
1212
FIXED_TRASH_ID,
1313
getErrorResult,
14-
getFlowRateAndOffsetParams,
14+
getFlowRateAndOffsetParamsTransferLike,
1515
getInitialRobotStateStandard,
1616
getRobotStatePickedUpTipStandard,
1717
getSuccessResult,
@@ -27,7 +27,7 @@ import type {
2727
AspirateParams,
2828
DispenseParams,
2929
} from '@opentrons/shared-data/protocol/flowTypes/schemaV3'
30-
30+
import type { ConsolidateArgs } from '../types'
3131
const airGapHelper = makeAirGapHelper({ offsetFromBottomMm: 11.54 })
3232
const aspirateHelper = makeAspirateHelper()
3333
const dispenseHelper = makeDispenseHelper()
@@ -61,18 +61,17 @@ function tripleMix(
6161
let invariantContext
6262
let initialRobotState
6363
let robotStatePickedUpOneTip
64-
let mixinArgs
64+
let mixinArgs: $Shape<ConsolidateArgs>
6565

6666
beforeEach(() => {
6767
invariantContext = makeContext()
6868
initialRobotState = getInitialRobotStateStandard(invariantContext)
6969
robotStatePickedUpOneTip = getRobotStatePickedUpTipStandard(invariantContext)
7070

7171
mixinArgs = {
72+
...getFlowRateAndOffsetParamsTransferLike(),
7273
// `volume` and `changeTip` should be explicit in tests,
7374
// those fields intentionally omitted from here
74-
...getFlowRateAndOffsetParams(),
75-
stepType: 'consolidate',
7675
commandCreatorFnName: 'consolidate',
7776
name: 'Consolidate Test',
7877
description: 'test blah blah',
@@ -1137,8 +1136,8 @@ describe('consolidate multi-channel', () => {
11371136
pipette: 'p300MultiId',
11381137
})
11391138

1140-
const args = {
1141-
stepType: 'consolidate',
1139+
const args: $Shape<ConsolidateArgs> = {
1140+
...getFlowRateAndOffsetParamsTransferLike(),
11421141
commandCreatorFnName: 'consolidate',
11431142
name: 'Consolidate Test',
11441143
description: 'test blah blah',
@@ -1160,12 +1159,10 @@ describe('consolidate multi-channel', () => {
11601159
touchTipAfterDispense: false,
11611160
mixInDestination: null,
11621161
blowoutLocation: null,
1163-
1164-
...getFlowRateAndOffsetParams(),
11651162
}
11661163

11671164
it('simple multi-channel: cols A1 A2 A3 A4 to col A12', () => {
1168-
const data = {
1165+
const data: ConsolidateArgs = {
11691166
...args,
11701167
volume: 140,
11711168
changeTip: 'once',

protocol-designer/src/step-generation/__tests__/distribute.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
dropTipHelper,
1010
FIXED_TRASH_ID,
1111
getErrorResult,
12-
getFlowRateAndOffsetParams,
12+
getFlowRateAndOffsetParamsTransferLike,
1313
getRobotInitialStateNoTipsRemain,
1414
getRobotStateWithTipStandard,
1515
getSuccessResult,
@@ -36,7 +36,7 @@ const touchTipHelper = makeTouchTipHelper()
3636
// TODO: Ian 2019-06-14 more elegant way to test the blowout offset calculation
3737
const BLOWOUT_OFFSET_ANY: any = expect.any(Number)
3838

39-
let mixinArgs
39+
let mixinArgs: $Shape<DistributeArgs>
4040
let invariantContext
4141
let robotStateWithTip
4242
let robotInitialStateNoTipsRemain
@@ -45,7 +45,7 @@ let blowoutSingleToSourceA1
4545

4646
beforeEach(() => {
4747
mixinArgs = {
48-
...getFlowRateAndOffsetParams(),
48+
...getFlowRateAndOffsetParamsTransferLike(),
4949
commandCreatorFnName: 'distribute',
5050
name: 'distribute test',
5151
description: 'test blah blah',
@@ -725,7 +725,7 @@ describe('advanced settings: volume, mix, pre-wet tip, tip touch, tip position',
725725

726726
describe('all advanced settings enabled', () => {
727727
it('should create commands in the expected order with expected params', () => {
728-
const args = {
728+
const args: $Shape<DistributeArgs> = {
729729
...mixinArgs,
730730
sourceWell: 'A1',
731731
destWells: ['B1', 'B2'],
@@ -744,7 +744,6 @@ describe('advanced settings: volume, mix, pre-wet tip, tip touch, tip position',
744744
// dispense column
745745
dispenseDelay: { seconds: 12, mmFromBottom: 14 },
746746
touchTipAfterDispense: true,
747-
blowoutLocation: 'trashId',
748747
blowoutFlowRateUlSec: 2.3,
749748
blowoutOffsetFromTopMm: 3.3,
750749
}

protocol-designer/src/step-generation/__tests__/mix.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getSuccessResult,
88
getErrorResult,
99
replaceTipCommands,
10-
getFlowRateAndOffsetParams,
10+
getFlowRateAndOffsetParamsMix,
1111
DEFAULT_PIPETTE,
1212
SOURCE_LABWARE,
1313
DEST_LABWARE,
@@ -30,6 +30,7 @@ let mixinArgs
3030

3131
beforeEach(() => {
3232
mixinArgs = {
33+
...getFlowRateAndOffsetParamsMix(),
3334
commandCreatorFnName: 'mix',
3435
name: 'mix test',
3536
description: 'test blah blah',
@@ -39,7 +40,9 @@ beforeEach(() => {
3940

4041
blowoutLocation: null,
4142
touchTip: false,
42-
...getFlowRateAndOffsetParams(),
43+
44+
aspirateDelay: null,
45+
dispenseDelay: null,
4346
}
4447

4548
invariantContext = makeContext()
@@ -117,7 +120,6 @@ describe('mix: advanced options', () => {
117120
times,
118121
wells: ['A1'],
119122
changeTip: 'once',
120-
...getFlowRateAndOffsetParams(),
121123
}
122124

123125
const result = mix(args, invariantContext, robotStateWithTip)

protocol-designer/src/step-generation/__tests__/transfer.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
DISPENSE_OFFSET_FROM_BOTTOM_MM,
99
dropTipHelper,
1010
getErrorResult,
11-
getFlowRateAndOffsetParams,
11+
getFlowRateAndOffsetParamsTransferLike,
1212
getRobotStateWithTipStandard,
1313
getSuccessResult,
1414
makeAirGapHelper,
@@ -21,6 +21,7 @@ import {
2121
makeDispenseAirGapHelper,
2222
} from '../__fixtures__'
2323
import { transfer } from '../commandCreators/compound/transfer'
24+
import type { TransferArgs } from '../types'
2425

2526
// well depth for 96 plate is 10.54, so need to add 1mm to top of well
2627
const airGapHelper = makeAirGapHelper({ offsetFromBottomMm: 11.54 })
@@ -33,11 +34,11 @@ const touchTipHelper = makeTouchTipHelper()
3334

3435
let invariantContext
3536
let robotStateWithTip
36-
let mixinArgs
37+
let mixinArgs: $Shape<TransferArgs>
3738

3839
beforeEach(() => {
3940
mixinArgs = {
40-
...getFlowRateAndOffsetParams(),
41+
...getFlowRateAndOffsetParamsTransferLike(),
4142
commandCreatorFnName: 'transfer',
4243
name: 'Transfer Test',
4344
description: 'test blah blah',

protocol-designer/src/step-generation/types.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type CommonArgs = {|
4141

4242
// ===== Processed form types. Used as args to call command creator fns =====
4343

44-
export type SharedTransferLikeArgs = {
44+
export type SharedTransferLikeArgs = {|
4545
...CommonArgs,
4646

4747
pipette: string, // PipetteId
@@ -80,9 +80,10 @@ export type SharedTransferLikeArgs = {
8080
dispenseFlowRateUlSec: number,
8181
/** offset from bottom of well in mm */
8282
dispenseOffsetFromBottomMm: number,
83-
}
83+
|}
8484

85-
export type ConsolidateArgs = {
85+
export type ConsolidateArgs = {|
86+
...SharedTransferLikeArgs,
8687
commandCreatorFnName: 'consolidate',
8788

8889
sourceWells: Array<string>,
@@ -97,9 +98,10 @@ export type ConsolidateArgs = {
9798
mixFirstAspirate: ?InnerMixArgs,
9899
/** Mix in destination well after dispense */
99100
mixInDestination: ?InnerMixArgs,
100-
} & SharedTransferLikeArgs
101+
|}
101102

102-
export type TransferArgs = {
103+
export type TransferArgs = {|
104+
...SharedTransferLikeArgs,
103105
commandCreatorFnName: 'transfer',
104106

105107
sourceWells: Array<string>,
@@ -114,9 +116,10 @@ export type TransferArgs = {
114116
mixBeforeAspirate: ?InnerMixArgs,
115117
/** Mix in destination well after dispense */
116118
mixInDestination: ?InnerMixArgs,
117-
} & SharedTransferLikeArgs
119+
|}
118120

119-
export type DistributeArgs = {
121+
export type DistributeArgs = {|
122+
...SharedTransferLikeArgs,
120123
commandCreatorFnName: 'distribute',
121124

122125
sourceWell: string,
@@ -134,9 +137,9 @@ export type DistributeArgs = {
134137

135138
/** Mix in first well in chunk */
136139
mixBeforeAspirate: ?InnerMixArgs,
137-
} & SharedTransferLikeArgs
140+
|}
138141

139-
export type MixArgs = {
142+
export type MixArgs = {|
140143
...$Exact<CommonArgs>,
141144
commandCreatorFnName: 'mix',
142145
labware: string,
@@ -163,7 +166,10 @@ export type MixArgs = {
163166
/** flow rates in uL/sec */
164167
aspirateFlowRateUlSec: number,
165168
dispenseFlowRateUlSec: number,
166-
}
169+
/** delays */
170+
aspirateDelay: ?InnerDelayArgs,
171+
dispenseDelay: ?InnerDelayArgs,
172+
|}
167173

168174
export type PauseArgs = {|
169175
...$Exact<CommonArgs>,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @flow
2+
import type { InnerDelayArgs } from '../../../step-generation'
3+
import type {
4+
DelayCheckboxFields,
5+
DelaySecondFields,
6+
} from '../../../form-types'
7+
8+
export function getDelayData<F: any>(
9+
hydratedFormData: F,
10+
checkboxField: DelayCheckboxFields,
11+
secondsField: DelaySecondFields,
12+
mmFromBottomField:
13+
| 'aspirate_delay_mmFromBottom'
14+
| 'dispense_delay_mmFromBottom'
15+
| 'mix_aspirate_delay_mmFromBottom'
16+
| 'mix_dispense_delay_mmFromBottom'
17+
): InnerDelayArgs | null {
18+
const checkbox = hydratedFormData[checkboxField]
19+
const seconds = hydratedFormData[secondsField]
20+
const mmFromBottom = hydratedFormData[mmFromBottomField]
21+
22+
if (
23+
checkbox &&
24+
(typeof seconds === 'number' && seconds > 0) &&
25+
(typeof mmFromBottom === 'number' && mmFromBottom > 0)
26+
) {
27+
return { seconds, mmFromBottom }
28+
}
29+
return null
30+
}

protocol-designer/src/steplist/formLevel/stepFormToArgs/mixFormToArgs.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
DEFAULT_MM_TOUCH_TIP_OFFSET_FROM_TOP,
1010
} from '../../../constants'
1111
import { getOrderedWells } from '../../utils'
12+
import { getDelayData } from './getDelayData'
1213
import type { HydratedMixFormDataLegacy } from '../../../form-types'
1314
import type { MixArgs } from '../../../step-generation'
1415

@@ -71,6 +72,21 @@ export const mixFormToArgs = (
7172
? DEFAULT_MM_BLOWOUT_OFFSET_FROM_TOP
7273
: 0
7374

75+
// Delay settings
76+
const aspirateDelay = getDelayData<HydratedMixFormDataLegacy>(
77+
hydratedFormData,
78+
'aspirate_delay_checkbox',
79+
'aspirate_delay_seconds',
80+
'mix_aspirate_delay_mmFromBottom'
81+
)
82+
83+
const dispenseDelay = getDelayData<HydratedMixFormDataLegacy>(
84+
hydratedFormData,
85+
'dispense_delay_checkbox',
86+
'dispense_delay_seconds',
87+
'mix_dispense_delay_mmFromBottom'
88+
)
89+
7490
return {
7591
commandCreatorFnName: 'mix',
7692
name: `Mix ${hydratedFormData.id}`, // TODO real name for steps
@@ -90,5 +106,7 @@ export const mixFormToArgs = (
90106
aspirateOffsetFromBottomMm,
91107
dispenseOffsetFromBottomMm,
92108
blowoutOffsetFromTopMm,
109+
aspirateDelay,
110+
dispenseDelay,
93111
}
94112
}

0 commit comments

Comments
 (0)