Skip to content

Commit

Permalink
add module substate
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Jan 6, 2025
1 parent 3a4dcdb commit bb6fb0f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from .magnetic_block_substate import MagneticBlockSubState, MagneticBlockId
from .absorbance_reader_substate import AbsorbanceReaderSubState, AbsorbanceReaderId
from .flex_stacker_substate import FlexStackerSubState, FlexStackerId

ModuleSubStateType = Union[
HeaterShakerModuleSubState,
Expand All @@ -21,6 +22,7 @@
ThermocyclerModuleSubState,
MagneticBlockSubState,
AbsorbanceReaderSubState,
FlexStackerSubState,
]

__all__ = [
Expand All @@ -36,6 +38,8 @@
"MagneticBlockId",
"AbsorbanceReaderSubState",
"AbsorbanceReaderId",
"FlexStackerSubState",
"FlexStackerId",
# Union of all module substates
"ModuleSubStateType",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Flex Stacker substate."""
from dataclasses import dataclass
from typing import NewType


FlexStackerId = NewType("FlexStackerId", str)


@dataclass(frozen=True)
class FlexStackerSubState:
"""Flex Stacker-specific state.
Provides calculations and read-only state access
for an individual loaded Flex Stacker Module.
"""

module_id: FlexStackerId
labware_name: str
18 changes: 18 additions & 0 deletions api/src/opentrons/protocol_engine/state/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@
TemperatureModuleSubState,
ThermocyclerModuleSubState,
AbsorbanceReaderSubState,
FlexStackerSubState,
MagneticModuleId,
HeaterShakerModuleId,
TemperatureModuleId,
ThermocyclerModuleId,
AbsorbanceReaderId,
FlexStackerId,
MagneticBlockSubState,
MagneticBlockId,
ModuleSubStateType,
Expand Down Expand Up @@ -762,6 +764,22 @@ def get_absorbance_reader_substate(
expected_type=AbsorbanceReaderSubState,
expected_name="Absorbance Reader",
)

def get_flex_stacker_substate(
self, module_id: str
) -> FlexStackerSubState:
"""Return a `FlexStackerSubState` for the given Flex Stacker.
Raises:
ModuleNotLoadedError: If module_id has not been loaded.
WrongModuleTypeError: If module_id has been loaded,
but it's not a Flex Stacker.
"""
return self._get_module_substate(
module_id=module_id,
expected_type=FlexStackerSubState,
expected_name="Flex Stacker",
)

def get_location(self, module_id: str) -> DeckSlotLocation:
"""Get the slot location of the given module."""
Expand Down

0 comments on commit bb6fb0f

Please sign in to comment.