From eb59ecf79f34d82fe69fa0c5fdee9363cc40869e Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Wed, 30 Oct 2024 23:41:22 -0500 Subject: [PATCH 1/5] Added a transform plugin to the aravis area detector. --- src/haven/devices/area_detector.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/haven/devices/area_detector.py b/src/haven/devices/area_detector.py index 95045745..7d51480e 100644 --- a/src/haven/devices/area_detector.py +++ b/src/haven/devices/area_detector.py @@ -39,6 +39,7 @@ PvaPlugin_V34, ROIPlugin_V31, ROIPlugin_V34, + TransformPlugin_V34, ) from ophyd.areadetector.plugins import StatsPlugin_V31 as OphydStatsPlugin_V31 from ophyd.areadetector.plugins import StatsPlugin_V34 as OphydStatsPlugin_V34 @@ -523,6 +524,7 @@ class AravisDetector(SingleImageModeTrigger, DetectorBase): "stats2", "stats3", "stats4", + "trans1", ) _default_read_attrs = ("cam", "hdf", "stats1", "stats2", "stats3", "stats4") @@ -539,6 +541,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) From f0fce100eda069363123865d87ded886df9e53ec Mon Sep 17 00:00:00 2001 From: Mark Wolfman Date: Wed, 30 Oct 2024 23:45:22 -0500 Subject: [PATCH 2/5] Updated default path for writing HDF AD files. --- src/haven/devices/area_detector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/haven/devices/area_detector.py b/src/haven/devices/area_detector.py index 7d51480e..83f2eb06 100644 --- a/src/haven/devices/area_detector.py +++ b/src/haven/devices/area_detector.py @@ -327,7 +327,7 @@ def __init__( try: self.write_path_template = self.write_path_template.format( name=self.parent.name, - root_path=config.get("area_detector_root_path", "tmp"), + root_path=config.get("area_detector_root_path", "/tmp"), ) except KeyError: warnings.warn(f"Could not format write_path_template {write_path_template}") From 82782883430ed0e7f5836d475a994dce3873fce2 Mon Sep 17 00:00:00 2001 From: yannachen Date: Thu, 31 Oct 2024 09:30:38 -0500 Subject: [PATCH 3/5] Added pixel_format signal to the aravis camera. --- src/haven/devices/area_detector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/haven/devices/area_detector.py b/src/haven/devices/area_detector.py index 83f2eb06..2662cd56 100644 --- a/src/haven/devices/area_detector.py +++ b/src/haven/devices/area_detector.py @@ -510,6 +510,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): From 47406f385d41700be071587cf582070ab7ff0239 Mon Sep 17 00:00:00 2001 From: yannachen Date: Fri, 1 Nov 2024 16:42:36 -0500 Subject: [PATCH 4/5] Updated the threaded ophyd area detectors so they can use the same write path template as ophyd-async. --- src/haven/devices/area_detector.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/haven/devices/area_detector.py b/src/haven/devices/area_detector.py index 2662cd56..4bbf76ce 100644 --- a/src/haven/devices/area_detector.py +++ b/src/haven/devices/area_detector.py @@ -316,18 +316,25 @@ 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}/%Y/%m/{name}/", **kwargs + self, *args, write_path_template="{root_path}/%Y/%m/{name}/", **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() try: self.write_path_template = self.write_path_template.format( name=self.parent.name, - root_path=config.get("area_detector_root_path", "/tmp"), + root_path=config.get("area_detector_root_path", "/tmp").lstrip('/'), ) except KeyError: warnings.warn(f"Could not format write_path_template {write_path_template}") From d79b465a16dafd13eadaac5393912db707b3978c Mon Sep 17 00:00:00 2001 From: yannachen Date: Thu, 12 Dec 2024 09:56:09 -0600 Subject: [PATCH 5/5] Fixes to the aravis support to try and get bloptools working. --- src/haven/devices/detectors/aravis.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/haven/devices/detectors/aravis.py b/src/haven/devices/detectors/aravis.py index 3710c6df..024d71ed 100644 --- a/src/haven/devices/detectors/aravis.py +++ b/src/haven/devices/detectors/aravis.py @@ -1,17 +1,27 @@ from ophyd_async.core import SubsetEnum from ophyd_async.epics.adaravis import AravisDetector as DetectorBase -from ophyd_async.epics.signal import epics_signal_rw_rbv +from ophyd_async.epics.signal import epics_signal_rw_rbv, epics_signal_r +from numpy.typing import NDArray +import numpy as np from .area_detectors import HavenDetector AravisTriggerSource = SubsetEnum["Software", "Line1"] +AravisPixelFormat = SubsetEnum["Mono8"] + + class AravisDetector(HavenDetector, DetectorBase): _ophyd_labels_ = {"cameras", "detectors"} def __init__(self, prefix, *args, **kwargs): super().__init__(*args, prefix=prefix, **kwargs) + self.image_array = epics_signal_r(NDArray[np.int16], f"{prefix}image1:ArrayData") + 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