#!/bin/csh -fx #+ # rotatloop -- step the rotator and pause between moves # # Purpose: # Given a stepsize, starting and ending rotator values, and a # desired time interval for sleeping, this script will move the # rotator and pause for the desired amount of time to allow one to # acquire data. The default action is to mvoe from the negative # to the positive limits of rotation in 10-degree increments, pausing # for 10 seconds between moves. # # Usage: # rotatloop [-silent] [-prompt] [-goi] [start [stop [step [sleep]]]] # # Arguments: # -silent = do not beep between moves # -goi = acquire an image at each position # -prompt = require user to press to move # start = starting DEIMOS PA value [deg; default=-410] # stop = ending DEIMOS PA value [deg; default=310] # step = increment between moves [deg; default=10] # sleep = number of seconds to sleep [sec; default=10] # # Output: # Transcript written to STDOUT # # Restrictions: # - Rotator must be in "Pos" mode to enable user control # - Angles must be provided in integer format # - If "-goi" is specified, pausing and sleeping are NOT done # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Examples: # # 1) Acquire an image every 10 deg between the rotator limits: # rotatloop -goi # # 2) Rotate from 0 to 360 in 15 deg increments, pausing at each # position until the observer presses a key: # rotatloop -prompt 0 360 15 # #- # Modification history: # 2002-Jul-03 GDW Original version # 2002-Sep-15 GDW Acquire image at each position #----------------------------------------------------------------------- set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd [-silent] [-prompt] [-goi] [start [stop [step [sleep]]]]" # define defaults... set sound = 1 # default is to make sound after each rotation set ask = 0 # default is to sleep rather than prompt set goi = 0 # default is not to acquire an image at each position @ start = -410 # default is to begin at negative limit @ stop = 310 # default is to end at positive limit @ step = 10 # default stepsize is positive 10 deg @ n_sleep = 10 # default sleeptime is 10 seconds # check for flags... foreach arg ( $* ) if ( "$arg" == "-silent") then shift set sound = 0 endif if ( "$arg" == "-prompt") then shift set ask = 1 endif if ( "$arg" == "-goi") then shift set goi = 1 endif end # parse remaining args... if ( $#argv >= 1 ) then @ start = $1 shift endif if ( $#argv >= 1 ) then @ stop = $1 shift endif if ( $#argv >= 1 ) then @ step = $1 shift endif if ( $#argv >= 1 ) then @ n_sleep = $1 shift endif if ( $#argv > 0 ) then printf "$usage\n" exit 1 endif # ensure that step is positive by computing the absolute value... set step = `abs $step` # check which direction we will rotate... if ( $start > $stop ) then set forward = 0 @ step = -$step else set forward = 1 endif # verify the rotator mode... set rotatmod = `show -s deirot -terse rotatmod` if ( "$rotatmod" != "Pos" ) then printf "ERROR in $cmd: rotator is not in Pos mode\n" exit 2 endif # initialize the angle to the starting value... @ angle = $start # start loop... while (1) # set the rotator to the appropriate value... modify -s deirot rotatval=$angle # notify the user as appropriate... if ( $sound ) then beep endif # sleep or wait for response... if ( $goi ) then goi else if ( $ask ) then pause else printf "Sleeping for $n_sleep seconds" sleepdots $n_sleep endif # increment/decrement... @ angle += $step # check for whether to quit... if ( $forward ) then if ( $angle > $stop ) then break endif else if ( $angle < $stop ) then break endif endif end