#
# testdaq wrapper
# Hagar Landsman April 2006
#
# wrapper to run testdaq using hub only
# Generate steering files
# ready
# go
#########################################
cd ~/fat-config
mkdir $1$2
cd $1$2
dtsxinit
~/bin/autogen-wrapper
# hagar-add check that correct number of doms was ofuund
# hagar - add check that enough/recent domcal files are in ~/domcal
cp *.xml ~/fat-config/.
ndoms=0
let ndoms=2+$FAT_NDOMS
n=0
n=`ls -ltr ~/fat-config | grep xml -c`
l=0
l=`grep domId ~/fat-config/DarkNoise-ATWD0.xml -c`
echo $l $ndoms $FAT_NDOMS
if [ $l -ne $ndoms ]; then
	echo 'missing doms testdaq files in ~/fat-config'
	echo 'script will continue, ctrl-c now to abort...counting to ten...'
	sleep 10
	echo'....9,10...starting testdaq'
fi
m=0
m=`ls -ltr ~/domcal | grep xml -c`
if [ $m -ne $ndoms ]; then
	echo 'missing domcal xml filesin ~/domcal '
	echo 'script will continue, ctrl-c now to abort...counting to ten...'
	sleep 10
	echo'....9,10...starting testdaq'
fi
echo $n different xml files were generated
echo For $l doms out of $ndoms DOMs, 
echo Found $m domcal files
sleep 10
off all
nohup ready &
line="11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
sleep 5
while [ "${line:38}" != "Waiting for RMI method calls" ]
do
        line=`tail -n1 ~/domhubapp.log`
	echo line=$line
done
echo Ready to start: go FAT $FAT_NUM, at $1$2
go FAT $FAT_NUM, at $1$2
exit
