Skip to content
Snippets Groups Projects
Commit 64a93102 authored by Jan David Mol's avatar Jan David Mol
Browse files

Merge branch 'L2SS-1999' into 'master'

Only skip emitting CHANGE_EVENT if an attribute is also polled by Tango.

Closes L2SS-1999

See merge request !986
parents 2e9d6ab7 c983b6b7
No related branches found
No related tags found
1 merge request!986Only skip emitting CHANGE_EVENT if an attribute is also polled by Tango.
......@@ -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
......
0.42.7
0.42.8
......@@ -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,6 +208,18 @@ class AttributePoller:
# Emit Tango CHANGE_EVENT, if configured to
if attr_data["send_change_events"]:
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):
......@@ -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(
......
......@@ -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 (
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment