@@ -41,6 +41,10 @@ import type {
41
41
CutoutId ,
42
42
} from '@opentrons/shared-data'
43
43
import type { OddModalHeaderBaseProps } from '/app/molecules/OddModal/types'
44
+ import { useSendIdentifyStacker } from '../ModuleWizardFlows/hooks'
45
+
46
+ const FLEX_STACKER_FIXTURE = 'flexStackerModuleV1'
47
+ const MODULE_IDENTIFY_TIME_MS = 10000
44
48
45
49
interface AddFixtureModalProps {
46
50
cutoutId : CutoutId
@@ -161,7 +165,10 @@ export function AddFixtureModal({
161
165
)
162
166
}
163
167
164
- const handleAddFixture = ( addedCutoutConfigs : CutoutConfigMap [ ] ) : void => {
168
+ const sendIdentifyStacker = useSendIdentifyStacker ( )
169
+ const attachedModules = useModulesQuery ( ) . data ?. data
170
+
171
+ const handleAddFixture = ( addedCutoutConfigs : CutoutConfigMap [ ] , fixtureSerialNumber ?: string ) : void => {
165
172
const addedCutoutConfigsWithCombo = replaceCutoutFixtureWithComboFixture (
166
173
addedCutoutConfigs ,
167
174
deckConfigWithAA ,
@@ -175,10 +182,32 @@ export function AddFixtureModal({
175
182
)
176
183
} ) as CutoutConfig [ ] // we can do this bc we are mapping each aa to the proper fixture
177
184
185
+ if ( fixtureSerialNumber ) {
186
+ const module = attachedModules ?. find (
187
+ m => m . serialNumber === fixtureSerialNumber
188
+ ) ?? null
189
+ if ( module !== null ) {
190
+ sendIdentifyStacker ( module , false )
191
+ }
192
+ }
193
+
178
194
updateDeckConfiguration ( newDeckConfig )
179
195
closeModal ( )
180
196
}
181
197
198
+ const handleIdentifyFixture = ( fixtureSerialNumber : string ) : void => {
199
+ const module = attachedModules ?. find (
200
+ m => m . serialNumber === fixtureSerialNumber
201
+ ) ?? null
202
+ if ( module !== null ) {
203
+ // Identify the stacker module
204
+ sendIdentifyStacker ( module , true , 'blue' )
205
+ //Ensure that the module reverts after a set time
206
+ setTimeout ( ( ) => { sendIdentifyStacker ( module , false ) } , MODULE_IDENTIFY_TIME_MS )
207
+ }
208
+
209
+ }
210
+
182
211
const fixtureOptions = availableOptions . map ( cutoutConfigs => {
183
212
const usbPort = ( modulesData ?. data ?? [ ] ) . find (
184
213
m => m . serialNumber === cutoutConfigs [ 0 ] . opentronsModuleSerialNumber
@@ -187,21 +216,44 @@ export function AddFixtureModal({
187
216
usbPort ?. hubPort != null
188
217
? `${ usbPort . port } .${ usbPort . hubPort } `
189
218
: usbPort ?. port
190
-
191
- return (
192
- < FixtureOption
193
- key = { cutoutConfigs [ 0 ] . cutoutFixtureId }
194
- optionName = { getFixtureDisplayName (
195
- cutoutConfigs [ 0 ] . cutoutFixtureId ,
196
- portDisplay
197
- ) }
198
- buttonText = { t ( 'add' ) }
199
- onClickHandler = { ( ) => {
200
- handleAddFixture ( cutoutConfigs )
201
- } }
202
- isOnDevice = { isOnDevice }
203
- />
204
- )
219
+
220
+ const fixtureSerialNumber = cutoutConfigs [ 0 ] . opentronsModuleSerialNumber
221
+ if ( fixtureSerialNumber !== undefined && cutoutConfigs [ 0 ] . cutoutFixtureId . includes ( FLEX_STACKER_FIXTURE ) ) {
222
+ return (
223
+ < FixtureOption
224
+ key = { cutoutConfigs [ 0 ] . cutoutFixtureId }
225
+ optionName = { getFixtureDisplayName (
226
+ cutoutConfigs [ 0 ] . cutoutFixtureId ,
227
+ portDisplay
228
+ ) }
229
+ buttonText = { t ( 'add' ) }
230
+ onClickHandler = { ( ) => {
231
+ handleAddFixture ( cutoutConfigs , fixtureSerialNumber )
232
+ } }
233
+ secondaryButtonText = { t ( 'identify' ) }
234
+ secondaryOnClickHandler = { ( ) => {
235
+ handleIdentifyFixture ( fixtureSerialNumber ) }
236
+ }
237
+ isOnDevice = { isOnDevice }
238
+ />
239
+ )
240
+ }
241
+ else {
242
+ return (
243
+ < FixtureOption
244
+ key = { cutoutConfigs [ 0 ] . cutoutFixtureId }
245
+ optionName = { getFixtureDisplayName (
246
+ cutoutConfigs [ 0 ] . cutoutFixtureId ,
247
+ portDisplay
248
+ ) }
249
+ buttonText = { t ( 'add' ) }
250
+ onClickHandler = { ( ) => {
251
+ handleAddFixture ( cutoutConfigs )
252
+ } }
253
+ isOnDevice = { isOnDevice }
254
+ />
255
+ )
256
+ }
205
257
} )
206
258
207
259
return (
@@ -224,6 +276,9 @@ export function AddFixtureModal({
224
276
</ Flex >
225
277
</ OddModal >
226
278
) : (
279
+ // This is the modal with the module fixtures
280
+ // Something that checks if this is a stacker module with a TODO to remove/update if other identifiable modules are added
281
+ // Call to the use identify thing that transitions back to regular after a second?
227
282
< Modal { ...modalProps } >
228
283
< Flex flexDirection = { DIRECTION_COLUMN } gridGap = { SPACING . spacing16 } >
229
284
< StyledText desktopStyle = "bodyDefaultRegular" >
0 commit comments