#!/bin/csh # ## Copyright (C) 2001 MBARI # Author: Kent Headley # MBARI provides this documentation and code "as is", with no warranty, # express or implied, of its quality or consistency. It is provided without # support and without obligation on the part of the Monterey Bay Aquarium # Research Institute to assist in its use, correction, modification, or # enhancement. This information should not be published or distributed to # third parties without specific written permission from MBARI. # getMooring - C Shell script to download data from OASIS Controller #    and extract the data # # Must use full DOS path instead of symlink to /oasis since tclsh80 converts # UNIX ('/') paths to DOS ('\') paths set TRUE = 1 set FALSE = 0 set DEPLOYMENT=202507 set CAN_MASTER=m1 set CAN_SLAVE=$FALSE if ( $CAN_SLAVE == $FALSE) then set CAN = $CAN_MASTER else set CAN = $CAN_MASTER-$CAN_SLAVE endif set ERROR_DIR = /mbari/oasis_coredata/deployments/$CAN/$DEPLOYMENT/$CAN/error set RAW = /mbari/oasis_coredata/deployments/$CAN/$DEPLOYMENT/raw set CFG = /mbari/oasis_coredata/deployments/$CAN/$DEPLOYMENT/cfg set BIN = /u/coredata/moorings/downloads/bin ############################################## # 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/extract2 set CFGFILE = $CFG/$CAN.cfg set EXTRACT_OPTS = "-B -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 = "2025M1" set TNC_ADDR = "$TNC_CALL" set TNC_TYPE = n #the deployed vipr address TBD #Viper Blue  134.89.45.24 #Viper Red  134.89.45.27 #Viper Green 134.89.45.28 #Viper Yellow 134.89.45.29 #192.168.101.x maps to 134.89.45.n:10000 #192.168.102.x maps to 134.89.45.n:20000 #192.168.103.x maps to 134.89.45.n:30000 #192.168.104.x maps to 134.89.45.n:40000 ##### TURN OFF AFTER TESTING !!!!! ## For testing lab qualtech DS400D Port1 - in the BirdCage ## ENABLE HERE for Bird Cage Lab testing on the MBARI network ##set TNC_PORT = 134.89.12.116:5001 ##### Do Not worry about these settings for deployment at this time ### *** Verify port number befor enabling!!! #####set TNC_PORT = 134.89.45.28:10000 #####set TNC_PORT = 134.89.45.28:20000 #####set TNC_PORT = 134.89.45.28:30000 ## Radio on 202406 - KS (14Jun2024) ##set TNC_PORT = 134.89.45.29:20000 ## ENABLE HERE for dockside testing (KS on 15Jun2024) ##set TNC_PORT = 134.89.45.29:20000 ## ENABLE HERE for dockside testing (KS on 18Jun2024) ##set TNC_PORT = 134.89.45.29:30000 ############################################ ## Radio on 202507 - KS (18Jun2025) set TNC_PORT = 134.89.45.29:30000 ############################################# # getoasis Configuration ############################################# if ( $CAN_SLAVE == $FALSE) then set DOWNLOAD = $BIN/vipr4slaves ####set DOWNLOAD = $BIN/vipr4slaves.10sec set DOWNLOAD_OPTS = " -p $TNC_PORT -c $CAN_MASTER -r $RCDFILE -n 30" else set DOWNLOAD = $BIN/vipr4slaves ####set DOWNLOAD = $BIN/vipr4slaves.10sec set DOWNLOAD_OPTS = " -p $TNC_PORT -c $CAN_MASTER -s $CAN_SLAVE -r $RCDFILE -n 30" endif ############################################# # Fail Mail ############################################# set ENABLE_FAILMAIL = $TRUE #set ENABLE_FAILMAIL = $FALSE set FAILMAIL = "jared@mbari.org,salamy@mbari.org" set MAIL_SUBJECT = "Failed M1 Download" # oasis (Tsunami/HPUX) set MAIL = "/bin/mailx -s " set MAIL_MSG = "** message from OASIS $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 echo "$DOWNLOAD $DOWNLOAD_OPTS >& $DATAFILE" $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 #deviceId is ssds virtual device for download process #parentId is the ssds id for the toroid ### EVEN YEARS ### ### sn/1 2012, 2014, 2016, 2018, 2020, 2022, 2024, 2026 etc #set deviceId = 1698 #set parentId = 1414 ### ODD YEARS ### #sn/2 2013, 2015, 2017, 2019, 2021, 2023, 2025, 2027 etc set deviceId = 1768 set parentId = 1305 unset noclobber echo "$DATAFILE,$starttime,$endtime,$filesize,$rtnsts" >> $DLLOG.$FILEBASE $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/riptstring2 -b -y 1 -c $CFGFILE $RAW/$DATAFILE" $BIN/riptstring2 -b -y 1 -c $CFGFILE $RAW/$DATAFILE endif ############################################# # Remove error file if no errors ############################################# if ( -z $ERRORFILE ) then rm -f $ERRORFILE endif set SEND_SSDS = $TRUE #######set SEND_SSDS = $FALSE if ( $SEND_SSDS == $TRUE ) then  echo " ssh -i /etc/ssh/keys/coredata/id_dsa -l ssdsadmin elvis dev/DPforSSDS/oasis/bin/oasisToSSDS -b -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN.pe rsist $RAW/$DATAFILE &"   ssh -i /etc/ssh/keys/coredata/id_dsa -l ssdsadmin elvis dev/DPforSSDS/oasis/bin/oasisToSSDS -b -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 " ssh -i /etc/ssh/keys/coredata/id_dsa -l ssdsadmin elvis dev/DPforSSDS/oasis/bin/oasisToSSDS -b -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN. tso.persist $RAW/$DATAFILE.tso"   ssh -i /etc/ssh/keys/coredata/id_dsa -l ssdsadmin elvis dev/DPforSSDS/oasis/bin/oasisToSSDS -b -c $CFGFILE -persistFile /mbari/ssdsdata/mooring/$CAN.tso.per sist $RAW/$DATAFILE.tso   mv $RAW/$DATAFILE.tso $RAW/erase endif