Skip to content

Commit

Permalink
fix(app): properly fall back to load order module matching on map vie…
Browse files Browse the repository at this point in the history
…w OT2 module setup

Don't look to deck configuration for matching specced modules to attached modules within the module
setup step of the OT2

Closes RQA-2735
  • Loading branch information
b-cooper committed May 16, 2024
1 parent ecd6ab0 commit a0a35d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const SetupModulesMap = ({
const attachedProtocolModuleMatches = getAttachedProtocolModuleMatches(
attachedModules,
protocolModulesInfo,
actualDeckConfig
actualDeckConfig,
robotType
)

const modulesOnDeck = attachedProtocolModuleMatches.map(module => ({
Expand Down
47 changes: 26 additions & 21 deletions app/src/organisms/ProtocolSetupModulesAndDeck/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {
DeckConfiguration,
FLEX_ROBOT_TYPE,
NON_CONNECTING_MODULE_TYPES,
OT2_ROBOT_TYPE,
RobotType,
checkModuleCompatibility,
getCutoutFixturesForModuleModel,
getCutoutIdsFromModuleSlotName,
Expand All @@ -16,14 +18,15 @@ export type AttachedProtocolModuleMatch = ProtocolModuleInfo & {
attachedModuleMatch: AttachedModule | null
}

// NOTE: this is a FLEX only function
// some logic copied from useModuleRenderInfoForProtocolById
// NOTE: some logic copied from useModuleRenderInfoForProtocolById
export function getAttachedProtocolModuleMatches(
attachedModules: AttachedModule[],
protocolModulesInfo: ProtocolModuleInfo[],
deckConfig: DeckConfiguration
deckConfig: DeckConfiguration,
robotType: RobotType = FLEX_ROBOT_TYPE
): AttachedProtocolModuleMatch[] {
const deckDef = getDeckDefFromRobotType(FLEX_ROBOT_TYPE) // this is only used for Flex ODD
const deckDef = getDeckDefFromRobotType(robotType)
const robotSupportsModuleConfig = robotType !== OT2_ROBOT_TYPE
const matchedAttachedModules: AttachedModule[] = []
const attachedProtocolModuleMatches = protocolModulesInfo.map(
protocolModule => {
Expand All @@ -49,12 +52,14 @@ export function getAttachedProtocolModuleMatches(
matchedAttachedModule.serialNumber ===
attachedModule.serialNumber
) &&
// check deck config has module with expected serial number in expected location
deckConfig.some(
({ cutoutId, opentronsModuleSerialNumber }) =>
attachedModule.serialNumber === opentronsModuleSerialNumber &&
moduleCutoutIds.includes(cutoutId)
)
// then if robotType supports configurable modules check the deck config has a
// a module with the expected serial number in the expected location
(!robotSupportsModuleConfig ||
deckConfig.some(
({ cutoutId, opentronsModuleSerialNumber }) =>
attachedModule.serialNumber === opentronsModuleSerialNumber &&
moduleCutoutIds.includes(cutoutId)
))
) ?? null
if (compatibleAttachedModule !== null) {
matchedAttachedModules.push(compatibleAttachedModule)
Expand Down Expand Up @@ -102,18 +107,18 @@ export function getUnmatchedModulesForProtocol(
)
return moduleTypeMatchIndex !== -1
? {
...acc,
// remove matched module from remaining modules list
remainingAttachedModules: acc.remainingAttachedModules.filter(
(_remainingAttachedModule, index) =>
index !== moduleTypeMatchIndex
),
}
...acc,
// remove matched module from remaining modules list
remainingAttachedModules: acc.remainingAttachedModules.filter(
(_remainingAttachedModule, index) =>
index !== moduleTypeMatchIndex
),
}
: {
...acc,
// append unmatchable module to list of requested modules that are missing a physical match
missingModuleIds: [...acc.missingModuleIds, module.moduleId],
}
...acc,
// append unmatchable module to list of requested modules that are missing a physical match
missingModuleIds: [...acc.missingModuleIds, module.moduleId],
}
},
{ missingModuleIds: [], remainingAttachedModules: attachedModules }
)
Expand Down

0 comments on commit a0a35d1

Please sign in to comment.