head	1.8;
access;
symbols
	Hobson_Rock_14Dec2009:1.8
	BEFORE_VCS_CHANGE:1.8
	Hobson_Rock_16Oct2009:1.8
	Hobson_Rock_29June2009:1.8
	mar19_2009:1.8
	mar18_2009:1.8
	feb13_2009:1.8
	feb10-2009:1.8
	feb09-2009:1.8
	dec15_2008:1.8
	dec12_2008:1.8
	ST_10_5:1.8
	ST_10_4b:1.8
	ST_10_4:1.8
	ST_10_3:1.8
	ST10_HW:1.8
	ST_10_2:1.8
	ST_10_1:1.8
	ST_10_0:1.8
	AUTONOMY_BRANCH:1.8.0.2
	AUTONOMY:1.8
	AUTONOMY-2008_07_30:1.8;
locks; strict;
comment	@# @;


1.8
date	2006.09.06.17.16.15;	author rob;	state Exp;
branches;
next	1.7;

1.7
date	2006.07.14.23.04.28;	author rob;	state Exp;
branches;
next	1.6;

1.6
date	2006.03.11.00.42.35;	author sib;	state Exp;
branches;
next	1.5;

1.5
date	2004.11.09.00.50.30;	author rob;	state Exp;
branches;
next	1.4;

1.4
date	2004.11.05.22.58.03;	author sib;	state Exp;
branches;
next	1.3;

1.3
date	2004.11.05.19.19.59;	author rob;	state Exp;
branches;
next	1.2;

1.2
date	2004.11.05.00.42.52;	author sib;	state Exp;
branches;
next	1.1;

1.1
date	2004.11.04.23.35.12;	author rob;	state Exp;
branches;
next	;


desc
@@


1.8
log
@Changed hardcoded log file name "resetdw.log" to an enviormental variable.
@
text
@#! /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.
SERVER=0   #Drop weight server state.  1=> Server running; 0=> not running.
FIRST=0
DATE=`date`
LOGNAME=resetdw.log
while [ true ]; do 
    clear;
    echo " "
    echo " "
    if [ $CNTCT = 0 ]; then
	if [ $FIRST = 0 ]; then
	    echo "resetdw is starting..."
	    echo "`date` resetdw is starting..." >> $LOGNAME
	    FIRST=1
	else
	    echo "Contact regained at $DATE"
	    echo "`date` Contact regained at $DATE" >> $LOGNAME
	fi
    else
	echo "Contact lost at $DATE"
	echo "`date` Contact lost at $DATE" >> $LOGNAME
	if [ $SERVER = 1 ]; then
	echo -e '\E[41;41m                                                 '
	echo -e '\E[41;41m                                                 '
	    echo "Drop weight server not running.                  "
	    echo "`date` Drop weight server not running." >> $LOGNAME
	    let TLEFT=(TSTART-$(date +%s))/60
	    if [ $TLEFT -gt 0 ]; then
		echo -e "WEIGHT WILL DROP IN $TLEFT MINUTES.                  "
		echo -e "`date` WEIGHT WILL DROP IN $TLEFT MINUTES." >> $LOGNAME
		if [ $TLEFT -lt 13 ]; then
		    sleep 1
		    echo -e '\E[41;41m \a                                                '
		    sleep 1
		    echo -e '\E[41;41m \a                                                '
		    sleep 1
		    echo -e '\E[41;41m \a                                                '
		fi

	   #echo -e '\E[41;37mWEIGHT WILL DROP IN $TLEFT MINUTES.          '
	    else
		let TSINCE=-$TLEFT
		echo "The weight dropped $TSINCE minutes ago."
		echo "`date` The weight dropped $TSINCE minutes ago.">> $LOGNAME
	    fi
	echo -e '\E[41;41m                                                 '
	echo -e '\E[41;41m                                                 '
	tput sgr0
	else
	    echo "Drop weight server detected."
	    echo "`date` Drop weight server detected." >> $LOGNAME
	fi
    fi
    cat temp.txt | grep DropWeightServer &> /dev/null
    LASTSERVER=$?
    rsh -l dorado1 $AUV_HOST 'if [ `slay -pQ dropWeightServer` ]; then echo "DropWeightServer Detected"; else "reset"; fi' &>temp.txt
    RETVAL=$?
    cat temp.txt >> $LOGNAME
    cat temp.txt
    cp temp.txt tempLast.txt
    if [ $RETVAL != 0 ] ; then
	if [ $CNTCT = 0 ]; then
	    DATE=`date`
	    SERVER=$LASTSERVER
	    let TSTART=$(date +%s)+900
	    cp tempLast.txt tempLost.txt
	fi
	CNTCT=1
	sleep 5
    else
	if [ $CNTCT = 1 ]; then
	    DATE=`date`
	fi
	CNTCT=0
	sleep 10
    fi
done
@


1.7
log
@Added an audible alarm if the weight is going to drop.  Also added logging to
the file resetdw.log.
@
text
@d11 1
d19 1
a19 1
	    echo "`date` resetdw is starting..." >> resetdw.log
d23 1
a23 1
	    echo "`date` Contact regained at $DATE" >> resetdw.log
d27 1
a27 1
	echo "`date` Contact lost at $DATE" >> resetdw.log
d32 1
a32 1
	    echo "`date` Drop weight server not running." >> resetdw.log
d36 1
a36 1
		echo -e "`date` WEIGHT WILL DROP IN $TLEFT MINUTES." >> resetdw.log
d50 1
a50 1
		echo "`date` The weight dropped $TSINCE minutes ago.">> resetdw.log
d57 1
a57 1
	    echo "`date` Drop weight server detected." >> resetdw.log
d64 1
a64 1
    cat temp.txt >> resetdw.log
@


1.6
log
@added support for AUV_HOST env variable to scripts
@
text
@d9 1
d16 8
a23 1
	echo "Contact regained at $DATE"
d26 1
d31 1
d34 11
a44 1
		echo "WEIGHT WILL DROP IN $TLEFT MINUTES.                  "
d49 1
d56 1
d63 1
@


1.5
log
@Added code  to detect the drop weight server when contact is lost, and
display a warning if it isn't detected.  Added some cool red color for
a primitive GUI.
@
text
@d39 1
a39 1
    rsh -l dorado1 mvc-mb 'if [ `slay -pQ dropWeightServer` ]; then echo "DropWeightServer Detected"; else "reset"; fi' &>temp.txt
@


1.4
log
@Changed shell variable to file method.
@
text
@d12 2
d18 15
a32 4
	echo "$SERVER"
	if [ $SERVER = 0 ]; then
	    echo "Drop weight server not running."
	    echo "WEIGHT WILL DROP IN xx MINUTES."
d37 2
d42 1
a42 1
    echo "RETVAL=$RETVAL"
d46 3
a48 2
	    SERVER=$(cat temp.txt | grep dropWeightServer &> /dev/null)
	    echo "$SERVER"
@


1.3
log
@Added detection of the drop weight server.
@
text
@d16 1
d24 1
a24 1
    RSTAT=$(rsh -l dorado1 mvc-mb 'if [ `slay -pQ dropWeightServer` ]; then echo "DropWeightServer Detected"; else "reset"; fi' 2>&1) 
d26 1
a26 1
    echo "$RSTAT"
d31 2
a32 1
	    SERVER=$(echo $RSTAT | grep dropWeightServer &> /dev/null)
@


1.2
log
@Fixed the "if" statement in the rsh.  Moved the "contact lost" echo up so that
the user has time to read it before it gets cleared.
@
text
@d7 2
a8 1
i=0
d12 1
a12 1
    if [ $i = 0 ]; then
d16 6
d23 1
a23 1
    rsh -l dorado1 mvc-mb 'if [ `slay -pQ dropWeightServer` ]; then echo "DropWeightServer Detected"; else "reset"; fi'
d25 2
d28 1
a28 1
	if [ $i = 0 ]; then
d30 1
d32 1
a32 2
#	echo "Contact lost at $DATE"
	i=1
d35 1
a35 1
	if [ $i = 1 ]; then
d38 1
a38 1
	i=0
@


1.1
log
@This script is designed to run on Cygwin on the ship.  It rsh'es into the AUV
and resets the dropweight watchdog.  Now, if the AUV should sink after a normal
mission termination, the weight will still drop.
@
text
@d13 2
d16 1
a16 1
    rsh -l dorado1 mvc-mb 'if [ -n `slay -pQ dropWeightServer` ]; then "reset"; else echo "DropWeightServer Detected"; fi'
d22 1
a22 1
	echo "Contact lost at $DATE"
@

