From 9babe27680ce68805394bb3ad8d9a109ca73e682 Mon Sep 17 00:00:00 2001 From: gac-x05la Date: Wed, 3 Jul 2024 16:55:41 +0200 Subject: [PATCH] Software stepscan with GF --- .../devices/gigafrost/gigafrostclient.py | 17 +++++++++++++--- .../devices/gigafrost/stddaq_preview.py | 20 +++++++++++-------- tomcat_bec/devices/gigafrost/stddaq_ws.py | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/tomcat_bec/devices/gigafrost/gigafrostclient.py b/tomcat_bec/devices/gigafrost/gigafrostclient.py index 075e049..b2c0a0a 100644 --- a/tomcat_bec/devices/gigafrost/gigafrostclient.py +++ b/tomcat_bec/devices/gigafrost/gigafrostclient.py @@ -6,7 +6,8 @@ Created on Thu Jun 27 17:28:43 2024 @author: mohacsi_i """ -from ophyd import Device, Component, EpicsSignal, EpicsSignalRO, Kind +from time import sleep +from ophyd import Device, Component, EpicsSignal, EpicsSignalRO, Kind, DeviceStatus from ophyd.device import Staged try: @@ -371,9 +372,19 @@ class GigaFrostClient(Device): """Standard ophyd method to stop an acquisition""" self.unstage() - def trigger(self): + def trigger(self) -> DeviceStatus: """Sends a software trigger""" - self.cmdSoftTrigger.set(1).wait() + # Soft triggering based on operation mode + if self._auto_soft_enable: + # BEC teststand operation mode: poedge of SoftEnable if Started + self.cmdSoftEnable.set(0).wait() + self.cmdSoftEnable.set(1).wait() + else: + self.cmdSoftTrigger.set(1).wait() + status = DeviceStatus(self, settle_time=2.0) + status.set_finished() + sleep(2.0) + return status @property def exposure_mode(self): diff --git a/tomcat_bec/devices/gigafrost/stddaq_preview.py b/tomcat_bec/devices/gigafrost/stddaq_preview.py index 5cdf7c5..7552f56 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_preview.py +++ b/tomcat_bec/devices/gigafrost/stddaq_preview.py @@ -27,11 +27,11 @@ class StdDaqPreview(Device): # pylint: disable=too-many-instance-attributes # Status attributes - status = Component(Signal, value="detached") + status = Component(Signal, value="detached", kind=Kind.omitted) image = Component(Signal, kind=Kind.hinted) frame = Component(Signal, kind=Kind.hinted) - shape = Component(Signal, kind=Kind.hinted) - _throttle = 0.5 + shape = Component(Signal, kind=Kind.omitted) + _throttle = 0.05 def __init__( self, *args, url: str = "tcp://129.129.95.38:20000", parent: Device = None, **kwargs @@ -73,12 +73,12 @@ class StdDaqPreview(Device): Example: ---------- - std.configure(throttle=0.5) + std.configure(throttle=0.05) Parameters ---------- throttle : float, optional - Additional throtling for the ophyd device. (default = 0.5 sec) + Additional throtling for the ophyd device. (default = 0.05 sec) """ self._throttle = throttle @@ -127,18 +127,22 @@ class StdDaqPreview(Device): t_curr = time() t_elapsed = t_curr - t_last - if t_elapsed > self._throttle: + if t_elapsed > 999999*self._throttle: self.frame.put(header['frame'], force=True) self.shape.put(header['shape'], force=True) self.image.put(image, force=True) t_last=t_curr - #print(header) - print(f"Frame: {header['frame']}\tMin: {np.min(image)}\tMax: {np.max(image)}") + print(f"Frame: {header['frame']}\t<<<<>>>>") + else: + print(f"Frame: {header['frame']}\tMin: {np.min(image)}\tMax: {np.max(image)}") if self._stop_polling: self.status.set("detached", force=True) print("Detaching monitor") break + except ValueError: + # Happens when ZMQ partially delivers the multipart message + pass except zmq.error.Again: sleep(0.1) except Exception as ex: diff --git a/tomcat_bec/devices/gigafrost/stddaq_ws.py b/tomcat_bec/devices/gigafrost/stddaq_ws.py index a2f12a0..27323bb 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_ws.py +++ b/tomcat_bec/devices/gigafrost/stddaq_ws.py @@ -30,7 +30,7 @@ class StdDaqWsClient(Device): # pylint: disable=too-many-instance-attributes # Status attributes - status = Component(Signal, value="unknown") + status = Component(Signal, value="unknown", kind=Kind.hinted) n_images = Component(Signal, value=10000, kind=Kind.config) file_path = Component(Signal, value="/gpfs/test/test-beamline", kind=Kind.config)