endladcp1
changeset 0 648bde652211
child 4 fda11de1826e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/endladcp1	Mon Oct 12 16:56:59 2009 -0400
@@ -0,0 +1,113 @@
+#!/usr/bin/expect -f
+#======================================================================
+#                    E N D L A D C P 1 
+#                    doc: Wed Mar 10 22:23:52 2004
+#                    dlm: Wed Nov 19 15:13:10 2008
+#                    (c) 2004 A.M. Thurnherr
+#                    uE-Info: 28 14 NIL 0 0 72 2 2 8 NIL ofnI
+#======================================================================
+
+# HISTORY:
+#  Apr  4, 2004: - adapted from [endladcp2]
+#  Jun 18, 2004: - BUG: could not handle station 008 (illegal octal digit)
+#  Jan 25, 2005: - BUG: bbabble could not be in relative path (on MacOSX)
+#  Feb 14, 2006: - BUG: log files were written to bin dir
+#  Oct  4, 2006: - adapted to older expect version
+#  Oct 28, 2006: - allowed for lrb downcasing filenames
+#  Nov 19, 2008: - added version
+
+#----------------------------------------------------------------------
+# Setup
+#----------------------------------------------------------------------
+
+log_user 0;
+source DEFAULTS.expect;
+regsub {dir1} [exec which dir1] {libBB.expect} path;
+source $path;
+
+print_version;
+
+if ![file isdirectory $raw_dir] {
+	error "directory $raw_dir does not exist";
+}
+
+if {$argc != 0} {
+  if {![affirm "downloading files to directory [lindex $argv 0] --- ok (y/N)? " 10]} {
+    exit;
+  }
+}
+
+#----------------------------------------------------------------------
+# Get Station Number
+#----------------------------------------------------------------------
+
+spawn bbabble -ms $tty0;
+
+set_color;
+send_user "Connecting to instrument...";
+wait_for_startup;
+reset_instrument;
+
+send_user "\nGetting station number...";
+set deployment_name [get_deployment_name];
+if {[scan $deployment_name $master_deployment_name_fmt stn] != 1} {
+	send_error "$deployment_name $master_deployment_name_fmt";
+	error "Can't get station number";
+}
+set stnstr [format $stn_format $stn];
+send_user "\[$stnstr\]";
+
+set cast_dir [format %s/%s $raw_dir $stnstr];
+if {![file isdirectory $cast_dir]} {
+	put_to_sleep;
+	error "cast directory $cast_dir does not exist!";
+}
+regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble;
+
+if {$argc == 1} {				# override download directory
+	set cast_dir [lindex $argv 0];
+	if {![file isdir $cast_dir]} {exec mkdir $cast_dir}
+}
+
+cd $cast_dir;
+if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} {
+	put_to_sleep;
+	error "cast directory [pwd] contains RDI data files!";
+}
+
+send \004;
+
+#----------------------------------------------------------------------
+# Download Data
+#----------------------------------------------------------------------
+
+regsub {.*/} $argv0 {} basename;
+start_logging [format %s_%s.log $basename $stnstr];
+
+spawn $bbabble -ms $tty0;
+wait_for_startup;
+
+send_user "\nSaving hardware configuration...";
+save_hardware_config [format %s000.LOG $deployment_name];
+resume_logging [format %s_%s.log $basename $stnstr];
+
+send_user "\nStarting download...";
+start_download;
+
+send_user "\n";
+set_color 0;
+log_user 1; wait_for_download_finish $stn $download_timeout; log_user 0;
+set_color;
+
+send_user "\nPutting instrument to sleep...";
+put_to_sleep;
+	
+send_user "\nChecking data file...\n";
+set_color 0;
+check_data [format %s000.000 [format $master_deployment_name_fmt $stn]];
+set_color;
+
+send_user "Backing up data file...";
+backup_master_data $stn;
+
+send_user "\nDone\n"