#!/bin/csh -f #+ # wfi -- wait for new DEIMOS image to be written to disk # # Purpose: # With no argument, wait for a new image to be written to disk # in the output directory, and print the name of the image to STDOUT. # With an argument, loop until the named image is written to disk. # # Usage: # wfi [-nowait] [-silent] [image] # # Arguments: # -nowait = do not wait if image not in progress; return immediately # -silent = do not print image name # image = name of the image for which to wait. This should be # the TAIL of the filename only (omit directory component) # # Output: # Full image name is written to stdout. # # Restrictions: # - If started during image readout, will not return the current image # # Exit values: # 0 = normal completion # 1 = wrong number of arguments # # Example: # 1) Wait until next image has been written to disk: # wfi # # 2) Wait until image d0813_0032.fits has been written to disk: # wfi d0813_0032.fits # # 3) Wait only if an image is being taken... # wfi -n # #- # Modification history: # 2001-Jul-25 GDW Original version # 2002-Aug-13 GDW Extensive mods # 2002-Oct-04 GDW Removed exposip checks #----------------------------------------------------------------------- set buf = $0 set cmd = $buf:t set usage = "Usage: $cmd [-silent] image" set verb = 1 set image = default # parse flags... while ( $#argv > 0 ) # check for -nowait flag... if ( "$1" =~ \-n* ) then set nowait=1 shift continue endif # check for silent flag... if ( "$1" =~ \-s* ) then set verb = 0 shift continue endif # exit flag check if no flags remain... break end # verify args... if ( $#argv > 1 ) then echo "$usage" exit 1 endif # parse args... if ( $#argv >= 1 ) then set image = $1 shift endif # in no-wait mode we return iommediately if no image is in progress... if ( $?nowait ) then set buf = ( `show -terse -s deiccd eraseip exposip pauseip wcrate wdisk` ) if ( "$buf" !~ *true* ) exit 0 endif # loop until (a) the specified image is written, # or (b) a new image is written... @ i = 0 while (1) @ i++ set new = `lastimage -tail` if ( "$image" == "$new" ) break if ( "$image" == "default" && $i > 1 ) break #@ waitfor -s deiccd exposip = t #@ waitfor -s deiccd exposip = f waitfor -s deiccd wcrate = t waitfor -s deiccd wcrate = f waitfor -s deiccd wdisk = t waitfor -s deiccd wdisk = f end # echo name if desired... if ( $verb ) then lastimage endif exit