Skip to content

Commit

Permalink
do not need int version of model
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Dec 8, 2022
1 parent 2ab4ef6 commit 9c19a98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
25 changes: 2 additions & 23 deletions api/src/opentrons/config/ot3_pipette_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,6 @@ def version_from_string(version: str) -> PipetteVersionType:
return PipetteVersionType(major, minor)


def version_from_int(version: int) -> PipetteVersionType:
"""Convert a version int to a py:obj:PipetteVersionType.
The version int will be a 2 digit value with the 10s place
representing the major version and the 1s place representing
a minor version.
Args:
version (int): The int version we wish to convert.
Returns:
PipetteVersionType: A pipette version object.
"""
major = cast(PipetteModelMajorVersionType, version // 10)
minor = cast(PipetteModelMinorVersionType, version % 10)
return PipetteVersionType(major, minor)


def version_from_generation(pipette_name_list: List[str]) -> PipetteVersionType:
"""Convert a string generation name to a py:obj:PipetteVersionType.
Expand All @@ -133,7 +114,7 @@ def version_from_generation(pipette_name_list: List[str]) -> PipetteVersionType:


def convert_pipette_name(
name: PipetteName, provided_version: Optional[Union[str, int]] = None
name: PipetteName, provided_version: Optional[str] = None
) -> PipetteModelVersionType:
"""Convert the py:data:PipetteName to a py:obj:PipetteModelVersionType.
Expand All @@ -149,10 +130,8 @@ def convert_pipette_name(
"""
split_pipette_name = name.split("_")
channels = channels_from_string(split_pipette_name[1])
if provided_version and isinstance(provided_version, str):
if provided_version:
version = version_from_string(provided_version)
elif provided_version and isinstance(provided_version, int):
version = version_from_int(provided_version)
else:
version = version_from_generation(split_pipette_name)

Expand Down
7 changes: 5 additions & 2 deletions api/src/opentrons/hardware_control/backends/ot3controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
capacitive_pass,
)
from opentrons_hardware.drivers.gpio import OT3GPIO
from opentrons_shared_data.pipette.dev_types import PipetteName

if TYPE_CHECKING:
from opentrons_shared_data.pipette.dev_types import PipetteName
from ..dev_types import (
OT3AttachedPipette,
AttachedGripper,
Expand Down Expand Up @@ -410,7 +410,8 @@ def _lookup_serial_key(pipette_name: FirmwarePipetteName) -> str:
@staticmethod
def _combine_serial_number(pipette_info: ohc_tool_types.PipetteInformation) -> str:
serialized_name = OT3Controller._lookup_serial_key(pipette_info.name)
return f"{serialized_name}V{pipette_info.model}{pipette_info.serial}"
version = ot3_pipette_config.version_from_string(pipette_info.model)
return f"{serialized_name}V{version.major}{version.minor}{pipette_info.serial}"

@staticmethod
def _build_attached_pip(
Expand All @@ -419,6 +420,8 @@ def _build_attached_pip(
if attached.name == FirmwarePipetteName.unknown:
raise InvalidPipetteName(name=attached.name_int, mount=mount)
try:
# TODO (lc 12-8-2022) We should return model as an int rather than
# a string.
# TODO (lc 12-6-2022) We should also provide the full serial number
# for PipetteInformation.serial so we don't have to use
# helper methods to convert the serial back to what was flashed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ async def fake_gai(expected):
left=PipetteInformation(
name=FirmwarePipetteName.p1000_single,
name_int=FirmwarePipetteName.p1000_single.value,
model="3.0",
model="3.3",
serial="hello",
),
right=None,
gripper=GripperInformation(model="0", serial="fake_serial"),
),
"P1KSV30hello",
"P1KSV33hello",
"GRPV0fake_serial",
"gripper",
),
Expand Down Expand Up @@ -343,7 +343,10 @@ async def fake_probe(can_messenger, expected, timeout):

tool_summary = ToolSummary(
left=PipetteInformation(
name=FirmwarePipetteName.p1000_single, name_int=0, model=41, serial="hello"
name=FirmwarePipetteName.p1000_single,
name_int=0,
model="4.1",
serial="hello",
),
right=None,
gripper=GripperInformation(model=0, serial="fake_serial"),
Expand Down

0 comments on commit 9c19a98

Please sign in to comment.