Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test hdf5 files with flou detector #680

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description = "Ophyd devices and other utils that could be used across DLS beaml
dependencies = [
"click",
"ophyd",
"ophyd-async>=0.3.1",
"ophyd-async @ git+https://github.com/bluesky/ophyd-async.git@b0ff0c38cd2cd6eac21fe1db7ee4d077e2c0eb29",
"bluesky",
"pyepics",
"dataclasses-json",
Expand All @@ -23,10 +23,10 @@ dependencies = [
"requests",
"graypy",
"pydantic",
"opencv-python-headless", # For pin-tip detection.
"aioca", # Required for CA support with ophyd-async.
"p4p", # Required for PVA support with ophyd-async.
"numpy<2.0", # Unpin when https://github.com/bluesky/ophyd-async/issues/387 resolved
"opencv-python-headless", # For pin-tip detection.
"aioca", # Required for CA support with ophyd-async.
"p4p", # Required for PVA support with ophyd-async.
"numpy<2.0", # Unpin when https://github.com/bluesky/ophyd-async/issues/387 resolved
"aiofiles",
"aiohttp",
]
Expand Down
55 changes: 44 additions & 11 deletions src/dodal/devices/xspress3/xspress3.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
AsyncStatus,
Device,
DeviceVector,
wait_for_value,
set_and_wait_for_other_value,
)
from ophyd_async.epics.signal.signal import (
epics_signal_r,
Expand Down Expand Up @@ -45,6 +45,16 @@ class AcquireRBVState(str, Enum):
ACQUIRE = "Acquiring"


class WritingRBVState(str, Enum):
DONE = "Done"
CAPTURE = "Capturing"


class WritingState(str, Enum):
DONE = "Done"
CAPTURE = "Capture"


class DetectorState(str, Enum):
IDLE = "Idle"
ACQUIRE = "Acquire"
Expand Down Expand Up @@ -115,6 +125,13 @@ def __init__(
self.acquire_rbv = epics_signal_r(AcquireRBVState, prefix + "Acquire_RBV")
self.trigger_mode = epics_signal_rw_rbv(TriggerMode, prefix + "TriggerMode")

self.file_path = epics_signal_rw_rbv(str, prefix + "HDF5:FilePath")
self.file_name = epics_signal_rw_rbv(str, prefix + "HDF5:FileName")
self.do_file_writing = epics_signal_rw(WritingState, prefix + "HDF5:Capture")
self.file_writing_rbv = epics_signal_r(
WritingRBVState, prefix + "HDF5:Capture_RBV"
)

self.detector_state = epics_signal_r(
DetectorState, prefix + "DetectorState_RBV"
)
Expand All @@ -130,21 +147,37 @@ def __init__(
@AsyncStatus.wrap
async def stage(self) -> None:
LOGGER.info("Arming Xspress3 detector...")
await self.trigger_mode.set(TriggerMode.BURST)
await wait_for_value(
self.detector_state,
lambda v: v in self.detector_busy_states,
await set_and_wait_for_other_value(
self.do_file_writing,
WritingState.CAPTURE,
self.file_writing_rbv,
WritingRBVState.CAPTURE,
timeout=self.timeout,
)
await self.acquire.set(AcquireState.ACQUIRE)
await wait_for_value(
self.acquire_rbv, AcquireRBVState.ACQUIRE, timeout=self.timeout
await self.trigger_mode.set(TriggerMode.BURST)

await set_and_wait_for_other_value(
self.acquire,
AcquireState.ACQUIRE,
self.acquire_rbv,
AcquireRBVState.ACQUIRE,
timeout=self.timeout,
)

@AsyncStatus.wrap
async def unstage(self) -> None:
await self.acquire.set(AcquireState.DONE)
LOGGER.info("unstaging Xspress3 detector...")
await wait_for_value(
self.acquire_rbv, AcquireRBVState.DONE, timeout=self.timeout
await set_and_wait_for_other_value(
self.do_file_writing,
WritingState.DONE,
self.file_writing_rbv,
WritingRBVState.DONE,
timeout=self.timeout,
)
await set_and_wait_for_other_value(
self.acquire,
AcquireState.DONE,
self.acquire_rbv,
AcquireRBVState.DONE,
timeout=self.timeout,
)
Loading