#!/bin/tcsh -ef
#
# ABOUT   : NOTCam loop script for repeated exposures in 
#           staring mode.
#
# USAGE   : notcam.loop-frame [-e] t N
#           -e      : Echo script on stdout, do not execute
#           t       : Time between read (min = 3.6)
#           N       : Number of reads (max = 14)
#                     Exposure time is "t * N"
#
# DEPENDS : notcam.frames, notcam.autosave_on, notcam.imtype
#
# PROVIDES: notcam.loop-frame
#
# TFUNCT  : Continues until aborted with Ctrl-C
#
# AUTHOR  : Anlaug Amanda Djupvik
#
# HISTORY : 2010/05/06 (Initial release, AAD)
#   

if ("$1" == "-e") then
   set e = "echo"
   shift
else
   set e = ""
endif

# Get command line arguments
set t = `echo "$1" | sed -n -e '/^[0-9.]*$/p'`
set N = `echo "$2" | sed -n -e '/^[0-9.]*$/p'`

# Check for errors in arguments
if ($t == '' || $N == '') then
   echo " Error in arguments"
   echo " Usage: notcam.loop-frame t N \n"
   echo "        t = time (in s) between reads"
   echo "        N = number of ramp-sampling reads \n"
   echo "        Total exptime is N * t. \n"
exit 1
endif

# Write to Talker
logger -p local0.debug -t "notcam.loop-frame" "[NOTE]: Loop script started. To be ended with Ctrl-C."

# Execute or Echo script

$e notcam.autosave_on
$e notcam.imtype OBJECT

onceagain:

$e notcam.frames $t $N

goto onceagain



