#! /bin/bash
#
# PURPOSE:      Reset the dropweight watchdog from the ship.
# FIRST AUTHOR: Rob McEwen, 3 Nov 2004, a sad day.
# CHANGE LOG:
#
CNTCT=0    #Contact state.  0 => AUV present; 1 => no contact.
DATE=`date`
while [ true ]; do 
    clear;
    if [ $CNTCT = 0 ]; then
	echo "Contact regained at $DATE"
    else
	echo "Contact lost at $DATE"
    fi
    rsh -l dorado1 mvc-mb 'if [ `slay -pQ dropWeightServer` ]; then echo "DropWeightServer Detected"; else "reset"; fi'
    RETVAL=$?
    if [ $RETVAL != 0 ] ; then
	CNTCT=1
	sleep 5
    else
	if [ $CNTCT = 1 ]; then
	    DATE=`date`
	fi
	CNTCT=0
	sleep 10
    fi
done
