Skip to content

Commit

Permalink
Implement drop_tip()'s state updates in terms of other public methods…
Browse files Browse the repository at this point in the history
…, where possible.

This is not intended to have any behavioral change.

The goal of this is to make it easier for callers (i.e. Protocol Engine) to see what they have to do in order to replicate the total effect of drop_tip(). And to make it easier for human code reviewers to confirm that that's done correctly.
  • Loading branch information
SyntaxColoring committed Oct 17, 2024
1 parent 98f92d7 commit c65dc75
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions api/src/opentrons/hardware_control/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,10 +1277,15 @@ async def drop_tip(self, mount: top_types.Mount, home_after: bool = True) -> Non
"""Drop tip at the current location."""
await self.tip_drop_moves(mount, home_after)

# todo(mm, 2024-10-17): Ideally, callers would be able to replicate the behavior
# of this method via self.drop_tip_moves() plus other public methods. This
# currently prevents that: there is no public equivalent for
# instrument.set_current_volume().
instrument = self.get_pipette(mount)
instrument.set_current_volume(0)
instrument.current_tiprack_diameter = 0.0
instrument.remove_tip()

self.set_current_tiprack_diameter(mount, 0.0)
await self.remove_tip(mount)

async def create_simulating_module(
self,
Expand Down
13 changes: 9 additions & 4 deletions api/src/opentrons/hardware_control/ot3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2323,14 +2323,19 @@ async def drop_tip(
self, mount: Union[top_types.Mount, OT3Mount], home_after: bool = False
) -> None:
"""Drop tip at the current location."""
await self.tip_drop_moves(mount=mount, home_after=home_after)

# todo(mm, 2024-10-17): Ideally, callers would be able to replicate the behavior
# of this method via self.drop_tip_moves() plus other public methods. This
# currently prevents that: there is no public equivalent for
# instrument.set_current_volume().
realmount = OT3Mount.from_mount(mount)
instrument = self._pipette_handler.get_pipette(realmount)
instrument.set_current_volume(0)

await self.tip_drop_moves(mount=mount, home_after=home_after)
self.set_current_tiprack_diameter(mount, 0.0)
await self.remove_tip(mount)

instrument.set_current_volume(0)
instrument.current_tiprack_diameter = 0.0
instrument.remove_tip()
# call this in case we're simulating:
if isinstance(self._backend, OT3Simulator):
self._backend._update_tip_state(realmount, False)
Expand Down

0 comments on commit c65dc75

Please sign in to comment.