Skip to content

Commit

Permalink
fix(protocol-engine): Fix hanging after cancellation (#14215)
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxColoring authored Dec 15, 2023
1 parent 9d4ce72 commit 9842207
Showing 1 changed file with 20 additions and 37 deletions.
57 changes: 20 additions & 37 deletions api/src/opentrons/protocol_engine/execution/hardware_stopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,29 @@ def __init__(
state_view=state_store,
)

async def _home_everything_except_plungers(self) -> None:
# TODO: Update this once gripper MotorAxis is available in engine.
try:
ot3api = ensure_ot3_hardware(hardware_api=self._hardware_api)
if (
not self._state_store.config.use_virtual_gripper
and ot3api.has_gripper()
):
await ot3api.home_z(mount=OT3Mount.GRIPPER)
except HardwareNotSupportedError:
pass
await self._movement_handler.home(
axes=[MotorAxis.X, MotorAxis.Y, MotorAxis.LEFT_Z, MotorAxis.RIGHT_Z]
)

async def _drop_tip(self) -> None:
"""Drop currently attached tip, if any, into trash after a run cancel."""
attached_tips = self._state_store.pipettes.get_all_attached_tips()

if attached_tips:
await self._hardware_api.stop(home_after=False)
# TODO: Update this once gripper MotorAxis is available in engine.
try:
ot3api = ensure_ot3_hardware(hardware_api=self._hardware_api)
if (
not self._state_store.config.use_virtual_gripper
and ot3api.has_gripper()
):
await ot3api.home_z(mount=OT3Mount.GRIPPER)
except HardwareNotSupportedError:
pass
await self._movement_handler.home(
axes=[MotorAxis.X, MotorAxis.Y, MotorAxis.LEFT_Z, MotorAxis.RIGHT_Z]
)

await self._home_everything_except_plungers()

# OT-2 Will only ever use the Fixed Trash Addressable Area
if self._state_store.config.robot_type == "OT-2 Standard":
Expand Down Expand Up @@ -125,28 +129,7 @@ async def do_stop_and_recover(
if drop_tips_after_run:
await self._drop_tip()
await self._hardware_api.stop(home_after=home_after_stop)

elif home_after_stop:
if len(self._state_store.pipettes.get_all_attached_tips()) == 0:
await self._hardware_api.stop(home_after=home_after_stop)
else:
try:
ot3api = ensure_ot3_hardware(hardware_api=self._hardware_api)
if (
not self._state_store.config.use_virtual_gripper
and ot3api.has_gripper()
):
await ot3api.home_z(mount=OT3Mount.GRIPPER)
except HardwareNotSupportedError:
pass

await self._movement_handler.home(
axes=[
MotorAxis.X,
MotorAxis.Y,
MotorAxis.LEFT_Z,
MotorAxis.RIGHT_Z,
]
)
else:
await self._hardware_api.stop(home_after=home_after_stop)
await self._hardware_api.stop(home_after=False)
if home_after_stop:
await self._home_everything_except_plungers()

0 comments on commit 9842207

Please sign in to comment.