From 41d574253ed73a9fd10b5e6965a0a6630d8d064c Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Tue, 5 Nov 2024 13:37:14 +0100 Subject: [PATCH] added cameras plus some fixes --- .../bec_ipython_client/plugins/omny/omny.py | 23 ++++ .../plugins/omny/omny_alignment_mixin.py | 2 +- .../plugins/omny/omny_optics_mixin.py | 2 +- .../plugins/omny/omny_rt.py | 2 + .../omny/omny_sample_transfer_mixin.py | 111 ++++++++++++++++-- csaxs_bec/device_configs/omny_config.yaml | 60 +++++----- csaxs_bec/devices/omny/galil/galil_ophyd.py | 4 +- 7 files changed, 161 insertions(+), 43 deletions(-) mode change 100644 => 100755 csaxs_bec/device_configs/omny_config.yaml diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index c1a62f6..0deb207 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -19,6 +19,9 @@ from csaxs_bec.bec_ipython_client.plugins.omny.omny_sample_transfer_mixin import from csaxs_bec.bec_ipython_client.plugins.omny.omny_rt import OMNY_rt_client from csaxs_bec.bec_ipython_client.plugins.omny.x_ray_eye_align import XrayEyeAlign +from bec_widgets.cli.client import BECDockArea as _BECDockArea + + logger = bec_logger.logger if builtins.__dict__.get("bec") is not None: @@ -543,6 +546,26 @@ class OMNY( self.OMNYTools = OMNYTools(self.client) OMNY_rt_client.__init__(self) self.align = XrayEyeAlign(self.client, self) + self.gui = getattr(client, 'gui',None) + self.fig = None + + + def start_gui(self): + if self.gui is None: + self.gui = _BECDockArea() + self.gui.show() + + def stop_gui(self): + if self.gui is not None: + self.fig = None + self.gui.close() + self.gui = None + + def add_image_dock(self): + self.fig = self.gui.add_dock(name="cam1").add_widget("BECImageWidget") + self.fig.image("cam200") + self.fig.set_rotation(3) + #self.gui.remove_dock(dock_name="Waveform Dock") def start_x_ray_eye_alignment(self): if self.OMNYTools.yesno( diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_alignment_mixin.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_alignment_mixin.py index f40c0a5..ae6e1b2 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_alignment_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_alignment_mixin.py @@ -192,7 +192,7 @@ class OMNYAlignmentMixin: print( f"Loading default mirror correction from file {correction_file} containing {int_num_elements} elements." ) - print(corr_pos) + #print(corr_pos) return corr_pos, corr_angle def read_additional_correction_x(self, correction_file: str): diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_optics_mixin.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_optics_mixin.py index 6ca6565..f5c3460 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_optics_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_optics_mixin.py @@ -306,7 +306,7 @@ class OMNYOpticsMixin: - def ffzp_info(self, mokev_val=-1, ofzpz_val=-1): + def ofzp_info(self, mokev_val=-1, ofzpz_val=-1): print(f"{ofzpz_val}") if mokev_val == -1: diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_rt.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_rt.py index f542c7c..61502c0 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_rt.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_rt.py @@ -142,6 +142,8 @@ class OMNY_rt_client: self.mirror_amplitutde_increase = 0 dev.rtx.controller.show_signal_strength_interferometer() + def show_signal_strength_interferometer(self): + dev.rtx.controller.show_signal_strength_interferometer() def omny_interferometer_align_incoupling_angle(self): dev.rtx.controller.omny_interferometer_align_incoupling_angle() diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py index 188e63a..7d1ed05 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py @@ -33,6 +33,11 @@ class OMNYSampleTransferMixin: self.shuttle_was_aligned[5]=False self.shuttle_was_aligned[6]=False + self.fig200 = None + self.fig201 = None + self.fig202 = None + self.fig203 = None + @staticmethod @@ -94,10 +99,98 @@ class OMNYSampleTransferMixin: raise OMNYTransferError("The shuttle did not close.") def _omnycam_parking(self): - pass + if self.fig200 is None: + self._omnycam_clear() + self.fig200 = self.gui.add_dock(name="omnycam200").add_widget("BECImageWidget") + if self._omnycam_check_device_exists(dev.cam200): + self.fig200.image("cam200") + time.sleep(0.3) + try: + self.fig200.set_rotation(deg_90=3) + except: + time.sleep(0.2) + self.fig200.set_rotation(deg_90=3) + self.fig200.lock_aspect_ratio(True) + else: + print("Cannot open cam200. Device does not exist.") + self.fig203 = self.gui.add_dock(name="omnycam203").add_widget("BECImageWidget") + if self._omnycam_check_device_exists(dev.cam203): + self.fig203.image("cam203") + time.sleep(0.3) + try: + self.fig203.set_rotation(deg_90=3) + except: + time.sleep(0.2) + self.fig203.set_rotation(deg_90=3) + self.fig203.lock_aspect_ratio(True) + else: + print("Cannot open cam203. Device does not exist.") + try: + self.gui.remove_dock(name="default_figure") + except: + pass - def _omnycam_samples(self): - pass + def _omnycam_clear(self): + try: + self.gui.remove_dock(name="omnycam200") + except: + pass + try: + self.gui.remove_dock(name="omnycam201") + except: + pass + try: + self.gui.remove_dock(name="omnycam202") + except: + pass + try: + self.gui.remove_dock(name="omnycam203") + except: + pass + self.fig200 = None + self.fig201 = None + self.fig202 = None + self.fig203 = None + + def _omnycam_check_device_exists(self,device): + try: + device + except: + return False + else: + return True + + def _omnycam_samplestage(self): + if self.fig201 is None: + self._omnycam_clear() + self.fig201 = self.gui.add_dock(name="omnycam201").add_widget("BECImageWidget") + if self._omnycam_check_device_exists(dev.cam201): + self.fig201.image("cam201") + time.sleep(0.3) + try: + self.fig201.set_rotation(deg_90=3) + except: + time.sleep(0.2) + self.fig201.set_rotation(deg_90=3) + self.fig201.lock_aspect_ratio(True) + else: + print("Cannot open cam201. Device does not exist.") + if self._omnycam_check_device_exists(dev.cam202): + self.fig202 = self.gui.add_dock(name="omnycam202").add_widget("BECImageWidget") + self.fig202.image("cam202") + time.sleep(0.3) + try: + self.fig202.set_rotation(deg_90=3) + except: + time.sleep(0.2) + self.fig202.set_rotation(deg_90=3) + self.fig202.lock_aspect_ratio(True) + else: + print("Cannot open cam202. Device does not exist.") + try: + self.gui.remove_dock(name="default_figure") + except: + pass def _otransfer_shuttle_align(self): _active_shuttle_pos = self._oparkz_slot_check() @@ -683,7 +776,7 @@ class OMNYSampleTransferMixin: # global _ogalil_encoder_steps_per_mm if pin_position==0: - self._omnycam_samples() + self._omnycam_samplestage() else: self._omnycam_parking() @@ -772,7 +865,7 @@ class OMNYSampleTransferMixin: if pin_position==0 or pin_position==100: # oeye_cam_in - self._omnycam_samples() + self._omnycam_samplestage() # if (_rt_status_feedback() == 0) { # print("May the feedback be disabled? Y/n?") # if(!yesno(1)) @@ -1315,9 +1408,9 @@ class OMNYSampleTransferMixin: def otransfer_help(self): - print("omny.transfer.otransfer_park_slot(slot) drive the parking station to transfer from with the gripper") - print("omny.transfer.otransfer_park_loadlock_slot(slot) drive the parking station to transfer from with the loadlock") - print("omny.transfer.otransfer_get_sample(position) pick with the gripper from ") - print("omny.transfer.otransfer_put_sample(position) put with the gripper to ") + print("omny.otransfer_park_slot(slot) drive the parking station to transfer from with the gripper") + print("omny.otransfer_park_loadlock_slot(slot) drive the parking station to transfer from with the loadlock") + print("omny.otransfer_get_sample(position) pick with the gripper from ") + print("omny.otransfer_put_sample(position) put with the gripper to ") print("To modify the storage information see dev.omny_samples.help()") diff --git a/csaxs_bec/device_configs/omny_config.yaml b/csaxs_bec/device_configs/omny_config.yaml old mode 100644 new mode 100755 index 340894e..0d6752f --- a/csaxs_bec/device_configs/omny_config.yaml +++ b/csaxs_bec/device_configs/omny_config.yaml @@ -1,6 +1,6 @@ -############################################################ -#################### IDS Camera ###################### -############################################################ +# ############################################################ +# #################### IDS Camera ###################### +# ############################################################ cam200: description: Camera200 deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera @@ -27,35 +27,35 @@ cam201: readOnly: false readoutPriority: async -# cam202: -# description: Camera202 -# deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera -# deviceConfig: -# camera_ID: 202 -# bits_per_pixel: 24 -# channels: 3 -# m_n_colormode: 1 -# enabled: true -# onFailure: buffer -# readOnly: false -# readoutPriority: async +cam202: + description: Camera202 + deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera + deviceConfig: + camera_ID: 202 + bits_per_pixel: 24 + channels: 3 + m_n_colormode: 1 + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: async -# cam203: -# description: Camera203 -# deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera -# deviceConfig: -# camera_ID: 203 -# bits_per_pixel: 24 -# channels: 3 -# m_n_colormode: 1 -# enabled: true -# onFailure: buffer -# readOnly: false -# readoutPriority: async +cam203: + description: Camera203 + deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera + deviceConfig: + camera_ID: 203 + bits_per_pixel: 24 + channels: 3 + m_n_colormode: 1 + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: async -# ############################################################ -# #################### flOMNI RT motors ###################### -# ############################################################ +############################################################ +#################### OMNY RT motors ######################## +############################################################ rtx: description: OMNY rt diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index f658401..62317c4 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -187,7 +187,7 @@ class GalilController(Controller): while self.is_axis_moving(None, axis_Id_numeric): time.sleep(0.01) if verbose: - self.get_device_manager().connector.send_client_info(f"Current microstep position {self._omny_get_microstep_position(axis_Id)}", scope="drive axis to limit", show_asap=True) + self.get_device_manager().connector.send_client_info(f"Current microstep position {self._omny_get_microstep_position(axis_Id):.0f}", scope="drive axis to limit", show_asap=True) time.sleep(0.5) # check if we actually hit the limit @@ -224,7 +224,7 @@ class GalilController(Controller): while self.is_axis_moving(None, axis_Id_numeric): time.sleep(0.1) if verbose: - self.get_device_manager().connector.send_client_info(f"Current microstep position {self._omny_get_microstep_position(axis_Id)} reference is before {self._omny_get_reference_limit(axis_Id)}", scope="find axis reference", show_asap=True) + self.get_device_manager().connector.send_client_info(f"Current microstep position {self._omny_get_microstep_position(axis_Id):.0f} reference is before {self._omny_get_reference_limit(axis_Id)}", scope="find axis reference", show_asap=True) time.sleep(0.5) if not self.axis_is_referenced(axis_Id_numeric):