Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions common_tests/eurotherm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

PV_SENSORS = ["A01", "A02", "A03", "A04", "A05", "A06"]

BINARY_VALUES = [0, 1]


# This class is only valid for classes which also derive from unittest.TestCase,
# and we can't derive from unittest.TestCase at runtime, because
Expand Down Expand Up @@ -241,20 +243,28 @@ def test_GIVEN_temperature_set_WHEN_changing_calibration_files_THEN_temperature_
self._set_setpoint_and_current_temperature(temperature)
self._assert_using_mock_table_location()
with use_calibration_file(self.ca, "None.txt", prefix="A01:"):
self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance)
self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance)
self.ca.assert_that_pv_is_number(
"A01:TEMP", temperature, tolerance=tolerance, timeout=30
)
self.ca.assert_that_pv_is_number(
"A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30
)

with use_calibration_file(self.ca, "C.txt", prefix="A01:"):
self.ca.assert_that_pv_is_number(
"A01:TEMP", temperature_calibrated, tolerance=tolerance
"A01:TEMP", temperature_calibrated, tolerance=tolerance, timeout=30
)
self.ca.assert_that_pv_is_number(
"A01:TEMP:SP:RBV", temperature_calibrated, tolerance=tolerance
"A01:TEMP:SP:RBV", temperature_calibrated, tolerance=tolerance, timeout=30
)

with use_calibration_file(self.ca, "None.txt", prefix="A01:"):
self.ca.assert_that_pv_is_number("A01:TEMP", temperature, tolerance=tolerance)
self.ca.assert_that_pv_is_number("A01:TEMP:SP:RBV", temperature, tolerance=tolerance)
self.ca.assert_that_pv_is_number(
"A01:TEMP", temperature, tolerance=tolerance, timeout=30
)
self.ca.assert_that_pv_is_number(
"A01:TEMP:SP:RBV", temperature, tolerance=tolerance, timeout=30
)

def _assert_units(self, units):
# High timeouts because setting units does not cause processing - wait for normal scan loop to come around.
Expand Down Expand Up @@ -418,3 +428,18 @@ def test_WHEN_high_limit_set_via_backdoor_THEN_high_lim_updates(self, _, val):
def test_WHEN_low_limit_set_via_backdoor_THEN_low_lim_updates(self, _, val):
self._lewis.backdoor_run_function_on_device("set_low_lim", [SENSORS[0], val])
self.ca.assert_that_pv_is_number("A01:LOWLIM", val, tolerance=0.05, timeout=15)

@parameterized.expand(parameterized_list(BINARY_VALUES))
def test_WHEN_automan_set_via_backdoor_THEN_automan_updates(self, _, val):
expected_value = {0: "OFF", 1: "ON"}[val]

self.ca.set_pv_value("A01:AUTOMAN:SP", val)
self.ca.assert_that_pv_is("A01:AUTOMAN", expected_value)

@parameterized.expand(parameterized_list(BINARY_VALUES))
@skip_if_recsim("Backdoor not available in recsim")
def test_WHEN_sensorbreak_set_via_backdoor_THEN_shows_updated_value(self, _, val):
Comment thread
FreddieAkeroyd marked this conversation as resolved.
expected_value = {0: "OFF", 1: "ON"}[val]

self._lewis.backdoor_run_function_on_device("set_snbrkpst", [SENSORS[0], val])
self.ca.assert_that_pv_is("A01:SNBRKPST", expected_value)
11 changes: 4 additions & 7 deletions tests/eurotherm_eibisynch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class EurothermTests(EurothermBaseTests, unittest.TestCase):
def setUp(self):
super(EurothermTests, self).setUp()
self._lewis.backdoor_run_function_on_device("set_scaling", ["01", 1.0])
self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0])
self._lewis: LewisLauncher

def get_device(self):
Expand Down Expand Up @@ -113,7 +114,7 @@ def test_GIVEN_None_txt_calib_file_WHEN_changed_to_C006_calib_file_THEN_the_cali
self.ca.assert_that_pv_is("A01:TEMP:RANGE:UNDER.B", c006_calibration_file_min)

def test_GIVEN_sim_delay_WHEN_temp_read_from_many_sensors_THEN_all_reads_correct(self) -> None:
self._lewis.backdoor_run_function_on_device("set_delay_time", [(300 / 1000)])
self._lewis.backdoor_run_function_on_device("set_delay_time", [(200 / 1000)])
for id in range(1, 7):
pv_sensor = f"A{id:02}"
sensor = f"{id:02}"
Expand All @@ -122,20 +123,16 @@ def test_GIVEN_sim_delay_WHEN_temp_read_from_many_sensors_THEN_all_reads_correct
self._lewis.backdoor_run_function_on_device(
"set_current_temperature", [sensor, float(temp)]
)
self.ca.assert_that_pv_is(f"{pv_sensor}:RBV", float(temp))

self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0])
self.ca.assert_that_pv_is(f"{pv_sensor}:RBV", float(temp), timeout=30.0)

def test_GIVEN_sim_delay_WHEN_temp_set_on_multiple_sensors_THEN_all_reads_correct(self) -> None:
self._lewis.backdoor_run_function_on_device("set_delay_time", [(300 / 1000)])
self._lewis.backdoor_run_function_on_device("set_delay_time", [(200 / 1000)])
for id in range(1, 7):
sensor = f"A{id:02}"
for temp in range(1, 3):
self._set_setpoint_and_current_temperature(float(temp), sensor=sensor)
self.ca.assert_that_pv_is(f"{sensor}:RBV", float(temp), timeout=30.0)

self._lewis.backdoor_run_function_on_device("set_delay_time", [0.0])

def test_GIVEN_many_sensors_WHEN_one_sensor_disconnect_THEN_other_sensors_read_ok(self) -> None:
# Ensure that A02 is connected
self._lewis.backdoor_run_function_on_device("set_connected", ["02", True])
Expand Down
Loading