@@ -13,11 +13,17 @@ import {
13
13
} from '@opentrons/components'
14
14
import { useUpdateDeckConfigurationMutation } from '@opentrons/react-api-client'
15
15
import {
16
+ FAKE_FIXTURE_IDS ,
16
17
FLEX_ROBOT_TYPE ,
18
+ FLEX_STACKER_FIXTURES ,
19
+ getAAForModuleFixture ,
20
+ getCutoutConfigReplacmentForModule ,
17
21
getCutoutFixturesForModuleModel ,
18
22
getDeckDefFromRobotType ,
19
23
getFixtureIdByCutoutIdFromModuleAnchorCutoutId ,
20
24
getModuleDisplayName ,
25
+ getReplacementFixtureForFixtureRemoval ,
26
+ replaceFixtureToFakeFixtureAndTransformCutoutFixturesToAA ,
21
27
SINGLE_CENTER_CUTOUTS ,
22
28
SINGLE_CENTER_SLOT_FIXTURE ,
23
29
SINGLE_LEFT_SLOT_FIXTURE ,
@@ -46,7 +52,7 @@ export const BODY_STYLE = css`
46
52
line-height : 1.75rem ;
47
53
}
48
54
`
49
- interface SelectLocationProps extends ModuleSetupWizardStepProps {
55
+ export interface SelectLocationProps extends ModuleSetupWizardStepProps {
50
56
deckConfig : DeckConfiguration
51
57
createMaintenanceRun : CreateMaintenanceRunType
52
58
isLoadedInRun : boolean
@@ -66,6 +72,11 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
66
72
attachedModule ,
67
73
deckConfig
68
74
)
75
+
76
+ const deckConfigWithAA = replaceFixtureToFakeFixtureAndTransformCutoutFixturesToAA (
77
+ deckConfig
78
+ )
79
+
69
80
const { t } = useTranslation ( 'module_wizard_flows' )
70
81
const moduleName = getModuleDisplayName ( attachedModule . moduleModel )
71
82
const handleOnClick = ( ) : void => {
@@ -90,18 +101,22 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
90
101
( acc , { mayMountTo } ) => [ ...acc , ...mayMountTo ] ,
91
102
[ ]
92
103
)
93
- const editableCutoutIds = deckConfig . reduce < CutoutId [ ] > (
104
+
105
+ const editableCutoutIds = deckConfigWithAA . reduce < CutoutId [ ] > (
94
106
( acc , { cutoutId, cutoutFixtureId, opentronsModuleSerialNumber } ) => {
95
107
const isCurrentConfiguration =
96
108
Object . values ( configuredFixtureIdByCutoutId ) . includes (
97
109
cutoutFixtureId
98
110
) && attachedModule . serialNumber === opentronsModuleSerialNumber
99
111
if (
100
112
// in run setup, module calibration only available when module location is already correctly configured
101
- ! isLoadedInRun &&
102
- mayMountToCutoutIds . includes ( cutoutId ) &&
103
- ( isCurrentConfiguration ||
104
- SINGLE_SLOT_FIXTURES . includes ( cutoutFixtureId ) )
113
+ ( ! isLoadedInRun &&
114
+ mayMountToCutoutIds . includes ( cutoutId ) &&
115
+ ( isCurrentConfiguration ||
116
+ SINGLE_SLOT_FIXTURES . includes ( cutoutFixtureId ) ||
117
+ // fake fixtures include mag block next to an empty staging slot and a waste chute next to an empty staging slot
118
+ FAKE_FIXTURE_IDS . includes ( cutoutFixtureId ) ) ) ||
119
+ FLEX_STACKER_FIXTURES . includes ( cutoutFixtureId )
105
120
) {
106
121
return [ ...acc , cutoutId ]
107
122
}
@@ -116,32 +131,43 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
116
131
moduleFixtures
117
132
)
118
133
if ( ! isEqual ( selectedFixtureIdByCutoutIds , configuredFixtureIdByCutoutId ) ) {
119
- updateDeckConfiguration (
120
- deckConfig . map ( cc => {
121
- if ( cc . cutoutId in configuredFixtureIdByCutoutId ) {
122
- let replacementFixtureId : CutoutFixtureId = SINGLE_LEFT_SLOT_FIXTURE
123
- if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
124
- replacementFixtureId = SINGLE_CENTER_SLOT_FIXTURE
125
- } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
126
- replacementFixtureId = SINGLE_RIGHT_SLOT_FIXTURE
127
- }
134
+ const updatedDeckConfig = deckConfig . map ( cc => {
135
+ if ( cc . cutoutId in configuredFixtureIdByCutoutId ) {
136
+ if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
128
137
return {
129
138
...cc ,
130
- cutoutFixtureId : replacementFixtureId ,
139
+ cutoutFixtureId : SINGLE_CENTER_SLOT_FIXTURE ,
131
140
opentronsModuleSerialNumber : undefined ,
132
141
}
133
- } else if ( cc . cutoutId in selectedFixtureIdByCutoutIds ) {
142
+ } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
134
143
return {
135
144
...cc ,
136
- cutoutFixtureId :
137
- selectedFixtureIdByCutoutIds [ cc . cutoutId ] ?? cc . cutoutFixtureId ,
138
- opentronsModuleSerialNumber : attachedModule . serialNumber ,
145
+ cutoutFixtureId : SINGLE_RIGHT_SLOT_FIXTURE ,
146
+ opentronsModuleSerialNumber : undefined ,
139
147
}
140
- } else {
141
- return cc
142
148
}
143
- } )
144
- )
149
+ return {
150
+ ...cc ,
151
+ cutoutFixtureId : SINGLE_LEFT_SLOT_FIXTURE ,
152
+ opentronsModuleSerialNumber : undefined ,
153
+ }
154
+ } else if ( cc . cutoutId in selectedFixtureIdByCutoutIds ) {
155
+ const fixtureReplacement = getCutoutConfigReplacmentForModule (
156
+ anchorCutoutId ,
157
+ selectedFixtureIdByCutoutIds [ cc . cutoutId ] ?? cc . cutoutFixtureId ,
158
+ attachedModule . moduleModel ,
159
+ deckConfig
160
+ )
161
+ return {
162
+ ...cc ,
163
+ cutoutFixtureId : fixtureReplacement ,
164
+ opentronsModuleSerialNumber : attachedModule . serialNumber ,
165
+ }
166
+ } else {
167
+ return cc
168
+ }
169
+ } )
170
+ updateDeckConfiguration ( updatedDeckConfig )
145
171
}
146
172
}
147
173
@@ -153,15 +179,25 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
153
179
updateDeckConfiguration (
154
180
deckConfig . map ( cc => {
155
181
if ( cc . cutoutId in removedFixtureIdByCutoutIds ) {
156
- let replacementFixtureId : CutoutFixtureId = SINGLE_LEFT_SLOT_FIXTURE
157
- if ( SINGLE_CENTER_CUTOUTS . includes ( cc . cutoutId ) ) {
158
- replacementFixtureId = SINGLE_CENTER_SLOT_FIXTURE
159
- } else if ( SINGLE_RIGHT_CUTOUTS . includes ( cc . cutoutId ) ) {
160
- replacementFixtureId = SINGLE_RIGHT_SLOT_FIXTURE
161
- }
182
+ const fixtureInPlace = deckConfigWithAA . find (
183
+ dc => dc . cutoutId === anchorCutoutId
184
+ )
185
+ const removedDefaultFixture = removedFixtureIdByCutoutIds [
186
+ cc . cutoutId
187
+ ] as CutoutFixtureId // we know there is a match by the condition
188
+ const aa = getAAForModuleFixture (
189
+ anchorCutoutId ,
190
+ removedDefaultFixture ,
191
+ attachedModule . moduleModel
192
+ )
193
+ const replacment = getReplacementFixtureForFixtureRemoval (
194
+ fixtureInPlace ?. cutoutFixtureId ?? removedDefaultFixture ,
195
+ anchorCutoutId ,
196
+ aa
197
+ )
162
198
return {
163
199
...cc ,
164
- cutoutFixtureId : replacementFixtureId ,
200
+ cutoutFixtureId : replacment ,
165
201
opentronsModuleSerialNumber : undefined ,
166
202
}
167
203
} else {
@@ -180,6 +216,7 @@ export function SelectLocation(props: SelectLocationProps): JSX.Element {
180
216
handleClickAdd = { handleAddFixture }
181
217
handleClickRemove = { handleRemoveFixture }
182
218
editableCutoutIds = { editableCutoutIds }
219
+ moduleModel = { attachedModule . moduleModel }
183
220
selectedCutoutId = {
184
221
deckConfig . find (
185
222
( { cutoutId, opentronsModuleSerialNumber } ) =>
0 commit comments