#!/bin/csh -f

# Grab from all cameras

#check command line
if ( $#argv != 5 ) then 
  echo "Usage: graball <start_time hh:mm:ss:ff> <stop_time hh:mm:ss:ff> <frame_step> <capture_number> <colour_format (rgb or yuv)>";
  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 CAPTURE=$argv[4]; #capture number
set COLOURSPACE=$argv[5]; #colour space.

# Get the current time code
set GRABBER=`cameras.csh 0`;
set MACHINE=$GRABBER[1];
set GRAB=$GRABBER[2];
set TIME_START=$OFFSET;
#`rsh $MACHINE $GRAB -g -a 00:${OFFSET}`;

# grab
set NUM_VIEWS=`cameras.csh`;
set i=0;
while ($i<$NUM_VIEWS)
  set GRABBER=`cameras.csh $i`;
  set MACHINE=$GRABBER[1];
  set GRAB=$GRABBER[2];
  set FILE=/video/grab.${i}.${CAPTURE}.grab
  rsh $MACHINE $GRAB -start $TIME -end $TIME_START -s $STEP -o $FILE -l ${FILE}.log -f $COLOURSPACE & 
  #+00:${TIME} -s $STEP -o $FILE -l ${FILE}.log &
  set i=`expr $i + 1`;
end

echo START TIME: $TIME_START
