From d32d7401a31230a9a3eecc0f6206eea1011ebefd Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Thu, 4 Jul 2024 17:21:13 +0200 Subject: [PATCH] continue with init --- .../bec_ipython_client/plugins/omny/omny.py | 174 +++++++++++++++++- 1 file changed, 170 insertions(+), 4 deletions(-) diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py index 5340c6b..46bf97c 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny.py @@ -57,8 +57,7 @@ class OMNYInitStagesMixin: dev.oosaz.drive_axis_to_limit("forward") dev.oosax.drive_axis_to_limit("forward") else: - print("Automatic init not possible. Initialize manually") - return + raise OMNYInitError("Automatic init not possible. Initialize manually") umv(dev.oshield, 0) @@ -132,14 +131,181 @@ class OMNYInitStagesMixin: user_input = input("find reference mark of oeyey?") if user_input == "y": dev.oeyez.drive_axis_to_limit("forward") - dev.oeyey.controller.socket_put_confirmed(""indspeed[7]=2000"") + print("oeyey now in limit") + dev.oeyey.controller.socket_put_confirmed("indspeed[7]=2000") dev.oeyey.find_reference() + print("oeyey is now referenced") dev.oeyey.limits = [-61, 1] #ensure closed shuttle and shuttle aligner down - if not dev.oshuttleopen.get_motor_limit_switch()[0]: + if not dev.oshuttleopen.get_motor_limit_switch()[1]: dev.oshuttleopen.drive_axis_to_limit("reverse") + + if not dev.oshuttleopen.get_motor_limit_switch()[1]: + raise OMNYInitError("Failed to drive shuttle opener to reverse limit") + else: + print("shuttle opener is down, i.e. in safe position to continue.") + #move shuttle aligner down + if not dev.oshuttlealign.get_motor_limit_switch()[0]: + dev.oshuttlealign.drive_axis_to_limit("forward") + + if not dev.oshuttlealign.get_motor_limit_switch()[0]: + raise OMNYInitError("Failed to drive shuttle opener to forward limit") + else: + print("shuttle aligner is down, i.e. in safe position to continue.") + + user_input = input("drive parking stage to +Z limit and reference?") + if user_input == "y": + dev.oparkz.drive_axis_to_limit("forward") + print("oparkz is in limit") + dev.oparkz.find_reference() + print("oparkz is referenced") + dev.oparkz.limits = [-165, 1] + + user_input = input("OK, tricky part. Can the OSA be moved to -z limit then -x limit. Risk of collition! y/n?") + if user_input == "y": + dev.oosaz.drive_axis_to_limit("forward") + dev.oosax.drive_axis_to_limit("forward") + else: + raise OMNYInitError("Automatic init not possible in this case. Please initialize manually.\n") + + user_input = input("drive otrackz to -Z limit?") + if user_input == "y": + dev.otrackz.drive_axis_to_limit("forward") + print("otrackz is in limit") + + user_input = input("drive osamx to +X limit?") + if user_input == "y": + dev.osamx.drive_axis_to_limit("forward") + print("osamx is in limit") + + user_input = input("drive oosay to +Y limit?") + if user_input == "y": + dev.oosay.drive_axis_to_limit("forward") + print("oosay is in limit") + + user_input = input("find reference mark of osamx?") + if user_input == "y": + dev.osamx.find_reference() + print("osamx is referenced") + dev.osamx.limits = [-1, 1] + #osamx range limit -2 to 7 good for cryolink + + #if osamz is ever needed, here is how it could be initialized (in spec code) + #if (!_ogalil_axis_is_referenced_mne(osamx) || fabs(A[osamx]) > 0.1 ) + #{ + #printf("The osamx stage is not referenced or is not at the reference position. Aborting.\n") + #exit + #} + #drive osamz to -Z limit + #+Z direction is critical because of cryolink connection + #if(!yesno("drive osamz to -Z limit and perform reference search?",1)) + # exit + #osamz to limit + #_ogalil_drive_to_limit_mne(osamz,1) + #_ogalil_find_reference_mark_mne(osamz) + #set_lm osamz -.5 .5 + + + user_input = input("drive osamy to -Y limit?") + if user_input == "y": + dev.osamy.drive_axis_to_limit("reverse") + print("osamy is in limit") + + +#check shield is at zero position + + +_ostages_init_confirm("perform reference search of oosax?") +_ogalil_find_reference_mark_mne("oosax") +set_lm oosax -1 4 +_ostages_init_confirm("perform reference search of oosay?") +_ogalil_find_reference_mark_mne("oosay") +set_lm oosay -.1 .6 +_ostages_init_confirm("perform reference search of osamy?") +_ogalil_find_reference_mark_mne("osamy") +set_lm osamy -1 1 +_ostages_init_confirm("perform reference search of oosaz?") +_ogalil_find_reference_mark_mne("oosaz") +set_lm oosaz -2 .1 + + +_ostages_init_confirm("find endswitch and reference mark of osamroy?") +global _ogalil_ignore_glitch_rotstage +_ogalil_ignore_glitch_rotstage=1 +_ogalil_drive_to_limit_mne("osamroy",0 ) + +_ogalil_find_reference_mark_mne("osamroy") +global _osamroy_last_rotation_angle +_osamroy_last_rotation_angle=0 +set_lm osamroy -27 337 +_ogalil_ignore_glitch_rotstage=0 + +_ostages_init_confirm("find reference marks of transfer Y?") +_ogalil_find_reference_mark_mne("otransy") + + +set_lm otransx -459 21 +set_lm otransy -41 1 +set_lm otransz -67.5 11 + + +_ostages_init_confirm("find endswitches and reference marks of tracking stage system?") + +_ogalil_drive_to_limit_mne("otracky",1) +_ogalil_find_reference_mark_mne("otracky") +_ogalil_find_reference_mark_mne("otrackz") + +_ogalil_folerr_not_ignore( 0) +_ogalil_folerr_not_ignore( 1) +_ogalil_folerr_not_ignore( 2) + +_ogalil_put_confirmed(2,"ACE=11264") +_ogalil_put_confirmed(2,"ACB=11264") +_ogalil_put_confirmed(2,"DCE=11264") +_ogalil_put_confirmed(2,"DCB=11264") + + + +ogalil_show_all +_ogalil_init_adjust + +}' + +def _ogalil_init_adjust '{ +if(!yesno("adjust all stages to approximate alignment?",1)) + exit + +oeye_cam_in + + +umv oosay 0.5 +set_lm oosay .4 .6 +set_lm osamy -1 3 +umv osamy 2.7 ofzpx -.8 ofzpy 1.6 +set_lm osamy 2.5 2.9 +set_lm ofzpx -2 0 +set_lm ofzpy -0 3 +set_lm ofzpz -2.5 60 +_oshield_ST_close +set_lm otracky -7 -3 +set_lm otrackz -2 1 +umv otracky -4.3431 otrackz -0.6948 + + +_ogalil_user_dial_offsets_to_zero() + +_ogalil_put_confirmed(1,"SPA=100") +_ogalil_put_confirmed(1,"ACA=1878") +_ogalil_put_confirmed(1,"DCA=1878") + +_ogalil_put_confirmed(2,"ACE=11264") +_ogalil_put_confirmed(2,"ACB=11264") +_ogalil_put_confirmed(2,"DCE=11264") +_ogalil_put_confirmed(2,"DCB=11264") + +_ogalil_put_confirmed(2,"axspeed[0]=1000")