Skip to content

Commit

Permalink
initial implementation for load_liquid volume-tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoegenburg committed Oct 18, 2024
1 parent 9797d74 commit 544d695
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/src/opentrons/protocol_engine/commands/load_liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pydantic import BaseModel, Field
from typing import Optional, Type, Dict, TYPE_CHECKING
from typing_extensions import Literal
from datetime import datetime

from .command import AbstractCommandImpl, BaseCommand, BaseCommandCreate, SuccessData
from ..errors.error_occurrence import ErrorOccurrence
Expand Down Expand Up @@ -53,6 +54,19 @@ async def execute(
self._state_view.labware.validate_liquid_allowed_in_labware(
labware_id=params.labwareId, wells=params.volumeByWell
)
# do this in WellStore?!
labware_id = params.labwareId
well_name = next(iter(params.volumeByWell))
volume = next(iter(params.volumeByWell.values()))
height = self._state_view.geometry.get_well_height_at_volume(
labware_id=labware_id, well_name=well_name, volume=volume
)
self._state_view.wells.set_liquid_height(
labware_id=labware_id,
well_name=well_name,
height=height,
time=datetime.now(),
)

return SuccessData(public=LoadLiquidResult(), private=None)

Expand Down
9 changes: 9 additions & 0 deletions api/src/opentrons/protocol_engine/state/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,15 @@ def get_well_height_after_volume(
target_volume=final_volume, well_geometry=well_geometry
)

def get_well_height_at_volume(
self, labware_id: str, well_name: str, volume: float
) -> float:
"""Convert well volume to height."""
well_geometry = self._labware.get_well_geometry(labware_id, well_name)
return find_height_at_well_volume(
target_volume=volume, well_geometry=well_geometry
)

def validate_dispense_volume_into_well(
self,
labware_id: str,
Expand Down
9 changes: 9 additions & 0 deletions api/src/opentrons/protocol_engine/state/wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,12 @@ def has_measured_liquid_height(self, labware_id: str, well_name: str) -> bool:
)
except KeyError:
return False

def set_liquid_height(
self, labware_id: str, well_name: str, height: float, time: datetime
) -> None:
"""Set the liquid height of the well."""
lhi = LiquidHeightInfo(height=height, last_measured=time)
if labware_id not in self._state.measured_liquid_heights:
self._state.measured_liquid_heights[labware_id] = {}
self._state.measured_liquid_heights[labware_id][well_name] = lhi

0 comments on commit 544d695

Please sign in to comment.