diff --git a/src/ophyd_async/tango/base_devices/_tango_readable.py b/src/ophyd_async/tango/base_devices/_tango_readable.py index 08b52f3a1b..94e85d96a3 100644 --- a/src/ophyd_async/tango/base_devices/_tango_readable.py +++ b/src/ophyd_async/tango/base_devices/_tango_readable.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Optional, Tuple, Union +from typing import Optional, Union from ophyd_async.core import ( StandardReadable, @@ -24,8 +24,6 @@ class TangoReadable(TangoDevice, StandardReadable): device is connected. """ - _polling: Tuple = (False, 0.1, None, 0.1) - def __init__( self, trl: Optional[str] = None, diff --git a/src/ophyd_async/tango/demo/_counter.py b/src/ophyd_async/tango/demo/_counter.py index b6d7b9efa4..6280358a47 100644 --- a/src/ophyd_async/tango/demo/_counter.py +++ b/src/ophyd_async/tango/demo/_counter.py @@ -9,7 +9,7 @@ Signal, SignalX, ) -from ophyd_async.tango import TangoReadable +from ophyd_async.tango import TangoReadable, tango_polling @dataclass @@ -17,6 +17,9 @@ class TangoCounterConfig: sample_time: Optional[float] = None +# Enable device level polling, useful for servers that do not support events +# Polling for individual signal can be enabled with a dict +@tango_polling((0.1, 0.1, 0.1), {"counts": (1.0, 0.1, 0.1)}) class TangoCounter(TangoReadable): # Enter the name and type of the signals you want to use # If type is None or Signal, the type will be inferred from the Tango device diff --git a/src/ophyd_async/tango/demo/_mover.py b/src/ophyd_async/tango/demo/_mover.py index c7d1c6f0df..847f268ed3 100644 --- a/src/ophyd_async/tango/demo/_mover.py +++ b/src/ophyd_async/tango/demo/_mover.py @@ -27,7 +27,8 @@ class TangoMoverConfig: velocity: Optional[float] = None -@tango_polling(0.1, 0.1, 0.1) +# Enable device level polling, useful for servers that do not support events +@tango_polling((0.1, 0.1, 0.1)) class TangoMover(TangoReadable, Movable, Stoppable): # Enter the name and type of the signals you want to use # If type is None or Signal, the type will be inferred from the Tango device diff --git a/src/ophyd_async/tango/signal/_tango_transport.py b/src/ophyd_async/tango/signal/_tango_transport.py index dd1126f610..8d7742b5c8 100644 --- a/src/ophyd_async/tango/signal/_tango_transport.py +++ b/src/ophyd_async/tango/signal/_tango_transport.py @@ -593,7 +593,7 @@ def __init__( } self.trl_configs: Dict[str, AttributeInfoEx] = {} self.descriptor: Descriptor = {} # type: ignore - self.polling = (False, 0.1, None, 0.1) + self._polling = (False, 0.1, None, 0.1) self.support_events = True self.status = None @@ -619,7 +619,7 @@ async def connect(self, timeout: float = DEFAULT_TIMEOUT): else: # The same, so only need to connect one await self._connect_and_store_config(self.read_trl) - self.proxies[self.read_trl].set_polling(*self.polling) + self.proxies[self.read_trl].set_polling(*self._polling) self.descriptor = get_trl_descriptor( self.datatype, self.read_trl, self.trl_configs ) @@ -642,7 +642,7 @@ async def get_setpoint(self) -> T: return await self.proxies[self.write_trl].get_w_value() def set_callback(self, callback: Optional[ReadingValueCallback]) -> None: - if self.support_events is False and self.polling[0] is False: + if self.support_events is False and self._polling[0] is False: raise RuntimeError( f"Cannot set event for {self.read_trl}. " "Cannot set a callback on an attribute that does not support events and" @@ -668,7 +668,7 @@ def set_polling( abs_change=None, rel_change=0.1, ): - self.polling = (allow_polling, polling_period, abs_change, rel_change) + self._polling = (allow_polling, polling_period, abs_change, rel_change) def allow_events(self, allow: Optional[bool] = True): self.support_events = allow