diff --git a/docs/examples/tango_demo.py b/docs/examples/tango_demo.py index 3a978fde04..503dccd1ec 100644 --- a/docs/examples/tango_demo.py +++ b/docs/examples/tango_demo.py @@ -1,15 +1,13 @@ import asyncio +import bluesky.plan_stubs as bps import bluesky.plans as bp from bluesky import RunEngine -from bluesky.callbacks.best_effort import BestEffortCallback -from bluesky.utils import ProgressBarManager from ophyd_async.tango.demo import ( DemoCounter, DemoMover, - TangoCounter, - TangoMover, + TangoDetector, ) from tango.test_context import MultiDeviceTestContext @@ -28,25 +26,28 @@ async def main(): - with tango_context as context: - motor1 = TangoMover( - trl=context.get_device_access("demo/motor/1"), name="motor1" + with tango_context: + detector = TangoDetector( + trl="", + name="detector", + counters_kwargs={"prefix": "demo/counter/", "count": 2}, + mover_kwargs={"trl": "demo/motor/1"}, ) - counter1 = TangoCounter( - trl=context.get_device_access("demo/counter/1"), name="counter1" - ) - counter2 = TangoCounter( - trl=context.get_device_access("demo/counter/2"), name="counter2" - ) - await motor1.connect() - await counter1.connect() - await counter2.connect() + await detector.connect() RE = RunEngine() - RE.subscribe(BestEffortCallback()) - RE.waiting_hook = ProgressBarManager() - # RE(bps.mv(motor1, 1)) - RE(bp.scan([counter1, counter2], motor1, -1, 1, 10)) + + RE(bps.read(detector)) + RE(bps.mv(detector, 0)) + RE(bp.count(list(detector.counters.values()))) + + set_status = detector.set(1.0) + await asyncio.sleep(0.1) + stop_status = detector.stop() + await set_status + await stop_status + assert all([set_status.done, stop_status.done]) + assert all([set_status.success, stop_status.success]) if __name__ == "__main__": diff --git a/src/ophyd_async/tango/demo/_detector.py b/src/ophyd_async/tango/demo/_detector.py index 089877ade3..85fd31bdef 100644 --- a/src/ophyd_async/tango/demo/_detector.py +++ b/src/ophyd_async/tango/demo/_detector.py @@ -6,7 +6,8 @@ ) from ophyd_async.tango import TangoReadable -from . import TangoCounter, TangoMover +from ._counter import TangoCounter +from ._mover import TangoMover class TangoDetector(TangoReadable): @@ -24,8 +25,8 @@ def __init__(self, *args, **kwargs): def set(self, value): return self.mover.set(value) - def stop(self): - return self.mover.stop() + def stop(self, success: bool = True) -> AsyncStatus: + return self.mover.stop(success) @AsyncStatus.wrap async def trigger(self):