diff --git a/src/secop_ophyd/SECoPDevices.py b/src/secop_ophyd/SECoPDevices.py index 7920c9e..533b7e4 100644 --- a/src/secop_ophyd/SECoPDevices.py +++ b/src/secop_ophyd/SECoPDevices.py @@ -13,7 +13,9 @@ Locatable, Location, PartialEvent, + Reading, Stoppable, + Subscribable, SyncOrAsync, Triggerable, ) @@ -41,6 +43,7 @@ T, observe_value, ) +from ophyd_async.core._utils import Callback from typing_extensions import Self from secop_ophyd.AsyncFrappyClient import AsyncFrappyClient @@ -307,7 +310,7 @@ async def describe_collect(self) -> SyncOrAsync[Dict[str, Dict[str, Descriptor]] return await self.describe() -class SECoPReadableDevice(SECoPBaseDevice, Triggerable): +class SECoPReadableDevice(SECoPBaseDevice, Triggerable, Subscribable): """ Standard readable SECoP device, corresponding to a SECoP module with the interface class "Readable" @@ -494,6 +497,14 @@ def wait_for_idle_factory(): def trigger(self) -> bps.Status: return AsyncStatus(awaitable=self.value.read(cached=False)) + def subscribe(self, function: Callback[dict[str, Reading]]) -> None: + """Subscribe to updates in the reading""" + self.value.subscribe(function=function) + + def clear_sub(self, function: Callback) -> None: + """Remove a subscription.""" + self.value.clear_sub(function=function) + class SECoPTriggerableDevice(SECoPReadableDevice, Triggerable, Stoppable): """