Skip to content

Commit

Permalink
fix(protocol-designer): add dependent fields when tiprack changes (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader authored Nov 13, 2024
1 parent 655581c commit 8835d1f
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,30 @@ const updatePatchOnPipetteChannelChange = (

const updatePatchOnPipetteChange = (
patch: FormPatch,
rawForm: FormData,
pipetteEntities: PipetteEntities
rawForm: FormData
): FormPatch => {
// when pipette ID is changed (to another ID, or to null),
// set any flow rates to null
if (fieldHasChanged(rawForm, patch, 'pipette')) {
return {
...patch,
...getDefaultFields(
'aspirate_flowRate',
'dispense_flowRate',
'tipRack',
'nozzles'
),
}
}

return patch
}

const updatePatchOnTiprackChange = (
patch: FormPatch,
rawForm: FormData
): FormPatch => {
if (fieldHasChanged(rawForm, patch, 'tipRack')) {
return {
...patch,
...getDefaultFields('aspirate_flowRate', 'dispense_flowRate'),
Expand Down Expand Up @@ -168,7 +186,7 @@ export function dependentFieldsUpdateMix(
labwareEntities,
pipetteEntities
),
chainPatch =>
updatePatchOnPipetteChange(chainPatch, rawForm, pipetteEntities),
chainPatch => updatePatchOnPipetteChange(chainPatch, rawForm),
chainPatch => updatePatchOnTiprackChange(chainPatch, rawForm),
])
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,40 @@ const updatePatchOnPipetteChange = (
'dispense_mix_volume',
'disposalVolume_volume',
'aspirate_mmFromBottom',
'dispense_mmFromBottom'
'dispense_mmFromBottom',
'nozzles',
'tipRack'
),
aspirate_airGap_volume: airGapVolume,
dispense_airGap_volume: airGapVolume,
}
}

return patch
}

const updatePatchOnTiprackChange = (
patch: FormPatch,
rawForm: FormData,
pipetteEntities: PipetteEntities
): FormPatch => {
if (fieldHasChanged(rawForm, patch, 'tipRack')) {
const pipette = patch.pipette
let airGapVolume: string | null = null

if (typeof pipette === 'string' && pipette in pipetteEntities) {
const minVolume = getMinPipetteVolume(pipetteEntities[pipette])
airGapVolume = minVolume.toString()
}

return {
...patch,
...getDefaultFields(
'aspirate_flowRate',
'dispense_flowRate',
'aspirate_mix_volume',
'dispense_mix_volume',
'disposalVolume_volume'
),
aspirate_airGap_volume: airGapVolume,
dispense_airGap_volume: airGapVolume,
Expand Down Expand Up @@ -662,5 +695,7 @@ export function dependentFieldsUpdateMoveLiquid(
chainPatch => updatePatchBlowoutFields(chainPatch, rawForm),
chainPatch =>
clampDispenseAirGapVolume(chainPatch, rawForm, pipetteEntities),
chainPatch =>
updatePatchOnTiprackChange(chainPatch, rawForm, pipetteEntities),
])
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ describe('well selection should update', () => {
wells: [],
aspirate_flowRate: null,
dispense_flowRate: null,
nozzles: null,
tipRack: null,
})
})
it('pipette single -> multi', () => {
Expand All @@ -105,6 +107,8 @@ describe('well selection should update', () => {
wells: [],
aspirate_flowRate: null,
dispense_flowRate: null,
nozzles: null,
tipRack: null,
})
})
it('pipette multi -> single', () => {
Expand All @@ -117,6 +121,8 @@ describe('well selection should update', () => {
wells: ['A10', 'B10', 'C10', 'D10', 'E10', 'F10', 'G10', 'H10'],
aspirate_flowRate: null,
dispense_flowRate: null,
nozzles: null,
tipRack: null,
})
})
it('select single-well labware', () => {
Expand Down

0 comments on commit 8835d1f

Please sign in to comment.