#!//bin/tcsh

# $1 0=all rocs  
# $2 VERSION NUMBER
# $3 threshold
# $4 number of triggers

if ($#argv < 4) then
    echo "Insufficent parameters:"
    echo " ./startall.csh ROC VERSION THRESHOLD TRIGGERS"
    echo "                ROC = 0 start all ROCS"
    exit
endif

if ($1 == 0) then
    echo "Start up all FDC ROCS with version "$2" threshold "$3" and triggers: "$4
    echo 'ROC2'
    ssh hdfdcops@rocfdc2 /home/hdfdcops/scripts/startupadcs.csh 2 $2 14 $3 $4 \&
    echo 'ROC3'
    ssh hdfdcops@rocfdc3 /home/hdfdcops/scripts/startupadcs.csh 3 $2 14 $3 $4 \&
    echo 'ROC5'
    ssh hdfdcops@rocfdc5 /home/hdfdcops/scripts/startupadcs.csh 5 $2 14 $3 $4 \&
    echo 'ROC6'
    ssh hdfdcops@rocfdc6 /home/hdfdcops/scripts/startupadcs.csh 6 $2 15 $3 $4 \&
    echo 'ROC7'
    ssh hdfdcops@rocfdc7 /home/hdfdcops/scripts/startupadcs.csh 7 $2 15 $3 $4 \& 
    echo 'ROC8'
    ssh hdfdcops@rocfdc8 /home/hdfdcops/scripts/startupadcs.csh 8 $2 14 $3 $4 \& 
    echo 'ROC9'
    ssh hdfdcops@rocfdc9 /home/hdfdcops/scripts/startupadcs.csh 9 $2 15 $3 $4 \& 
    echo 'ROC10'
    ssh hdfdcops@rocfdc10 /home/hdfdcops/scripts/startupadcs.csh 10 $2 15 $3 $4 \&  
    echo 'ROC11'
    ssh hdfdcops@rocfdc11 /home/hdfdcops/scripts/startupadcs.csh 11 $2 14 $3 $4 \&  
    echo 'ROC12'
    ssh hdfdcops@rocfdc12 /home/hdfdcops/scripts/startupadcs.csh 12 $2 14 $3 $4 \&  
else
    if ((($1 > 1) && ($1 < 4)) || (($1 > 4) && ($1<13))) then
	echo "Start up all FDC ROC "$1" with version "$2" threshold "$3" and triggers: "$4
	
	ssh -f hdfdcops@rocfdc$1 /home/hdfdcops/scripts/startupadcs.csh $1 $2 14 $3 $4 \&
    endif
endif
