Skip to content

Commit

Permalink
remove double listing of modules from odd protocol hardware reqs
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Apr 10, 2024
1 parent 65582a6 commit 52a60e8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
63 changes: 33 additions & 30 deletions app/src/pages/Protocols/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
getDeckDefFromRobotType,
RunTimeParameter,
getCutoutFixtureIdsForModuleModel,
getCutoutFixturesForModuleModel,
FLEX_MODULE_ADDRESSABLE_AREAS,
} from '@opentrons/shared-data'
import { getLabwareSetupItemGroups } from '../utils'
import { getProtocolUsesGripper } from '../../../organisms/ProtocolSetupInstruments/utils'
Expand All @@ -28,7 +30,6 @@ import type {
RobotType,
} from '@opentrons/shared-data'
import type { LabwareSetupItem } from '../utils'
import type { AttachedModule } from '@opentrons/api-client'

interface ProtocolPipette {
hardwareType: 'pipette'
Expand Down Expand Up @@ -96,33 +97,32 @@ export const useRequiredProtocolHardwareFromAnalysis = (

const requiredGripper: ProtocolGripper[] = getProtocolUsesGripper(analysis)
? [
{
hardwareType: 'gripper',
connected:
attachedInstruments.some(i => i.instrumentType === 'gripper') ??
false,
},
]
{
hardwareType: 'gripper',
connected:
attachedInstruments.some(i => i.instrumentType === 'gripper') ??
false,
},
]
: []

const handleModuleConnectionCheckFor = (
attachedModules: AttachedModule[],
model: ModuleModel
): boolean => {
const ASSUME_ALWAYS_CONNECTED_MODULES = ['magneticBlockV1']

return !ASSUME_ALWAYS_CONNECTED_MODULES.includes(model)
? attachedModules.some(m => m.moduleModel === model)
: true
}

const requiredModules: ProtocolModule[] = analysis.modules.map(
({ location, model }) => {
const cutoutIdForSlotName = getCutoutIdForSlotName(location.slotName, deckDef)
const moduleFixtures = getCutoutFixturesForModuleModel(model, deckDef)

const configuredModuleSerialNumber = deckConfig.find(({ cutoutId, cutoutFixtureId }) => (
cutoutId === cutoutIdForSlotName
&& moduleFixtures.map(mf => mf.id).includes(cutoutFixtureId)
))?.opentronsModuleSerialNumber ?? null
const isConnected = moduleFixtures.every(mf => mf.expectOpentronsModuleSerialNumber)
? attachedModules.some(m => m.moduleModel === model && m.serialNumber === configuredModuleSerialNumber)
: true
return {
hardwareType: 'module',
moduleModel: model,
slot: location.slotName,
connected: handleModuleConnectionCheckFor(attachedModules, model),
connected: isConnected,
hasSlotConflict: deckConfig.some(
({ cutoutId, cutoutFixtureId }) =>
cutoutId === getCutoutIdForSlotName(location.slotName, deckDef) &&
Expand Down Expand Up @@ -160,16 +160,19 @@ export const useRequiredProtocolHardwareFromAnalysis = (
}
)

const requiredFixtures = requiredDeckConfigCompatibility.map(
({ cutoutFixtureId, cutoutId, compatibleCutoutFixtureIds }) => ({
hardwareType: 'fixture' as const,
cutoutFixtureId: compatibleCutoutFixtureIds[0],
location: { cutout: cutoutId },
hasSlotConflict:
cutoutFixtureId != null &&
!compatibleCutoutFixtureIds.includes(cutoutFixtureId),
})
)
const requiredFixtures = requiredDeckConfigCompatibility
// filter out all module fixtures as they're handled in the requiredModules section via hardwareType === 'module'
.filter(({ requiredAddressableAreas }) => !FLEX_MODULE_ADDRESSABLE_AREAS.some(modAA => requiredAddressableAreas.includes(modAA)))
.map(
({ cutoutFixtureId, cutoutId, compatibleCutoutFixtureIds }) => ({
hardwareType: 'fixture' as const,
cutoutFixtureId: compatibleCutoutFixtureIds[0],
location: { cutout: cutoutId },
hasSlotConflict:
cutoutFixtureId != null &&
!compatibleCutoutFixtureIds.includes(cutoutFixtureId),
})
)

return {
requiredProtocolHardware: [
Expand Down
1 change: 1 addition & 0 deletions shared-data/js/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export interface CutoutFixture {
mayMountTo: CutoutId[]
displayName: string
providesAddressableAreas: Record<CutoutId, AddressableAreaName[]>
expectOpentronsModuleSerialNumber: boolean
fixtureGroup: CutoutFixtureGroup
height: number
}
Expand Down

0 comments on commit 52a60e8

Please sign in to comment.