1 #====================================================================== |
|
2 # D E F A U L T S . E X P E C T |
|
3 # doc: Wed Mar 10 21:14:18 2004 |
|
4 # dlm: Sat Nov 4 04:19:14 2006 |
|
5 # (c) 2004 A.M. Thurnherr |
|
6 # uE-Info: 26 46 NIL 0 0 72 2 2 8 NIL ofnI |
|
7 #====================================================================== |
|
8 |
|
9 #-------- |
|
10 # HISTORY |
|
11 #-------- |
|
12 |
|
13 # Mar 10, 2004: - created during NBP0402 |
|
14 # Apr 4, 2004: - final version NBP0402 |
|
15 # Jun 14, 2004: - copied for CLIVAR P02 |
|
16 # Jun 15, 2004: - adapted to BB150/Workhorse setup |
|
17 # Jun 16, 2004: - ditto |
|
18 # Jun 19, 2004: - BUG: could not handle multiple BB150 data files |
|
19 # Dec 20, 2004: - adapted for CLIVAR A16S |
|
20 # Jan 19, 2006: - updated documentation |
|
21 # - allowed for empty-string time_server |
|
22 # Oct 3, 2006: - adapted for LADDER cruise |
|
23 # Oct 28, 2006: - continued |
|
24 # Nov 1, 2006: - change master/slave serial numbers after CTD4 |
|
25 # (should have been done after CTD3, but I spaced; A.T.) |
|
26 # Nov 4, 2006: - changed backup dir structure |
|
27 # Nov 11,2006: - slave away as beam1 is broken (but did not work since |
|
28 # CTD15 on Nov 16; F.T) |
|
29 |
|
30 #----------- |
|
31 # TWEAKABLES |
|
32 #----------- |
|
33 |
|
34 # At the beginning of each cast, the clock of the acquisition computer should |
|
35 # synchronized with the master clock used for timestamping the GPS information. |
|
36 # The easiest way to accomplish this is by probing an NTP server on the ship |
|
37 # (if there is one), which can be defined by setting the following variable. |
|
38 # If there is no such server available, the variable should be set to the |
|
39 # empty string (set time_server ""), in which case clock synchronization must |
|
40 # be done differently (e.g. manually). |
|
41 |
|
42 set time_server "199.92.161.2"; |
|
43 |
|
44 # bbabble needs to know the tty device name(s) of the serial connection(s) |
|
45 # to the ADCP head(s). If only one head is connected, tty1 is ignored. |
|
46 # If two heads are connected, the device names are exchangeable, i.e. |
|
47 # either instrument can be connected to either port. |
|
48 |
|
49 set tty0 "/dev/ttyS0"; |
|
50 set tty1 "/dev/ttyS1"; |
|
51 |
|
52 # In case of 2 ADCP heads, babble needs to know which is the master and |
|
53 # which is the slave. This is accomplished by setting the following variables |
|
54 # to the corresponding instrument serial numbers (PS0 output). By convention, |
|
55 # the downlooker is the master. If only a single head is connected, both |
|
56 # variables are ignored. |
|
57 |
|
58 set master_sn 7877; |
|
59 set slave_sn 1412; |
|
60 |
|
61 # Before deployment, every ADCP head has to be programmed by sending it |
|
62 # a corresponding command file, defined by the following variables. If only |
|
63 # a single head is connected, the slave_* variable is ignored. |
|
64 |
|
65 set master_cmd_file "MASTER.cmd"; |
|
66 set slave_cmd_file "SLAVE.cmd"; |
|
67 |
|
68 # For convenience, it is best to use the station number to name the ADCP data |
|
69 # files, and to indicate whether the data file comes from the master or |
|
70 # slave. The following variables variables define the printf(3) format |
|
71 # that is used to create the files names from the station number. If only |
|
72 # a single head is connected, the slave_* variable is ignored. |
|
73 # NOTE: Some implementations of the ymodem protocol (notably lrb running |
|
74 # under Mandrake 8) use lowercase for the downloaded file. It is |
|
75 # therefore better to use only lowercase characters in the deployment |
|
76 # names. |
|
77 |
|
78 set master_deployment_name_fmt "%03ddn"; |
|
79 set slave_deployment_name_fmt "%03dup"; |
|
80 |
|
81 # Older RDI instruments (e.g. the BB150) do not allow the data-file name |
|
82 # to be defined in the instrument, in which case the files have to be |
|
83 # renamed after downloading. The following variables define the shell |
|
84 # globbing patterns for the master and slave. For example, the UH BB150 |
|
85 # used during CLIVAR P02 generated files with extension .612; the coresponding |
|
86 # globbing pattern is "*.612". If only a single head is connected, the |
|
87 # slave_* variable is ignored. |
|
88 |
|
89 set master_download_glob ""; |
|
90 set slave_download_glob ""; |
|
91 |
|
92 # For consistency it is nicest if low station numbers contain leading |
|
93 # zeroes. The following variable defines the corresponding printf(3) format. |
|
94 |
|
95 set stn_format "%03d"; |
|
96 |
|
97 # The following directory is used to store command files, instrument |
|
98 # configurations and ADCP data. Separate subdirectories (named according to |
|
99 # stn_format) are used for each cast. |
|
100 |
|
101 set raw_dir "../data/raw"; |
|
102 |
|
103 # After downloading, the data directory is backed up to the following |
|
104 # directory. Make sure that it resides on a different disk than raw_dir. |
|
105 # Empty string disables backup for testing purposes. |
|
106 # NOTE: RELATIVE PATHNAMES MUST START FROM CAST DIR (NOT ACQUISITION DIR) |
|
107 |
|
108 set backup_dir "../../backup/raw"; |
|
109 |
|
110 # bbabble can be made to abort downloading after a preset amount of time, |
|
111 # defined by the following variable. |
|
112 |
|
113 set download_timeout 999999; |
|
114 |
|
115 #---------------------------------------------------------------------- |
|
116 # Semi-Standard Functions |
|
117 #---------------------------------------------------------------------- |
|
118 |
|
119 proc set_computer_time {} { # set computer clock |
|
120 global time_server; |
|
121 if {[string length $time_server] == 0} {return} |
|
122 exec sudo rdate -s $time_server; |
|
123 } |
|
124 |
|
125 proc check_data {file} { # check data file |
|
126 exec sh -c "scanbb $file"; |
|
127 exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty"; |
|
128 } |
|
129 |
|
130 proc backup_master_data {stn} { # copy data to network |
|
131 global master_deployment_name_fmt master_cmd_file backup_dir; |
|
132 if {[string length $backup_dir] == 0} {return} |
|
133 |
|
134 if {![file isdirectory $backup_dir]} { |
|
135 error "$backup_dir does not exist relative to [pwd]"; |
|
136 } |
|
137 |
|
138 set master_dir [format $backup_dir/$master_deployment_name_fmt $stn]; |
|
139 if {![file isdirectory $master_dir]} {exec mkdir $master_dir}; |
|
140 exec sh -c "cp [format $master_deployment_name_fmt $stn]* $master_dir"; |
|
141 exec sh -c "cp $master_cmd_file* $master_dir"; |
|
142 exec sh -c "cp *log $master_dir"; |
|
143 } |
|
144 |
|
145 proc backup_slave_data {stn} { # copy data to network |
|
146 global slave_deployment_name_fmt slave_cmd_file backup_dir; |
|
147 if {[string length $backup_dir] == 0} {return} |
|
148 |
|
149 if {![file isdirectory $backup_dir]} { |
|
150 error "$backup_dir does not exist relative to [pwd]"; |
|
151 } |
|
152 |
|
153 set slave_dir [format $backup_dir/$slave_deployment_name_fmt $stn]; |
|
154 if {![file isdirectory $slave_dir]} {exec mkdir $slave_dir}; |
|
155 exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $slave_dir"; |
|
156 exec sh -c "cp $slave_cmd_file* $slave_dir"; |
|
157 exec sh -c "cp *log $slave_dir"; |
|
158 } |
|
159 |
|
160 proc rename_master_download_file {target} { # BB150 |
|
161 global master_download_glob; |
|
162 |
|
163 if {[string length $master_download_glob] == 0} {return} |
|
164 set files [glob -nocomplain $master_download_glob]; |
|
165 set nfiles [llength $files]; |
|
166 if {$nfiles == 0} { |
|
167 if {![file exists $target]} { |
|
168 error "can't find downloaded master file"; |
|
169 } |
|
170 return; |
|
171 } |
|
172 if {$nfiles > 1} { |
|
173 send_user "WARNING: Multiple files downloaded from master --- rename, backup, check manually!"; |
|
174 } |
|
175 exec mv [lindex $files end] $target; |
|
176 } |
|
177 |
|
178 proc rename_slave_download_file {target} { # BB150 |
|
179 global slave_download_glob; |
|
180 |
|
181 if {[string length $slave_download_glob] == 0} {return} |
|
182 set files [glob -nocomplain $slave_download_glob]; |
|
183 set nfiles [llength $files]; |
|
184 if {$nfiles == 0} { |
|
185 if {![file exists $target]} { |
|
186 error "can't find downloaded slave file"; |
|
187 } |
|
188 return; |
|
189 } |
|
190 if {$nfiles > 1} { |
|
191 send_user "WARNING: Multiple files downloaded from slave --- rename, backup, check manually!"; |
|
192 } |
|
193 exec mv [lindex $files end] $target; |
|
194 } |
|