Skip to content

Commit 262235c

Browse files
do the same for dispense
1 parent b259093 commit 262235c

File tree

1 file changed

+37
-72
lines changed

1 file changed

+37
-72
lines changed

api/src/opentrons/protocol_engine/commands/dispense_while_tracking.py

+37-72
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic.json_schema import SkipJsonSchema
1010

1111
from ..state.update_types import CLEAR, StateUpdate
12-
from ..types import CurrentWell, DeckPoint
12+
from ..types import DeckPoint
1313
from .pipetting_common import (
1414
PipetteIdMixin,
1515
DispenseVolumeMixin,
@@ -99,13 +99,6 @@ async def execute(self, params: DispenseWhileTrackingParams) -> _ExecuteReturn:
9999

100100
# TODO(pbm, 10-15-24): call self._state_view.geometry.validate_dispense_volume_into_well()
101101

102-
current_location = self._state_view.pipettes.get_current_location()
103-
current_position = await self._gantry_mover.get_position(params.pipetteId)
104-
current_well = CurrentWell(
105-
pipette_id=params.pipetteId,
106-
labware_id=params.labwareId,
107-
well_name=params.wellName,
108-
)
109102
state_update = StateUpdate()
110103
move_result = await move_to_well(
111104
movement=self._movement,
@@ -114,8 +107,7 @@ async def execute(self, params: DispenseWhileTrackingParams) -> _ExecuteReturn:
114107
labware_id=params.labwareId,
115108
well_name=params.wellName,
116109
well_location=params.wellLocation,
117-
current_well=current_well,
118-
operation_volume=-params.volume,
110+
operation_volume=params.volume,
119111
)
120112
state_update.append(move_result.state_update)
121113
if isinstance(move_result, DefinedErrorData):
@@ -132,9 +124,9 @@ async def execute(self, params: DispenseWhileTrackingParams) -> _ExecuteReturn:
132124
push_out=params.pushOut,
133125
location_if_error={
134126
"retryLocation": (
135-
current_position.x,
136-
current_position.y,
137-
current_position.z,
127+
move_result.public.position.x,
128+
move_result.public.position.y,
129+
move_result.public.position.z,
138130
)
139131
},
140132
pipetting=self._pipetting,
@@ -150,67 +142,40 @@ async def execute(self, params: DispenseWhileTrackingParams) -> _ExecuteReturn:
150142
)
151143

152144
if isinstance(dispense_result, DefinedErrorData):
153-
if (
154-
isinstance(current_location, CurrentWell)
155-
and current_location.pipette_id == params.pipetteId
156-
):
157-
return DefinedErrorData(
158-
public=dispense_result.public,
159-
state_update=dispense_result.state_update.set_liquid_operated(
160-
labware_id=current_location.labware_id,
161-
well_names=self._state_view.geometry.get_wells_covered_by_pipette_with_active_well(
162-
current_location.labware_id,
163-
current_location.well_name,
164-
params.pipetteId,
165-
),
166-
volume_added=CLEAR,
167-
),
168-
state_update_if_false_positive=dispense_result.state_update_if_false_positive,
169-
)
170-
else:
171-
return dispense_result
172-
else:
173-
if (
174-
isinstance(current_location, CurrentWell)
175-
and current_location.pipette_id == params.pipetteId
176-
):
177-
volume_added = (
178-
self._state_view.pipettes.get_liquid_dispensed_by_ejecting_volume(
179-
pipette_id=params.pipetteId,
180-
volume=dispense_result.public.volume,
181-
)
182-
)
183-
if volume_added is not None:
184-
volume_added *= self._state_view.geometry.get_nozzles_per_well(
185-
current_location.labware_id,
186-
current_location.well_name,
145+
return DefinedErrorData(
146+
public=dispense_result.public,
147+
state_update=dispense_result.state_update.set_liquid_operated(
148+
labware_id=params.labwareId,
149+
well_names=self._state_view.geometry.get_wells_covered_by_pipette_with_active_well(
150+
params.labwareId,
151+
params.wellName,
187152
params.pipetteId,
188-
)
189-
return SuccessData(
190-
public=DispenseWhileTrackingResult(
191-
volume=dispense_result.public.volume,
192-
position=result_deck_point,
193153
),
194-
state_update=dispense_result.state_update.set_liquid_operated(
195-
labware_id=current_location.labware_id,
196-
well_names=self._state_view.geometry.get_wells_covered_by_pipette_with_active_well(
197-
current_location.labware_id,
198-
current_location.well_name,
199-
params.pipetteId,
200-
),
201-
volume_added=volume_added
202-
if volume_added is not None
203-
else CLEAR,
204-
),
205-
)
206-
else:
207-
return SuccessData(
208-
public=DispenseWhileTrackingResult(
209-
volume=dispense_result.public.volume,
210-
position=result_deck_point,
211-
),
212-
state_update=dispense_result.state_update,
213-
)
154+
volume_added=CLEAR,
155+
),
156+
state_update_if_false_positive=dispense_result.state_update_if_false_positive,
157+
)
158+
159+
return SuccessData(
160+
public=DispenseWhileTrackingResult(
161+
volume=dispense_result.public.volume,
162+
position=result_deck_point,
163+
),
164+
state_update=dispense_result.state_update.set_liquid_operated(
165+
labware_id=params.labwareId,
166+
well_names=self._state_view.geometry.get_wells_covered_by_pipette_with_active_well(
167+
params.labwareId,
168+
params.wellName,
169+
params.pipetteId,
170+
),
171+
volume_added=dispense_result.public.volume
172+
* self._state_view.geometry.get_nozzles_per_well(
173+
params.labwareId,
174+
params.wellName,
175+
params.pipetteId,
176+
),
177+
),
178+
)
214179

215180

216181
class DispenseWhileTracking(

0 commit comments

Comments
 (0)