Skip to content

Commit

Permalink
allow location conflict to grab serial number of first matching module
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Apr 1, 2024
1 parent 4ea0518 commit 1977256
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
import { Trans, useTranslation } from 'react-i18next'
import {
useDeckConfigurationQuery,
useModulesQuery,
useUpdateDeckConfigurationMutation,
} from '@opentrons/react-api-client'
import {
Expand Down Expand Up @@ -32,6 +33,8 @@ import {
THERMOCYCLER_MODULE_V2,
getCutoutFixtureIdsForModuleModel,

Check failure on line 34 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'getCutoutFixtureIdsForModuleModel' is defined but never used

Check failure on line 34 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'getCutoutFixtureIdsForModuleModel' is defined but never used
getCutoutFixturesForModuleModel,
getAddressableAreaNamesFromLoadedModule,
getCutoutIdForSlotName,

Check failure on line 37 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'getCutoutIdForSlotName' is defined but never used

Check failure on line 37 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'getCutoutIdForSlotName' is defined but never used
} from '@opentrons/shared-data'
import { getTopPortalEl } from '../../../../App/portal'
import { LegacyModal } from '../../../../molecules/LegacyModal'
Expand All @@ -46,6 +49,7 @@ import type {
DeckDefinition,
} from '@opentrons/shared-data'
import { replace } from 'lodash'

Check failure on line 51 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'replace' is defined but never used

Check failure on line 51 in app/src/organisms/Devices/ProtocolRun/SetupModuleAndDeck/LocationConflictModal.tsx

View workflow job for this annotation

GitHub Actions / js checks

'replace' is defined but never used
import { cs } from 'date-fns/locale'

interface LocationConflictModalProps {
onCloseClick: () => void
Expand All @@ -70,6 +74,7 @@ export const LocationConflictModal = (
isOnDevice = false,
} = props
const { t, i18n } = useTranslation(['protocol_setup', 'shared'])
const attachedModules = useModulesQuery().data?.data ?? []
const deckConfig = useDeckConfigurationQuery().data ?? []
const { updateDeckConfiguration } = useUpdateDeckConfigurationMutation()
const deckConfigurationAtLocationFixtureId = deckConfig.find(
Expand Down Expand Up @@ -105,15 +110,17 @@ export const LocationConflictModal = (

updateDeckConfiguration(newRequiredFixtureDeckConfig)
} else if (requiredModule != null) {
const addressableAreas = getAddressableAreaNamesFromLoadedModule(requiredModule, cutoutId.replace('cutout', ''), deckDef)
const cutoutFixtures = getCutoutFixturesForModuleModel(requiredModule, deckDef)
const cutoutIdsToReplace = cutoutFixtures.map(cf => cf.mayMountTo[0])
const newDeckConfig = deckConfig.map(fixture => {
const replacementFixture = cutoutFixtures.find(cf => cf.mayMountTo[0] === fixture.cutoutId)
return cutoutIdsToReplace.includes(fixture.cutoutId) && replacementFixture != null
? { ...fixture, cutoutFixtureId: replacementFixture?.id }
const replacementFixture = cutoutFixtures.find(cf => (
cf.mayMountTo.includes(fixture.cutoutId)
&& addressableAreas.some(aa => cf.providesAddressableAreas[cutoutId].includes(aa))
))
return cutoutId === fixture.cutoutId && replacementFixture != null
? { ...fixture, cutoutFixtureId: replacementFixture?.id, opentronsModuleSerialNumber: attachedModules.find(m => m.moduleModel === requiredModule)?.serialNumber }
: fixture
})

updateDeckConfiguration(newDeckConfig)
}
onCloseClick()
Expand Down
7 changes: 4 additions & 3 deletions shared-data/js/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,12 @@ export function getCutoutIdsFromModuleSlotName(
}

export function getAddressableAreaNamesFromLoadedModule(
params: LoadModuleCreateCommand['params'],
moduleModel: ModuleModel,
slotName: ModuleLocation['slotName'],
deckDef: DeckDefinition
): AddressableAreaName[] {
const moduleFixtures = getCutoutFixturesForModuleModel(params.model, deckDef)
const cutoutIds = getCutoutIdsFromModuleSlotName(params.location.slotName, moduleFixtures)
const moduleFixtures = getCutoutFixturesForModuleModel(moduleModel, deckDef)
const cutoutIds = getCutoutIdsFromModuleSlotName(slotName, moduleFixtures)
return moduleFixtures.reduce<AddressableAreaName[]>(
(acc, cutoutFixture) => {
const providedAddressableAreas =
Expand Down
3 changes: 2 additions & 1 deletion shared-data/js/helpers/getAddressableAreasInProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export function getAddressableAreasInProtocol(
!acc.includes(params.location.slotName as AddressableAreaName)
) {
const addressableAreaNames = getAddressableAreaNamesFromLoadedModule(
params,
params.model,
params.location.slotName,
deckDef
)

Expand Down
1 change: 0 additions & 1 deletion shared-data/js/helpers/getSimplestFlexDeckConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export function getSimplestDeckConfigForProtocol(
}
return acc
}, FLEX_SIMPLEST_DECK_CONFIG_PROTOCOL_SPEC)

return simplestDeckConfig
}

Expand Down

0 comments on commit 1977256

Please sign in to comment.