1
+ import flatMap from 'lodash/flatMap'
1
2
import uuidv1 from 'uuid/v4'
2
3
3
4
import {
4
5
FLEX_ROBOT_TYPE ,
5
6
FLEX_STANDARD_DECKID ,
6
7
getAllLiquidClassDefs ,
7
- getDeckDefFromRobotType ,
8
8
getFlexNameConversion ,
9
- TRASH_BIN_ADAPTER_FIXTURE ,
10
- WASTE_CHUTE_FIXTURES ,
11
9
} from '@opentrons/shared-data'
12
10
import {
13
- consolidate ,
14
- distribute ,
15
11
getLiquidClassName ,
16
12
getSlotInLocationStack ,
17
- getWasteChuteAddressableAreaNamePip ,
18
13
pythonImports ,
19
14
pythonMetadata ,
20
15
pythonRequirements ,
21
- transfer ,
22
16
} from '@opentrons/step-generation'
23
17
24
- import { generateQuickTransferArgs } from './'
18
+ import { generateQuickTransferArgs } from './generateQuickTransferArgs'
19
+ import { generateQuickTransferRobotStateTimeline } from './generateQuickTransferRobotStateTimeline'
25
20
import { pythonDef } from './pythonDef'
26
21
27
22
import type {
28
- AddressableAreaName ,
29
23
CommandAnnotationV1Mixin ,
30
24
CommandV14Mixin ,
31
25
CreateCommand ,
32
- CutoutId ,
33
26
DeckConfiguration ,
34
27
LabwareDefinition2 ,
35
28
LabwareV2Mixin ,
@@ -39,7 +32,6 @@ import type {
39
32
LoadPipetteCreateCommand ,
40
33
OT3RobotMixin ,
41
34
} from '@opentrons/shared-data'
42
- import type { CommandCreatorResult } from '@opentrons/step-generation'
43
35
import type { QuickTransferSummaryState } from '../types'
44
36
45
37
const uuid : ( ) => string = uuidv1
@@ -151,87 +143,22 @@ export function createQuickTransferFile(
151
143
}
152
144
: null
153
145
154
- let nonLoadCommandCreator : CommandCreatorResult | null = null
155
- if ( stepArgs ?. commandCreatorFnName === 'transfer' ) {
156
- nonLoadCommandCreator = transfer (
157
- stepArgs ,
158
- invariantContext ,
159
- initialRobotState
160
- )
161
- } else if ( stepArgs ?. commandCreatorFnName === 'consolidate' ) {
162
- nonLoadCommandCreator = consolidate (
163
- stepArgs ,
164
- invariantContext ,
165
- initialRobotState
166
- )
167
- } else if ( stepArgs ?. commandCreatorFnName === 'distribute' ) {
168
- nonLoadCommandCreator = distribute (
169
- stepArgs ,
170
- invariantContext ,
171
- initialRobotState
172
- )
173
- }
174
-
175
- const nonLoadCommands =
176
- nonLoadCommandCreator != null && 'commands' in nonLoadCommandCreator
177
- ? nonLoadCommandCreator . commands
178
- : [ ]
146
+ const robotStateTimeline = generateQuickTransferRobotStateTimeline ( {
147
+ stepArgs,
148
+ initialRobotState,
149
+ invariantContext,
150
+ } )
151
+ const nonLoadCommands : CreateCommand [ ] = flatMap (
152
+ robotStateTimeline . timeline ,
153
+ timelineFrame => timelineFrame . commands
154
+ )
179
155
180
- let finalDropTipCommands : CreateCommand [ ] = [ ]
181
- let addressableAreaName : AddressableAreaName | null = null
182
- if (
183
- quickTransferState . dropTipLocation . cutoutFixtureId ===
184
- TRASH_BIN_ADAPTER_FIXTURE
185
- ) {
186
- const trashLocation = quickTransferState . dropTipLocation . cutoutId
187
- const deckDef = getDeckDefFromRobotType ( FLEX_ROBOT_TYPE )
188
- const cutouts : Record < CutoutId , AddressableAreaName [ ] > | null =
189
- deckDef . cutoutFixtures . find (
190
- cutoutFixture => cutoutFixture . id === 'trashBinAdapter'
191
- ) ?. providesAddressableAreas ?? null
192
- addressableAreaName =
193
- trashLocation != null && cutouts != null
194
- ? cutouts [ trashLocation ] ?. [ 0 ] ?? null
195
- : null
196
- } else if (
197
- WASTE_CHUTE_FIXTURES . includes (
198
- quickTransferState . dropTipLocation . cutoutFixtureId
199
- )
200
- ) {
201
- addressableAreaName = getWasteChuteAddressableAreaNamePip (
202
- pipetteEntity . spec . channels
203
- )
204
- }
205
- if ( addressableAreaName == null ) {
206
- console . error (
207
- `expected to find addressableAreaName with trashBin or wasteChute location but could not`
208
- )
209
- } else {
210
- finalDropTipCommands = [
211
- {
212
- key : uuid ( ) ,
213
- commandType : 'moveToAddressableAreaForDropTip' ,
214
- params : {
215
- pipetteId : pipetteEntity . id ,
216
- addressableAreaName,
217
- } ,
218
- } ,
219
- {
220
- key : uuid ( ) ,
221
- commandType : 'dropTipInPlace' ,
222
- params : {
223
- pipetteId : pipetteEntity . id ,
224
- } ,
225
- } ,
226
- ]
227
- }
228
156
const commands : CreateCommand [ ] = [
229
157
loadPipetteCommand ,
230
158
...loadAdapterCommands ,
231
159
...loadLabwareCommands ,
232
160
...( loadLiquidCommand != null ? [ loadLiquidCommand ] : [ ] ) ,
233
161
...nonLoadCommands ,
234
- ...finalDropTipCommands ,
235
162
]
236
163
const sourceLabwareName = quickTransferState . source . metadata . displayName
237
164
let destinationLabwareName = sourceLabwareName
0 commit comments