Skip to content

Commit

Permalink
Use wait_for_value
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Jul 22, 2024
1 parent e973db3 commit 9b85ea2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/dodal/devices/i24/pmac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from enum import Enum, IntEnum

from bluesky.protocols import Triggerable
from ophyd_async.core import AsyncStatus, StandardReadable, observe_value
from ophyd_async.core import (
AsyncStatus,
StandardReadable,
wait_for_value,
)
from ophyd_async.core.signal import SignalR, SignalRW
from ophyd_async.core.signal_backend import SignalBackend
from ophyd_async.core.soft_signal_backend import SoftSignalBackend
Expand Down Expand Up @@ -120,12 +124,13 @@ def __init__(
super().__init__(backend, timeout, name)

@AsyncStatus.wrap
async def set(self, prog_num: int):
async def set(self, prog_num: int, timeout: float):
prog_str = f"&2b{prog_num}r"
await self.signal.set(prog_str, wait=True)
async for reading in observe_value(self.status):
if reading == ScanState.DONE:
return
wait_for_value(self.status, ScanState.DONE, timeout)
# async for reading in observe_value(self.status):
# if reading == ScanState.DONE:
# return


class PMAC(StandardReadable):
Expand Down
2 changes: 1 addition & 1 deletion tests/devices/unit_tests/i24/test_pmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ async def test_set_pmac_string_for_enc_reset(fake_pmac: PMAC, RE):
async def test_run_proogram(fake_pmac: PMAC, RE):
set_mock_value(fake_pmac.scanstatus, 0)
prog_num = 10
RE(bps.abs_set(fake_pmac.run_program, prog_num, wait=True))
RE(bps.abs_set(fake_pmac.run_program, prog_num, timeout=1, wait=True))

assert await fake_pmac.pmac_string.get_value() == f"&2b{prog_num}r"

0 comments on commit 9b85ea2

Please sign in to comment.