Skip to content

Commit 20fe711

Browse files
ahiuchingausmb2268
authored andcommitted
add in hopper location for getLabwareDisplayLocation
1 parent 0014de6 commit 20fe711

File tree

4 files changed

+82
-44
lines changed

4 files changed

+82
-44
lines changed

components/src/assets/localization/en/protocol_command_text.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"single": "single",
9494
"single_nozzle_layout": "single nozzle layout",
9595
"slot": "Slot {{slot_name}}",
96+
"stacker_hopper_display": "Stacker {{row}}",
9697
"target_temperature": "target temperature",
9798
"tc_awaiting_for_duration": "Waiting for Thermocycler profile to complete",
9899
"tc_run_profile_steps": "Temperature: {{celsius}}°C, hold time: {{duration}}",

components/src/organisms/CommandText/useCommandTextString/utils/__tests__/getLabwareDisplayLocation.test.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,50 @@ describe('getLabwareDisplayLocation with translations', () => {
268268
}
269269
})
270270
})
271+
272+
detailLevels.forEach(detailLevel => {
273+
it(`should handle labware on a stacker module with detailLevel "${detailLevel}"`, () => {
274+
const locationSequence: LabwareLocationSequence = [
275+
{ kind: 'onAddressableArea', addressableAreaName: 'flexStackerModuleV1D4' },
276+
{ kind: 'onModule', moduleId: 'mockModuleId' },
277+
{
278+
kind: 'onCutoutFixture',
279+
cutoutId: 'cutoutD3',
280+
possibleCutoutFixtureIds: ['flexStackerModuleV1WithWasteChuteRightAdapterNoCover']
281+
}]
282+
vi.mocked(getModuleModel).mockReturnValue('flexStackerModuleV1')
283+
vi.mocked(getModuleDisplayLocation).mockReturnValue('D3')
284+
vi.mocked(getModuleDisplayName).mockReturnValue('Flex Stacker')
285+
vi.mocked(getModuleType).mockReturnValue('flexStackerModuleType')
286+
287+
render({
288+
location: locationSequence,
289+
params: { ...defaultParams, detailLevel }
290+
})
291+
292+
screen.getByText('Slot D4')
293+
})
294+
})
295+
296+
detailLevels.forEach(detailLevel => {
297+
it(`should handle labware in stacker hopper with detailLevel "${detailLevel}"`, () => {
298+
const locationSequence: LabwareLocationSequence = [
299+
{ kind: "inStackerHopper", moduleId: "UUID" }
300+
]
301+
302+
vi.mocked(getModuleModel).mockReturnValue('flexStackerModuleV1')
303+
vi.mocked(getModuleDisplayLocation).mockReturnValue('D3')
304+
vi.mocked(getModuleDisplayName).mockReturnValue('Flex Stacker')
305+
vi.mocked(getModuleType).mockReturnValue('flexStackerModuleType')
306+
307+
render({
308+
location: locationSequence,
309+
params: { ...defaultParams, detailLevel }
310+
})
311+
312+
screen.getByText('Stacker D')
313+
})
314+
})
271315
})
272316

273317
describe('labware on another labware', () => {
@@ -448,4 +492,3 @@ describe('getLabwareDisplayLocation with translations', () => {
448492
})
449493
})
450494
})
451-

components/src/organisms/CommandText/useCommandTextString/utils/getLabwareDisplayLocation.tsx

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {
2-
FLEX_STACKER_MODULE_V1,
2+
FLEX_STACKER_MODULE_TYPE,
33
getModuleDisplayName,
44
getModuleType,
55
getOccludedSlotCountForModule,
6+
getModuleDeckLabel,
67
MOVABLE_TRASH_ADDRESSABLE_AREAS,
78
THERMOCYCLER_MODULE_V1,
89
THERMOCYCLER_MODULE_V2,
@@ -51,23 +52,18 @@ export function getLabwareDisplayLocation(
5152
const { t, isOnDevice = false, location } = params
5253
const locationResult = Array.isArray(location)
5354
? getLabwareLocationFromSequence({
54-
...params,
55-
locationSequence: location,
56-
})
55+
...params,
56+
locationSequence: location,
57+
})
5758
: getLabwareLocation({
58-
...params,
59-
location: location ?? null,
60-
})
59+
...params,
60+
location: location ?? null,
61+
})
6162
if (locationResult == null) {
6263
return ''
6364
}
6465

65-
const { slotName: initialSlotName, moduleModel, adapterName } = locationResult
66-
const slotName =
67-
moduleModel === THERMOCYCLER_MODULE_V1 ||
68-
moduleModel === THERMOCYCLER_MODULE_V2
69-
? 'A1+B1'
70-
: initialSlotName
66+
const { slotName, moduleModel, adapterName } = locationResult
7167

7268
if (slotName === 'offDeck' || slotName === 'systemLocation') {
7369
return t('off_deck')
@@ -83,37 +79,26 @@ export function getLabwareDisplayLocation(
8379
}
8480
// Module location without adapter
8581
else if (moduleModel != null && adapterName == null) {
82+
const moduleSlot = getModuleDeckLabel(getModuleType(moduleModel), slotName)
83+
if (getModuleType(moduleModel) === FLEX_STACKER_MODULE_TYPE) {
84+
// in hopper location always return Stacker {{row}}
85+
return t('stacker_hopper_display', {
86+
row: getSlotRow(moduleSlot as string),
87+
})
88+
}
8689
if (params.detailLevel === 'slot-only') {
87-
switch (moduleModel) {
88-
case THERMOCYCLER_MODULE_V1:
89-
case THERMOCYCLER_MODULE_V2:
90-
return t('slot', { slot_name: 'A1+B1' })
91-
case FLEX_STACKER_MODULE_V1:
92-
return t('stacker_display_name', {
93-
stacker_slot: getSlotColumn(slotName),
94-
})
95-
default:
96-
return t('slot', { slot_name: slotName })
97-
}
98-
} else {
99-
switch (moduleModel) {
100-
case FLEX_STACKER_MODULE_V1:
101-
return t('stacker_column_display_name', {
102-
stacker_slot: getSlotColumn(slotName),
103-
})
104-
default:
105-
return isOnDevice
106-
? `${getModuleDisplayName(moduleModel)}, ${slotName}`
107-
: t('module_in_slot', {
108-
count: getOccludedSlotCountForModule(
109-
getModuleType(moduleModel),
110-
params.robotType
111-
),
112-
module: getModuleDisplayName(moduleModel),
113-
slot_name: slotName,
114-
})
115-
}
90+
return t('slot', { slot_name: moduleSlot })
11691
}
92+
return isOnDevice
93+
? `${getModuleDisplayName(moduleModel)}, ${moduleSlot}`
94+
: t('module_in_slot', {
95+
count: getOccludedSlotCountForModule(
96+
getModuleType(moduleModel),
97+
params.robotType
98+
),
99+
module: getModuleDisplayName(moduleModel),
100+
slot_name: moduleSlot,
101+
})
117102
}
118103
// Adapter locations
119104
else if (adapterName != null) {
@@ -138,7 +123,7 @@ export function getLabwareDisplayLocation(
138123
}
139124
}
140125

141-
function getSlotColumn(slotName: string): string {
126+
function getSlotRow(slotName: string): string {
142127
return slotName.charAt(0)
143128
}
144129

components/src/organisms/CommandText/useCommandTextString/utils/getLabwareLocation.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ export function getLabwareLocationFromSequence(
130130
: moduleModel ?? undefined,
131131
}
132132
}
133+
} else if (sequenceItem.kind === 'inStackerHopper') {
134+
return {
135+
...acc,
136+
slotName: getModuleDisplayLocation(
137+
loadedModules,
138+
sequenceItem.moduleId
139+
),
140+
moduleModel: getModuleModel(loadedModules, sequenceItem.moduleId),
141+
}
133142
}
134143
// TODO(tz, 4-16-25): add inHopperLocation when logic is merged
135144
else if (detailLevel === 'full') {

0 commit comments

Comments
 (0)