Skip to content

Commit 7fc8623

Browse files
authored
fix(step-generation): properly check module state for moveLabware (#19097)
Our `moveLabware` atomic command creator's checks for save moves to and from a module seem broke at some point. This PR ensures we robustly check the module state object before determining lid/latch safety for moving a labware to or from the module. Closes RQA-4474 Closes RQA-4475
1 parent 43b1be4 commit 7fc8623

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

step-generation/src/commandCreators/atomic/moveLabware.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import type {
3333
CommandCreator,
3434
CommandCreatorError,
3535
CommandCreatorWarning,
36+
ModuleState,
3637
} from '../../types'
3738

3839
/** Move labware from one location to another, manually or via a gripper. */
@@ -164,10 +165,25 @@ export const moveLabware: CommandCreator<MoveLabwareParams> = (
164165
const initialSlot =
165166
initialAdapterSlot != null ? initialAdapterSlot : initialLabwareSlot
166167

167-
const initialModuleState =
168-
initialSlot != null
169-
? prevRobotState.modules[initialSlot]?.moduleState
170-
: null
168+
const getModuleStateFromSlotOrId = (
169+
identifier: string | null
170+
): ModuleState | null => {
171+
if (identifier == null) {
172+
return null
173+
} else if (identifier in prevRobotState.modules) {
174+
// identifier is a module id
175+
return prevRobotState.modules[identifier].moduleState
176+
} else {
177+
// identifier is a slot name
178+
return (
179+
Object.values(prevRobotState.modules).find(
180+
({ slot }) => slot === identifier
181+
)?.moduleState ?? null
182+
)
183+
}
184+
}
185+
186+
const initialModuleState = getModuleStateFromSlotOrId(initialSlot)
171187
if (initialModuleState != null) {
172188
if (
173189
initialModuleState.type === THERMOCYCLER_MODULE_TYPE &&
@@ -220,13 +236,8 @@ export const moveLabware: CommandCreator<MoveLabwareParams> = (
220236
warnings.push(warningCreators.labwareInWasteChuteHasLiquid())
221237
}
222238

223-
if (
224-
destinationModuleIdOrSlot != null &&
225-
prevRobotState.modules[destinationModuleIdOrSlot] != null
226-
) {
227-
const destModuleState =
228-
prevRobotState.modules[destinationModuleIdOrSlot].moduleState
229-
239+
const destModuleState = getModuleStateFromSlotOrId(destinationModuleIdOrSlot)
240+
if (destModuleState != null) {
230241
if (
231242
destModuleState.type === THERMOCYCLER_MODULE_TYPE &&
232243
destModuleState.lidOpen !== true

0 commit comments

Comments
 (0)