Skip to content

Commit

Permalink
substitute channels for nozzle type
Browse files Browse the repository at this point in the history
  • Loading branch information
brenthagen committed May 17, 2024
1 parent 9f55259 commit 01fd89c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 59 deletions.
3 changes: 1 addition & 2 deletions app/src/organisms/QuickTransferFlow/SelectDestWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export function SelectDestWells(props: SelectDestWellsProps): JSX.Element {
selectWells={wellGroup => {
setSelectedWells(prevWells => ({ ...prevWells, ...wellGroup }))
}}
// TODO: nozzle type
nozzleType={null}
channels={state.pipette?.channels ?? 1}
/>
) : null}
</Flex>
Expand Down
3 changes: 1 addition & 2 deletions app/src/organisms/QuickTransferFlow/SelectSourceWells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ export function SelectSourceWells(props: SelectSourceWellsProps): JSX.Element {
selectWells={wellGroup => {
setSelectedWells(prevWells => ({ ...prevWells, ...wellGroup }))
}}
// TODO: nozzle type
nozzleType={null}
channels={state.pipette?.channels ?? 1}
/>
) : null}
</Flex>
Expand Down
31 changes: 10 additions & 21 deletions app/src/organisms/WellSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
RobotCoordinateSpace,
WELL_LABEL_OPTIONS,
} from '@opentrons/components'
import { COLUMN } from '@opentrons/shared-data'
import {
arrayToWellGroup,
getCollidingWells,
Expand All @@ -16,38 +15,30 @@ import {
import { SelectionRect } from './SelectionRect'

import type { WellFill, WellGroup, WellStroke } from '@opentrons/components'
import type { LabwareDefinition2 } from '@opentrons/shared-data'
import type { GenericRect, NozzleType } from './types'
import type {
LabwareDefinition2,
PipetteChannels,
} from '@opentrons/shared-data'
import type { GenericRect } from './types'

interface WellSelectionProps {
definition: LabwareDefinition2
/** array of primary wells. Overrides labwareProps.selectedWells */
selectedPrimaryWells: WellGroup
selectWells: (wellGroup: WellGroup) => unknown
nozzleType: NozzleType | null
}

type ChannelType = 8 | 96

const getChannelsFromNozzleType = (nozzleType: NozzleType): ChannelType => {
if (nozzleType === '8-channel' || nozzleType === COLUMN) {
return 8
} else {
return 96
}
channels: PipetteChannels
}

export function WellSelection(props: WellSelectionProps): JSX.Element {
const { definition, selectedPrimaryWells, selectWells, nozzleType } = props
const { definition, selectedPrimaryWells, selectWells, channels } = props

const [highlightedWells, setHighlightedWells] = React.useState<WellGroup>({})

const _wellsFromSelected: (
selectedWells: WellGroup
) => WellGroup = selectedWells => {
// Returns PRIMARY WELLS from the selection.
if (nozzleType != null) {
const channels = getChannelsFromNozzleType(nozzleType)
if (channels === 8 || channels === 96) {
// for the wells that have been highlighted,
// get all 8-well well sets and merge them
const primaryWells: WellGroup = reduce(
Expand Down Expand Up @@ -76,8 +67,7 @@ export function WellSelection(props: WellSelectionProps): JSX.Element {
}

const handleSelectionMove: (rect: GenericRect) => void = rect => {
if (nozzleType != null) {
const channels = getChannelsFromNozzleType(nozzleType)
if (channels === 8 || channels === 96) {
const selectedWells = _getWellsFromRect(rect)
const allWellsForMulti: WellGroup = reduce(
selectedWells,
Expand Down Expand Up @@ -107,11 +97,10 @@ export function WellSelection(props: WellSelectionProps): JSX.Element {

// For rendering, show all wells not just primary wells
const allSelectedWells =
nozzleType != null
channels === 8 || channels === 96
? reduce<WellGroup, WellGroup>(
selectedPrimaryWells,
(acc, _, wellName): WellGroup => {
const channels = getChannelsFromNozzleType(nozzleType)
const wellSet = getWellSetForMultichannel(
definition,
wellName,
Expand Down
32 changes: 0 additions & 32 deletions app/src/organisms/WellSelection/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,3 @@ export interface BoundingRect {
width: number
height: number
}

export interface LocationLiquidState {
[ingredGroup: string]: { volume: number }
}

export interface WellContents {
// eg 'A1', 'A2' etc
wellName?: string
groupIds: string[]
ingreds: LocationLiquidState
highlighted?: boolean
selected?: boolean
maxVolume?: number
}
export type ContentsByWell = {
[wellName: string]: WellContents
} | null

export const COLUMN = 'COLUMN'
const SINGLE = 'SINGLE'
const ROW = 'ROW'
const QUADRANT = 'QUADRANT'
export const ALL = 'ALL'

export type NozzleConfigurationStyle =
| typeof COLUMN
| typeof SINGLE
| typeof ROW
| typeof QUADRANT
| typeof ALL

export type NozzleType = NozzleConfigurationStyle | '8-channel'
6 changes: 4 additions & 2 deletions app/src/organisms/WellSelection/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { WellGroup } from '@opentrons/components'
import type { WellSetHelpers } from '@opentrons/shared-data'
import type { BoundingRect, GenericRect } from './types'

// Collision detection for SelectionRect / SelectableLabware
// Collision detection for SelectionRect / WellSelection
export const rectCollision = (
rect1: BoundingRect,
rect2: BoundingRect
Expand Down Expand Up @@ -62,9 +62,11 @@ export const getCollidingWells = (rectPositions: GenericRect): WellGroup => {
)
return collidedWellData
}

export const arrayToWellGroup = (w: string[]): WellGroup =>
w.reduce((acc, wellName) => ({ ...acc, [wellName]: null }), {})
// cross-PD memoization of well set utils

// memoization of well set utils
const wellSetHelpers: WellSetHelpers = makeWellSetHelpers()
const {
canPipetteUseLabware,
Expand Down

0 comments on commit 01fd89c

Please sign in to comment.