diff --git a/protocol-designer/src/file-data/selectors/commands.ts b/protocol-designer/src/file-data/selectors/commands.ts index 7c291edb713..924767297bd 100644 --- a/protocol-designer/src/file-data/selectors/commands.ts +++ b/protocol-designer/src/file-data/selectors/commands.ts @@ -54,43 +54,19 @@ export const getInitialRobotState: ( stepFormSelectors.getInitialDeckSetup, stepFormSelectors.getInvariantContext, getLabwareLiquidState, - stepFormSelectors.getSavedStepForms, - (initialDeckSetup, invariantContext, labwareLiquidState, savedStepForms) => { - const onlyPipettingFormSteps = Object.entries(savedStepForms).filter( - ([stepId, form]) => - form.stepType === 'moveLiquid' || form.stepType === 'mix' + (initialDeckSetup, invariantContext, labwareLiquidState) => { + const pipettes: Record = mapValues( + initialDeckSetup.pipettes, + (p: PipetteOnDeck): PipetteTemporalProperties => ({ + mount: p.mount, + }) ) - const lastPipetteFormStep = - onlyPipettingFormSteps.length > 0 - ? onlyPipettingFormSteps[onlyPipettingFormSteps.length - 1] - : null - const lastPipettingStepNozzles = - lastPipetteFormStep != null ? lastPipetteFormStep[1]?.nozzles : undefined - - const prevPipetteFormStep = - onlyPipettingFormSteps.length > 1 - ? onlyPipettingFormSteps[onlyPipettingFormSteps.length - 2] - : null - // NOTE: previous pipetting step nozzles is necessary - // in order to know when to emit the configureNozzleLayout - // command - const prevPipettingStepNozzles = - prevPipetteFormStep != null ? prevPipetteFormStep[1]?.nozzles : undefined const labware: Record = mapValues( initialDeckSetup.labware, (l: LabwareOnDeck): LabwareTemporalProperties => ({ slot: l.slot, }) ) - const pipettes: Record = mapValues( - initialDeckSetup.pipettes, - (p: PipetteOnDeck): PipetteTemporalProperties => ({ - mount: p.mount, - nozzles: p.name === 'p1000_96' ? lastPipettingStepNozzles : undefined, - prevNozzles: - p.name === 'p1000_96' ? prevPipettingStepNozzles : undefined, - }) - ) const modules: Record = mapValues( initialDeckSetup.modules, (m: ModuleOnDeck): ModuleTemporalProperties => { diff --git a/step-generation/src/commandCreators/compound/consolidate.ts b/step-generation/src/commandCreators/compound/consolidate.ts index 3eabe0066a2..e43e482084b 100644 --- a/step-generation/src/commandCreators/compound/consolidate.ts +++ b/step-generation/src/commandCreators/compound/consolidate.ts @@ -18,7 +18,6 @@ import { airGapHelper, dispenseLocationHelper, moveHelper, - getConfigureNozzleLayoutCommandReset, getIsTallLabwareWestOf96Channel, getWasteChuteAddressableAreaNamePip, } from '../../utils' @@ -466,11 +465,10 @@ export const consolidate: CommandCreator = ( const dropTipAfterDispenseAirGap = airGapAfterDispenseCommands.length > 0 ? dropTipCommand : [] - const nozzles = prevRobotState.pipettes[args.pipette].nozzles - const prevNozzles = prevRobotState.pipettes[args.pipette].prevNozzles + const stateNozzles = prevRobotState.pipettes[args.pipette].nozzles const configureNozzleLayoutCommand: CurriedCommandCreator[] = // only emit the command if previous nozzle state is different - is96Channel && args.nozzles != null && nozzles !== prevNozzles + is96Channel && args.nozzles != null && args.nozzles !== stateNozzles ? [ curryCommandCreator(configureNozzleLayout, { nozzles: args.nozzles, @@ -478,10 +476,6 @@ export const consolidate: CommandCreator = ( }), ] : [] - const configureNozzleLayoutCommandReset = getConfigureNozzleLayoutCommandReset( - args.pipette, - prevNozzles - ) return [ ...configureNozzleLayoutCommand, @@ -497,7 +491,6 @@ export const consolidate: CommandCreator = ( ...blowoutCommand, ...airGapAfterDispenseCommands, ...dropTipAfterDispenseAirGap, - ...configureNozzleLayoutCommandReset, ] } ) diff --git a/step-generation/src/commandCreators/compound/distribute.ts b/step-generation/src/commandCreators/compound/distribute.ts index 8c5f43e0af4..12c93ce9a3e 100644 --- a/step-generation/src/commandCreators/compound/distribute.ts +++ b/step-generation/src/commandCreators/compound/distribute.ts @@ -16,7 +16,6 @@ import { blowoutUtil, wasteChuteCommandsUtil, getDispenseAirGapLocation, - getConfigureNozzleLayoutCommandReset, getIsTallLabwareWestOf96Channel, getWasteChuteAddressableAreaNamePip, } from '../../utils' @@ -448,11 +447,10 @@ export const distribute: CommandCreator = ( ] : [] - const nozzles = prevRobotState.pipettes[args.pipette].nozzles - const prevNozzles = prevRobotState.pipettes[args.pipette].prevNozzles + const stateNozzles = prevRobotState.pipettes[args.pipette].nozzles const configureNozzleLayoutCommand: CurriedCommandCreator[] = // only emit the command if previous nozzle state is different - is96Channel && args.nozzles != null && nozzles !== prevNozzles + is96Channel && args.nozzles != null && args.nozzles !== stateNozzles ? [ curryCommandCreator(configureNozzleLayout, { nozzles: args.nozzles, @@ -460,10 +458,6 @@ export const distribute: CommandCreator = ( }), ] : [] - const configureNozzleLayoutCommandReset = getConfigureNozzleLayoutCommandReset( - args.pipette, - prevNozzles - ) return [ ...configureNozzleLayoutCommand, @@ -485,7 +479,6 @@ export const distribute: CommandCreator = ( ...blowoutCommands, ...airGapAfterDispenseCommands, ...dropTipAfterDispenseAirGap, - ...configureNozzleLayoutCommandReset, ] } ) diff --git a/step-generation/src/commandCreators/compound/mix.ts b/step-generation/src/commandCreators/compound/mix.ts index c2e183448a5..01d870eeb4b 100644 --- a/step-generation/src/commandCreators/compound/mix.ts +++ b/step-generation/src/commandCreators/compound/mix.ts @@ -5,7 +5,6 @@ import { blowoutUtil, curryCommandCreator, reduceCommandCreators, - getConfigureNozzleLayoutCommandReset, getIsTallLabwareWestOf96Channel, } from '../../utils' import * as errorCreators from '../../errorCreators' @@ -179,11 +178,10 @@ export const mix: CommandCreator = ( ], } } - const nozzles = prevRobotState.pipettes[pipette].nozzles - const prevNozzles = prevRobotState.pipettes[pipette].prevNozzles + const stateNozzles = prevRobotState.pipettes[pipette].nozzles const configureNozzleLayoutCommand: CurriedCommandCreator[] = // only emit the command if previous nozzle state is different - is96Channel && data.nozzles != null && nozzles !== prevNozzles + is96Channel && data.nozzles != null && data.nozzles !== stateNozzles ? [ curryCommandCreator(configureNozzleLayout, { nozzles: data.nozzles, @@ -202,10 +200,6 @@ export const mix: CommandCreator = ( }), ] : [] - const configureNozzleLayoutCommandReset = getConfigureNozzleLayoutCommandReset( - pipette, - prevNozzles - ) // Command generation const commandCreators = flatMap( wells, @@ -264,7 +258,6 @@ export const mix: CommandCreator = ( ...mixCommands, ...blowoutCommand, ...touchTipCommands, - ...configureNozzleLayoutCommandReset, ] } ) diff --git a/step-generation/src/commandCreators/compound/transfer.ts b/step-generation/src/commandCreators/compound/transfer.ts index 4158b6b8deb..76c8067d04d 100644 --- a/step-generation/src/commandCreators/compound/transfer.ts +++ b/step-generation/src/commandCreators/compound/transfer.ts @@ -18,7 +18,6 @@ import { getTrashOrLabware, dispenseLocationHelper, moveHelper, - getConfigureNozzleLayoutCommandReset, getIsTallLabwareWestOf96Channel, getWasteChuteAddressableAreaNamePip, } from '../../utils' @@ -275,11 +274,10 @@ export const transfer: CommandCreator = ( changeTipNow = isInitialSubtransfer || destinationWell !== prevDestWell } - const nozzles = prevRobotState.pipettes[args.pipette].nozzles - const prevNozzles = prevRobotState.pipettes[args.pipette].prevNozzles + const stateNozzles = prevRobotState.pipettes[args.pipette].nozzles const configureNozzleLayoutCommand: CurriedCommandCreator[] = // only emit the command if previous nozzle state is different - is96Channel && args.nozzles != null && nozzles !== prevNozzles + is96Channel && args.nozzles != null && args.nozzles !== stateNozzles ? [ curryCommandCreator(configureNozzleLayout, { nozzles: args.nozzles, @@ -287,10 +285,6 @@ export const transfer: CommandCreator = ( }), ] : [] - const configureNozzleLayoutCommandReset = getConfigureNozzleLayoutCommandReset( - args.pipette, - prevNozzles - ) const configureForVolumeCommand: CurriedCommandCreator[] = LOW_VOLUME_PIPETTES.includes( invariantContext.pipetteEntities[args.pipette].name @@ -598,7 +592,6 @@ export const transfer: CommandCreator = ( ...blowoutCommand, ...airGapAfterDispenseCommands, ...dropTipAfterDispenseAirGap, - ...configureNozzleLayoutCommandReset, ] // NOTE: side-effecting prevSourceWell = sourceWell diff --git a/step-generation/src/getNextRobotStateAndWarnings/forConfigureNozzleLayout.ts b/step-generation/src/getNextRobotStateAndWarnings/forConfigureNozzleLayout.ts new file mode 100644 index 00000000000..dbfcb5f50e7 --- /dev/null +++ b/step-generation/src/getNextRobotStateAndWarnings/forConfigureNozzleLayout.ts @@ -0,0 +1,21 @@ +import { NozzleConfigurationStyle } from '@opentrons/shared-data' +import type { InvariantContext, RobotStateAndWarnings } from '../types' + +interface ConfigureNozzleLayoutParams { + pipetteId: string + configurationParams: { + style: NozzleConfigurationStyle + primaryNozzle?: string + } +} + +export function forConfigureNozzleLayout( + params: ConfigureNozzleLayoutParams, + invariantContext: InvariantContext, + robotStateAndWarnings: RobotStateAndWarnings +): void { + const { pipetteId, configurationParams } = params + const { robotState } = robotStateAndWarnings + + robotState.pipettes[pipetteId].nozzles = configurationParams.style +} diff --git a/step-generation/src/getNextRobotStateAndWarnings/index.ts b/step-generation/src/getNextRobotStateAndWarnings/index.ts index 4d2febd2554..11d76b22276 100644 --- a/step-generation/src/getNextRobotStateAndWarnings/index.ts +++ b/step-generation/src/getNextRobotStateAndWarnings/index.ts @@ -45,6 +45,7 @@ import type { RobotState, RobotStateAndWarnings, } from '../types' +import { forConfigureNozzleLayout } from './forConfigureNozzleLayout' // WARNING this will mutate the prevRobotState function _getNextRobotStateAndWarningsSingleCommand( @@ -123,6 +124,11 @@ function _getNextRobotStateAndWarningsSingleCommand( break case 'configureNozzleLayout': + forConfigureNozzleLayout( + command.params, + invariantContext, + robotStateAndWarnings + ) break case 'touchTip': diff --git a/step-generation/src/robotStateSelectors.ts b/step-generation/src/robotStateSelectors.ts index eca0fa6e2c6..3b13aecf86d 100644 --- a/step-generation/src/robotStateSelectors.ts +++ b/step-generation/src/robotStateSelectors.ts @@ -104,11 +104,11 @@ export function getNextTiprack( const filteredSortedTipRackIdsFor96Channel = sortedTipracksIds.filter( tiprackId => { const tipRackLocation = robotState.labware[tiprackId].slot - const tiprackLocation = invariantContext.labwareEntities[tipRackLocation] + const adapterEntity = invariantContext.labwareEntities[tipRackLocation] const has96TiprackAdapterId = - tiprackLocation?.def.parameters.loadName === + adapterEntity?.def.parameters.loadName === 'opentrons_flex_96_tiprack_adapter' && - tiprackLocation?.def.namespace === 'opentrons' + adapterEntity?.def.namespace === 'opentrons' return nozzles === ALL ? has96TiprackAdapterId : !has96TiprackAdapterId } diff --git a/step-generation/src/types.ts b/step-generation/src/types.ts index 3db20b00afe..3e754acdcde 100644 --- a/step-generation/src/types.ts +++ b/step-generation/src/types.ts @@ -42,7 +42,6 @@ export interface LabwareTemporalProperties { export interface PipetteTemporalProperties { mount: Mount nozzles?: NozzleConfigurationStyle - prevNozzles?: NozzleConfigurationStyle } export interface MagneticModuleState { diff --git a/step-generation/src/utils/misc.ts b/step-generation/src/utils/misc.ts index bfb67bf014b..f2a4f952258 100644 --- a/step-generation/src/utils/misc.ts +++ b/step-generation/src/utils/misc.ts @@ -8,8 +8,6 @@ import { getWellsDepth, getWellNamePerMultiTip, WASTE_CHUTE_CUTOUT, - COLUMN, - ALL, PipetteChannels, ONE_CHANNEL_WASTE_CHUTE_ADDRESSABLE_AREA, EIGHT_CHANNEL_WASTE_CHUTE_ADDRESSABLE_AREA, @@ -18,7 +16,6 @@ import { import { reduceCommandCreators, wasteChuteCommandsUtil } from './index' import { aspirate, - configureNozzleLayout, dispense, moveToAddressableArea, moveToWell, @@ -26,10 +23,7 @@ import { import { blowout } from '../commandCreators/atomic/blowout' import { curryCommandCreator } from './curryCommandCreator' import { movableTrashCommandsUtil } from './movableTrashCommandsUtil' -import type { - LabwareDefinition2, - NozzleConfigurationStyle, -} from '@opentrons/shared-data' +import type { LabwareDefinition2 } from '@opentrons/shared-data' import type { BlowoutParams } from '@opentrons/shared-data/protocol/types/schemaV4' import type { AdditionalEquipmentEntities, @@ -700,17 +694,3 @@ export const airGapHelper: CommandCreator = ( return reduceCommandCreators(commands, invariantContext, prevRobotState) } - -export const getConfigureNozzleLayoutCommandReset = ( - pipetteId: string, - prevNozzles?: NozzleConfigurationStyle -): CurriedCommandCreator[] => { - return prevNozzles === COLUMN - ? [ - curryCommandCreator(configureNozzleLayout, { - nozzles: ALL, - pipetteId, - }), - ] - : [] -}