diff --git a/api/src/opentrons/protocol_engine/state/state_summary.py b/api/src/opentrons/protocol_engine/state/state_summary.py index 91ddcd40c62..96d6683edf8 100644 --- a/api/src/opentrons/protocol_engine/state/state_summary.py +++ b/api/src/opentrons/protocol_engine/state/state_summary.py @@ -6,12 +6,12 @@ from ..errors import ErrorOccurrence from ..types import ( EngineStatus, + LiquidHeightSummary, LoadedLabware, LabwareOffset, LoadedModule, LoadedPipette, Liquid, - LiquidHeightInfo, ) @@ -29,4 +29,4 @@ class StateSummary(BaseModel): startedAt: Optional[datetime] completedAt: Optional[datetime] liquids: List[Liquid] = Field(default_factory=list) - wells: List[LiquidHeightInfo] = Field(default_factory=list) + wells: List[LiquidHeightSummary] = Field(default_factory=list) diff --git a/api/src/opentrons/protocol_engine/state/wells.py b/api/src/opentrons/protocol_engine/state/wells.py index 6aa06cd4703..e50a23fdcf2 100644 --- a/api/src/opentrons/protocol_engine/state/wells.py +++ b/api/src/opentrons/protocol_engine/state/wells.py @@ -8,7 +8,7 @@ ) from opentrons.protocol_engine.commands.liquid_probe import LiquidProbeResult from opentrons.protocol_engine.commands.pipetting_common import LiquidNotFoundError -from opentrons.protocol_engine.types import LiquidHeightInfo +from opentrons.protocol_engine.types import LiquidHeightInfo, LiquidHeightSummary from .abstract_store import HasState, HandlesActions from ..actions import Action @@ -19,7 +19,6 @@ class WellState: """State of all wells.""" - # Dict[Labware: Dict[Wellname: [Height,TimeRecorded]]] measured_liquid_heights: Dict[str, Dict[str, LiquidHeightInfo]] @@ -82,16 +81,36 @@ def __init__(self, state: WellState) -> None: """ self._state = state - def get_all(self) -> List[LiquidHeightInfo]: + def get_all(self) -> List[LiquidHeightSummary]: """Get all well liquid heights.""" - allHeights = [] # type: List[LiquidHeightInfo] - for val in self._state.measured_liquid_heights.values(): - allHeights.extend(a for a in val.values()) + allHeights = [] # type: List[LiquidHeightSummary] + # for key, in self._state.measured_liquid_heights.items(): + # lhs = LiquidHeightSummary(labware_id=) + # allHeights.extend(a for a in val.values()) + # return allHeights + for labware in self._state.measured_liquid_heights.keys(): + for well, lhi in self._state.measured_liquid_heights[labware].items(): + lhs = LiquidHeightSummary( + labware_id=labware, + well_name=well, + height=lhi.height, + last_measured=lhi.last_measured, + ) + allHeights.append(lhs) return allHeights - def get_all_in_labware(self, labware_id: str) -> List[LiquidHeightInfo]: + def get_all_in_labware(self, labware_id: str) -> List[LiquidHeightSummary]: """Get all well liquid heights for a particular labware.""" - return list(self._state.measured_liquid_heights[labware_id].values()) + allHeights = [] # type: List[LiquidHeightSummary] + for well, lhi in self._state.measured_liquid_heights[labware_id].items(): + lhs = LiquidHeightSummary( + labware_id=labware_id, + well_name=well, + height=lhi.height, + last_measured=lhi.last_measured, + ) + allHeights.append(lhs) + return allHeights def get_last_measured_liquid_height( self, labware_id: str, well_name: str diff --git a/api/src/opentrons/protocol_engine/types.py b/api/src/opentrons/protocol_engine/types.py index 504fa7cc2bb..a94c24a9923 100644 --- a/api/src/opentrons/protocol_engine/types.py +++ b/api/src/opentrons/protocol_engine/types.py @@ -307,6 +307,15 @@ class LiquidHeightInfo(BaseModel): last_measured: datetime +class LiquidHeightSummary(BaseModel): + """Payload for liquid state height in StateSummary.""" + + labware_id: str + well_name: str + height: float + last_measured: datetime + + @dataclass(frozen=True) class CurrentAddressableArea: """The latest addressable area the robot has accessed."""