From 25baba611a9419ae6ce8013333332412bb1c1255 Mon Sep 17 00:00:00 2001 From: rclarke0 Date: Thu, 2 May 2024 17:42:24 -0400 Subject: [PATCH] module counts --- .../opentrons/protocol_api/module_contexts.py | 17 +- hardware-testing/Normalization_with_PCR.py | 314 ++++++++++++++++++ hardware-testing/test.csv | 2 + 3 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 hardware-testing/Normalization_with_PCR.py create mode 100644 hardware-testing/test.csv diff --git a/api/src/opentrons/protocol_api/module_contexts.py b/api/src/opentrons/protocol_api/module_contexts.py index 8605069ccc7..577668dd102 100644 --- a/api/src/opentrons/protocol_api/module_contexts.py +++ b/api/src/opentrons/protocol_api/module_contexts.py @@ -1,7 +1,7 @@ from __future__ import annotations import logging -from typing import List, Optional, Union, cast +from typing import List, Optional, Union, cast, Dict from opentrons_shared_data.labware.dev_types import LabwareDefinition from opentrons_shared_data.module.dev_types import ModuleModel, ModuleType @@ -62,6 +62,7 @@ def __init__( self._protocol_core = protocol_core self._core_map = core_map self._api_version = api_version + self._open_close_count: Dict[str, float] = {} @property # type: ignore[misc] @requires_version(2, 0) @@ -109,7 +110,13 @@ def load_labware_object(self, labware: Labware) -> Labware: ), "Labware is not configured with this module as its parent" return self._core.geometry.add_labware(labware) - + + def _open_close_counter(self): + serial = self._core.get_serial_number() + if serial not in self._open_close_count: + self._open_close_count[serial] = 0.0 + self._open_close_count[serial] += 1 + def load_labware( self, name: str, @@ -521,12 +528,14 @@ def serial_number(self) -> str: @requires_version(2, 0) def open_lid(self) -> str: """Open the lid.""" + self._open_close_counter() return self._core.open_lid().value @publish(command=cmds.thermocycler_close) @requires_version(2, 0) def close_lid(self) -> str: """Close the lid.""" + self._open_close_counter() return self._core.close_lid().value @publish(command=cmds.thermocycler_set_block_temp) @@ -914,6 +923,8 @@ def open_labware_latch(self) -> None: if they are parked adjacent to the left or right of the Heater-Shaker. """ self._core.open_labware_latch() + self._open_close_counter() + @requires_version(2, 13) @publish(command=cmds.heater_shaker_close_labware_latch) @@ -924,6 +935,8 @@ def close_labware_latch(self) -> None: even if the latch was manually closed before starting the protocol. """ self._core.close_labware_latch() + self._open_close_counter() + @requires_version(2, 13) @publish(command=cmds.heater_shaker_deactivate_shaker) diff --git a/hardware-testing/Normalization_with_PCR.py b/hardware-testing/Normalization_with_PCR.py new file mode 100644 index 00000000000..ab07e5ca3ae --- /dev/null +++ b/hardware-testing/Normalization_with_PCR.py @@ -0,0 +1,314 @@ +def get_values(*names): + import json + _all_values = json.loads("""{"csv_samp":"Destination Well,Water Transfer Volume (ul),DNA Transfer Volume (ul),Mastermix Volume (ul),Mastermix Source Tube\\nA1,3,7,40,A1\\nB1,3,7,40,A1","temp_mod_on":true,"rxn_vol":50,"p50_mount":"right","protocol_filename":"Normalization_with_PCR"}""") + return [_all_values[n] for n in names] + + +# flake8: noqa + +from opentrons import protocol_api +from opentrons import types +import random +import math + +metadata = { + 'ctx.Name': 'PCR Protocol', + 'author': 'Rami Farawi