Skip to content

Commit

Permalink
fix(api): Sleeps do not happen in thermocycler and tempdeck when simu…
Browse files Browse the repository at this point in the history
…lating.

closes #7506
  • Loading branch information
amitlissack authored Mar 19, 2021
1 parent ec40357 commit 8ef61c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions api/src/opentrons/hardware_control/modules/tempdeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ async def await_temperature(self, awaiting_temperature: float):
Polls temperature module's temperature until
the specified temperature is reached
"""
if self.is_simulated:
return

await self.wait_for_is_running()

async def _await_temperature(awaiting_temperature: float):
Expand Down
9 changes: 9 additions & 0 deletions api/src/opentrons/hardware_control/modules/thermocycler.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ async def wait_for_lid_temp(self):
Subject to change without a version bump.
"""
if self.is_simulated:
return

while self._driver.lid_temp_status != 'holding at target':
await asyncio.sleep(0.1)

Expand All @@ -206,13 +209,19 @@ async def wait_for_temp(self):
Subject to change without a version bump.
"""
if self.is_simulated:
return

while self.status != 'holding at target':
await asyncio.sleep(0.1)

async def wait_for_hold(self, hold_time=0):
"""
This method returns only when hold time has elapsed
"""
if self.is_simulated:
return

# If hold time is within the HOLD_TIME_FUZZY_SECONDS time gap, then,
# because of the driver's status poller delays, it is impossible to
# know for certain if self.hold_time holds the most recent value.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import asyncio
from unittest import mock
import mock
from opentrons.hardware_control import modules, ExecutionManager

from opentrons.drivers.rpi_drivers.types import USBPort
Expand Down Expand Up @@ -161,13 +161,11 @@ def async_return(result):
set_temp_driver_mock.reset_mock()

# Test hold_time < HOLD_TIME_FUZZY_SECONDS. Here we know
# that asyncio.sleep will be called with the direct hold
# that wait_for_hold will be called with the direct hold
# time rather than increments of 0.1
sleep_mock = mock.Mock()
async_sleep_mock = mock.Mock(side_effect=asyncio.coroutine(sleep_mock))
monkeypatch.setattr(asyncio, 'sleep', async_sleep_mock)
hw_tc.wait_for_hold = mock.AsyncMock()
await hw_tc.set_temperature(40, hold_time_seconds=2)
async_sleep_mock.assert_called_once_with(2)
hw_tc.wait_for_hold.assert_called_once_with(2)
set_temp_driver_mock.assert_called_once_with(temp=40,
hold_time=2,
volume=None,
Expand Down

0 comments on commit 8ef61c0

Please sign in to comment.