#! /bin/tcsh -f # # automatically (try to) put the sample loop in the beam # # Optionally, use jpegs of pre-centered sample as a guide # # set tempfile = tempfile if(! -w . && -w /tmp/${USER}) cd /tmp/${USER} if(! -w . && -w $HOME) cd $HOME set path = ( `dirname $0` $path ) set ref = () set manouver = "" set good_hits = "" foreach arg ( $* ) if("$arg" == "-wideangle") set WIDE_ANGLE if("$arg" == "-noidea") set WIDE_ANGLE if("$arg" == "-nofaceon") set NOFACEON if("$arg" =~ *.jpg) then if(-e "$arg") then set ref = ( $ref $arg ) else echo "ERROR: $arg does not exist! " endif endif if("$arg" =~ *.com) then if(-e "$arg") then set manouver = "$arg" else echo "ERROR: $arg does not exist! " endif endif end light.com 1 100% light.com 2 0% diode.com out backlight.com out again: # adjust pin length using camera 4? if($?WIDE_ANGLE) then stage.com down phi.com 0 center_tip.com phi.com 90 center_tip.com # unset WIDE_ANGLE endif stage.com low if ($status) stage.com low if ($status) then set BAD = "unable to move stage" goto exit endif sleep 3 center_tip.com -blob 100 if($status) then if(! $?WIDE_ANGLE) then set WIDE_ANGLE goto again endif set BAD = "first midmag center_tip failed" goto exit endif phi.com by 90 center_tip.com -blob 100 if($status) then set BAD = "second midmag center_tip failed" goto exit endif if("$ref" =~ *.jpg) then set alg = `echo "$ref" | awk '{print substr($0,index($0,"alg")+3)+0}'` if("$alg" != "0") set alg = "alg=$alg" samerot.com 10 $alg if($status) then set BAD = "samerot failed" goto exit endif set phi0 = `phi.com | awk '{print $5}'` set phi = `echo $ref | awk -v phi0=$phi0 -F "_" '{print $NF+phi0}'` phi.com $phi endif stage.com up if($status) then set BAD = "unable to move to high mag" goto exit endif center_tip.com if($status) then set BAD = "first himag center_tip failed" goto exit endif phi.com by -90 center_tip.com if($status) then set BAD = "second himag center_tip failed" goto exit endif if ( -e "$manouver") then phi.com by 90 echo "executing prescripted manouver: $manouver" source $manouver else echo "executing default centering manouver" set fov = `fov.com |& awk 'NF>1{print $(NF-1),$NF}' | tail -1` set leftside = `echo $fov | awk '{print $1/3}'` if("$leftside" == "") set leftside = 0.2 sample.com 0 0 $leftside endif if(("$ref" !~ *.jpg) && (! $?NOFACEON)) then faceon.com 6 if($status) exit 9 phi.com by -90 center_middle.com -maxmove 0.1 phi.com by 90 center_middle.com -maxmove 0.1 endif foreach file ( $ref ) set phi = `echo $file | awk -v phi0=$phi0 -F "_" '{print $NF+phi0}'` phi.com $phi putback.com $file 200 edges CC=0.2 if($status) then # try wider field of view set retreat = `sample.com | awk '{print $5,$6,$7}'` camera.com 2 ; sleep 3 putback.com edges $file 450 CC=0.7 if($status) then # what now? next image I guess... camera.com 1 ; sleep 3 continue endif # wide view worked, try again at high-mag? set good_hits = ( $file $good_hits ) camera.com 1 ; sleep 3 putback.com $file edges CC=0.7 if($status) then # what now? next image I guess... camera.com 1 sample.com to $retreat continue endif endif # final pull-in putback.com $file 20 if(! $status) then set good_hits = ( $file $good_hits ) endif end if( "$ref" != "" && ( $#good_hits < $#ref )) then # this is bad set BAD = "putback program failed" goto exit endif exit: if($?BAD) then echo "ERROR: $BAD" exit 9 endif exit