Skip to content

Commit

Permalink
schema and deck def updates with addressable area logic added
Browse files Browse the repository at this point in the history
  • Loading branch information
CaseyBatten committed Mar 15, 2024
1 parent bceeb45 commit ecccea0
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 34 deletions.
17 changes: 17 additions & 0 deletions api/src/opentrons/hardware_control/modules/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Tuple,
Awaitable,
Union,
Set,
cast,
TYPE_CHECKING,
)
Expand Down Expand Up @@ -64,6 +65,22 @@ def from_model(cls, model: ModuleModel) -> ModuleType:
if isinstance(model, MagneticBlockModel):
return cls.MAGNETIC_BLOCK

@classmethod
def to_module_fixture_id(cls, module_type: ModuleType) -> str:
if module_type == ModuleType.THERMOCYCLER:
# Thermocyclers are "loaded" in B1 only
return "thermocyclerModuleFront"
if module_type == ModuleType.TEMPERATURE:
return "temperatureModule"
if module_type == ModuleType.HEATER_SHAKER:
return "heaterShakerModule"
if module_type == ModuleType.MAGNETIC_BLOCK:
return "magneticBlockModule"
else:
raise ValueError(
f"Module Type {module_type} does not have a related fixture ID."
)


class MagneticModuleModel(str, Enum):
MAGNETIC_V1: str = "magneticModuleV1"
Expand Down
32 changes: 27 additions & 5 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from typing import Dict, Optional, Type, Union, List, Tuple, TYPE_CHECKING

from opentrons.protocol_engine.commands import LoadModuleResult
from opentrons_shared_data.deck.dev_types import DeckDefinitionV5, SlotDefV3
from opentrons_shared_data.deck.dev_types import (
DeckDefinitionV5,
SlotDefV3,
CutoutFixture,
)
from opentrons_shared_data.labware.labware_definition import LabwareDefinition
from opentrons_shared_data.labware.dev_types import LabwareDefinition as LabwareDefDict
from opentrons_shared_data.pipette.dev_types import PipetteNameType
Expand Down Expand Up @@ -625,10 +629,28 @@ def get_staging_slot_definitions(self) -> Dict[str, SlotDefV3]:
def _ensure_module_location(
self, slot: DeckSlotName, module_type: ModuleType
) -> None:
slot_def = self.get_slot_definition(slot)
compatible_modules = slot_def["compatibleModuleTypes"]
if module_type.value not in compatible_modules:
raise ValueError(f"A {module_type.value} cannot be loaded into slot {slot}")
if self._engine_client.state.config.robot_type == "OT-2 Standard":
slot_def = self.get_slot_definition(slot)
compatible_modules = slot_def["compatibleModuleTypes"]
if module_type.value not in compatible_modules:
raise ValueError(
f"A {module_type.value} cannot be loaded into slot {slot}"
)
else:
cutout_fixture_id = ModuleType.to_module_fixture_id(module_type)
potential_fixtures_in_slot = self._engine_client.state.addressable_areas._state.potential_cutout_fixtures_by_cutout_id[
self._engine_client.state.addressable_areas.get_cutout_id_by_deck_slot_name(
slot
)
]
module_fixture_found = False
for fixture in potential_fixtures_in_slot:
if fixture.cutout_fixture_id == cutout_fixture_id:
module_fixture_found = True
if not module_fixture_found:
raise ValueError(
f"A {module_type.value} cannot be loaded into slot {slot}"
)

def get_slot_item(
self, slot_name: Union[DeckSlotName, StagingSlotName]
Expand Down
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_api/core/legacy/deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,11 @@ def resolve_module_location(
if isinstance(location, str) or isinstance(location, int):
slot_def = self.get_slot_definition(str(location))
compatible_modules = slot_def["compatibleModuleTypes"]
cutout_fixture_id = ModuleType.to_module_fixture_id(module_type)
if module_type.value in compatible_modules:
return location
elif cutout_fixture_id == slot_def["id"]:
return location
else:
raise ValueError(
f"A {dn_from_type[module_type]} cannot be loaded"
Expand Down
3 changes: 3 additions & 0 deletions api/src/opentrons/protocol_engine/state/addressable_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ def get_addressable_area_center(self, addressable_area_name: str) -> Point:
z=position.z,
)

def get_cutout_id_by_deck_slot_name(self, slot_name: DeckSlotName) -> str:
return DECK_SLOT_TO_CUTOUT_MAP[slot_name]

def get_fixture_by_deck_slot_name(
self, slot_name: DeckSlotName
) -> Optional[CutoutFixture]:
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/protocol_engine/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,10 @@ class AreaType(Enum):
MOVABLE_TRASH = "movableTrash"
FIXED_TRASH = "fixedTrash"
WASTE_CHUTE = "wasteChute"
THERMOCYCLER = "thermocycler"
HEATER_SHAKER = "heaterShaker"
TEMPERATURE = "temperatureModule"



@dataclass(frozen=True)
Expand Down
9 changes: 3 additions & 6 deletions robot-server/robot_server/deck_configuration/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,9 @@ def get_configuration_errors(
allowed_cutout_ids=allowed_cutout_ids,
)
)
# replace this with a serial number check set instead
# if serial number in def is null, we expect nothing from the put statement, raise if there is something
# if it is not null, we expect something from the put statement! if theres nothing then raise an error
if found_cutout_fixture[
"opentronsModuleSerialNumber"
] is None and isinstance(placement.opentrons_modules_serial_number, str):
"expectOpentronsModuleSerialNumber"
] == False and isinstance(placement.opentrons_modules_serial_number, str):
errors.add(
UnexpectedSerialNumberError(
cutout_id=placement.cutout_id,
Expand All @@ -132,7 +129,7 @@ def get_configuration_errors(
)
)
elif (
isinstance(found_cutout_fixture["opentronsModuleSerialNumber"], str)
found_cutout_fixture["expectOpentronsModuleSerialNumber"] == True
and placement.opentrons_modules_serial_number is None
):
errors.add(
Expand Down
Loading

0 comments on commit ecccea0

Please sign in to comment.