From 77b50efa9fe8c8c737ac3354c293a59a9549f45d Mon Sep 17 00:00:00 2001 From: gac-x05la Date: Tue, 5 Nov 2024 15:26:34 +0100 Subject: [PATCH] Seems working --- .../devices/gigafrost/gigafrostcamera.py | 29 ++++++++++--------- tomcat_bec/devices/gigafrost/stddaq_client.py | 9 +++++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/tomcat_bec/devices/gigafrost/gigafrostcamera.py b/tomcat_bec/devices/gigafrost/gigafrostcamera.py index bb54858..d90f16b 100644 --- a/tomcat_bec/devices/gigafrost/gigafrostcamera.py +++ b/tomcat_bec/devices/gigafrost/gigafrostcamera.py @@ -171,12 +171,12 @@ class GigaFrostCameraMixin(CustomDetectorMixin): d['image_width'] = scanargs[f'{prefix}image_width'] if f'{prefix}image_height' in scanargs: d['image_height'] = scanargs[f'{prefix}image_height'] - if f'{prefix}num_burst' in scanargs: - d['num_burst'] = scanargs[f'{prefix}num_burst'] - if f'{prefix}exposure_time' in scanargs: - d['exposure_time'] = scanargs[f'{prefix}exposure_time'] - if f'{prefix}exposure_period' in scanargs: - d['exposure_period'] = scanargs[f'{prefix}exposure_period'] + if f'{prefix}exposure_num_burst' in scanargs: + d['exposure_num_burst'] = scanargs[f'{prefix}exposure_num_burst'] + if f'{prefix}exposure_time_ms' in scanargs: + d['exposure_time_ms'] = scanargs[f'{prefix}exposure_time_ms'] + if f'{prefix}exposure_period_ms' in scanargs: + d['exposure_period_ms'] = scanargs[f'{prefix}exposure_period_ms'] if f'{prefix}correction_mode' in scanargs: d['correction_mode'] = scanargs[f'{prefix}correction_mode'] if f'{prefix}scanid' in scanargs: @@ -482,7 +482,8 @@ class GigaFrostCamera(PSIDetectorBase): super().trigger() # There's no status readback from the camera, so we just wait - sleep_time = self.cfgExposure.value*self.cfgCntNum.value*0.001+0.050 + sleep_time = self.cfgExposure.value*self.cfgCntNum.value*0.001+0.2 + sleep(sleep_time) return DeviceStatus(self, done=True, success=True, settle_time=sleep_time) def configure(self, d: dict = None): @@ -494,9 +495,9 @@ class GigaFrostCamera(PSIDetectorBase): Number of images to be taken during each scan. Set to -1 for an unlimited number of images (limited by the ringbuffer size and backend speed). (default = 10) - exposure_time : float, optional + exposure_time_ms : float, optional Exposure time [ms]. (default = 0.2) - exposure_period : float, optional + exposure_period_ms : float, optional Exposure period [ms], ignored in soft trigger mode. (default = 1.0) image_width : int, optional ROI size in the x-direction [pixels] (default = 2016) @@ -526,9 +527,9 @@ class GigaFrostCamera(PSIDetectorBase): # If Bluesky style configure if d is not None: - num_images = d.get('num_images', 10) - exposure_time = d.get('exposure_time', 0.2) - exposure_period = d.get('exposure_period', 1.0) + num_images = d.get('exposure_num_burst', 10) + exposure_time_ms = d.get('exposure_time_ms', 0.2) + exposure_period_ms = d.get('exposure_period_ms', 2*exposure_time_ms) image_width = d.get('image_width', 2016) image_height = d.get('image_height', 2016) scanid = d.get('scanid', 0) @@ -536,8 +537,8 @@ class GigaFrostCamera(PSIDetectorBase): correction_mode = d.get('correction_mode', 5) # change settings - self.cfgExposure.set(exposure_time).wait() - self.cfgFramerate.set(exposure_period).wait() + self.cfgExposure.set(exposure_time_ms).wait() + self.cfgFramerate.set(exposure_period_ms).wait() self.cfgRoiX.set(image_width).wait() self.cfgRoiY.set(image_height).wait() self.cfgScanId.set(scanid).wait() diff --git a/tomcat_bec/devices/gigafrost/stddaq_client.py b/tomcat_bec/devices/gigafrost/stddaq_client.py index 1060491..8f7f47b 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_client.py +++ b/tomcat_bec/devices/gigafrost/stddaq_client.py @@ -69,7 +69,14 @@ class StdDaqMixin(CustomDeviceMixin): ii = 0 self.parent.connect() while True: - reply = self.parent.message(message) + try: + reply = self.parent.message(message) + except ConnectionClosedOK: + # # NOTE: Sometimes the stdDAQ rejects both start and stop commands, needs nuking + # self.parent.restart() + # sleep(0.5) + self.parent.connect() + reply = self.parent.message(message) if reply is not None: reply = json.loads(reply)