#!/bin/csh -f #+ #NAME # wfmech - waits until all motors (SPEC or IMAG) are idle using OGS keywords # #- # Modification History: # 20041005 - MB: Copied from NIRC2 and adapted for OSIRIS # 20181109 - jlyke: Re-work to handle the safeties for new imager FW's # 20190512 - jlyke: Add fix_sfilter to spec side of wfmech # # Boiler plate for "-h" support for command autohelp. if ("$1" == "-h") then help $0 | more exit $status endif # Boilerplate for syncheck. # Note that the boiler plate should be transparent for all usages, # but to make correct use of syncheck you will need to specify the # correct pattern. set noglob set CheckStatus = `syncheck -command $0 $* -pattern [SPEC,spec,IMAG,imag]` unset noglob if ("$CheckStatus" != "OK") then help $0 exit 1 endif # End of help/syncheck boiler plate. # Set up to trap control-C onintr reset # Set default values set fcmd = $0 set cmd = ${fcmd:t} # Decide if we should check SPEC or IMAG set mode = $1 switch ($mode) case "SPEC": case "spec": set side = "spec" set iterations = 1 set MotList = (ss1 ss2 sfw slm) ### Direct subserver commands # set MotList = (om1s om2s om3s om4s) breaksw case "IMAG": case "imag": set side = "imag" # OGS has protections agains open-open that move IF1/2 multiple times set iterations = 2 set MotList = (if1 if2) # set MotList = (om5s om6s) ### Direct subserver commands breaksw default: echo "Specified mode must be SPEC or IMAG" exit 1 breaksw endsw # Check all motors. set timeout = 30 set sfwtime = 3 set iter = 0 while ( $iter < $iterations ) foreach Motor ($MotList) echo -n "${cmd} ${mode}: Waiting for ${Motor}." set count = 0 set flag = `show -s osiris -terse "$Motor"stat` # set flag = `show -s "$Motor" -terse status` ### Direct subserver commands while ( ("$flag" != "OK") && ($count <= $timeout) ) @ count++ # if sfw and count > server update time and the wheel is not moving if ("$Motor" == "sfw" && $count > $sfwtime && $flag != "Moving") then fix_sfilter endif echo -n "." sleep 1 set flag = `show -s osiris -terse "$Motor"stat` # set flag = `show -s "$Motor" -terse status` ### Direct subserver commands end if ( "$flag" == "OK" ) then echo "OK" else echo "Timed Out" exit 2 endif end # foreach sleep 1 @ iter++ end # while # fix_sfilter for SPEC if ($side == "spec") then fix_sfilter endif # one last check for imag if ($side == "imag") then set count = 0 # when not done, there are spaces and a "?" in the filter name set ifilter = (`show -s osiris -terse ifilter | sed -e 's/\?/-/g'`) echo -n "${cmd} ${mode}: Waiting for final config." while ($#ifilter > 1 && $count <= $timeout ) @ count++ echo -n "." sleep 1 set ifilter = (`show -s osiris -terse ifilter | sed -e 's/\?/-/g'`) end if ( $#ifilter == 1 ) then echo "OK" else echo "Timed Out" exit 2 endif endif exit reset: # put stuff here exit 1