Skip to content

Commit

Permalink
(#117) (#45) only update elapsed time in status if not supplied
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Apr 18, 2024
1 parent 350e905 commit 21560a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/ophyd_async/core/async_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ async def _notify_watchers_from(self, iterator: AsyncIterator[WatcherUpdate[T]])
async for update in iterator:
if self._timeout and time.monotonic() > self._timeout:
raise TimeoutError()
self._last_update = replace(
update, time_elapsed=time.monotonic() - self._start
self._last_update = (
update
if update.time_elapsed is None
else replace(update, time_elapsed=time.monotonic() - self._start)
)
for watcher in self._watchers:
self._update_watcher(watcher, self._last_update)
Expand Down
5 changes: 3 additions & 2 deletions tests/core/test_device_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import pytest
from bluesky import plan_stubs as bps
from bluesky.run_engine import RunEngine, TransitionError
from bluesky.run_engine import RunEngine
from super_state_machine.errors import TransitionError

from ophyd_async.core import DEFAULT_TIMEOUT, Device, DeviceCollector, NotConnected
from ophyd_async.epics.motion import motor
Expand Down Expand Up @@ -96,7 +97,7 @@ async def set_up_device():
RE = RunEngine(call_returns_result=True, loop=loop)

def my_plan():
sim_motor.done_moving._backend._set_value(True) # type: ignore
sim_motor.motor_done_move._backend._set_value(True) # type: ignore
yield from bps.mov(sim_motor, 3.14)

RE(my_plan())
Expand Down
4 changes: 2 additions & 2 deletions tests/epics/motion/test_motor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ async def sim_motor():
AsyncStatus.wrap

async def fake_stop(*args, **kwargs):
sim_motor.done_moving._backend._set_value(True) # type: ignore
sim_motor.motor_done_move._backend._set_value(True) # type: ignore
await asyncio.sleep(0.01)

sim_motor.stop_.trigger = fake_stop # type: ignore
sim_motor.motor_stop.trigger = fake_stop # type: ignore
assert sim_motor.name == "sim_motor"
set_sim_value(sim_motor.motor_egu, "mm")
set_sim_value(sim_motor.precision, 3)
Expand Down

0 comments on commit 21560a0

Please sign in to comment.