diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index 73b9d7c..c47609f 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -426,6 +426,16 @@ class OMNYInitStagesMixin: else: return False +class OMNYSampleTransferMixin: + def _otransfer_gripper_safe_xray_in_operation(self): +#if(!_ogalil_all_axes_on_all_controllers_are_referenced()) +#{ +# printf("Not all axes are referenced. Aborting.\n") +# exit +#} +#_otransfer_gripper_to_park_z +#}' + class FlomniSampleTransferMixin: @@ -1291,6 +1301,17 @@ class OMNY( self.special_angles = [] self.special_angle_repeats = 1 + @property + def near_field(self): + val = self.client.get_global_var("near_field") + if val is None: + return False + return val + + @near_field.setter + def near_field(self, val: bool): + self.client.set_global_var("near_field", val) + @property def tomo_shellstep(self): val = self.client.get_global_var("tomo_shellstep") 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 f9d68bf..55a409c 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 @@ -81,131 +81,125 @@ class OMNYOpticsMixin: return False def oeye_xray_in(self): - self._otransfer_gripper_safe_xray_in_operation() -if(!_oshield_is_ST_closed()) -{ - printf("The shield of the sample stage is not closed. Aborting.\n") - exit -} + if self._oeye_xray_is_in(): + pass + else: + #todo + # self._otransfer_gripper_safe_xray_in_operation() + #if(!_oshield_is_ST_closed()) + #{ + # printf("The shield of the sample stage is not closed. Aborting.\n") + # exit + #} + omny_oeye_xray_inx = self._get_user_param_safe("oeyex", "xray_in") + omny_oeye_xray_iny = self._get_user_param_safe("oeyey", "xray_in") + omny_oeye_xray_inz = self._get_user_param_safe("oeyez", "xray_in") -_oeyey_mv _omny_oeye_xray_iny -if (fabs(A[oeyey]-_omny_oeye_xray_iny)>0.1) -{ - printf("The oeye did not move up. Aborting.\n") - exit -} -umv oeyex _omny_oeye_xray_inx oeyez -2 -#initial position for the vis light microscope -#do not open the shield when the microscope is at the vis mic position -#found eoeyx -45.13, z -84.9, y 0.64 -#for a samy position of 2.8 with delta off -#the osa position should be in z around 7.4. in x it seems better -#around -0.6, where potentially xrays dont pass anymore -# -}' + self._oeyey_mv(omny_oeye_xray_iny) + omny_oeye_currenty = dev.oeyey.get().readback + if np.fabs(omny_oeye_currenty-omny_oeye_xray_iny)>0.1: + raise OMNYError("The oeye did not move up.\n") + umv(dev.oeyex, omny_oeye_xray_inx, dev.oeyez, omny_oeye_xray_inz) + + #some notes for the vis microscope: + #initial position for the vis light microscope + #do not open the shield when the microscope is at the vis mic position + #found eoeyx -45.13, z -84.9, y 0.64 + #for a samy position of 2.8 with delta off + #the osa position should be in z around 7.4. in x it seems better + #around -0.6, where potentially xrays dont pass anymore + # -def _oosa_check_y '{ -if(fabs(A[oosay]-0.9)>0.05) - umv oosay 0.9 -if(fabs(A[oosay]-0.9)>0.1) -{ - printf("oosay is not around 0.9. Aborting.") - exit -} -}' + def _oosa_check_y(self): + omny_oosa_currenty = dev.oosay.get().readback + if np.fabs(omny_oosa_currenty-0.9)>0.05: + umv(dev.oosay, 0.9) + omny_oosa_currenty = dev.oosay.get().readback + if np.fabs(omny_oosa_currenty-0.9)>0.05: + raise OMNYError("oosay is not around 0.9. Aborting.") -def _oosa_to_move_corridor '{ -_oosa_check_y -set_lm oosax -3 3.7 #risk collision with shield - umv oosax -2 -if(fabs(A[oosax]+2)>0.1) -{ - printf("oosax did not reach target position. Not moving in z.\n") - exit -} -}' + def _oosa_to_move_corridor(self): + self._oosa_check_y() + dev.oosax.limits = [-3, 3.7] #risk collision with shield + umv(dev.oosax, -2) + dev.oosax.read(cached=False) + omny_oosa_currentx = dev.oosax.get().readback + if np.fabs(omny_oosa_currentx+2)>0.1: + raise OMNYError("oosax did not reach target position. Not moving in z.\n") -def oosa_in '{ -_omnycam_samplestage -_oosa_check_y -if(A[oshield]<15) - _oshield_ST_close -global near_field -if(near_field==0){ - if (A[oosaz]<6.4) - _oosa_to_move_corridor - set_lm oosaz 6.4 6.6 - umv oosaz 6.5 - umv oosax 3.0270-0.005 - umv oosay 0.4122 + def oosa_in(self): + #todo _omnycam_samplestage + self._oosa_check_y() + dev.oshield.read(cached=False) + omny_oshield_current = dev.oshield.get().readback + if omny_oshield_current<15: + #todo _oshield_ST_close + print("todo") + if self.near_field==False: + dev.oosaz.read(cached=False) + omny_oosa_currentz = dev.oosaz.get().readback + if omny_oosa_currentz<6.4: + self._oosa_to_move_corridor() + dev.oosaz.limits = [6.4, 6.6] + umv(dev.oosaz, 6.5) + umv(dev.oosax, 3.022) + umv(oosay, 0.4122) + #### For the 30 nm FZP 220 um we use this part + # umv oosaz 6.5 + # umv oosax 3.2453 + # umv oosay 0.386015 - #### For the 30 nm FZP 220 um we use this part -# umv oosaz 6.5 -# umv oosax 3.2453 -# umv oosay 0.386015 + if self.near_field==True: + dev.oosaz.read(cached=False) + omny_oosa_currentz = dev.oosaz.get().readback + if omny_oosa_currentz>0: + self._oosa_to_move_corridor() + dev.oosaz.limits = [-0.4, -0.6] + umv(dev.oosaz, -0.4452) + umv(dev.oosax, 3.2124-0.008) + omny_osamy_current = dev.osamy.get().readback + if omny_osamy_current<3.25: + umv(dev.oosay, 0.5330-0.002) + else: + raise OMNYError("Failed to move oosa in. osamy position is too large.") + #todo + # _omny_interferometer_align_tracking + # rt_feedback_enable + def oosa_out(self): + #todo: _omnycam_samplestage + self._oosa_check_y() + dev.oshield.read(cached=False) + omny_oshield_current = dev.oshield.get().readback + if omny_oshield_current<15: + #todo: self._oshield_ST_close() + print("todo") + omny_oosaz_current = dev.oosaz.get().readback + if self.near_field==False: + if omny_oosaz_current<6.4: + self._oosa_to_move_corridor() + dev.oosaz.limits = [6.4, 6.6] + umv(dev.oosaz, 6.5) + umv(dev.oosax, -2) + if self.near_field==True: + if omny_oosaz_current>0: + self._oosa_to_move_corridor() + dev.oosaz.limits = [-0.4, -0.6] + umv(dev.oosaz, -0.45) + umv(dev.oosax, -2) + #todo _omny_interferometer_align_tracking - - -} -if(near_field==1){ - if (A[oosaz]>0) - _oosa_to_move_corridor - set_lm oosaz -0.4 -0.6 - umv oosaz -0.4452 - umv oosax 3.2124-0.008 - if (A[osamy]<3.25) - { - umv oosay 0.5330-0.002 - } - else - { - printf("\n\nFailed to move in oosa. osamy is too large.\n\n\n") - exit - } -} -_omny_interferometer_align_tracking -rt_feedback_enable - -}' - -def oosa_out '{ -_omnycam_samplestage -_oosa_check_y -if(A[oshield]<15) - _oshield_ST_close -global near_field -if(near_field==0){ - if (A[oosaz]<6.4) - _oosa_to_move_corridor - set_lm oosaz 6.4 6.6 - umv oosaz 6.5 - umv oosax -2 -} -if(near_field==1){ - if (A[oosaz]>0) - _oosa_to_move_corridor - set_lm oosaz -0.4 -0.6 - umv oosaz -0.45 - umv oosax -2 -} -_omny_interferometer_align_tracking -}' - -def oosa_move_out_of_shield '{ -_omnycam_samplestage -_oosa_check_y -#if (A[oosaz]>0.1) - -_oosa_to_move_corridor -if (fabs(A[osamx])>0.2) - umv osamx 0 -if (A[oosaz] > 0.1) -{ - set_lm oosaz -0.1 0.1 - umv oosaz 0 -} -}' + def oosa_move_out_of_shield(self): + #todo: _omnycam_samplestage + self._oosa_check_y() + self._oosa_to_move_corridor() + omny_osamx_current = dev.osamx.get().readback + if np.fabs(omny_osamx_current)>0.2: + umv(dev.osamx, 0) + omny_oosaz_current = dev.oosaz.get().readback + if omny_oosaz_current > 0.1: + dev.oosaz.limits = [-0.1, 0.1] + umv(dev.oosaz, 0) 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 new file mode 100644 index 0000000..3639517 --- /dev/null +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py @@ -0,0 +1,1865 @@ +import time +import numpy as np + +from rich import box +from rich.console import Console +from rich.table import Table + +class OMNYTransferError(Exception): + pass + +class OMNYSampleTransferMixin: + @staticmethod + def _get_user_param_safe(device, var): + param = dev[device].user_parameter + if not param or param.get(var) is None: + raise ValueError(f"Device {device} has no user parameter definition for {var}.") + return param.get(var) + + +def _otransfer_shuttle_aligner_down '{ +if (!_ogalil_high_limit_set(1,7)) + _ogalil_drive_to_limit(1,7,1) + +if (!_ogalil_high_limit_set(1,7)) + exit +}' + +def _otransfer_wait_aligner_movement() '{ +local returnval + +_ogalil_put(1,"MG_BGH") +returnval=_ogalil_get(1) +return(returnval) + +}' + +def _otransfer_wait_opener_movement() '{ +local returnval + +_ogalil_put(1,"MG_BGG") +returnval=_ogalil_get(1) +return(returnval) + +}' + + +def _otransfer_move_aligner_down_in_case '{ +_ogalil_put_confirmed( 1,"SHH") +searchwrongendswitch=0 +while (searchwrongendswitch<100 && _ogalil_low_limit_set(1,7) == 0) +{ + _ogalil_put_confirmed( 1,"PRH=200") + _ogalil_put_confirmed( 1,"BGH") + while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} + searchwrongendswitch++ + p searchwrongendswitch + if (_ogalil_low_limit_set(1,7)) + { + printf("Aligner is back down.\n") + p searchwrongendswitch + } +} +_ogalil_put_confirmed( 1,"MOH") +}' + + +def _otransfer_shuttle_align '{ +_otransfer_gripper_to_park_z +_otransfer_oparkz_safe_shuttle_operation +_otransfer_shuttle_aligner_down + +global _otransfer_shuttle_was_aligned +if (_otransfer_shuttle_was_aligned==0) { +#make sure shuttle closed +if(!_ogalil_low_limit_set(1,6)) +{ + _ogalil_drive_to_limit(1,6,0) +} +if (!_ogalil_low_limit_set(1,6)) + { + printf("shuttle did not close. exiting.\n") + exit + } +_omnycam_parking +printf("Aligning shuttle\n") +#ensure safety threads are running +_ogalil_put_confirmed(1,"XQ#SAFETY") + +#ensure aligner is in down position +#if (!_ogalil_high_limit_set(1,7)) +#{ +#printf("Strange, the aligner is not in the down position. Moving down.\n") +#_ogalil_drive_to_limit(1,7,1) +#} +#sleep(0.1) + + +################################### +# +# This is a routine for broken hardware +# +# The positive movement moves the aligner down. From the geometry +# of the setup, the negative limit switch will be activated after the +# positive limit switch, even in a positive movement +# We have to use this property because the positive switch is stuck. +################################### + +# ensure we are in negative switch (with aligner down) +if (!_ogalil_low_limit_set(1,7)) +{ + printf("Not in correct start position for alignment. Aborting.\n") + _ogalil_put_confirmed( 1,"MO") + printf("Shall I try to move it to the correct start position? Do this only once!\n") + if(yesno(1)) { + _ogalil_put_confirmed( 1,"SHH") + _ogalil_put_confirmed( 1,"PRH=200") + _ogalil_put_confirmed( 1,"LDH=1") + _ogalil_put_confirmed( 1,"BGH") + sleep(1) + _ogalil_put_confirmed( 1,"MO") + _ogalil_put_confirmed( 1,"LDH=0") + } + else + { + exit + } +} +# disable negative switch +_ogalil_put_confirmed( 1,"LDH=2") + +# move negative direction (ie up) and check out of negative switch +_ogalil_put_confirmed( 1,"SHH") +_ogalil_put_confirmed( 1,"SPH=3000") +_ogalil_put_confirmed( 1,"ACH=60000") +_ogalil_put_confirmed( 1,"DCH=60000") + +_ogalil_put_confirmed( 1,"PRH=-5000") +_ogalil_put_confirmed( 1,"BGH") +while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} + +if (_ogalil_low_limit_set(1,7)) +{ + printf("Aligner did not move or switch error. Aborting.\n") + _ogalil_put_confirmed( 1,"MOH") + exit +} + +# enable negative switch again +# but disable forward switch (is broken) +_ogalil_put_confirmed( 1,"LDH=1") + +# movements for alignment and down again +_ogalil_put_confirmed( 1,"PRH=-19500") +_ogalil_put_confirmed( 1,"BGH") +while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} +sleep(0.5) +_ogalil_put_confirmed( 1,"PRH=3000") +_ogalil_put_confirmed( 1,"BGH") +while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} +sleep(0.5) +_ogalil_put_confirmed( 1,"PRH=-3000") +_ogalil_put_confirmed( 1,"BGH") +while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} +sleep(0.5) +_ogalil_put_confirmed( 1,"PRH=23500") +_ogalil_put_confirmed( 1,"BGH") +while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} +#_ogalil_put_confirmed( 1,"MOH") +sleep(0.2) + +# move down (positive movement) and check for negative (backward motion) switch +local searchwrongendswitch +searchwrongendswitch=0 +#_ogalil_put_confirmed( 1,"SHH") + +while (searchwrongendswitch<10 && _ogalil_low_limit_set(1,7) == 0) +{ + _ogalil_put_confirmed( 1,"PRH=200") + _ogalil_put_confirmed( 1,"BGH") + while(_otransfer_wait_aligner_movement()==1) {sleep(0.2)} + searchwrongendswitch++ + if (_ogalil_low_limit_set(1,7)) + { + printf("Aligner is back down.\n") + #p searchwrongendswitch + } +} +_ogalil_put_confirmed( 1,"MOH") + +_otransfer_shuttle_was_aligned=1 +} +if (!_ogalil_high_limit_set(1,7)) +{ + printf("The shuttle aligner did not move back. Aborting.\n") + exit +} +}' + +def _otransfer_shield_open(pin_position) '{ +if(pin_position>0 && pin_position<7) +{ + if (!_ogalil_high_limit_set(1,6)) + { + + if (!_ogalil_low_limit_set(1,6)) { + printf("Open lid function called, but lid is not closed.\n") + exit + } + + _otransfer_gripper_to_park_z + + #ensure safety threads are running + _ogalil_put_confirmed(1,"XQ#SAFETY") + sleep(0.1) + _ogalil_put_confirmed( 1,"SHG") + _ogalil_put_confirmed( 1,"SPG=30000") + _ogalil_put_confirmed( 1,"ACG=10000") + _ogalil_put_confirmed( 1,"DCG=10000") + _ogalil_put_confirmed( 1,"PRG=17000") + _ogalil_put_confirmed( 1,"BGG") + while(_otransfer_wait_opener_movement()==1) {sleep(0.1)} + _ogalil_put_confirmed( 1,"PRG=37000") + _ogalil_put_confirmed( 1,"BGG") + while(_otransfer_wait_opener_movement()==1) {sleep(0.1)} + _ogalil_put_confirmed( 1,"MOG") + + } + if (!_ogalil_high_limit_set(1,6)) + { + printf("Did not manage to open the lid\n") + exit + } +} + +if(pin_position==0 || pin_position==100) +{ + _oshield_ST_open +} +}' + +def _oshield_is_ST_open() '{ + _ogalil_put(0,"MG @IN[8014]") + return(_ogalil_get(0)) +}' + +def _oshield_is_ST_closed() '{ + local shield_is_open + _ogalil_put(0,"MG @IN[8014]") + shield_is_open = _ogalil_get(0) + if (fabs(A[oshield]-15.5)<0.1 && shield_is_open == 0) + return(1) + else + return(0) +}' + +def _oshield_ST_open '{ + +_otransfer_gripper_up +if(A[oosaz]>0.1 || A[oosax]>-1.5) +{ + oosa_move_out_of_shield +} +if(A[oosaz]>0.1 || !_ogalil_all_axes_on_all_controllers_are_referenced()) +{ + printf("The osa is either not referenced or too close to the sample.\n") + exit +} + +if (!_oshield_is_ST_open()) +{ +umv oshield -11.9 +local _shieldattemptopencounter +_shieldattemptopencounter=0 +while(!_oshield_is_ST_open() && _shieldattemptopencounter<10) +{ + _smar_rt_move_openloop_steps(0,2,-250,4000) + sleep(0.2) + _shieldattemptopencounter++ +} +} + +if(_oshield_is_ST_open()) +{ +} +else +{ + printf("The shield of the sample stage did not open. Aborting.\n") + exit +} +}' + + + +def _otransfer_shield_close(pin_position) '{ + +if(pin_position==100) + umv ofzpz 75 + #otherwise the shield will collide with the long FZP holder. + +_otransfer_gripper_to_park_z + +_omnycam_parking +if((pin_position>0 && pin_position<8)) +{ + #starting from open state + if (_ogalil_high_limit_set(1,6)) + { + #ensure safety threads are running + _ogalil_put_confirmed(1,"XQ#SAFETY") + sleep(0.1) + _ogalil_put_confirmed( 1,"SHG") + _ogalil_put_confirmed( 1,"SPG=15000") + _ogalil_put_confirmed( 1,"ACG=10000") + _ogalil_put_confirmed( 1,"DCG=10000") + _ogalil_put_confirmed( 1,"PRG=-50000") + _ogalil_put_confirmed( 1,"BGG") + while(_otransfer_wait_opener_movement()==1) {sleep(0.1)} + _ogalil_put_confirmed( 1,"MOG") + } + + if (!_ogalil_low_limit_set(1,6)) + { + _ogalil_drive_to_limit(1,6,0) + } + #_ogalil_put_confirmed( 1,"DPG=0") + if (!_ogalil_low_limit_set(1,6)) + { + exit + } +} + +if(pin_position==100) +{ + _oshield_ST_close +} +#there is a sample in the gripper. do not close the shield because the next sample will be mounted... +## && epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==1) +## functionality to be checked and also collision with optical fiber + +if(pin_position==0) +{ + _oshield_ST_close +} + +}' + +def _oshield_ST_close '{ +if(A[oosaz]>0.1) +{ + oosa_move_out_of_shield +} + +if(A[oosaz]>0.1 || !_ogalil_all_axes_on_all_controllers_are_referenced()) +{ + printf("The osa is either not referenced or too close to the sample.\n") + exit +} +_otransfer_gripper_up +umv oshield 15.5 +}' + + + +def _otransfer_gripper_up '{ +read_motors(6) +if(A[otransy] < -1.3) +{ +umv otransy -1.2 +} +if(A[otransy] < -1.3) + { + printf("The gripper did not move up. Aborting.\n") + exit + } +}' + +def _otransfer_oparkz_safe_shuttle_operation '{ +if(_oparkz_slot_check()==10) + exit +}' + + + + + +def _otransfer_gripper_to_park_z '{ + +if(!_otransfer_gripper_querry_status_closed()) { +printf("The gripper appears to be open, while it was expected to be closed.\n May it be closed now? (Y/n) ") +if(yesno(1)) + _ogalil_put_confirmed( 0,"XQ#GRCLOS") + sleep(0.5) +} + +if(!_ogalil_all_axes_on_all_controllers_are_referenced()) + { + printf("Not all axes are referenced. Aborting.\n") + exit + } + +read_motors(6) +if(fabs(A[otransx]-20)<0.1 && A[otransy]>-2 && fabs(A[otransz]+50)<0.1) +{ + printf("Gripper is in parking position\n") +} +else +{ +_otransfer_gripper_up + +#if coming from a position beyond a shuttle in parking station +if (A[otransx] < -2) + _otransfer_ensure_shield_parking_closed + +#coming from an OSA or FZP transfer. Ensure shield open +if (A[otransx] < -350) +{ + #if xray eye is in, move it out + if(A[oeyez]<-5) + { + oeye_cam_in + } + + #is executed in shield_st_open - _otransfer_gripper_up + _oshield_ST_open + umv otransz 0 + #not needed with new transfer stages + #umv otransx -210 + #umv otransz -18 + #umv otransx 20 + #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 otransx -350 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 (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL") == 0) + { + global _omny_oeye_xray_inx + global _omny_oeye_xray_iny + _oeyey_mv _omny_oeye_xray_iny + umv otransx -100 oeyex _omny_oeye_xray_inx oeyez -2 + } + else + { + umv otransx -100 + } + } + else + { + _oshield_ST_close + umv otransx -100 + } +} +#if process was aborted while moving to ST +if (A[otransx] < -105) +{ + #if xray eye is in, move it out + if(A[oeyez]<-5) + { + oeye_cam_in + } + _oshield_ST_close + umv otransz 0 + #not needed with new transfer stage + #umv otransx -210 + #umv otransz -18 + umv otransx -100 +} +umv otransx 20 otransz -50 +} + +}' + +def _otransfer_gripper_safe_xray_in_operation '{ +if(!_ogalil_all_axes_on_all_controllers_are_referenced()) +{ + printf("Not all axes are referenced. Aborting.\n") + exit +} +_otransfer_gripper_to_park_z +}' + +def _otransfer_mode_query() '{ +_ogalil_put(0,"MG mntmod") +return(_ogalil_get(0)) +}' + +def _otransfer_mode_ensurenot '{ +if(_otransfer_mode_query()) +{ + printf("System is in transfer mode. Aborting.") + exit +} +}' + +def otransfer_park_slot '{ +if ($# != 1 ) { +printf("Wrong number of arguments. otransfer_park_slot \n") +exit +} + +_oparkz_slot($1) +}' + +def otransfer_park_loadlock_slot '{ +if ($# != 1 ) { +printf("Wrong number of arguments. otransfer_park_loadlock_slot \n") +exit +} +#if the valve of the loadlock is not closed, ask before movement +if(epics_get("XOMNY-ES1-LL1VG1:POSITION")!="CLOSED") { +printf("Please confirm that the leica transfer is in back position.") + if(!yesno(1)) + exit +} + +_oparkz_leica_slot($1) +}' + +def _oparkz_drive_and_check(targetpos) '{ +if (fabs(A[oparkz]-targetpos)>=0.05) +{ + _otransfer_mode_ensurenot + #make sure shield closed + if (!_ogalil_low_limit_set(1,6)) + { + _ogalil_drive_to_limit(1,6,0) + } + + if (!_ogalil_low_limit_set(1,6)) + { + exit + } + + _otransfer_shuttle_aligner_down + umv oparkz targetpos +} +}' + +def _oparkz_check(targetpos) '{ +if (fabs(A[oparkz]-targetpos)<0.05) + return(1) +else + return(0) +}' + +def _oparkz_slot_check() '{ +local parkingposition +parkingposition=10 +if(_oparkz_check(-0.9)) + parkingposition=6 +if(_oparkz_check(-0.9-29)) + parkingposition=5 +if(_oparkz_check(-0.9-29*2)) + parkingposition=4 +if(_oparkz_check(-0.9-29*3)) + parkingposition=3 +if(_oparkz_check(-0.9-29*3-42-.05)) + parkingposition=2 + +if (parkingposition == 10) { + printf("Oparkz is not in a parking position.\n") + } +else { + printf("Active parkting position: %d\n", parkingposition) + } +return(parkingposition) +}' + + + + +def _oparkz_slot(slot_number) '{ +global _otransfer_shuttle_was_aligned +_otransfer_shuttle_was_aligned=0 +if(slot_number == 2) + _oparkz_drive_and_check(-0.9-29*3-42-.05) +if(slot_number == 3) + _oparkz_drive_and_check(-0.9-29*3) +if(slot_number == 4) + _oparkz_drive_and_check(-0.9-29*2) +if(slot_number == 5) + _oparkz_drive_and_check(-0.9-29) +if(slot_number == 6) + _oparkz_drive_and_check(-0.9) +if(slot_number < 2 || slot_number >6) { + printf("Invalid slot number.\n") + exit +} +}' + +def _oparkz_leica_slot(slot_number) '{ +if(slot_number == 2) + _oparkz_drive_and_check(-6-29*3-42-.05) +if(slot_number == 3) + _oparkz_drive_and_check(-6-29*3) +if(slot_number == 4) + _oparkz_drive_and_check(-6-29*2) +if(slot_number == 5) + _oparkz_drive_and_check(-6-29) +if(slot_number == 6) + _oparkz_drive_and_check(-6) +if(slot_number < 2 || slot_number >6) { + printf("Invalid slot number.\n") + exit +} +}' + +def _oparkz_drive_and_check_leica(targetpos) '{ +if (fabs(A[oparkz]-targetpos)>=0.05) +{ + _otransfer_mode_ensurenot + #make sure shuttle closed + if(!_ogalil_low_limit_set(1,6)) + { + _ogalil_drive_to_limit(1,6,0) + } + if (!_ogalil_low_limit_set(1,6)) + { + printf("shuttle did not close. exiting.\n") + exit + } + _otransfer_shuttle_aligner_down + umv oparkz targetpos +# umv oparkz targetpos +} +}' + +#when mounting a sample, this variable is defined at the release position of the sample +def _otransfer_get_release_position() '{ +local rel_pos +_ogalil_put(0,"MGrelpos") +rel_pos=_ogalil_get(0) +return(rel_pos) +}' + +#when a sample is picked, this variable is defined after touching the top of the pin +def _otransfer_get_toppin_position() '{ +local top_pos +_ogalil_put(0,"MGtoppin") +top_pos=_ogalil_get(0) +return(top_pos) +}' + +def _otransfer_check_release_position '{ + + + +}' + + +def _otransfer_move_gripper_to_pin_pos(pin_position) '{ + +#pos 0 ST / position in separate macro +#pos 1 to 6 at sample shuttle +#pos 7 FZP in shuttle +#pos 10 FZP in fixed holder right +#pos 100 FZP stage / position in separate macro + + +#make sure shuttle closed +if(!_ogalil_low_limit_set(1,6) && pin_position>6) + { + _ogalil_drive_to_limit(1,6,0) + } +if (!_ogalil_low_limit_set(1,6)) + { + printf("shuttle at the parking station did not close. exiting.\n") + exit + } + + + + +global _otransy_approach_height + + +local _otrans_pin_pos_x[] +local _otrans_pin_pos_y[] +local _otrans_pin_pos_z[] + +#when mounting omny nov 17 we had to change the z position +#for the shuttles by 350 more positive for an undetermined reason + + +local zoffsettransfer +local xoffsettransfer + +zoffsettransfer=0 +xoffsettransfer=0 +#at RT was -0.05 at cryo -0.15 + +#old stages +#_otrans_pin_pos_x[1] = -1.78+0.2+xoffsettransfer +#_otrans_pin_pos_y[1] = -24.0 +#_otrans_pin_pos_z[1] = -42.2594+zoffsettransfer +# +#so position x changed from old to new by +0.2432 +#and in z the position changed by +0.6 + + + +_otrans_pin_pos_x[1] = -1.3368+xoffsettransfer +_otrans_pin_pos_y[1] = -25.0 +_otrans_pin_pos_z[1] = -41.6591+zoffsettransfer + +_otrans_pin_pos_x[2] = -1.3368+xoffsettransfer +_otrans_pin_pos_y[2] = -25.0 +_otrans_pin_pos_z[2] = -41.6591-8+zoffsettransfer + +_otrans_pin_pos_x[3] = -1.3368+7+xoffsettransfer +_otrans_pin_pos_y[3] = -25.0 +_otrans_pin_pos_z[3] = -41.6591+zoffsettransfer + +_otrans_pin_pos_x[4] = -1.3368+7+xoffsettransfer +_otrans_pin_pos_y[4] = -25.0 +_otrans_pin_pos_z[4] = -41.6591-8+zoffsettransfer + +_otrans_pin_pos_x[5] = -1.3368+14+xoffsettransfer +_otrans_pin_pos_y[5] = -25.0 +_otrans_pin_pos_z[5] = -41.6591+zoffsettransfer + +_otrans_pin_pos_x[6] = -1.3368+14+xoffsettransfer +_otrans_pin_pos_y[6] = -25.0 +_otrans_pin_pos_z[6] = -41.6591-8+zoffsettransfer + +#FZP Holder +_otrans_pin_pos_x[7] = -1.884+0.2+0.2432 +_otrans_pin_pos_y[7] = -17 +_otrans_pin_pos_z[7] = -49.94+0.6 + +#OSA Holder 1 +_otrans_pin_pos_x[8] = -13.4159+0.2432 +_otrans_pin_pos_y[8] = -16 +_otrans_pin_pos_z[8] = -46.5638+0.6 + +#OSA Holder 2 +_otrans_pin_pos_x[9] = -13.4159+18.5+0.2432 +_otrans_pin_pos_y[9] = -16 +_otrans_pin_pos_z[9] = -46.5638+0.6 + +#fixed FZP Holder right +_otrans_pin_pos_x[10] = -80.9+0.2+0.2432 +_otrans_pin_pos_y[10] = -16.0 +_otrans_pin_pos_z[10] = -46.07-0.21+0.6 + +#fixed FZP Holder left +_otrans_pin_pos_x[11] = -80.9+0.2+0.2432 +_otrans_pin_pos_y[11] = -16.0 +_otrans_pin_pos_z[11] = -46.07+18-0.21+0.6 + +#fixed holders +#offset at room temperature at omny hutch was +0.3 +#then changed to +0.1 at cryo at csaxs oct 2018 +#probably because the gripper is cold +#but no change required 2019 when back at omny hutch so not clear +_otrans_pin_pos_x[12] = -104.67+0.2432 +_otrans_pin_pos_y[12] = -23.9601 +_otrans_pin_pos_z[12] = -49.600 + +_otrans_pin_pos_x[13] = -104.67+0.2432 +_otrans_pin_pos_y[13] = -23.9601 +_otrans_pin_pos_z[13] = -49.600+8 + +_otrans_pin_pos_x[14] = -104.67+0.2432 +_otrans_pin_pos_y[14] = -23.9601 +_otrans_pin_pos_z[14] = -49.600+16 + +#fixed holders +#positions may need 0.3 further pos correction in x +_otrans_pin_pos_x[32] = -104.8718+0.2 +_otrans_pin_pos_y[32] = -24.9601 +_otrans_pin_pos_z[32] = -42.1385-0.05-8-15-0.21+0.6 + +_otrans_pin_pos_x[33] = -104.8718+0.2+0.2432 +_otrans_pin_pos_y[33] = -24.9601 +_otrans_pin_pos_z[33] = -42.1385-0.05-15-0.21+0.6 + +_otrans_pin_pos_x[34] = -104.8718+0.2+0.2432 +_otrans_pin_pos_y[34] = -24.9601 +_otrans_pin_pos_z[34] = -42.1385-0.05+8-15-0.21+0.6 + +if(_otrans_pin_pos_y[pin_position]==0 && pin_position != 100 && pin_position != 0) { +printf("Position %d not a valid pin position\n", pin_position) +exit +} + + +if(pin_position >= 1 && pin_position <= 9) +{ + #if gripper is at ST, this will move the gripper close to the parking + #lot prior opening the shuttle + _otransfer_gripper_to_park_z + _otransfer_shuttle_align + _otransfer_shield_open(pin_position) + _otransy_approach_height=_otrans_pin_pos_y[pin_position] + umv otransx _otrans_pin_pos_x[pin_position] otransz _otrans_pin_pos_z[pin_position] +} + +if(pin_position >= 10 && pin_position <= 14) +{ + if(_oparkz_slot_check()!=6) + { + printf("Sample position ranging from 10 to 14 are only defined for parkz slot 6\n") + exit + } + + _otransfer_gripper_to_park_z + _otransfer_oparkz_safe_shuttle_operation + _otransy_approach_height=_otrans_pin_pos_y[pin_position] + umv otransx _otrans_pin_pos_x[pin_position] + umv otransz _otrans_pin_pos_z[pin_position] +} + +if(pin_position >= 32 && pin_position <= 34) +{ + if(_oparkz_slot_check()!=2) + { + printf("Sample position ranging from 32 to 34 are only defined for parkz slot 2\n") + exit + } + printf("These positions need check before use\n") + exit + _otransfer_gripper_to_park_z + _otransfer_oparkz_safe_shuttle_operation + _otransy_approach_height=_otrans_pin_pos_y[pin_position] + umv otransx _otrans_pin_pos_x[pin_position] + umv otransz _otrans_pin_pos_z[pin_position] +} + +#sample stage +if(pin_position==0) +{ +#oeye_cam_in +_otransfer_gripper_to_park_z +_otransfer_stage_to_ST(pin_position) +_otransy_approach_height=-34 +global xrayeye_alignment_done +xrayeye_alignment_done = 0 + +#change sample name and increase measurement id if sample is at sample stage + +if (epics_get("XOMNY-SAMPLE_DB_omny:0.VAL") == 1) { + local _new_sample_name + _new_sample_name = epics_get("XOMNY-SAMPLE_DB_omny:0.DESC") + # increase the metadatasetID, even if _dataset_id_on_hold==true + global _dataset_id_on_hold + if (_dataset_id_on_hold){ + _meta_dataset_id++ + } + metadata_set("samplename", "string", 1, _new_sample_name) + } +} + +#FZP +if(pin_position==100) +{ +_otransfer_gripper_to_park_z +_otransfer_stage_to_FZP +_otransy_approach_height=-7 +} + +#OSA +if(pin_position==101) +{ +printf("OSA Transfer disabled in macro.\n") +exit +_otransfer_gripper_to_park_z +_otransfer_stage_to_OSA +_otransy_approach_height=-15 +} + +#set the force of the gripper for pushing +#positions with FZP holder +if(pin_position == 7 || pin_position == 10 || pin_position == 11 || pin_position == 100 ) + _ogalil_put_confirmed(0,"pushfrce=1.5") +else + _ogalil_put_confirmed(0,"pushfrce=0.8") + + + +}' + +def _otransfer_ensure_shield_parking_closed '{ + if (!_ogalil_low_limit_set(1,6)){ + printf("The shield of the shuttle at the parking is not closed. Aborting.\n") + exit + } +}' + + +def _otransfer_controller_query_mount_mode() '{ +_ogalil_put(0,"MG mntmod") +return(_ogalil_get(0)) +}' + +def _otransfer_controller_enable_mount_mode '{ +_ogalil_put_confirmed(0,"XQ#MNTMODE") +sleep(0.5) +if (!_otransfer_controller_query_mount_mode()) +{ + printf("System not switched to mount mode. Aborting.\n") + exit +} +}' + +def _otransfer_controller_disable_mount_mode '{ +_ogalil_put_confirmed(0,"XQ#POSMODE") +sleep(0.5) +if (_otransfer_controller_query_mount_mode()) +{ + printf("System is still in mount mode. Aborting.\n") + exit +} +}' + + +def _otransfer_gripper_querry_status_closed() '{ +_ogalil_put_confirmed(0,"XQ#GRSTAT") +sleep(0.05) +_ogalil_put(0,"MG grstat") +return(_ogalil_get(0)) +}' + +def otransfer_put_sample '{ +if ($# != 1 ) { +printf("Wrong number of arguments. otransfer_put_sample \n") +exit +} +_otransfer_gripper_put_sample($1) +}' + +def _otransfer_gripper_put_sample(pin_position) '{ +if(pin_position!=int(pin_position)) +{ + printf("The position has to be an integer number.\n") + exit; +} +_otransfer_check_sensor_connected +if(!_otransfer_check_free_slot_available_at_position(pin_position,0)) + exit; +global _otransy_approach_height +global _ogalil_encoder_steps_per_mm +if(pin_position==0) + _omnycam_samplestage +else + _omnycam_parking +_otransfer_gripper_to_park_z +_otransfer_move_gripper_to_pin_pos(pin_position) +_otransfer_controller_enable_mount_mode +_ogalil_put_confirmed(0,sprintf("mntaprch=%.0f",_otransy_approach_height*_ogalil_encoder_steps_per_mm)) + +printf("Ready. Press Enter to start the mount process now...") +if(yesno(1)) +{ +} + +_ogalil_put_confirmed(0,"XQ#GRPUT") + +printf("The mount process started.\n") + +_otransfer_confirm + +_otransfer_controller_disable_mount_mode + +#update the new sample status in storage +_otransfer_check_free_slot_available_at_position(pin_position,1) + +#this also moves the gripper to parking position +_otransfer_shield_close(pin_position) + + +otransfer_storage +#_omnycam_standby +}' + +def _otransfer_confirm '{ +local confirm +local mntprgs +mntprgs=1 + +while(mntprgs != 0) +{ + sleep(1) + + _ogalil_put(0,"MG confirm") + confirm =_ogalil_get(0) + sleep(0.02) + _ogalil_put(0,"MG mntprgs") + mntprgs =_ogalil_get(0) + sleep(0.02) + if (confirm == 0) + { + #printf("Confirm check - no confirmation needed yet.\n") + } + if (confirm == -1) + { + #we are getting a sample + if (mntprgs == -1) { + printf("TopPin position is %.3f mm\n",_otransfer_get_toppin_position()) + if(_otransfer_get_toppin_position()>-25.4) + printf("THIS IS LARGER THAN THE CURRENT THRESHOLD OF -25.4. ARE YOU SURE THE PIN IS OK AND DOES NOT HAVE A DAMAGE IN THE BOTTOM?\n") + printf("All OK? Please confirm. Y/n?") + } + #we are mounting a sample + if (mntprgs == 1) { + printf("All OK? Please confirm. First confirmation = sample release. Y/n?") + } + if (mntprgs == 0) { + printf("All OK? Please confirm. Y/n?") + } + + if(!yesno(1)) + exit + else + _ogalil_put_confirmed(0,"confirm=1") + } +} +}' + + +def _otransfer_check_sensor_connected '{ +local sensorvoltage +_ogalil_put(0,"MG@AN[8001]") +sensorvoltage = _ogalil_get(0) +local sensorvoltagetarget +sensorvoltagetarget = -2.94 +if(sensorvoltage > sensorvoltagetarget-0.5 && sensorvoltage < sensorvoltagetarget+0.5) +{ + #printf("Sensorvoltage is %.2f V. Sensor seems connected.\n",sensorvoltage) +} +else +{ + printf("Sensorvoltage is %.2f V. This indicates a sensor error.\n",sensorvoltage) + exit +} + +}' + +def otransfer_get_sample '{ +if ($# != 1 ) { +printf("Wrong number of arguments. otransfer_get_sample \n") +exit +} +_otransfer_gripper_get_sample($1) +}' + +def _otransfer_gripper_get_sample(pin_position) '{ +if(pin_position!=int(pin_position)) +{ + printf("The position has to be an integer number.\n") + exit; +} +_omnycam_parking_overview +printf("Please confirm that currently there is no sample in the gripper. It would be dropped! Y/n?") +if(!yesno(1)) + exit; +_otransfer_check_sensor_connected +if(!_otransfer_check_sample_available_at_position(pin_position,0)) + exit; +global _otransy_approach_height +global _ogalil_encoder_steps_per_mm + +if(pin_position==0 || pin_position==100) +{ +# oeye_cam_in + _omnycam_samplestage +# if (_rt_status_feedback() == 0) { +# printf("May the feedback be disabled? Y/n?") +# if(!yesno(1)) +# exit; +#} +# rt_feedback_disable +} +else +{ +_omnycam_parking +} + +_otransfer_move_gripper_to_pin_pos(pin_position) + +_otransfer_controller_enable_mount_mode +_ogalil_put_confirmed(0,sprintf("getaprch=%.0f",_otransy_approach_height*_ogalil_encoder_steps_per_mm)) + +printf("Ready. Press Enter to start the unmount process now...") +if(yesno(1)) +{ +} + +_ogalil_put_confirmed(0,"XQ#GRGET") + +printf("The Unmount process started.\n") + + _otransfer_confirm + + _otransfer_controller_disable_mount_mode + #update database + _otransfer_check_sample_available_at_position(pin_position,1) + + _otransfer_shield_close(pin_position) + + +otransfer_storage +#_omnycam_standby +}' + +def _otransfer_stage_to_ST(pin_position) '{ +_otransfer_gripper_to_park_z + +_otransfer_ensure_shield_parking_closed + +if (A[oshield] < 15) +{ + printf("The sample stage shield is not closed, though it is supposed to be. Aborting.\n") + exit +} + +#if xray eye is in, move it out +if(A[oeyez]<-5) + oeye_cam_in + +#old gripper motor +#check ST position and move gripper to ST +#umv otransz -18 +#umv osamroy -25 osamy 2.7 osamx 0 otransx -213 +#umv otransz 0 +#umv otransx -458.5000 + +#move gripper to ST +#now much more direct because motor transz is shorter +#also incorporate simultaneous cam in movement + +if (_rt_status_feedback() == 0) { + printf("May the feedback be disabled? Y/n?") + if(!yesno(1)) + exit; +} + +rt_feedback_disable + +if(rt_at_omny_hutch==0) + fshon + +if (A[oeyez]<-20) +{ + printf("Eyez is too close to the sample stage for unknown reason. Aborting.\n") + exit +} + +#eye did not move up yet, so we do it here simultaneous to rest in steps +if(A[oeyey] < -50) +{ + _ogalil_put( 2,"axspeed[7]=10000") + umv otransz 0 otransx -100 oeyey -45 oeyez -2 +} +else +{ + umv otransz 0 otransx -100 oeyez -2 +} + +if (fabs(A[oeyez]+2)>0.1) +{ + printf("The oeye is too close in z for transfer. ERROR! Aborting.\n") + exit +} + +#if the osa is out of the shield, we already move the shield with the other stages +if(A[oosaz]<0.1 && A[oosax] < -1.5) + { + if(A[oeyey] < -40) + { + umv osamroy -25 osamy 2.7 osamx 0 otransx -350 oeyex 0 oeyey -15 + } + else + { + umv osamroy -25 osamy 2.7 osamx 0 otransx -350 oeyex 0 + } + umv oshield 0 otransx -458.1545+0.05 oeyey -4.8 + umv oshield -12 otransz -45.6494 + } +else + { + umv osamroy -25 osamy 2.7 osamx 0 otransx -458.1545+0.05 oeyex 0 oeyey -4.8 + } +oeye_cam_in + +_otransfer_shield_open(pin_position) +umv otransz -45.6494 + +}' + +def _otransfer_stage_to_FZP '{ + +printf("This routine needs checking after park pos of gripper and new transfer stages changed.\n") +exit + +printf("Please confirm that the npoint piezo controller is off. y/n.") +if(!yesno(1)) + exit + +_otransfer_gripper_to_park_z + +#put overview camera in +oeye_cam_in +umv otransz 0 otransx -100 oeyez -2 +umv osamroy -25 osamy 2.7 osamx 0 otransx -458.1567 oeyex 0 + +_oshield_ST_open +#this moves the osa out of the shield +#such then it can be moved out of the way +umv oosax 3.2 oosay 0.6 + +set_lm ofzpz -2.5 78 +umv ofzpz 78.6018 ofzpy 7.8604 ofzpx -0.8485 + +umv otransz -68.0006 + +# positions from manual change +#Sat Dec 04 10:52:31 2021 +# otransx otransy otransz ofzpx ofzpy ofzpz +#User +# High 33.0000 1.0000 11.0000 2.0000 3.0000 -2.5000 +# Current -458.1567 -17.8210 -68.0006 -0.8485 7.8604 78.6018 +# Low -459.0000 -41.0000 -70.5000 -2.0000 -1.0000 80.0000 +#Dial +# High 33.0000 1.0000 11.0000 2.0000 3.0000 2.5000 +# Current -458.1567 -17.8210 -68.0006 -0.8485 7.8604 -78.6018 +# Low -459.0000 -41.0000 -70.5000 -2.0000 -1.0000 -80.0000 + + +}' + +def _otransfer_stage_to_OSA '{ + + +printf("This routine needs checking after park pos of gripper changed and new transfer stages.\n") +exit + +if(A[ofzpz]>40) { +printf("The FZP stage is too close in z direction. Please move it to at least 60 mm or less upstream.\n") +exit +} + +_otransfer_gripper_to_park_z + +#put overview camera in +oeye_cam_in + +umv otransz -18 +umv otransx -213 +umv otransz 0 +set_lm otransx -469 33 +umv otransx -467.0612 +_oshield_ST_open +#this moves the osa out of the shield +#such then it can be moved here +umv oosax 3.2 oosay 0.6 oosaz 0 + +umv otransz -55.6013 +if(fabs(A[ofzpz]-77.7)>0.1) +{ + printf("FZP did not reach target position. Potentially the motor is too hot.\n") + exit +} + +}' + +def otransfer_storage '{ + +local k + +printf_red ("\nStatus of the parking station:\n\n") +printf (" 1 2 3 4 5 6\n") +for (k=1;k<7;k++) { +if (epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.VAL",k)) == 1) + printf("%6s",epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC",k))) +else + printf(" ") +} +printf("\n\n ") +_oparkz_slot_check() + +printf_blue ("\n\n--------------------------------------\n") +printf_red ("\nStatus of shuttle A") +for (k=1;k<7;k++) { +if (epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC",k)) == "A") + printf(" - installed at parking position %d", k) +} + printf("\n") + +for (k=1;k<7;k=k+2) { + printf("%25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_A:%d.DESC",k))) + printf(" %d %d ", k, k+1) + printf("%-25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_A:%d.DESC",k+1))) + printf("\n") +} +printf_red ("\nStatus of shuttle B") +for (k=1;k<7;k++) { +if (epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC",k)) == "B") + printf(" - installed at parking position %d", k) +} + printf("\n") + +for (k=1;k<7;k=k+2) { + printf("%25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_B:%d.DESC",k))) + printf(" %d %d ", k, k+1) + printf("%-25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_B:%d.DESC",k+1))) + printf("\n") +} + +printf_red ("\nStatus of shuttle C") +for (k=1;k<7;k++) { +if (epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC",k)) == "C") + printf(" - installed at parking position %d", k) +} + printf("\n") + +for (k=1;k<7;k=k+2) { + printf("%25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_C:%d.DESC",k))) + printf(" %d %d ", k, k+1) + printf("%-25s",epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_C:%d.DESC",k+1))) + printf("\n") +} +printf_blue ("\n--------------------------------------\n") + +printf_red ("\nStatus of OMNY positions:\n\n") + +printf(" Gripper ") +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL") > 0) { + text_bf; + printf(" \"%s\" which is a ", epics_get("XOMNY-SAMPLE_DB_omny:110.DESC")); + if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==1) + printf("sample pin\n") + if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==2) + printf("FZP\n") + if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==3) + printf("OSA\n") + text_non_bf;} +else + printf(" no sample in gripper \n"); + +printf(" OMNY stage ") +if (epics_get("XOMNY-SAMPLE_DB_omny:0.VAL") == 1) { + text_bf; printf(" %s \n", epics_get("XOMNY-SAMPLE_DB_omny:0.DESC")); text_non_bf;} +else + printf(" free \n"); + +printf("\n Fixed positions\n") +local array fixedpos[10] +fixedpos[0]=10 +fixedpos[1]=11 +fixedpos[2]=12 +fixedpos[3]=13 +fixedpos[4]=14 +fixedpos[5]=32 +fixedpos[6]=33 +fixedpos[7]=34 +fixedpos[8]=100 +fixedpos[9]=101 +for (k=0;k<10;k=k+1) { + printf(" Position %3d: ", fixedpos[k]) + if (epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.VAL",fixedpos[k])) == 1) { + printf(" %s \n", epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.DESC",fixedpos[k])))} + else + printf(" free \n"); +} + +printf("\n Special shuttles\n") + printf(" FZP shuttle: %s\n", epics_get("XOMNY-SAMPLE_DB_shuttle_FZP:0.DESC")) + printf(" OSA shuttle p0: %s\n", epics_get("XOMNY-SAMPLE_DB_shuttle_OSA:0.DESC")) + printf(" OSA shuttle p1: %s\n", epics_get("XOMNY-SAMPLE_DB_shuttle_OSA:1.DESC")) + +printf("\nTo change a position status: otransfer_modify_samples <0 for free, 1 for used>\n") +printf("To change the loading status of the parking stage use otransfer_modify_parking \n") + +}' + +def _otransfer_modify_sample(_ocontainer, _oposition, _ostatus, _oname) '{ +#_ocontainer is A, B, C for the pin containers +#it can also be FZP, OSA and omny + +if(_ocontainer=="omny") +{ +#free a position +if (_ostatus==0) +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_%s:%d.VAL", _ocontainer, _oposition),0) + epics_put(sprintf("XOMNY-SAMPLE_DB_%s:%d.DESC", _ocontainer, _oposition),"-") +} + +#sample at position +if (_ostatus>0) +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_%s:%d.VAL",_ocontainer, _oposition),_ostatus) + epics_put(sprintf("XOMNY-SAMPLE_DB_%s:%d.DESC", _ocontainer, _oposition), _oname) +} +} +else +{ +#free a position +if (_ostatus==0) +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.VAL", _ocontainer, _oposition),0) + epics_put(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.DESC", _ocontainer, _oposition),"-") +} + +#sample at position +if (_ostatus>0) +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.VAL",_ocontainer, _oposition),_ostatus) + epics_put(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.DESC", _ocontainer, _oposition), _oname) +} +} + +}' + +def _otransfer_modify_parking(_oparkposition, _ocontainer) '{ +#_ocontainer is A, B, C for the pin containers +#it can also be FZP, and OSA + +_otransfer_check_parking(_ocontainer) + +#free a position +if (_ocontainer=="0") +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_parking:%d.VAL", _oparkposition),0) + epics_put(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", _oparkposition),"-") +} +else +{ + epics_put(sprintf("XOMNY-SAMPLE_DB_parking:%d.VAL", _oparkposition),1) + epics_put(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", _oparkposition), _ocontainer) +} + +}' + +def _otransfer_check_sample_available_at_position(_osampleposition,_picked_it) '{ +#called with _picked_it == 0 prior transfer. This checks that the gripper is empty and that there +#is a sample to get from that position +#called with _picked_it == 1 after the gripper action. then the storage is modified accordingly to the action + +local samplename + +#check that gripper is empty +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")>0) +{ + printf("There is sample \"%s\" in the gripper. Aborting.\n", epics_get("XOMNY-SAMPLE_DB_omny:110.DESC")) + exit +} + +# _osampleposition 1 to 6 are in shuttles +if ((_osampleposition>0 && _osampleposition<7)) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "A" || installedshuttle == "B" || installedshuttle == "C") + { + #is there a sample available? + if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.VAL",installedshuttle,_osampleposition))==1) + { + if(_picked_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.DESC",installedshuttle,_osampleposition)) + _otransfer_modify_sample(installedshuttle, _osampleposition, 0, "-") + _otransfer_modify_sample("omny",110,1,samplename) + } + return(1) + } + else + { + printf("There is no sample availabe at that position.\n") + return(0) + } + } + else + { + printf("There is no sample shuttle installed at the current parkz position.\n") + return(0) + } +} + +# _osampleposition 7 for FZPs +if (_osampleposition==7) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "FZP") + { + #is there an FZP available? + if (epics_get("XOMNY-SAMPLE_DB_shuttle_FZP:0.VAL")==1) + { + if(_picked_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_FZP:0.DESC")) + _otransfer_modify_sample(installedshuttle, 0, 0, "-") + _otransfer_modify_sample("omny",110,2,samplename) + } + return(1) + } + else + { + printf("There is no FZP available.\n") + return(0) + } + } + else + { + printf("There is no FZP shuttle installed at the current parkz position.\n") + return(0) + } +} +# _osampleposition 8, 9 for OSAs +if (_osampleposition==8||_osampleposition==9) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "OSA") + { + #is there an OSA available? + if ((epics_get("XOMNY-SAMPLE_DB_shuttle_OSA:0.VAL")==1 && _osampleposition == 8) \\ + || (epics_get("XOMNY-SAMPLE_DB_shuttle_OSA:1.VAL")==1 && _osampleposition == 9)) + { + if(_picked_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_OSA:%d.DESC",(_osampleposition-8))) + _otransfer_modify_sample(installedshuttle, (_osampleposition-8), 0, "-") + _otransfer_modify_sample("omny",110,3,samplename) + } + return(1) + } + else + { + printf("There is no OSA available.\n") + return(0) + } + } + else + { + printf("There is no OSA shuttle installed at the current parkz position.\n") + return(0) + } +} + +# _osampleposition for fixed positions +if ((_osampleposition==0)||(_osampleposition>9&&_osampleposition<15)||(_osampleposition>31&&_osampleposition<35)||_osampleposition==100||_osampleposition==101) +{ + if (epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.VAL", _osampleposition))==1) + { + if(_picked_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.DESC", _osampleposition)) + _otransfer_modify_sample("omny", _osampleposition, 0, "-") + #FZP was picked + if (_osampleposition == 10 || _osampleposition == 11 || _osampleposition == 100) + _otransfer_modify_sample("omny",110,2,samplename) + #OSA was picked + if (_osampleposition == 101) + _otransfer_modify_sample("omny",110,2,samplename) + #pin was picked + if (_osampleposition == 0 || _osampleposition == 12 || _osampleposition == 13 || _osampleposition == 14 || \\ + _osampleposition == 32 || _osampleposition == 33 || _osampleposition == 34) + _otransfer_modify_sample("omny",110,1,samplename) + } + return(1) + } + else + { + printf("There is nothing to get from this position.\n") + return(0) + } + +} + +return(0) + +}' + +def _otransfer_check_free_slot_available_at_position(_osampleposition,_put_it) '{ +#called with _put_it == 0 prior transfer. This checks that the gripper has a sample and that there +#is a free sample position available that position +#called with _put_it == 1 after the gripper action. then the storage is modified accordingly to the action + +local samplename +local sampletype + +#check that gripper has a sample empty +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==0) +{ + printf("There is no sample in the gripper. Aborting.\n") + exit +} + +#sample pin +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==1) + if ((_osampleposition>-1 && _osampleposition<7) || (_osampleposition>11 && _osampleposition<15) || (_osampleposition>31 && _osampleposition<35)) + { } + else + { + printf("There is a sample pin in the gripper, which is not compatible with position %d\n", _osampleposition) + exit + } +#FZP holder +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==2) + if (_osampleposition == 7 || _osampleposition == 10 || _osampleposition == 11 || _osampleposition == 100) + { } + else + { + printf("There is a FZP holder in the gripper, which is not compatible with position %d\n", _osampleposition) + exit + } +#OSA holder +if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==3) + if (_osampleposition == 8 || _osampleposition == 9 || _osampleposition == 101 ) + { } + else + { + printf("There is an OSA holder in the gripper, which is not compatible with position %d\n", _osampleposition) + exit + } + + +# _osampleposition 1 to 6 are in shuttles +if ((_osampleposition>0 && _osampleposition<7)) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "A" || installedshuttle == "B" || installedshuttle == "C") + { + #is there free position available? + if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.VAL",installedshuttle,_osampleposition))==0) + { + if(_put_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + _otransfer_modify_sample(installedshuttle, _osampleposition, 1, samplename) + _otransfer_modify_sample("omny",110,0,"-") + } + return(1) + } + else + { + printf("There is no free sample slot availabe at that position.\n") + return(0) + } + } + else + { + printf("There is no sample shuttle installed at the current parkz position.\n") + return(0) + } +} + +# _osampleposition 7 for FZPs +if (_osampleposition==7) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "FZP") + { + #is there a free FZP slot available? + if (epics_get("XOMNY-SAMPLE_DB_shuttle_FZP:0.VAL")==0) + { + if(_put_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + _otransfer_modify_sample(installedshuttle, 0, 1, samplename) + _otransfer_modify_sample("omny",110,0,"-") + } + return(1) + } + else + { + printf("There is no free FZP position available.\n") + return(0) + } + } + else + { + printf("There is no FZP shuttle installed at the current parkz position.\n") + return(0) + } +} + +# _osampleposition 8, 9 for OSAs +if (_osampleposition==8||_osampleposition==9) { + local activeparkingposition + local installedshuttle + activeparkingposition = _oparkz_slot_check() + if(activeparkingposition==10) + exit + installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + #is there a samle shuttle at this position? + if(installedshuttle == "OSA") + { + #is there a free OSA slot available? + if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_OSA:%d.VAL",(_osampleposition-8)))==0) + { + if(_put_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + _otransfer_modify_sample(installedshuttle, (_osampleposition-8), 1, samplename) + _otransfer_modify_sample("omny",110,0,"-") + } + return(1) + } + else + { + printf("There is no free OSA position available.\n") + return(0) + } + } + else + { + printf("There is no OSA shuttle installed at the current parkz position.\n") + return(0) + } +} + +# _osampleposition for fixed positions +if ((_osampleposition==0)||(_osampleposition>9&&_osampleposition<15)||(_osampleposition>31&&_osampleposition<35)||_osampleposition == 100||_osampleposition == 101) { + #is there a free slot available? + if (epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.VAL", _osampleposition))==0) + { + if(_put_it==1) + { + samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + _otransfer_modify_sample("omny",110,0,"-") + _otransfer_modify_sample("omny",_osampleposition,1,samplename) + } + return(1) + } + else + { + printf("There is no free space at this position.\n") + return(0) + } + +} + +return(0) + +}' + + +def _otransfer_check_parking(_ocontainer) '{ +#_ocontainer is A, B, C for the pin containers +#it can also be FZP, and OSA +for (k=1;k<7;k++) { + if( epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", k)) == _ocontainer) { + printf("Shuttle %s is already installed at parking position %d.", _ocontainer, k) + exit + } +} +}' + +def otransfer_modify_parking '{ + +if ($# != 2 ) { #change singe position status +printf("Wrong number of arguments. otransfer_modify_parking \n") +printf(" ranges from 1 to 6.\n") +printf(" can be 0=empty, 1=A, 2=B, 3=C, 4=OSA, 5=FZP\n") +exit +} + +local _shuttle + +#this is done because the argument cannot be the capital A +if ($2==1) + _shuttle = "A" +if ($2==2) + _shuttle = "B" +if ($2==3) + _shuttle = "C" +if ($2==4) + _shuttle = "OSA" +if ($2==5) + _shuttle = "FZP" + +if ((_shuttle=="A" || _shuttle=="B" || _shuttle=="C" || _shuttle=="FZP" || _shuttle=="OSA" || _shuttle==0 ) && ($1>0 && $1<7)) + _otransfer_modify_parking($1, _shuttle) +else + printf("Error. Position number not available.\n") + +otransfer_storage + + +}' + +def otransfer_modify_samples '{ + +if ($# != 3 ) { #change singe position status +printf("Wrong number of arguments. otransfer_modify_samples <0 for free, 1 for used>\n") +printf(" can be 0=OMNY, 1=A, 2=B, 3=C, 4=OSA, 5=FZP\n") +exit +} + +local _storage + +#this is done because the argument cannot be the capital A +if ($1==0) + _storage = "omny" +if ($1==1) + _storage = "A" +if ($1==2) + _storage = "B" +if ($1==3) + _storage = "C" +if ($1==4) + _storage = "OSA" +if ($1==5) + _storage = "FZP" + +local _oname + +#new position is used. so ask for sample name +if ($3 == 1) + _oname = getsval("What is the name of this sample?","noname") + +if ((_storage=="A" && $2>0 && $2<7) || (_storage=="B" && $2>0 && $2<7) || (_storage=="C" && $2>0 && $2<7) || (_storage=="FZP" && $2==0) || (_storage=="OSA" && $2>=0 && $2<2) || (_storage=="omny")) + _otransfer_modify_sample(_storage, $2, $3, _oname) +else + printf("Error. Position number not available.\n") + +otransfer_storage + +}' + + + + + +def otransfer_help '{ +text_bf +printf("otransfer is not in a -to be used by users- state\n") +text_non_bf +printf("otransfer_park_slot drive the parking station to transfer from with the gripper\n") +printf("otransfer_park_loadlock_slot drive the parking station to transfer from with the loadlock\n") +printf("otransfer_get_sample pick with the gripper from \n") +printf("otransfer_put_sample put with the gripper to \n") +printf("otransfer_storage print the status of the sample storage\n") +printf("otransfer_modify_parking modify the shuttle status in the parking station\n") +printf("otransfer_modify_samples modify the sample status\n") + +}' diff --git a/csaxs_bec/device_configs/omny_config.yaml b/csaxs_bec/device_configs/omny_config.yaml index d1a3404..3af78f9 100644 --- a/csaxs_bec/device_configs/omny_config.yaml +++ b/csaxs_bec/device_configs/omny_config.yaml @@ -392,7 +392,7 @@ oeyez: readOnly: false readoutPriority: baseline userParameter: - in: 0 + xray_in: -2 oeyey: description: Xray eye Y deviceClass: csaxs_bec.devices.omny.galil.ogalil_ophyd.OMNYGalilMotor