From 347c63d500a783979fbc8978740a2716613d3e3a Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Wed, 17 Jul 2024 08:48:58 +0200 Subject: [PATCH] fixes after first load in bec --- .../bec_ipython_client/plugins/omny/omny.py | 6 +- .../plugins/omny/omny_alignment_mixin.py | 3 + .../plugins/omny/omny_optics_mixin.py | 2 +- .../omny/omny_sample_transfer_mixin.py | 58 +++++++++++-------- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index e25854c..c09c397 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -13,7 +13,7 @@ from typeguard import typechecked from csaxs_bec.bec_ipython_client.plugins.cSAXS import cSAXSBeamlineChecks from csaxs_bec.bec_ipython_client.plugins.omny.omny_optics_mixin import OMNYOpticsMixin -from csaxs_bec.bec_ipython_client.plugins.omny.omny_alignment import OMNYAlignmentMixin +from csaxs_bec.bec_ipython_client.plugins.omny.omny_alignment_mixin import OMNYAlignmentMixin from csaxs_bec.bec_ipython_client.plugins.omny.omny_sample_transfer_mixin import OMNYSampleTransferMixin #from csaxs_bec.bec_ipython_client.plugins.flomni.x_ray_eye_align import XrayEyeAlign @@ -1384,5 +1384,5 @@ if __name__ == "__main__": builtins.__dict__["dev"] = dev builtins.__dict__["bec"] = bec builtins.__dict__["umv"] = umv - flomni = Flomni(bec) - flomni.start_x_ray_eye_alignment() + omny = OMNY(bec) + omny.start_x_ray_eye_alignment() 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 f49795a..9e851f7 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 @@ -1,10 +1,13 @@ import time import numpy as np +import os from rich import box from rich.console import Console from rich.table import Table +from typeguard import typechecked + class OMNYAlignmentError(Exception): pass 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 55a409c..5a94e9c 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 @@ -75,7 +75,7 @@ class OMNYOpticsMixin: omny_oeye_currentx = dev.oeyex.get().readback omny_oeye_currenty = dev.oeyey.get().readback - if np.fabs(omny_oeye_currentx - omny_oeye_xray_inx)<0.1 and np.fabs(omny_oeye_currenty - omny_oeye_xray_iny)<0.1) + if np.fabs(omny_oeye_currentx - omny_oeye_xray_inx)<0.1 and np.fabs(omny_oeye_currenty - omny_oeye_xray_iny)<0.1: return True else: return False 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 047c97b..9369bdb 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 @@ -1,13 +1,23 @@ import time +import builtins + import numpy as np from rich import box from rich.console import Console from rich.table import Table +from typeguard import typechecked + from csaxs_bec.bec_ipython_client.plugins.cSAXS import epics_get, epics_put, fshopen, fshclose +if builtins.__dict__.get("bec") is not None: + bec = builtins.__dict__.get("bec") + dev = builtins.__dict__.get("dev") + umv = builtins.__dict__.get("umv") + umvr = builtins.__dict__.get("umvr") + class OMNYTransferError(Exception): pass @@ -204,7 +214,7 @@ class OMNYSampleTransferMixin: if not self._otransfer_is_shuttle_closed(): raise OMNYTransferError("Open lid function called, but lid is not closed, i.e. in an undefined state") - self._otransfer_gripper_to_park_z(): + self._otransfer_gripper_to_park_z() #ensure safety threads are running dev.oshuttleopen.controller.socket_put_confirmed("XQ#SAFETY") @@ -350,28 +360,28 @@ class OMNYSampleTransferMixin: #coming from an OSA or FZP transfer. Ensure shield open if dev.otransz.get().readback < -350: - #if xray eye is in, move it out - if dev.oeyez.get().readback<-5: - self.oeye_cam_in() + #if xray eye is in, move it out + if dev.oeyez.get().readback<-5: + self.oeye_cam_in() - #is executed in shield_st_open - _otransfer_gripper_up - self._oshield_ST_open() - umv(dev.otransz, 0) - #the oosa has in principle to be out because of shield open above - #if that is the case, then we do simultaneous shield and trans movement - if(A[oosaz]<0.1): - umv(dev.otransx, -350, dev.oshield, 15.5) - #if the gripper is empty, then we can already move the xeye to the xray position - #simultaneous motion to reduce time. otherwise later manual eye in - if not dev.omny_samples.is_sample_in_gripper(): - #todo the oeyey mv may not be accessible - _omny_oeye_xray_inx = self._get_user_param_safe(dev.oeyex, "xray_in") - _omny_oeye_xray_iny = self._get_user_param_safe(dev.oeyey, "xray_in") - self._oeyey_mv(_omny_oeye_xray_iny) - umv(dev.otransx, -100, dev.oeyex, _omny_oeye_xray_inx, dev.oeyez, -2) + #is executed in shield_st_open - _otransfer_gripper_up + self._oshield_ST_open() + umv(dev.otransz, 0) + #the oosa has in principle to be out because of shield open above + #if that is the case, then we do simultaneous shield and trans movement + oosaz_current = dev.oosaz.get().readback + if oosaz_current<0.1: + umv(dev.otransx, -350, dev.oshield, 15.5) + #if the gripper is empty, then we can already move the xeye to the xray position + #simultaneous motion to reduce time. otherwise later manual eye in + if not dev.omny_samples.is_sample_in_gripper(): + #todo the oeyey mv may not be accessible + _omny_oeye_xray_inx = self._get_user_param_safe(dev.oeyex, "xray_in") + _omny_oeye_xray_iny = self._get_user_param_safe(dev.oeyey, "xray_in") + self._oeyey_mv(_omny_oeye_xray_iny) + umv(dev.otransx, -100, dev.oeyex, _omny_oeye_xray_inx, dev.oeyez, -2) else: umv(dev.otransx, -100) - else: self._oshield_ST_close() umv(dev.otransx, -100) @@ -594,13 +604,13 @@ class OMNYSampleTransferMixin: #FZP - if(pin_position==100): + if pin_position==100: self._otransfer_gripper_to_park_z() self._otransfer_stage_to_FZP() _otransy_approach_height=-7 #OSA - if(pin_position==101) + if pin_position==101: raise OMNYTransferError("OSA Transfer disabled. Needs commissioning.") # self._otransfer_gripper_to_park_z # self._otransfer_stage_to_OSA @@ -639,7 +649,7 @@ class OMNYSampleTransferMixin: def otransfer_put_sample(self, pin_position:int): self._otransfer_check_sensor_connected() - if not self._otransfer_check_free_slot_available_at_position(pin_position,0) + if not self._otransfer_check_free_slot_available_at_position(pin_position,0): raise OMNYTransferError(f"position {position} is not free") # global _ogalil_encoder_steps_per_mm @@ -727,7 +737,7 @@ class OMNYSampleTransferMixin: # exit; #} # rt_feedback_disable - else + else: self._omnycam_parking()