CRUISE_SETUP.expect
changeset 5 f41d45fe7ae9
parent 4 fda11de1826e
child 6 1ab5767c18dd
--- a/CRUISE_SETUP.expect	Tue Sep 14 13:34:39 2010 -0400
+++ b/CRUISE_SETUP.expect	Fri Dec 10 15:29:27 2010 +0000
@@ -1,9 +1,9 @@
 #======================================================================
 #                    C R U I S E _ S E T U P . E X P E C T 
 #                    doc: Wed Mar 10 21:14:18 2004
-#                    dlm: Thu Aug 26 19:49:03 2010
+#                    dlm: Fri Dec 10 15:19:49 2010
 #                    (c) 2004 A.M. Thurnherr
-#                    uE-Info: 118 24 NIL 0 0 72 2 2 8 NIL ofnI
+#                    uE-Info: 198 69 NIL 0 0 72 2 2 8 NIL ofnI
 #======================================================================
 
 #--------
@@ -18,12 +18,14 @@
 # Jan 19, 2006: - updated documentation
 #		- allowed for empty-string time_server
 # Nov  4, 2006: - changed backup dir structure
-# Aug 25, 2010: - rename* funs modified to allow them to be used to 
+# Aug 25, 2010: - rename* funs modified to allow them to be used to ensure
 #		  that downladed file names have correct case
 #		- renamed from DEFAULTS.expect to CRUISE_SETUP.expect
 # Aug 26, 2010: - added ymodem_receive_cmd
 #		- changed default string quotes to {} to prevent Tcl variable
 #		  and command substitutions
+# Oct 18, 2010: - changed comment for ymodem_receive_cmd to account for the
+#		  fact that bbabble now uses the -u option by default
 
 #-----------
 # TWEAKABLES
@@ -31,13 +33,16 @@
 
 # At the beginning of each cast, the clock of the acquisition computer should
 # synchronized with the master clock used for timestamping the GPS information.
-# The easiest way to accomplish this is by probing an NTP server on the ship
-# (if there is one), which can be defined by setting the following variable.
-# If there is no such server available, the variable should be set to the
-# empty string (set time_server {}), in which case clock synchronization must
-# be done differently (e.g. manually).
+# The best way to accomplish this is to run a NTP daemon (e.g. ntpd) polling
+# an NTP server on the ship.
+# If running ntpd is inconvenient or not possible, the follwing variable can
+# be set to the name of the NTP server, in which case the time is sync'ed
+# at the beginning of each cast with the function set_computer_time (defined
+# below).
+# If there is no NTP server available, the variable should be set to the
+# empty string and the clock must be sync'ed manually.
 
-set time_server	{199.92.161.2};
+set time_server	{};
 
 # bbabble needs to know the tty device name(s) of the serial connection(s)
 # to the ADCP head(s). If only one head is connected, tty1 is ignored.
@@ -68,13 +73,9 @@
 # slave. The following variables variables define the printf(3) format
 # that is used to create the files names from the station number. If only
 # a single head is connected, the slave_* variable is ignored.
-# NOTE: Some implementations of the ymodem protocol (notably lrb running
-#	under Mandrake 8) use lowercase for the downloaded file. It is
-#	therefore better to use only lowercase characters in the deployment
-#	names.
 
-set master_deployment_name_fmt	{%03ddn};
-set slave_deployment_name_fmt	{%03dup};
+set master_deployment_name_fmt	{%03dDL};
+set slave_deployment_name_fmt	{%03dUL};
 
 # Older RDI instruments (e.g. the BB150) do not allow the data-file name
 # to be defined in the instrument, in which case the files have to be
@@ -109,11 +110,10 @@
 set backup_dir {../../backup/raw};
 
 # By default, bbabble will look for standard UN*X ymodem receive
-# programs (rb and lrb). If neither of these exist, if neither is in the
-# current $PATH, or if options have to be passed (as is the case on some
-# Linux distributions to ensure that the downloaded files have consistent
-# (upper-)case filenames, the following variable can be set to a non-empty
-# string, such as {rb -u}
+# programs (rb and lrb) and call the first one it finds with the
+# -u option. If neither of the standard programs exist, if neither is in the
+# current $PATH, or if non-standard options have to be passed the following
+# variable can be set to a non-empty string, such as {/sw/bin/rb -u}
 
 set ymodem_receive_cmd {}
 
@@ -126,47 +126,77 @@
 # Semi-Standard Functions
 #----------------------------------------------------------------------
 
+# The program for polling an NTP server is different on different
+# UN*X systems. Either rdate or ntpdate should be available. Note
+# that sudo will propt for the login password of the user running
+# the LADCP acquisition, unless it is explicitly set to allow execution
+# of the command without a password.
+
 proc set_computer_time {} {				# set computer clock
 	global time_server;
 	if {[string length $time_server] == 0} {return}
 	exec sudo rdate -s $time_server;
+#	exec sudo ntpdate -s $time_server;
 }
 
+#----------------------------------------------------------------------
+
+# After the LADCP data files have been downloaded they should be
+# checked. A simple yet effective check consists in estimating the
+# bottom depth (zmax) and end depth (zend) by time-integrating the
+# vertical-velocity measurements. There are two different publicly
+# available programs to accomplish this: scanbb from the UH LADCP
+# software suite, and mkProfile from the perl-utilities available
+# from the LDEO LADCP repository.
+
 proc check_data {file} {				# check data file
-	exec sh -c "scanbb $file";
-	exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty";
+	exec sh -c "mkProfile -Q $file 2> `basename $file .000`.profinfo";
+	exec sh -c "cat `basename $file .000`.profinfo > /dev/tty";
+#	exec sh -c "scanbb $file";
+#	exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty";
 }
 
-proc backup_master_data {stn} {				# copy data to network
-	global master_deployment_name_fmt master_cmd_file backup_dir;
+#----------------------------------------------------------------------
+
+# The following two routines backup the master and slave files from the
+# raw directory. 
+
+proc backup_master_data {stn} {
+	global stn_fmt master_deployment_name_fmt master_cmd_file backup_dir;
 	if {[string length $backup_dir] == 0} {return}
 
 	if {![file isdirectory $backup_dir]} {
 		error "$backup_dir does not exist relative to [pwd]";
 	}
 
-	set master_dir [format $backup_dir/$master_deployment_name_fmt $stn];
-	if {![file isdirectory $master_dir]} {exec mkdir $master_dir};
-	exec sh -c "cp [format $master_deployment_name_fmt $stn]* $master_dir";
-	exec sh -c "cp $master_cmd_file* $master_dir";
-	exec sh -c "cp *log $master_dir";
+	set stnstr [format $stn_format $stn];
+	set cast_dir [format %s/%s $backup_dir $stnstr];
+	if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir};
+	exec sh -c "cp [format $master_deployment_name_fmt $stn]* $cast_dir";
+	exec sh -c "cp $master_cmd_file* $cast_dir";
+	exec sh -c "cp *log $cast_dir";
 }
 	
 proc backup_slave_data {stn} {				# copy data to network
-	global slave_deployment_name_fmt slave_cmd_file backup_dir;
+	global stn_fmt slave_deployment_name_fmt slave_cmd_file backup_dir;
 	if {[string length $backup_dir] == 0} {return}
 
 	if {![file isdirectory $backup_dir]} {
 		error "$backup_dir does not exist relative to [pwd]";
 	}
 
-	set slave_dir [format $backup_dir/$slave_deployment_name_fmt $stn];
-	if {![file isdirectory $slave_dir]} {exec mkdir $slave_dir};
-	exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $slave_dir";
-	exec sh -c "cp $slave_cmd_file* $slave_dir";
-	exec sh -c "cp *log $slave_dir";
+	set stnstr [format $stn_format $stn];
+	set cast_dir [format %s/%s $backup_dir $stnstr];
+	if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir};
+	exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $cast_dir";
+	exec sh -c "cp $slave_cmd_file* $cast_dir";
+	exec sh -c "cp *log $cast_dir";
 }
 
+#----------------------------------------------------------------------
+
+# See comments on master_download_glob and slave_download_glob above.
+
 proc rename_master_download_file {target} {		# rename after download 
 	global master_download_glob;
 	
@@ -206,3 +236,5 @@
 		exec mv [lindex $files end] $target;
 	}
 }
+
+