#!/bin/csh -f

#check command line
if ( $#argv != 5 ) then 
  echo "Usage: grab <record_time mm:ss:ff> <offset_time mm:ss:ff> <frame_step> <camera_number> <capture_number>";
  exit 1 
endif

#get the command line
set TIME=$argv[1]; #number of frames
set OFFSET=$argv[2]; #offset to start grabbing
set STEP=$argv[3]; #delay between frames
set CAMERA=$argv[4]; #camera number
set CAPTURE=$argv[5]; #capture number

#grab command
set FILE=/video/grab.${CAMERA}.${CAPTURE};
set GRABBER=`cameras.csh $CAMERA`;
set MACHINE=$GRABBER[1];
set GRAB=$GRABBER[2];

# Create the start time code
set TIME_START=`rsh $MACHINE $GRAB -g -a 00:${OFFSET}`;
echo
echo START TIME: $TIME_START

#capture
echo
rsh $MACHINE $GRAB -start $TIME_START -end +00:${TIME} -s $STEP -o $FILE -l ${FILE}.log

