|
2 | 2 | from __future__ import annotations
|
3 | 3 |
|
4 | 4 | from typing import Optional, TYPE_CHECKING, cast, Union
|
| 5 | +from opentrons.protocols.api_support.types import APIVersion |
5 | 6 |
|
6 | 7 | from opentrons.types import Location, Mount
|
7 | 8 | from opentrons.hardware_control import SyncHardwareAPI
|
|
44 | 45 | from .protocol import ProtocolCore
|
45 | 46 |
|
46 | 47 |
|
| 48 | +_DISPENSE_VOLUME_VALIDATION_ADDED_IN = APIVersion(2, 17) |
| 49 | + |
| 50 | + |
47 | 51 | class InstrumentCore(AbstractInstrument[WellCore]):
|
48 | 52 | """Instrument API core using a ProtocolEngine.
|
49 | 53 |
|
@@ -180,6 +184,15 @@ def dispense(
|
180 | 184 | in_place: whether this is a in-place command.
|
181 | 185 | push_out: The amount to push the plunger below bottom position.
|
182 | 186 | """
|
| 187 | + if self._protocol_core.api_version < _DISPENSE_VOLUME_VALIDATION_ADDED_IN: |
| 188 | + # In older API versions, when you try to dispense more than you can, |
| 189 | + # it gets clamped. |
| 190 | + volume = min(volume, self.get_current_volume()) |
| 191 | + else: |
| 192 | + # Newer API versions raise an error if you try to dispense more than |
| 193 | + # you can. Let the error come from Protocol Engine's validation. |
| 194 | + pass |
| 195 | + |
183 | 196 | if well_core is None:
|
184 | 197 | if not in_place:
|
185 | 198 | if isinstance(location, (TrashBin, WasteChute)):
|
@@ -733,7 +746,6 @@ def configure_nozzle_layout(
|
733 | 746 | primary_nozzle: Optional[str],
|
734 | 747 | front_right_nozzle: Optional[str],
|
735 | 748 | ) -> None:
|
736 |
| - |
737 | 749 | if style == NozzleLayout.COLUMN:
|
738 | 750 | configuration_model: NozzleLayoutConfigurationType = (
|
739 | 751 | ColumnNozzleLayoutConfiguration(
|
|
0 commit comments