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

Updates from AI optics beamtime #294

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions src/haven/devices/area_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from ophyd.areadetector.plugins import (
TIFFPlugin_V31,
TIFFPlugin_V34,
TransformPlugin_V34,
)
from ophyd.flyers import FlyerInterface
from ophyd.sim import make_fake_device
Expand Down Expand Up @@ -320,15 +321,22 @@ class DynamicFileStore(Device):
"""File store mixin that alters the write_path_template based on
iconfig values.

Parameters
==========
write_path_template
A format string to use for deciding file paths. Can accept keys
{root_path} and {name}.

"""

def __init__(
self, *args, write_path_template="/{root_path}/{name}/%Y/%m/", **kwargs
self, *args, write_path_template="/{root_path}/{name}/%Y/%m/%d/", **kwargs
):
write_path_template = write_path_template.lstrip("/")
super().__init__(*args, write_path_template=write_path_template, **kwargs)
# Format the file_write_template with per-device values
config = load_config()
root_path = config.get("area_detector_root_path", "tmp")
root_path = config.get("area_detector_root_path", "tmp").lstrip("/")
# Remove the leading slash for some reason...makes ophyd happy
root_path = root_path.lstrip("/")
try:
Expand Down Expand Up @@ -517,6 +525,7 @@ class Eiger500K(SingleTrigger, DetectorBase):
class AravisCam(AsyncCamMixin, CamBase):
gain_auto = ADCpt(EpicsSignal, "GainAuto")
acquire_time_auto = ADCpt(EpicsSignal, "ExposureAuto")
pixel_format = ADCpt(EpicsSignal, "PixelFormat")


class AravisDetector(SingleImageModeTrigger, DetectorBase):
Expand All @@ -531,6 +540,7 @@ class AravisDetector(SingleImageModeTrigger, DetectorBase):
"stats2",
"stats3",
"stats4",
"trans1",
)
_default_read_attrs = ("cam", "hdf", "stats1", "stats2", "stats3", "stats4")

Expand All @@ -547,6 +557,7 @@ class AravisDetector(SingleImageModeTrigger, DetectorBase):
stats3 = ADCpt(StatsPlugin_V34, "Stats3:", kind=Kind.normal)
stats4 = ADCpt(StatsPlugin_V34, "Stats4:", kind=Kind.normal)
stats5 = ADCpt(StatsPlugin_V34, "Stats5:", kind=Kind.normal)
trans1 = ADCpt(TransformPlugin_V34, "Trans1:", kind=Kind.config)
hdf = ADCpt(HDF5FilePlugin, "HDF1:", kind=Kind.normal)
# tiff = ADCpt(TIFFFilePlugin, "TIFF1:", kind=Kind.normal)

Expand Down
16 changes: 14 additions & 2 deletions src/haven/devices/detectors/aravis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from ophyd_async.core import PathProvider, SubsetEnum
import numpy as np
from ophyd_async.core import Array1D, PathProvider, SubsetEnum
from ophyd_async.epics.adaravis import AravisDetector as DetectorBase
from ophyd_async.epics.core import epics_signal_rw_rbv
from ophyd_async.epics.core import epics_signal_r, epics_signal_rw_rbv

from .area_detectors import HavenDetector, default_path_provider

Expand All @@ -10,6 +11,10 @@ class AravisTriggerSource(SubsetEnum):
LINE1 = "Line1"


class AravisPixelFormat(SubsetEnum):
MONO_8 = "Mono8"


class AravisDetector(HavenDetector, DetectorBase):
_ophyd_labels_ = {"cameras", "detectors"}

Expand All @@ -18,7 +23,14 @@ def __init__(
):
if path_provider is None:
path_provider = default_path_provider()
self.image_array = epics_signal_r(
Array1D[np.int16], f"{prefix}image1:ArrayData"
)
super().__init__(*args, prefix=prefix, path_provider=path_provider, **kwargs)
self.drv.pixel_format = epics_signal_rw_rbv(
AravisPixelFormat,
f"{prefix}cam1:PixelFormat",
)
# Replace a signal that has different enum options
self.drv.trigger_source = epics_signal_rw_rbv(
AravisTriggerSource, # type: ignore
Expand Down