# getM2 - C Shell script to download data from OASIS Controller # and extract the data # set TRUE = 1 set FALSE = 0 # # WARNING - if this is for oasis pre-deployment, make sure to # set SEND_SSDS = $FALSE below until you have the correct m2.cfg # file else you will ingest data into current deployment!!! set SEND_SSDS = $TRUE #set SEND_SSDS = $FALSE set OASIS = /oasis set CFG = $OASIS/cfg set RAW = $OASIS/raw set BIN = $OASIS/bin set CAN = m2 set ERROR_DIR = $OASIS/$CAN/error # # General # set FILEBASE = `date +%Y%j` # Missing Records File set RCDFILE = $RAW/oasis.rcd # Download Logs (old & new) set DLLOG = "dlinfo" set OLDLOG = "dlinfo.log" set noclobber set noglob # # extract Configuration # set EXTRACT = $BIN/extract set CFGFILE = $CFG/$CAN.cfg set EXTRACT_OPTS = "-r -f $RCDFILE -y 1 -c $CFGFILE" set DATAFILE = $CAN.$FILEBASE.00 set i = 0 while ( -e $RAW/$DATAFILE ) @ i++ set DATAFILE = $CAN.$FILEBASE.`printf "%02d" $i` end set ERRORFILE = $ERROR_DIR/$DATAFILE # # TNC Configuration # set TNC_CALL = "2010M2" set TNC_ADDR = "$TNC_CALL" # p: PACCOMM k: Kenwood n: None set TNC_TYPE = n # TNC_PORT now allows TCP download to an address:port_number. Enjoy! ###Enable for ORANGE radio/terminal server for M2-2010 set TNC_PORT = 134.89.45.22:10002 #Enable for BLUE radio/terminal server for M2-2010 #################set TNC_PORT = 134.89.45.23:10001 #zorba-lab qualtech DS400D Port1 #set TNC_PORT = 134.89.12.116:5000 # # getoasis Configuration # set DOWNLOAD = $BIN/getoasis set DOWNLOAD_OPTS = "-b 9600 -T $TNC_TYPE -p $TNC_PORT -a "$TNC_ADDR" -c $CAN -r $RCDFILE" # # Fail Mail # set FAILMAIL = "rich@mbari.org,erich@mbari.org,dfrench@mbari.org,kemi@mbari.org" set ENABLE_FAILMAIL = $FALSE set MAIL_SUBJECT = "Failed OASIS Download" # oasis (Tsunami/HPUX) set MAIL = "/bin/mailx -s " set MAIL_MSG = "** message from OASIS M2 $TNC_CALL **" ############################################# # Should not need to modify below this line # ############################################# cd $RAW # Record start of download set starttime = `date +"%x %H:%M:%S"` set starttime_es = `perl -e 'print time, "\n"'` # Download the data and record error status $DOWNLOAD $DOWNLOAD_OPTS >& $DATAFILE set rtnsts = $status # Record the end of download set endtime = `date +"%x %H:%M:%S"` set endtime_es = `perl -e 'print time, "\n"'` # Get the raw data filesize set filesize = `ls -l $DATAFILE | sed -f $BIN/fs.sed` # Log download statistics and submit to SSDS - IDs are unique for mooring deployment #sn/1 2010,2012,2014 etc set deviceId = 1699 set parentId = 1306 # sn/2 2011,2013 etc #set deviceId = 1769 #set parentId = ??????? unset noclobber echo "$DATAFILE,$starttime,$endtime,$filesize,$rtnsts" >> $DLLOG.$FILEBASE /oasis/bin/ssdsSubmit.pl $deviceId $parentId "$starttime_es,$endtime_es,$filesize,$rtnsts" & echo "$DATAFILE,$starttime,$endtime,$filesize,$rtnsts" >> $OLDLOG set noclobber # # Send failmail # if ($ENABLE_FAILMAIL == $TRUE) then if ( $rtnsts ) then $MAIL "$MAIL_SUBJECT" $FAILMAIL << ! Download failure of file $DATAFILE Return code was $rtnsts 0 = Success 1 = Argument error (bad command line arguments) 2 = Couldn't acquire TNC port (hung download or someone's using port) 3 = Couldn't connect to OASIS (it's not listening) 4 = Download error (something broke after it connected) 5 = Abort error (somebody killed the download) `date` $MAIL_MSG ! endif endif # Extract data if ( (-e $DATAFILE) && !(-z $DATAFILE) ) then echo "$EXTRACT $EXTRACT_OPTS $DATAFILE >& $ERRORFILE" $EXTRACT $EXTRACT_OPTS $DATAFILE >& $ERRORFILE #rip tstring for ssds processing echo "$BIN/riptstring -y 1 -c $CFGFILE $RAW/$DATAFILE" $BIN/riptstring -y 1 -c $CFGFILE $RAW/$DATAFILE endif # Remove error file if no errors if ( -z $ERRORFILE ) then rm -f $ERRORFILE endif # Send the data to SSDS # Added 20 Jan 2005 Bob Herlien # ### DO NOT ENABLE BELOW UNTIL SSDS INSTRUMENT CFG ### IS SET TO INGEST CORRECT INSTRUMENTS if ( $SEND_SSDS == $TRUE ) then echo "remsh elvis -l ssdsadmin dev/DPforSSDS/oasis/bin/oasisToSSDS -c $CFGFILE $RAW/$DATAFILE" remsh elvis -l ssdsadmin dev/DPforSSDS/oasis/bin/oasisToSSDS -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN.persist $RAW/$DATAFILE & # process an oasis binary file which is intended to be a modified tstring-only datafile echo "remsh elvis -l ssdsadmin dev/DPforSSDS/oasis/bin/oasisToSSDS -b -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN.tso.persist $RAW/$DATAFILE.tso" remsh elvis -l ssdsadmin dev/DPforSSDS/oasis/bin/oasisToSSDS -b -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN.tso.persist $RAW/$DATAFILE.tso & # mv $RAW/$DATAFILE.tso $RAW/erase endif