From 1fa58c2632d787f053c0d9c99b6a63d685f210f1 Mon Sep 17 00:00:00 2001 From: gac-x05la Date: Mon, 4 Nov 2024 16:35:38 +0100 Subject: [PATCH] Clared nested devices but still not everyone getting config --- .../device_configs/microxas_test_bed.yaml | 44 ++++++++++------ tomcat_bec/devices/__init__.py | 2 + .../aerotech/AerotechDriveDataCollection.py | 41 ++++++++------- .../devices/gigafrost/gigafrostcamera.py | 50 +++++++++---------- tomcat_bec/devices/gigafrost/stddaq_client.py | 47 +++++++---------- 5 files changed, 92 insertions(+), 92 deletions(-) diff --git a/tomcat_bec/device_configs/microxas_test_bed.yaml b/tomcat_bec/device_configs/microxas_test_bed.yaml index 749e23e..1edd1ef 100644 --- a/tomcat_bec/device_configs/microxas_test_bed.yaml +++ b/tomcat_bec/device_configs/microxas_test_bed.yaml @@ -129,22 +129,34 @@ es1_ddaq: # readoutPriority: monitored # softwareTrigger: true -# gfclient: -# description: GigaFrost camera client -# deviceClass: tomcat_bec.devices.GigaFrostClient -# deviceConfig: -# prefix: 'X02DA-CAM-GF2:' -# backend_url: 'http://sls-daq-001:8080' -# auto_soft_enable: true -# daq_ws_url: 'ws://129.129.95.111:8080' -# daq_rest_url: 'http://129.129.95.111:5000' -# deviceTags: -# - camera -# enabled: true -# onFailure: buffer -# readOnly: false -# readoutPriority: monitored -# softwareTrigger: true +gfcam: + description: GigaFrost camera client + deviceClass: tomcat_bec.devices.GigaFrostCamera + deviceConfig: + prefix: 'X02DA-CAM-GF2:' + backend_url: 'http://sls-daq-001:8080' + auto_soft_enable: true + deviceTags: + - camera + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: monitored + softwareTrigger: true + +gfdaq: + description: GigaFrost stdDAQ client + deviceClass: tomcat_bec.devices.StdDaqClient + deviceConfig: + ws_url: 'ws://129.129.95.111:8080' + rest_url: 'http://129.129.95.111:5000' + deviceTags: + - std-daq + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: monitored + softwareTrigger: true daq_stream0: description: stdDAQ preview (2 every 555) diff --git a/tomcat_bec/devices/__init__.py b/tomcat_bec/devices/__init__.py index a3acd2f..d1adb74 100644 --- a/tomcat_bec/devices/__init__.py +++ b/tomcat_bec/devices/__init__.py @@ -11,4 +11,6 @@ from .grashopper_tomcat import GrashopperTOMCAT from .psimotor import EpicsMotorMR, EpicsMotorEC from .gigafrost.gigafrostclient import GigaFrostClient +from .gigafrost.gigafrostcamera import GigaFrostCamera +from .gigafrost.stddaq_client import StdDaqClient from .gigafrost.stddaq_preview import StdDaqPreviewDetector diff --git a/tomcat_bec/devices/aerotech/AerotechDriveDataCollection.py b/tomcat_bec/devices/aerotech/AerotechDriveDataCollection.py index b689e0d..9e77763 100644 --- a/tomcat_bec/devices/aerotech/AerotechDriveDataCollection.py +++ b/tomcat_bec/devices/aerotech/AerotechDriveDataCollection.py @@ -21,9 +21,6 @@ from bec_lib import bec_logger logger = bec_logger.logger - - - class AerotechDriveDataCollectionMixin(CustomDeviceMixin): # parent : aa1Tasks def on_stage(self) -> None: @@ -31,26 +28,28 @@ class AerotechDriveDataCollectionMixin(CustomDeviceMixin): """ # Fish out our configuration from scaninfo (via explicit or generic addressing) scanparam = self.parent.scaninfo.scan_msg.info - prefix = self.parent.parent.name if self.parent.parent is not None else self.parent.name + alias = self.parent.parent.name if self.parent.parent is not None else self.parent.name + logger.warning(f"[{alias}] Scan parameters:\n{scanparam}") d = {} if 'kwargs' in scanparam: - scanargs = scanparam['kwargs'] - if f'{prefix}_num_points_total' in scanargs: - d['num_points'] = scanargs[f'{prefix}_num_points_total'] - if f'{prefix}_ddc_trigger' in scanargs: - d['ddc_trigger'] = scanargs[f'{prefix}_ddc_trigger'] - if f'{prefix}_ddc_source0' in scanargs: - d['ddc_source0'] = scanargs[f'{prefix}_ddc_source0'] - if f'{prefix}_ddc_source1' in scanargs: - d['ddc_source1'] = scanargs[f'{prefix}_ddc_source1'] - if 'num_points_total' in scanargs: - d['num_points'] = scanargs['num_points_total'] - if 'ddc_trigger' in scanargs: - d['ddc_trigger'] = scanargs['ddc_trigger'] - if 'ddc_source0' in scanargs: - d['ddc_source0'] = scanargs['ddc_source0'] - if 'ddc_source1' in scanargs: - d['ddc_source1'] = scanargs['ddc_source1'] + scanargs = scanparam['kwargs'] + for prefix in ["", alias + "_"]: + if f'{prefix}_num_points_total' in scanargs: + d['num_points'] = scanargs[f'{prefix}_num_points_total'] + if f'{prefix}_ddc_trigger' in scanargs: + d['ddc_trigger'] = scanargs[f'{prefix}_ddc_trigger'] + if f'{prefix}_ddc_source0' in scanargs: + d['ddc_source0'] = scanargs[f'{prefix}_ddc_source0'] + if f'{prefix}_ddc_source1' in scanargs: + d['ddc_source1'] = scanargs[f'{prefix}_ddc_source1'] + if 'num_points_total' in scanargs: + d['num_points'] = scanargs['num_points_total'] + if 'ddc_trigger' in scanargs: + d['ddc_trigger'] = scanargs['ddc_trigger'] + if 'ddc_source0' in scanargs: + d['ddc_source0'] = scanargs['ddc_source0'] + if 'ddc_source1' in scanargs: + d['ddc_source1'] = scanargs['ddc_source1'] # Perform bluesky-style configuration if len(d)>0: diff --git a/tomcat_bec/devices/gigafrost/gigafrostcamera.py b/tomcat_bec/devices/gigafrost/gigafrostcamera.py index be9c18f..ac85729 100644 --- a/tomcat_bec/devices/gigafrost/gigafrostcamera.py +++ b/tomcat_bec/devices/gigafrost/gigafrostcamera.py @@ -161,33 +161,33 @@ class GigaFrostCameraMixin(CustomDetectorMixin): "IOC might be in unknown configuration." ) + self.parent._update_scaninfo() + # Fish out our configuration from scaninfo (via explicit or generic addressing) - prefix = self.parent.parent.name if self.parent.parent is not None else self.parent.name + scanparam = self.parent.scaninfo.scan_msg.info + alias = self.parent.parent.name if self.parent.parent is not None else self.parent.name + logger.warning(f"[{alias}] Scan parameters:\n{scanparam}") d = {} - if hasattr(self.parent.scaninfo, prefix + '_image_width'): - val = int(getattr(self.parent.scaninfo, prefix + '_image_width')) - d['image_width'] = val - if hasattr(self.parent.scaninfo, prefix + '_image_height'): - val = int(getattr(self.parent.scaninfo, prefix + '_image_height')) - d['image_height'] = val - if hasattr(self.parent.scaninfo, prefix + '_num_burst'): - val = int(getattr(self.parent.scaninfo, prefix + '_num_burst')) - d['num_burst'] = val - if hasattr(self.parent.scaninfo, prefix + '_exposure_time'): - val = float(getattr(self.parent.scaninfo, prefix + '_exposure_time')) - d['exposure_time'] = val - if hasattr(self.parent.scaninfo, prefix + '_exposure_period'): - val = float(getattr(self.parent.scaninfo, prefix + '_exposure_period')) - d['exposure_period'] = val - if hasattr(self.parent.scaninfo, prefix + '_correction_mode'): - val = int(getattr(self.parent.scaninfo, prefix + '_correction_mode')) - d['correction_mode'] = val - if hasattr(self.parent.scaninfo, prefix + '_scanid'): - val = int(getattr(self.parent.scaninfo, prefix + '_scanid')) - d['scanid'] = val - if hasattr(self.parent.scaninfo, prefix + '_trigger_mode'): - val = int(getattr(self.parent.scaninfo, prefix + '_trigger_mode')) - d['trigger_mode'] = val + if 'kwargs' in scanparam: + scanargs = scanparam['kwargs'] + for prefix in ["", alias + "_"]: + if f'{prefix}image_width' in scanargs: + 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}correction_mode' in scanargs: + d['correction_mode'] = scanargs[f'{prefix}correction_mode'] + if f'{prefix}scanid' in scanargs: + d['scanid'] = scanargs[f'{prefix}scanid'] + if f'{prefix}trigger_mode' in scanargs: + d['trigger_mode'] = scanargs[f'{prefix}trigger_mode'] + # Perform bluesky-style configuration if len(d)>0: logger.warning(f"[{self.parent.name}] Configuring with:\n{d}") diff --git a/tomcat_bec/devices/gigafrost/stddaq_client.py b/tomcat_bec/devices/gigafrost/stddaq_client.py index 5d3eae7..1943bcc 100644 --- a/tomcat_bec/devices/gigafrost/stddaq_client.py +++ b/tomcat_bec/devices/gigafrost/stddaq_client.py @@ -34,36 +34,23 @@ class StdDaqMixin(CustomDeviceMixin): NOTE: Tomcat might use multiple cameras with their own separate DAQ instances. """ - logger.warning(self.parent.scaninfo.__dict__.keys()) - # Fish out our configuration from scaninfo (via explicit or generic addressing) - scaninfo = self.parent.scaninfo - prefix = self.parent.parent.name if self.parent.parent is not None else self.parent.name + scanparam = self.parent.scaninfo.scan_msg.info + alias = self.parent.parent.name if self.parent.parent is not None else self.parent.name + logger.warning(f"[{alias}] Scan parameters:\n{scanparam}") d = {} - if hasattr(self.parent.scaninfo, prefix + '_image_width'): - val = int(getattr(self.parent.scaninfo, prefix + '_image_width')) - d['image_width'] = val - if hasattr(self.parent.scaninfo, prefix + '_image_height'): - val = int(getattr(self.parent.scaninfo, prefix + '_image_height')) - d['image_height'] = val - if hasattr(self.parent.scaninfo, 'image_width'): - val = int(getattr(self.parent.scaninfo, prefix + 'image_width')) - d['image_width'] = val - if hasattr(self.parent.scaninfo, 'image_height'): - val = int(getattr(self.parent.scaninfo, 'image_height')) - d['image_height'] = val - if hasattr(self.parent.scaninfo, prefix + '_num_images'): - val = int(getattr(self.parent.scaninfo, prefix + '_num_images')) - d['num_images'] = val - if hasattr(self.parent.scaninfo, prefix + '_file_path'): - val = str(getattr(self.parent.scaninfo, prefix + '_file_path')) - d['file_path'] = val - if hasattr(self.parent.scaninfo, 'num_images'): - val = int(getattr(self.parent.scaninfo, 'num_images')) - d['num_images'] = val - if hasattr(self.parent.scaninfo, 'file_path'): - val = str(getattr(self.parent.scaninfo, 'file_path')) - d['file_path'] = val + if 'kwargs' in scanparam: + scanargs = scanparam['kwargs'] + for prefix in ["", alias + "_"]: + if f'{prefix}image_width' in scanargs: + 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_points_total' in scanargs: + d['num_points_total'] = scanargs[f'{prefix}num_points_total'] + if f'{prefix}file_path' in scanargs: + d['file_path'] = scanargs[f'{prefix}file_path'] + # Perform bluesky-style configuration if len(d)>0: logger.warning(f"[{self.parent.name}] Configuring with:\n{d}") @@ -267,7 +254,7 @@ class StdDaqClient(PSIDeviceBase): Parameters as 'd' dictionary ---------------------------- - num_images : int, optional + num_points_total : int, optional 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) @@ -301,7 +288,7 @@ class StdDaqClient(PSIDeviceBase): self.cfg_pixel_width.set(d['image_width']).wait() if 'image_height' in d: self.cfg_pixel_height.set(d['image_height']).wait() - if 'num_images' in d: + if 'num_points_total' in d: self.num_images.set(d['num_images']).wait() if 'file_path' in d: self.file_path.set(d['file_path']).wait()