Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import type {
LoadedLabware,
LoadedModule,
} from '@opentrons/shared-data'
import type { LabwareOffsetLocationSequence } from '@opentrons/api-client'
import type {
LabwareOffsetLocationSequence,
OnAddressableAreaOffsetLocationSequenceComponent,
} from '@opentrons/api-client'

// Returns the offset location sequence, which is used to get/store offsets from the server,
// and drive LPC UI.
Expand All @@ -12,7 +15,14 @@ export function getLwOffsetLocSeqFromLocSeq(
lw: LoadedLabware[],
modules: LoadedModule[]
): LabwareOffsetLocationSequence {
return locSequence.reduce<LabwareOffsetLocationSequence>(
// The addressable area name is always the last item of an offset loc seq, but
// can appear above a module in a loc seq, so we always append the addressable
// area component last.
// This assumes there is always only one addressable area component!
const { mainItems, addressableAreaComponent } = locSequence.reduce<{
mainItems: LabwareOffsetLocationSequence
addressableAreaComponent: OnAddressableAreaOffsetLocationSequenceComponent | null
}>(
(acc, locSeqComponent) => {
const { kind } = locSeqComponent

Expand All @@ -22,30 +32,46 @@ export function getLwOffsetLocSeqFromLocSeq(
const matchingMod = modules.find(mod => mod.id === moduleId)

return matchingMod != null
? [...acc, { kind, moduleModel: matchingMod.model }]
? {
...acc,
mainItems: [
...acc.mainItems,
{ kind, moduleModel: matchingMod.model },
],
}
: acc
}
case 'onAddressableArea': {
return [
return {
...acc,
{
addressableAreaComponent: {
kind,
addressableAreaName: locSeqComponent.addressableAreaName,
},
]
}
}
case 'onLabware': {
const { labwareId } = locSeqComponent
const matchingLw = lw.find(aLw => aLw.id === labwareId)

return matchingLw != null
? [...acc, { kind, labwareUri: matchingLw.definitionUri }]
? {
...acc,
mainItems: [
...acc.mainItems,
{ kind, labwareUri: matchingLw.definitionUri },
],
}
: acc
}
default:
return acc
}
},
[]
{ mainItems: [], addressableAreaComponent: null }
)

return addressableAreaComponent != null
? [...mainItems, addressableAreaComponent]
: mainItems
}
Loading