#! /bin/tcsh -f # # user guide for re-aligning the beamline # # test -t 1 if($status) set AUTO set pwd = `pwd` if("$pwd" !~ /home*) then cd if(-e temp) cd temp endif if(! $?AUTO) then #animate -delay 200 /data/calibrations/images/yag_aligned_?.jpg & #display /data/calibrations/images/yag_aligned_1.jpg & animate -delay 50 /data/calibrations/images/workarea.jpg /data/calibrations/images/workarea.jpg /data/calibrations/images/workarea_hilight.jpg /data/calibrations/images/jigs2.jpg /data/calibrations/images/jig_hand2.jpg /data/calibrations/images/jig_hand_close.jpg -delay 500 /data/calibrations/images/yag_aligned_1.jpg & endif foreach Arg ( $* ) set arg = `echo "$Arg" | awk '{print tolower($1)}'` if("$arg" == "nofinish") set nofinish if("$arg" == "mounted") set already_mounted end set beamline = `beamline.com` # remember user's current set oldpinlength = `sample.com | awk '{print $7}'` set test = `echo $oldpinlength 18 | awk '{print ( $1 < $2 )}'` if($test) set oldpinlength = 18 # skip ahead? if($?already_mounted) goto mounted phi.com 90 stage.com down if ($status) then door.com | grep open if(! $status) then echo "please shut the hutch door." echo "press when you have done this." echo -n "->" if(! $?AUTO) then set in = ( $< ) else sleep 10 echo "" endif else sleep 5 endif stage.com down if ($status) then set BAD = "cannot move stage" set reason = `tail -10000 /data/log/pmac1DHS.log | awk '/collimator/ && /completed/ {print $NF}' | tail -1` if ("$reason" != "normal") set BAD = "$reason" goto exit endif endif mounted: # CAVEAT: predefined position for particular jig #set sample_pos = ( -0.3 0.0 -0.2 ) #if("$beamline" == "1231") set sample_pos = ( 1.34 1.1 8.0 ) #sample.com to $sample_pos pinlength.com 19.2 if ($status) then set BAD = "cannot move sample" goto exit endif echo "\n\n\n\n\n\n\n\n\n\n" echo "please mount the YAG jig (see picture)" echo "then shut the hutch door" #echo "then center the thread as best as you can." echo "press when you have done this." echo -n "->" if(! $?AUTO) then set in = ( $< ) else sleep 5 echo "" endif #kill %1 # sometimes the hutch parker has already started set test = `tac /data/log/watchdog.log | awk '/start_operation recoverFromMount/{print 1; exit} /operation_completed recoverFromMount/{print 0;exit}'` if ( $test ) then # wait for the hutch_parker to finish echo "waiting for hutch to unpark" echo -n "" | xos3_exchange.tcl 1 "operation_completed recoverFromMount" 10 > /dev/null if("$status") then echo "WARNING: wait_for_park returned an error..." endif endif # align the YAG jig automatically stage.com low if ($status) then # try again echo "wait a moment..." sleep 5 stage.com low stage.com low if($status) then set BAD = "cannot move stage" set reason = `tail -10000 /data/log/pmac1DHS.log | awk '/collimator/ && /completed/ {print $NF}' | tail -1` if ("$reason" != "normal") set BAD = "$reason" goto exit endif endif light.com 100% light.com 2 0% diode.com out backlight.com out # wait for the video camera to settle stable_video.com center_tip.com -reso 704x480 phi.com by 90 stable_video.com center_tip.com -reso 704x480 restore_pin.com -mounted -prefix /data/calibrations/images/yag if($status) then set BAD = "position restoration failed" endif if(! $?BAD) then set test = `pinlength.com | awk '{print (1.5& /dev/null #shutter.com open #snap.com open.jpg -nodisplay >& /dev/null # get faceon by minimizing diode current? #echo -n "" >! tempfile.txt #foreach phi ( `seq 0 10 360` ) # phi.com $phi >& /dev/null # set Iend = `blmotor.com Iend | awk '{print $NF}'` # echo "$phi $Iend" | tee -a tempfile.txt #end echo "focusing on YAG..." set oldlight = `light.com | awk 'NR==1{printf "%.2f", $NF/100}' | tail -1` diode.com in focus.com beam sleep 1 find_beam.com if($status) then set BAD = "cannot see beam." goto exit endif set beam = `beam.com | awk '{print $(NF-1),$NF}' | tail -1` echo "\n\n\n\n\n\n\n\n\n\n" echo "please adjust the crosshairs on the touch screen to match the beam profile." echo "(use the mouse hidden behind the touch screen)" echo "press when you have done this." echo -n "->" if(! $?AUTO) then set in = ( $< ) else sleep 5 echo "" endif diode.com out #light.com $light sample.com to $back shutter.com close phi.com 135 center_middle.com phi.com 45 center_middle.com find_axis.com if($status) then set BAD = "cannot find rotation axis." goto exit endif set axis = `cat /data/calibrations/rotation_axis_in_camera1.txt` set beam = `beam.com | awk '{print $(NF-1),$NF}' | tail -1` set delta = `echo $axis $beam 480 | awk '{print ($1-$3)*$4/1000}'` set stage = `stage.com | awk '{print $5}'` set newstage = `echo $stage $delta | awk '{print $1+$2}'` stage.com $newstage # reset the "up" position to this value stage.com save center_middle.com phi.com by 90 center_middle.com phi.com by 180 phi.com by 180 phi.com 45 echo "is the center of rotation on the center of the beam? [Yes]" echo -n "->" if(! $?AUTO) then set in = ( $< ) else sleep 5 echo "" endif if ("$in" =~ [Nn]*) then echo "starting over..." goto again endif phi.com $phi0 tuneup.com if ($status) then set BAD = "unable to optimize beam" goto exit endif # find the tip of the jig in ultra-lo-res camera? finish: if($?nofinish) goto exit stage.com down & distance.com 600 & pinlength.com $oldpinlength & wait echo "please put the YAG jig back into its holder." echo "you may now resume collecting data." exit: if ($?BAD) then cat << EOF Automatic microscope alignment failed... $BAD call 9-928-5556 EOF endif exit