#!/bin/csh -f

# Grab from 2 cameras

#check command line
if ( $#argv != 6 ) then 
  echo "Usage: grab2 <record_time mm:ss:ff> <offset_time mm:ss:ff> <frame_step> <camera_number1> <camera_number2> <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 CAMERA1=$argv[4]; #camera number
set CAMERA2=$argv[5]; #camera number
set CAPTURE=$argv[6]; #capture number

#grab command
set FILE1=/video/grab.${CAMERA1}.${CAPTURE};
set GRABBER1=`cameras.csh $CAMERA1`;
set MACHINE1=$GRABBER1[1];
set GRAB1=$GRABBER1[2];
set FILE2=/video/grab.${CAMERA2}.${CAPTURE};
set GRABBER2=`cameras.csh $CAMERA2`;
set MACHINE2=$GRABBER2[1];
set GRAB2=$GRABBER2[2];

# Get the current time code
set TIME_START=`rsh $MACHINE1 $GRAB1 -g -a 00:${OFFSET}`;

#capture
echo
rsh $MACHINE1 $GRAB1 -start $TIME_START -end +00:${TIME} -s $STEP -o $FILE1 -l ${FILE1}.log &
rsh $MACHINE2 $GRAB2 -start $TIME_START -end +00:${TIME} -s $STEP -o $FILE2 -l ${FILE2}.log &
echo START TIME: $TIME_START
