#! /bin/csh -f # # Jiffy for changing divergence goto Setup Return_from_Setup: set hdiv = "" set vdiv = "" if("$1" != "") then set hdiv = `echo $1 | awk '$1+0>0.0001 && $1+0 <= 4{print $1+0}'` endif if("$2" != "") then set vdiv = `echo $2 | awk '$1>=0.7{$1=0.7} $1+0>0.0001 && $1+0 < 0.8{print $1+0}'` endif if(("$hdiv" != "")||("$vdiv" != "")) then set old_hdiv = `echo "getpos Horizontal Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 1 | awk '{print $1+0}'` set old_vdiv = `echo "getpos Vertical Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 1 | awk '{print $1+0}'` # use current values for unmentioned motor if("$hdiv" == "") set hdiv = $old_hdiv if("$vdiv" == "") set vdiv = $old_vdiv set stat = `echo "moveto Horizontal Convergance Angle ${hdiv}\r\nmoveto Horizontal Convergance Angle ${hdiv}\r" | sock_exchange.tcl bl${beamline}b 10001 2 | awk '/Local/'` set stat = `echo "moveto Vertical Convergance Angle ${vdiv}\r\nmoveto Vertical Convergance Angle ${vdiv}\r" | sock_exchange.tcl bl${beamline}b 10001 2 | awk '/Local/'` if("$stat" != "") then echo "unable to move motor." echo 'please switch the beamline control computer (bl'${beamline}'b) to "Remote Control"' else echo -n "moving slits to $hdiv x $vdiv mrad" endif set start_time = `echo "puts [clock seconds]" | tclsh` usleep 500000 set stat = `echo "getstat Horizontal Convergance Angle\r\ngetstat Vertical Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 2 | awk '{stat+=$1} END{print stat}'` while ($stat) sleep 1 set stat = `echo "getstat Horizontal Convergance Angle\r\ngetstat Vertical Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 2 | awk '{stat+=$1} END{print stat}'` echo -n "." end echo "" set hdiv = `echo "getpos Horizontal Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 1 | awk '{print $1+0}'` set vdiv = `echo "getpos Vertical Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 1 | awk '{print $1+0}'` # set end_time = `echo "puts [clock seconds]" | tclsh` # echo "$start_time $end_time $hdiv $old_hdiv" | awk '$3+0!=$4+0{printf "%ds elapsed, %.1f s/mrad\n", $2-$1, ($2-$1)/sqrt(($3-$4)^2)}' endif echo "getpos Horizontal Convergance Angle\r\ngetpos Vertical Convergance Angle\r" | sock_exchange.tcl bl${beamline}b 10001 2 |\ awk 'NR==1{printf "Beam Divergance: "} {printf "%.4f ", $1+0}' echo "" exit Setup: if(! $?beamline) then # default to beamline this computer belongs to setenv beamline `beamline.com` if($status) then echo "ERROR: $beamline" exit 9 endif endif #if(! $?beamline) setenv beamline 831 ############################################################# # platform-specific issues set test = `echo "123asdf" | awk '{print $1+0}'` if("$test" != "123") then alias awk nawk set test = `echo "123asdf" | awk '{print $1+0}'` if("$test" != "123") alias awk gawk set test = `echo "123asdf" | awk '{print $1+0}'` if("$test" != "123") then echo "ERROR: awk no good" exit 9 endif endif set test = `echo -n "\r" |& od -c | wc -w` if("$test" != 3) then alias echo /bin/echo set test = `echo -n "\r" |& od -c | wc -w` if("$test" != 3) alias echo '/bin/echo -e' set test = `echo -n "\r" |& od -c | wc -w` if("$test" != 3) alias echo /usr/bin/echo set test = `echo -n "\r" |& od -c | wc -w` if("$test" != 3) alias echo '/bin/echo \!* | awk '\''/^-n/{printf "%s", substr($0,4) ; exit} {print}'\' set test = `echo -n "\r" |& od -c | wc -w` if("$test" != 3) then echo "ERROR: echo command is broken" exit 9 endif endif set test = `echo "string is digit 1" | /usr/bin/tclsh |& wc -l` if($test != 0) then set test = `echo "string is digit 1" | tclsh |& wc -l` if($test != 0) alias tclsh tclsh8.2 set test = `echo "string is digit 1" | tclsh |& wc -l` if($test != 0) alias tclsh tclsh8.3 set test = `echo "string is digit 1" | tclsh |& wc -l` if($test != 0) then setenv LD_LIBRARY_PATH ~jamesh alias tclsh ~jamesh/tclsh8.2 echo "" | tclsh >& /dev/null if("$status") then echo "ERROR: tclsh not available" exit 9 endif endif alias sock_exchange.tcl "tclsh `which sock_exchange.tcl` \!*" endif ###################################################################### if(! $?beamline) then # default to beamline this computer belongs to setenv beamline `beamline.com` if($status) then echo "ERROR: $beamline" exit 9 endif endif #if(! $?beamline) setenv beamline 831 set host = bl${beamline}b set tempfile = /tmp/blmotor_tmp$$ if(-w "/tmp/${USER}/") set tempfile = /tmp/${USER}/blmotor_tmp$$ goto Return_from_Setup