Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #495 from DiamondLightSource/480_better_status_log…
Browse files Browse the repository at this point in the history
…ging

480 better status logging
  • Loading branch information
DominicOram authored Jan 27, 2023
2 parents 44bc20d + 7912a9a commit 6ab36e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/artemis/devices/eiger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from enum import Enum
from typing import Optional

from ophyd import Component, Device, EpicsSignalRO, StatusBase
from ophyd import Component, Device, EpicsSignalRO
from ophyd.areadetector.cam import EigerDetectorCam
from ophyd.status import Status
from ophyd.status import AndStatus, Status, SubscriptionStatus

from artemis.devices.detector import DetectorParams
from artemis.devices.eiger_odin import EigerOdin
Expand Down Expand Up @@ -41,7 +41,7 @@ class EigerDetector(Device):

STALE_PARAMS_TIMEOUT = 60

filewriters_finished: StatusBase
filewriters_finished: SubscriptionStatus

detector_params: Optional[DetectorParams] = None

Expand Down Expand Up @@ -129,7 +129,7 @@ def change_roi_mode(self, enable: bool):
if not status.success:
self.log.error("Failed to switch to ROI mode")

def set_cam_pvs(self) -> Status:
def set_cam_pvs(self) -> AndStatus:
assert self.detector_params is not None
status = self.cam.acquire_time.set(self.detector_params.exposure_time)
status &= self.cam.acquire_period.set(self.detector_params.exposure_time)
Expand Down
12 changes: 3 additions & 9 deletions src/artemis/devices/eiger_odin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from typing import List, Tuple

from ophyd import (
Component,
Device,
EpicsSignal,
EpicsSignalRO,
EpicsSignalWithRBV,
StatusBase,
)
from ophyd import Component, Device, EpicsSignal, EpicsSignalRO, EpicsSignalWithRBV
from ophyd.areadetector.plugins import HDF5Plugin_V22
from ophyd.status import SubscriptionStatus

from artemis.devices.status import await_value

Expand Down Expand Up @@ -120,7 +114,7 @@ class EigerOdin(Device):
meta: OdinMetaListener = Component(OdinMetaListener, "OD:META:")
nodes: OdinNodesStatus = Component(OdinNodesStatus, "")

def create_finished_status(self) -> StatusBase:
def create_finished_status(self) -> SubscriptionStatus:
writing_finished = await_value(self.meta.ready, 0)
for node_pv in self.nodes.nodes:
writing_finished &= await_value(node_pv.writing, 0)
Expand Down
3 changes: 1 addition & 2 deletions src/artemis/devices/status.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Any, TypeVar

from ophyd import StatusBase
from ophyd.status import SubscriptionStatus

T = TypeVar("T")


def await_value(subscribable: Any, expected_value: T) -> StatusBase:
def await_value(subscribable: Any, expected_value: T) -> SubscriptionStatus:
def value_is(value, **_):
return value == expected_value

Expand Down

0 comments on commit 6ab36e0

Please sign in to comment.