Skip to content

Commit d2e6dce

Browse files
ahiuchingausmb2268
authored andcommitted
add getModuleDeckLabel util in shared-data
1 parent 77563c3 commit d2e6dce

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
FLEX_STACKER_MODULE_TYPE,
3+
TC_MODULE_LOCATION_OT2,
4+
TC_MODULE_LOCATION_OT3,
5+
THERMOCYCLER_MODULE_TYPE,
6+
} from '..'
7+
8+
import type { ModuleType } from '../types'
9+
10+
const getFlexStackerDisplayLocationFromSlotName = (
11+
slotName: string
12+
): string => {
13+
return `${slotName}+${slotName[0]}4`
14+
}
15+
16+
/**
17+
* Returns a string to represent a module's deck location, to be used in Deck Configuration and Protocol Setup.
18+
* @param moduleType - The type of the module.
19+
* @param slotName - The slot name where the module is located.
20+
* @returns A string representing the module's deck label.
21+
*
22+
* For all labware loaded on/offdeck or on module, use `getLabwareDeckLabel` instead.
23+
*/
24+
export function getModuleDeckLabel(
25+
moduleType: ModuleType,
26+
slotName: string
27+
): string {
28+
switch (moduleType) {
29+
case THERMOCYCLER_MODULE_TYPE:
30+
if (slotName === '7') {
31+
// OT-2 thermocycler module slotName is always '7'
32+
return TC_MODULE_LOCATION_OT2
33+
} else {
34+
return TC_MODULE_LOCATION_OT3
35+
}
36+
case FLEX_STACKER_MODULE_TYPE:
37+
return getFlexStackerDisplayLocationFromSlotName(slotName)
38+
default:
39+
return slotName
40+
}
41+
}

shared-data/js/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export * from './getLiquidsByIdForLabware'
6060
export * from './getStackedItemsOnStartingDeck'
6161
export * from './getStandardDeckViewLayerBlockList'
6262
export * from './getWellFillFromLabwareId'
63+
export * from './getModuleDeckLabel'
6364

6465
export const getLabwareDefIsStandard = (def: LabwareDefinition): boolean =>
6566
def?.namespace === OPENTRONS_LABWARE_NAMESPACE

0 commit comments

Comments
 (0)