#!/bin/csh -f
#+
#OSIRIS library of scripts
#
#NAME
#     wait4dar - turns DAR offloading on/off
#
#SYNOPSIS
#     wait4dar mode
#
#DESCRIPTION
#     sets the keyword WFDAR to on or off, telling the wfao script whether
#     or not to force an offload of the DAR shifts to the field steering
#     mirrors.
#
#     If no argument is given, the current settings are shown.
#
#OPTIONS
#     mode
#          set to one of [on,off]
#
#EXAMPLES
#     wait4dar off
#          turns off DAR offloading and waiting
#
#ENVIRONMENT VARIABLES
#     none
#
#FILES
#     none
#
#SERVERS & KEYWORDS
#     service = osiris
#          keywords: wfdar
#
#SCRIPTS CALLED
#     help, syncheck
#
#EXIT STATUS
#     0 - normal exit, no error
#     1 - script aborted by an interrupt
#     2 - syncheck error
#
#SEE ALSO
#     ???
#-
#
# Modification History:
# 20050220 - MB: Adapted from NIRC2 scripts
#

# 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 {[on,off]}`  
unset noglob

if ("$CheckStatus" != "OK") then
    help $0 | more
    exit 2
endif

# End of help/syncheck boiler plate.

if ($#argv == 0) then
    set wfdar = `show -s osiris -terse wfdar`
    cat <<END

Currently the "wait-for-DAR-offload" flag is: $wfdar

END
    exit 0
endif

modify -s osiris silent wfdar = $1
