diff --git a/api/src/opentrons/protocol_api/core/engine/well.py b/api/src/opentrons/protocol_api/core/engine/well.py index e18bdb8ecf6a..7b4e195515b4 100644 --- a/api/src/opentrons/protocol_api/core/engine/well.py +++ b/api/src/opentrons/protocol_api/core/engine/well.py @@ -210,3 +210,19 @@ def get_liquid_volume(self) -> LiquidTrackingType: return self._engine_client.state.geometry.get_current_well_volume( labware_id=labware_id, well_name=well_name ) + + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + labware_id = self.labware_id + well_name = self._name + return self._engine_client.state.geometry.get_well_height_at_volume( + labware_id=labware_id, well_name=well_name, volume=volume + ) + + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + labware_id = self.labware_id + well_name = self._name + return self._engine_client.state.geometry.get_well_volume_at_height( + labware_id=labware_id, well_name=well_name, height=height + ) diff --git a/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py b/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py index e0a12039c518..4bcbb8ca5142 100644 --- a/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py +++ b/api/src/opentrons/protocol_api/core/legacy/legacy_well_core.py @@ -142,6 +142,14 @@ def get_liquid_volume(self) -> LiquidTrackingType: """Get the current well volume.""" return 0.0 + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + return 0.0 + + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + return 0.0 + # TODO(mc, 2022-10-28): is this used and/or necessary? def __repr__(self) -> str: """Use the well's display name as its repr.""" diff --git a/api/src/opentrons/protocol_api/core/well.py b/api/src/opentrons/protocol_api/core/well.py index d02cea5cb24b..c3e081df6b90 100644 --- a/api/src/opentrons/protocol_api/core/well.py +++ b/api/src/opentrons/protocol_api/core/well.py @@ -103,5 +103,13 @@ def current_liquid_height(self) -> LiquidTrackingType: def get_liquid_volume(self) -> LiquidTrackingType: """Get the current volume within a well.""" + @abstractmethod + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + + @abstractmethod + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + WellCoreType = TypeVar("WellCoreType", bound=AbstractWellCore) diff --git a/api/src/opentrons/protocol_api/labware.py b/api/src/opentrons/protocol_api/labware.py index 7c0b3fd4b6cf..b67ca1c0337f 100644 --- a/api/src/opentrons/protocol_api/labware.py +++ b/api/src/opentrons/protocol_api/labware.py @@ -346,6 +346,16 @@ def current_liquid_volume(self) -> LiquidTrackingType: """Get the current liquid volume in a well.""" return self._core.get_liquid_volume() + @requires_version(2, 24) + def volume_from_height(self, height: LiquidTrackingType) -> LiquidTrackingType: + """Return the volume contained in a well at any height.""" + return self._core.volume_from_height(height) + + @requires_version(2, 24) + def height_from_volume(self, volume: LiquidTrackingType) -> LiquidTrackingType: + """Return the height in a well corresponding to a given volume.""" + return self._core.height_from_volume(volume) + @requires_version(2, 21) def estimate_liquid_height_after_pipetting( self,