Skip to content

Commit

Permalink
subscribalbe readable (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Braun <[email protected]>
  • Loading branch information
Bilchreis and Peter Braun authored Nov 22, 2024
1 parent 5d43248 commit bab3da3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/secop_ophyd/SECoPDevices.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
Locatable,
Location,
PartialEvent,
Reading,
Stoppable,
Subscribable,
SyncOrAsync,
Triggerable,
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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):
"""
Expand Down

0 comments on commit bab3da3

Please sign in to comment.