Skip to content

Commit

Permalink
fixup white screen in pd map
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper committed Nov 9, 2023
1 parent 913464f commit 9c7d19f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 52 deletions.
8 changes: 4 additions & 4 deletions app/src/resources/deck_configuration/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function getDeckConfigFromProtocolCommands(
)
}

function getCutoutFixturesForAddressableAreas(
export function getCutoutFixturesForAddressableAreas(
addressableAreas: AddressableAreaName[],
cutoutFixtures: CutoutFixture[]
): CutoutFixture[] {
Expand All @@ -186,7 +186,7 @@ function getCutoutFixturesForAddressableAreas(
)
}

function getCutoutFixturesForCutoutId(
export function getCutoutFixturesForCutoutId(
cutoutId: CutoutId,
cutoutFixtures: CutoutFixture[]
): CutoutFixture[] {
Expand All @@ -195,7 +195,7 @@ function getCutoutFixturesForCutoutId(
)
}

function getCutoutIdForAddressableArea(
export function getCutoutIdForAddressableArea(
addressableArea: AddressableAreaName,
cutoutFixtures: CutoutFixture[]
): CutoutId | null {
Expand All @@ -210,7 +210,7 @@ function getCutoutIdForAddressableArea(
}, null)
}

function getSimplestFixtureForAddressableAreas(
export function getSimplestFixtureForAddressableAreas(
cutoutId: CutoutId,
requiredAddressableAreas: AddressableAreaName[],
allCutoutFixtures: CutoutFixture[]
Expand Down
6 changes: 3 additions & 3 deletions components/src/hardware-sim/BaseDeck/SingleSlotFixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import * as React from 'react'
import { SlotBase } from './SlotBase'
import { SlotClip } from './SlotClip'

import type { Cutout, DeckDefinition, ModuleType } from '@opentrons/shared-data'
import type { CutoutId, DeckDefinition, ModuleType } from '@opentrons/shared-data'

interface SingleSlotFixtureProps extends React.SVGProps<SVGGElement> {
cutoutId: Cutout
cutoutId: CutoutId
deckDefinition: DeckDefinition
moduleType?: ModuleType
fixtureBaseColor?: React.SVGProps<SVGPathElement>['fill']
Expand Down Expand Up @@ -37,7 +37,7 @@ export function SingleSlotFixture(
}

const contentsByCutoutLocation: {
[cutoutId in Cutout]: JSX.Element
[cutoutId in CutoutId]: JSX.Element
} = {
cutoutA1: (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { shallow } from 'enzyme'
import fixture_96_plate from '@opentrons/shared-data/labware/fixtures/2/fixture_96_plate.json'
import {
CoordinateTuple,
DeckSlot,
LabwareDefinition2,
MAGNETIC_MODULE_TYPE,
Expand All @@ -18,27 +19,23 @@ describe('SlotControlsComponent', () => {
typeof labwareModuleCompatibility.getLabwareIsCompatible
>
beforeEach(() => {
const slot: DeckSlot = {
id: 'deckSlot1',
position: [1, 2, 3],
boundingBox: {
xDimension: 10,
yDimension: 20,
zDimension: 40,
},
displayName: 'slot 1',
compatibleModules: [MAGNETIC_MODULE_TYPE],
const slotId = 'D1'
const slotPosition: CoordinateTuple = [1, 2, 3]
const slotBoundingBox = {
xDimension: 10,
yDimension: 20,
zDimension: 40,
}

const labwareOnDeck = {
labwareDefURI: 'fixture/fixture_96_plate',
id: 'plate123',
slot: '3',
def: fixture_96_plate as LabwareDefinition2,
}

props = {
slot,
slotId,
slotPosition,
slotBoundingBox,
addLabware: jest.fn(),
moveDeckItem: jest.fn(),
selectedTerminalItemId: START_TERMINAL_ITEM_ID,
Expand Down
79 changes: 48 additions & 31 deletions protocol-designer/src/components/DeckSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import {
WASTE_CHUTE_CUTOUT,
WASTE_CHUTE_LOAD_NAME,
AddressableAreaName,
CutoutFixture,
CutoutId,
} from '@opentrons/shared-data'
import { FLEX_TRASH_DEF_URI, OT_2_TRASH_DEF_URI } from '../../constants'
import { selectors as labwareDefSelectors } from '../../labware-defs'
Expand Down Expand Up @@ -156,21 +158,21 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
// NOTE: naively hard-coded to show warning north of slots 1 or 3 when occupied by any module
const multichannelWarningSlotIds: AddressableAreaName[] = showGen1MultichannelCollisionWarnings
? compact([
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '1' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '4')?.id
: null,
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '3' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '6')?.id
: null,
])
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '1' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '4')?.id
: null,
allModules.some(
moduleOnDeck =>
moduleOnDeck.slot === '3' &&
MODULES_WITH_COLLISION_ISSUES.includes(moduleOnDeck.model)
)
? deckDef.locations.addressableAreas.find(s => s.id === '6')?.id
: null,
])
: []

return (
Expand Down Expand Up @@ -283,8 +285,8 @@ export const DeckSetupContents = (props: ContentsProps): JSX.Element => {
) : null}

{labwareLoadedOnModule == null &&
!shouldHideChildren &&
!isAdapter ? (
!shouldHideChildren &&
!isAdapter ? (
<SlotControls
key={moduleOnDeck.slot}
slotPosition={[0, 0, 0]} // Module Component already handles nested positioning
Expand Down Expand Up @@ -505,7 +507,7 @@ export const DeckSetup = (): JSX.Element => {
const trashBinFixtures = [
{
fixtureId: trash?.id,
fixtureLocation: trash?.slot as Cutout,
fixtureLocation: trash?.slot != null ? getCutoutIdForAddressableArea(trash?.slot as AddressableAreaName, deckDef.cutoutFixtures) : null,
loadName: TRASH_BIN_LOAD_NAME,
},
]
Expand All @@ -515,13 +517,9 @@ export const DeckSetup = (): JSX.Element => {
const stagingAreaFixtures: AdditionalEquipmentEntity[] = Object.values(
activeDeckSetup.additionalEquipmentOnDeck
).filter(aE => aE.name === STAGING_AREA_LOAD_NAME)
const locations = Object.values(
activeDeckSetup.additionalEquipmentOnDeck
).map(aE => aE.location)

const filteredSlots = DEFAULT_SLOTS.filter(
slot => !locations.includes(slot.fixtureLocation)
)
const filteredAddressableAreas = deckDef.locations.addressableAreas.filter(aa => isAddressableAreaStandardSlot(aa.id))


return (
<div className={styles.deck_row}>
Expand All @@ -538,16 +536,18 @@ export const DeckSetup = (): JSX.Element => {
<DeckFromLayers robotType={robotType} layerBlocklist={[]} />
) : (
<>
{filteredSlots.map(fixture => (
<SingleSlotFixture
key={fixture.fixtureId}
cutoutId={fixture.fixtureLocation as Cutout}
{filteredAddressableAreas.map(addressableArea => {
const cutoutId = getCutoutIdForAddressableArea(addressableArea.id, deckDef.cutoutFixtures)
return cutoutId != null ? (<SingleSlotFixture
key={addressableArea.id}
cutoutId={cutoutId}
deckDefinition={deckDef}
slotClipColor={darkFill}
showExpansion={fixture.fixtureLocation === 'A1'}
showExpansion={cutoutId === 'cutoutA1'}
fixtureBaseColor={lightFill}
/>
))}
) : null
})}
{stagingAreaFixtures.map(fixture => (
<StagingAreaFixture
key={fixture.id}
Expand All @@ -559,6 +559,7 @@ export const DeckSetup = (): JSX.Element => {
))}
{trash != null
? trashBinFixtures.map(fixture => (
fixture.fixtureLocation != null ? (
<React.Fragment key={fixture.fixtureId}>
<SingleSlotFixture
cutoutId={fixture.fixtureLocation}
Expand All @@ -575,7 +576,8 @@ export const DeckSetup = (): JSX.Element => {
backgroundColor={darkFill}
/>
</React.Fragment>
))
) : null
))
: null}
{wasteChuteFixtures.map(fixture => (
<WasteChuteFixture
Expand Down Expand Up @@ -610,3 +612,18 @@ export const DeckSetup = (): JSX.Element => {
</div>
)
}

function getCutoutIdForAddressableArea(
addressableArea: AddressableAreaName,
cutoutFixtures: CutoutFixture[]
): CutoutId | null {
return cutoutFixtures.reduce<CutoutId | null>((acc, cutoutFixture) => {
const [cutoutId] =
Object.entries(
cutoutFixture.providesAddressableAreas
).find(([_cutoutId, providedAAs]) =>
providedAAs.includes(addressableArea)
) ?? []
return (cutoutId as CutoutId) ?? acc
}, null)
}
1 change: 0 additions & 1 deletion protocol-designer/src/components/modules/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { MODULES_WITH_COLLISION_ISSUES } from '@opentrons/step-generation'
import { ModuleModel } from '@opentrons/shared-data'
export function isModuleWithCollisionIssue(model: ModuleModel): boolean {
// @ts-expect-error(sa, 2021-6-21): ModuleModel is a super type of the elements in MODULES_WITH_COLLISION_ISSUES
return MODULES_WITH_COLLISION_ISSUES.includes(model)
}

0 comments on commit 9c7d19f

Please sign in to comment.