From 1d40fd62b34f98ada148d0d032c2ea55da3cb98c Mon Sep 17 00:00:00 2001 From: Brian Arthur Cooper Date: Fri, 15 Nov 2019 11:11:04 -0500 Subject: [PATCH] fix(api): connect context to real thermocycler during calibration (#4454) The calibration session currently picks up the simulated context from the beginning of the session. This means that the simulated modules are also usedduring labware calibration. This temporarily connect the thermocycler during calibration so the session is aware of the lid's open/close state. This is a short term patch that will be removed in place of better session management to replace the current RPC over HTTP session communication. --- api/src/opentrons/protocol_api/contexts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/api/src/opentrons/protocol_api/contexts.py b/api/src/opentrons/protocol_api/contexts.py index 28be1a8eb3c..052d7358698 100644 --- a/api/src/opentrons/protocol_api/contexts.py +++ b/api/src/opentrons/protocol_api/contexts.py @@ -239,11 +239,24 @@ def temp_connect(self, hardware: hc.API): """ old_hw = self._hw_manager.hardware + old_tc = None + tc_context = None try: self._hw_manager.set_hw(hardware) + for mod_ctx in self._modules: + if isinstance(mod_ctx, ThermocyclerContext): + tc_context = mod_ctx + hw_tc = next(hw_mod for hw_mod in + hardware.attached_modules.values() + if hw_mod.name() == 'thermocycler') + if hw_tc: + old_tc = mod_ctx._module + mod_ctx._module = hw_tc yield self finally: self._hw_manager.set_hw(old_hw) + if tc_context is not None and old_tc is not None: + tc_context._module = old_tc @requires_version(2, 0) def connect(self, hardware: hc.API):