diff --git a/README.md b/README.md index 9ad42dfab7d9d9e4c1180775232d19d0725f28fa..93d84eba05487b6f790974c1637301b5faed01c3 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,7 @@ Next change the version in the following places: # Release Notes +* 0.42.8 Emit metrics even if attribute is polled by AttributePoller as well as Tango * 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 diff --git a/tangostationcontrol/VERSION b/tangostationcontrol/VERSION index 6028e3fe54dc09cdf4b68290140d73650d32328f..959c4e57349b1e88ca7191129b8d0e6c633ed43e 100644 --- a/tangostationcontrol/VERSION +++ b/tangostationcontrol/VERSION @@ -1 +1 @@ -0.42.7 +0.42.8 diff --git a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py index 4ba72ceef770ecc53279c265975acf5ba3cd735a..2887d50d9f2b6eea70f78a414d86b2ef83b36a22 100644 --- a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py @@ -47,7 +47,6 @@ from tangostationcontrol.common.device_decorators import ( ) from tangostationcontrol.common.constants import ( DEFAULT_METRICS_POLLING_PERIOD_MS, - DEFAULT_POLLING_PERIOD_MS, ) from lofar_station_client.common import CaseInsensitiveDict from tangostationcontrol.common.events import EventSubscriptions, ChangeEvents @@ -197,18 +196,6 @@ class AttributePoller: if not self.polling_allowed(): return - if self.device.is_attribute_polled(attr_name): - # ChangeEvents.send_change_event is not allowed for attributes already pollled - # by Tango. Also, because they're already polled, Tango will emit the change - # events for us. So we simply filter those attributes out. - logger.info( - f"Not polling {attr_name} anymore as it is already polled by Tango." - ) - - # We don't want to report the above every second. Remove this attribute from the list - del self._poll_list[attr_name] - continue - value = await self._read_attribute_nothrow(attr_name) # stop polling if we turned to OFF/FAULT during this loop @@ -221,7 +208,19 @@ class AttributePoller: # Emit Tango CHANGE_EVENT, if configured to if attr_data["send_change_events"]: - self._send_change_event(attr_name, value) + if self.device.is_attribute_polled(attr_name): + # ChangeEvents.send_change_event is not allowed for attributes already pollled + # by Tango. Also, because they're already polled, Tango will emit the change + # events for us. So we simply filter those attributes out. + logger.info( + f"Not emitting change events for {attr_name} anymore as it is already polled by Tango (which will emit change events instead)." + ) + + # We don't want to report the above every second. Disable sending change events + # for this attribute. + attr_data["send_change_events"] = False + else: + self._send_change_event(attr_name, value) async def poll(self): if not self.polling_allowed(): @@ -333,9 +332,6 @@ class LOFARDevice(Device): dtype=bool, fget=lambda self: self.event_loop_thread and self.event_loop_thread.is_running(), - # Tango needs to poll this, as otherwise this attribute will never - # be exposed as "False" as the event thread must run to do so. - polling_period=DEFAULT_POLLING_PERIOD_MS, ) poll_thread_running_R = attribute( @@ -347,9 +343,6 @@ class LOFARDevice(Device): and self.poll_task and self.poll_task.is_running() ), - # Tango needs to poll this, as otherwise this attribute will never - # be exposed as "False" as the event thread must run to do so. - polling_period=DEFAULT_POLLING_PERIOD_MS, ) @attribute( diff --git a/tangostationcontrol/tangostationcontrol/devices/metadata.py b/tangostationcontrol/tangostationcontrol/devices/metadata.py index 9e1cb58c623c14bb45c6e866645b309acd185499..7e0e7f7fb5e08d35dea623c0fcd25f7d134e51e7 100644 --- a/tangostationcontrol/tangostationcontrol/devices/metadata.py +++ b/tangostationcontrol/tangostationcontrol/devices/metadata.py @@ -16,10 +16,6 @@ from tango.server import device_property, attribute, command from lofar_station_client.common import CaseInsensitiveDict from tangostationcontrol.asyncio import PeriodicTask -from tangostationcontrol.common.constants import ( - DEFAULT_POLLING_PERIOD_MS, -) - from tangostationcontrol.common.device_decorators import only_in_states, log_exceptions from tangostationcontrol.common.events.register_subscriptions import ( register_change_event_subscriptions, @@ -70,9 +66,6 @@ class Metadata(LOFARDevice): @attribute( doc="Whether the metadata is periodically published", dtype=bool, - # Tango needs to poll this, as otherwise this attribute will never - # be exposed as "False" as the event thread must run to do so. - polling_period=DEFAULT_POLLING_PERIOD_MS, ) def metadata_periodic_publish_thread_running_R(self): return ( diff --git a/tangostationcontrol/tangostationcontrol/devices/observation_control.py b/tangostationcontrol/tangostationcontrol/devices/observation_control.py index 6925317b41db07cf4c1bb5d1bd8a54ac4f741136..4e98f2213a918edd4ee801ac1e3a01e4258421b1 100644 --- a/tangostationcontrol/tangostationcontrol/devices/observation_control.py +++ b/tangostationcontrol/tangostationcontrol/devices/observation_control.py @@ -13,7 +13,6 @@ from tango import ( from tango.server import command, attribute, device_property from tangostationcontrol.observation.observation_controller import ObservationController from tangostationcontrol.asyncio import PeriodicTask -from tangostationcontrol.common.constants import DEFAULT_POLLING_PERIOD_MS from tangostationcontrol.common.device_decorators import DurationMetric, log_exceptions from tangostationcontrol.common.lofar_logging import ( device_logging_to_python, @@ -124,9 +123,6 @@ class ObservationControl(LOFARDevice): and self.observation_update_task and self.observation_update_task.is_running() ), - # Tango needs to poll this, as otherwise this attribute will never - # be exposed as "False" as the event thread must run to do so. - polling_period=DEFAULT_POLLING_PERIOD_MS, ) def __init__(self, cl, name):