Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): Opentrons simulate pick up tip message formatting #16178

Open
wants to merge 2 commits into
base: chore_release-8.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions api/src/opentrons/legacy_commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
from typing import TYPE_CHECKING, List, Union, overload


from .helpers import stringify_location, stringify_disposal_location, listify
from .helpers import (
stringify_location,
stringify_disposal_location,
listify,
stringify_pickup_location_range,
)
from . import types as command_types

from opentrons.types import Location
Expand Down Expand Up @@ -247,7 +252,12 @@ def return_tip() -> command_types.ReturnTipCommand:
def pick_up_tip(
instrument: InstrumentContext, location: Well
) -> command_types.PickUpTipCommand:
location_text = stringify_location(location)
if instrument._core.get_active_channels() < instrument.channels:
location_text = stringify_pickup_location_range(
instrument._core.get_nozzle_map(), location
)
else:
location_text = stringify_location(location)
text = f"Picking up tip from {location_text}"
return {
"name": command_types.PICK_UP_TIP,
Expand Down
67 changes: 66 additions & 1 deletion api/src/opentrons/legacy_commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from opentrons.protocol_api.disposal_locations import TrashBin, WasteChute
from opentrons.protocol_api._types import OffDeckType
from opentrons.types import Location, DeckLocation

from opentrons.hardware_control.nozzle_manager import NozzleConfigurationType, NozzleMap

CommandLocation = Union[Location, Well]

Expand Down Expand Up @@ -41,6 +41,71 @@ def stringify_location(location: Union[CommandLocation, List[CommandLocation]])
return ", ".join(loc_str_list)


def stringify_pickup_location_range( # noqa: C901
nozzle_map: NozzleMap, location: Well
) -> str:
if nozzle_map.configuration == NozzleConfigurationType.SINGLE:
loc_str_list = [_stringify_new_loc(location)]
else:
labware_columns = location.parent.columns()
critical_column = 0
critical_row = 0
for column in labware_columns:
if location in column:
critical_row = column.index(location)
critical_column = labware_columns.index(column)

if nozzle_map.starting_nozzle == "A1":
last_well_col = len(labware_columns) - 1
last_well_row = len(labware_columns[0]) - 1
if critical_column + len(nozzle_map.columns) < len(labware_columns):
last_well_col = critical_column + (len(nozzle_map.columns) - 1)
if critical_row + len(nozzle_map.rows) < len(
labware_columns[critical_column]
):
last_well_row = critical_row + (len(nozzle_map.rows) - 1)

last_well = labware_columns[last_well_col][last_well_row]
loc_str_list = [location.well_name + "-" + _stringify_new_loc(last_well)]

elif nozzle_map.starting_nozzle == "A12":
last_well_col = 0
last_well_row = len(labware_columns[0]) - 1
if critical_column - len(nozzle_map.columns) >= 0:
last_well_col = critical_column - (len(nozzle_map.columns) - 1)
if critical_row + len(nozzle_map.rows) < len(
labware_columns[critical_column]
):
last_well_row = critical_row + (len(nozzle_map.rows) - 1)

last_well = labware_columns[last_well_col][last_well_row]
loc_str_list = [location.well_name + "-" + _stringify_new_loc(last_well)]

elif nozzle_map.starting_nozzle == "H1":
first_well_col = len(labware_columns) - 1
first_well_row = 0
if critical_column + len(nozzle_map.columns) < len(labware_columns):
first_well_col = critical_column + (len(nozzle_map.columns) - 1)
if critical_row - len(nozzle_map.rows) >= 0:
first_well_row = critical_row - (len(nozzle_map.rows) - 1)

first_well = labware_columns[first_well_col][first_well_row]
loc_str_list = [first_well.well_name + "-" + _stringify_new_loc(location)]

elif nozzle_map.starting_nozzle == "H12":
first_well_col = 0
first_well_row = 0
if critical_column - len(nozzle_map.columns) >= 0:
first_well_col = critical_column - (len(nozzle_map.columns) - 1)
if critical_row - len(nozzle_map.rows) >= 0:
first_well_row = critical_row - (len(nozzle_map.rows) - 1)

first_well = labware_columns[first_well_col][first_well_row]
loc_str_list = [first_well.well_name + "-" + _stringify_new_loc(location)]

return ", ".join(loc_str_list)


def stringify_disposal_location(location: Union[TrashBin, WasteChute]) -> str:
if isinstance(location, TrashBin):
return f"Trash Bin on slot {location.location.id}"
Expand Down
Loading