From c0abb78030b3f1cee3a6a152f394725bde3dc185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corn=C3=A9=20Lukken?= <lukken@astron.nl> Date: Thu, 19 Sep 2024 08:51:55 +0000 Subject: [PATCH] L2SS-1993: Rename state of protection control to prevent collision --- README.md | 1 + tangostationcontrol/VERSION | 2 +- .../devices/protection_control.py | 10 +++++----- .../devices/test_protection_control_device.py | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a6ff51ff9..9ad42dfab 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Next change the version in the following places: # Release Notes +* 0.42.7 Prevent Prometheus name collision in ProtectionControl state attribute * 0.42.6 Fix crash caused by emitting change events for attributes polled by Tango * 0.42.5 Add additional features to protection control * 0.42.4 Add integration test fixture that routinely tests against cross test dependencies diff --git a/tangostationcontrol/VERSION b/tangostationcontrol/VERSION index e4e9a42eb..6028e3fe5 100644 --- a/tangostationcontrol/VERSION +++ b/tangostationcontrol/VERSION @@ -1 +1 @@ -0.42.6 +0.42.7 diff --git a/tangostationcontrol/tangostationcontrol/devices/protection_control.py b/tangostationcontrol/tangostationcontrol/devices/protection_control.py index dba1916a6..621a55802 100644 --- a/tangostationcontrol/tangostationcontrol/devices/protection_control.py +++ b/tangostationcontrol/tangostationcontrol/devices/protection_control.py @@ -126,12 +126,12 @@ class ProtectionControl(LOFARDevice): # Attributes # ---------- - @attribute(dtype=ProtectionStateEnum, fisallowed="is_attribute_access_allowed") - def state_R(self): + @attribute(dtype=ProtectionStateEnum) + def protection_state_R(self): if self._protection_manager: - return self._protection_manager.state + return int(self._protection_manager.state) else: - return ProtectionStateEnum.DEACTIVATED + return int(ProtectionStateEnum.DEACTIVATED) @attribute( doc="Whether the station is periodically evaluated against damage", @@ -194,7 +194,7 @@ class ProtectionControl(LOFARDevice): "this value can be extremely stale!", dtype=str, ) - def last_threshold_device_attribute(self): + def last_threshold_device_attribute_R(self): return self._metrics.threshold_device_attribute # -------- diff --git a/tangostationcontrol/test/devices/test_protection_control_device.py b/tangostationcontrol/test/devices/test_protection_control_device.py index 7f06d5110..eed4590ff 100644 --- a/tangostationcontrol/test/devices/test_protection_control_device.py +++ b/tangostationcontrol/test/devices/test_protection_control_device.py @@ -9,6 +9,7 @@ from tango.test_context import DeviceTestContext from tangostationcontrol.common.constants import DEFAULT_POLLING_PERIOD_MS from tangostationcontrol.devices import protection_control +from tangostationcontrol.protection.state import ProtectionStateEnum from test.devices import device_base @@ -35,6 +36,21 @@ class TestProtectionControlDevice(device_base.DeviceTestCase): self.assertTrue(proxy.protection_monitor_thread_running_R) + def test_protection_control_state(self, _database): + + with DeviceTestContext( + protection_control.ProtectionControl, + process=False, + timeout=10, + ) as proxy: + + self.assertEqual(ProtectionStateEnum.DEACTIVATED, proxy.protection_state_R) + + proxy.initialise() + proxy.on() + + self.assertEqual(ProtectionStateEnum.OFF, proxy.protection_state_R) + def test_periodic_reattempt(self, _database): with DeviceTestContext( protection_control.ProtectionControl, -- GitLab