27 # Oct 18, 2010: - changed comment for ymodem_receive_cmd to account for the |
27 # Oct 18, 2010: - changed comment for ymodem_receive_cmd to account for the |
28 # fact that bbabble now uses the -u option by default |
28 # fact that bbabble now uses the -u option by default |
29 # Dec 10, 2010: - updated comments |
29 # Dec 10, 2010: - updated comments |
30 # - made mkProfile default file-checking program |
30 # - made mkProfile default file-checking program |
31 # - made backup dir structure consistent with raw dir structure |
31 # - made backup dir structure consistent with raw dir structure |
|
32 # Jul 3, 2020: - expunged master/slave terminology |
32 |
33 |
33 #----------- |
34 #----------- |
34 # TWEAKABLES |
35 # TWEAKABLES |
35 #----------- |
36 #----------- |
36 |
37 |
37 # At the beginning of each cast, the clock of the acquisition computer should |
38 # At the beginning of each cast, the clock of the acquisition computer should |
38 # synchronized with the master clock used for timestamping the GPS information. |
39 # synchronized with the primary clock used for timestamping the GPS information. |
39 # The best way to accomplish this is to run a NTP daemon (e.g. ntpd) polling |
40 # The best way to accomplish this is to run a NTP daemon (e.g. ntpd) polling |
40 # an NTP server on the ship. |
41 # an NTP server on the ship. |
41 # If running ntpd is inconvenient or not possible, the follwing variable can |
42 # If running ntpd is inconvenient or not possible, the follwing variable can |
42 # be set to the name of the NTP server, in which case the time is sync'ed |
43 # be set to the name of the NTP server, in which case the time is sync'ed |
43 # at the beginning of each cast with the function set_computer_time (defined |
44 # at the beginning of each cast with the function set_computer_time (defined |
53 # either instrument can be connected to either port. |
54 # either instrument can be connected to either port. |
54 |
55 |
55 set tty0 {/dev/ttyS0}; |
56 set tty0 {/dev/ttyS0}; |
56 set tty1 {/dev/ttyS1}; |
57 set tty1 {/dev/ttyS1}; |
57 |
58 |
58 # In case of 2 ADCP heads, babble needs to know which is the master and |
59 # In case of 2 ADCP heads, babble needs to know which is of the instruments |
59 # which is the slave. This is accomplished by setting the following variables |
60 # sends the sync pulses and which instrument receives them. |
|
61 # This is accomplished by setting the following variables |
60 # to the corresponding instrument serial numbers (PS0 output). By convention, |
62 # to the corresponding instrument serial numbers (PS0 output). By convention, |
61 # the downlooker is the master. If only a single head is connected, both |
63 # the downlooker sends the sync pulses. If only a single head is connected, both |
62 # variables are ignored. |
64 # variables are ignored. |
63 |
65 |
64 set master_sn 7877; |
66 set DL_sn 7877; |
65 set slave_sn 1412; |
67 set UL_sn 1412; |
66 |
68 |
67 # Before deployment, every ADCP head has to be programmed by sending it |
69 # Before deployment, every ADCP head has to be programmed by sending it |
68 # a corresponding command file, defined by the following variables. If only |
70 # a corresponding command file, defined by the following variables. If only |
69 # a single head is connected, the slave_* variable is ignored. |
71 # a single head is connected, the UL_* variable is ignored. |
70 |
72 |
71 set master_cmd_file {MASTER.cmd}; |
73 set DL_cmd_file {DOWNLOOKER.cmd}; |
72 set slave_cmd_file {SLAVE.cmd}; |
74 set UL_cmd_file {UPLOOKER.cmd}; |
73 |
75 |
74 # For convenience, it is best to use the station number to name the ADCP data |
76 # For convenience, it is best to use the station number to name the ADCP data |
75 # files, and to indicate whether the data file comes from the master or |
77 # files, and to indicate whether the data file comes from the DL or |
76 # slave. The following variables variables define the printf(3) format |
78 # UL. The following variables variables define the printf(3) format |
77 # that is used to create the files names from the station number. If only |
79 # that is used to create the files names from the station number. If only |
78 # a single head is connected, the slave_* variable is ignored. |
80 # a single head is connected, the UL_* variable is ignored. |
79 |
81 |
80 set master_deployment_name_fmt {%03dDL}; |
82 set DL_deployment_name_fmt {%03dDL}; |
81 set slave_deployment_name_fmt {%03dUL}; |
83 set UL_deployment_name_fmt {%03dUL}; |
82 |
84 |
83 # Older RDI instruments (e.g. the BB150) do not allow the data-file name |
85 # Older RDI instruments (e.g. the BB150) do not allow the data-file name |
84 # to be defined in the instrument, in which case the files have to be |
86 # to be defined in the instrument, in which case the files have to be |
85 # renamed after downloading. The following variables define the shell |
87 # renamed after downloading. The following variables define the shell |
86 # globbing patterns for the master and slave. For example, the UH BB150 |
88 # globbing patterns for the DL and UL. For example, the UH BB150 |
87 # used during CLIVAR P02 generated files with extension .612; the coresponding |
89 # used during CLIVAR P02 generated files with extension .612; the coresponding |
88 # globbing pattern is {*.612}. If only a single head is connected, the |
90 # globbing pattern is {*.612}. If only a single head is connected, the |
89 # slave_* variable is ignored. |
91 # UL_* variable is ignored. |
90 # NB: For dual-headed LADCP systems it is important that the globs do not |
92 # NB: For dual-headed LADCP systems it is important that the globs do not |
91 # match both master and slave data files. {*.000} therefore will not |
93 # match both DL and UL data files. {*.000} therefore will not |
92 # work for dual-head Workhorse systems. |
94 # work for dual-head Workhorse systems. |
93 |
95 |
94 set master_download_glob {}; |
96 set DL_download_glob {}; |
95 set slave_download_glob {}; |
97 set UL_download_glob {}; |
96 |
98 |
97 # For consistency it is nicest if low station numbers contain leading |
99 # For consistency it is nicest if low station numbers contain leading |
98 # zeroes. The following variable defines the corresponding printf(3) format. |
100 # zeroes. The following variable defines the corresponding printf(3) format. |
99 |
101 |
100 set stn_format {%03d}; |
102 set stn_format {%03d}; |
159 # exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty"; |
161 # exec sh -c "sed -n '/^zmax/,/^zend/s/ at.*/m/p' `basename $file .000`.scn > /dev/tty"; |
160 } |
162 } |
161 |
163 |
162 #---------------------------------------------------------------------- |
164 #---------------------------------------------------------------------- |
163 |
165 |
164 # The following two routines backup the master and slave files from the |
166 # The following two routines backup the DL and UL files from the |
165 # raw directory. |
167 # raw directory. |
166 |
168 |
167 proc backup_master_data {stn} { |
169 proc backup_DL_data {stn} { |
168 global stn_format master_deployment_name_fmt master_cmd_file backup_dir; |
170 global stn_format DL_deployment_name_fmt DL_cmd_file backup_dir; |
169 if {[string length $backup_dir] == 0} {return} |
171 if {[string length $backup_dir] == 0} {return} |
170 |
172 |
171 if {![file isdirectory $backup_dir]} { |
173 if {![file isdirectory $backup_dir]} { |
172 error "$backup_dir does not exist relative to [pwd]"; |
174 error "$backup_dir does not exist relative to [pwd]"; |
173 } |
175 } |
174 |
176 |
175 set stnstr [format $stn_format $stn]; |
177 set stnstr [format $stn_format $stn]; |
176 set cast_dir [format %s/%s $backup_dir $stnstr]; |
178 set cast_dir [format %s/%s $backup_dir $stnstr]; |
177 if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir}; |
179 if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir}; |
178 exec sh -c "cp [format $master_deployment_name_fmt $stn]* $cast_dir"; |
180 exec sh -c "cp [format $DL_deployment_name_fmt $stn]* $cast_dir"; |
179 exec sh -c "cp $master_cmd_file* $cast_dir"; |
181 exec sh -c "cp $DL_cmd_file* $cast_dir"; |
180 exec sh -c "cp *log $cast_dir"; |
182 exec sh -c "cp *log $cast_dir"; |
181 } |
183 } |
182 |
184 |
183 proc backup_slave_data {stn} { # copy data to network |
185 proc backup_UL_data {stn} { # copy data to network |
184 global stn_format slave_deployment_name_fmt slave_cmd_file backup_dir; |
186 global stn_format UL_deployment_name_fmt UL_cmd_file backup_dir; |
185 if {[string length $backup_dir] == 0} {return} |
187 if {[string length $backup_dir] == 0} {return} |
186 |
188 |
187 if {![file isdirectory $backup_dir]} { |
189 if {![file isdirectory $backup_dir]} { |
188 error "$backup_dir does not exist relative to [pwd]"; |
190 error "$backup_dir does not exist relative to [pwd]"; |
189 } |
191 } |
190 |
192 |
191 set stnstr [format $stn_format $stn]; |
193 set stnstr [format $stn_format $stn]; |
192 set cast_dir [format %s/%s $backup_dir $stnstr]; |
194 set cast_dir [format %s/%s $backup_dir $stnstr]; |
193 if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir}; |
195 if {![file isdirectory $cast_dir]} {exec mkdir $cast_dir}; |
194 exec sh -c "cp [format $slave_deployment_name_fmt $stn]* $cast_dir"; |
196 exec sh -c "cp [format $UL_deployment_name_fmt $stn]* $cast_dir"; |
195 exec sh -c "cp $slave_cmd_file* $cast_dir"; |
197 exec sh -c "cp $UL_cmd_file* $cast_dir"; |
196 exec sh -c "cp *log $cast_dir"; |
198 exec sh -c "cp *log $cast_dir"; |
197 } |
199 } |
198 |
200 |
199 #---------------------------------------------------------------------- |
201 #---------------------------------------------------------------------- |
200 |
202 |
201 # See comments on master_download_glob and slave_download_glob above. |
203 # See comments on DL_download_glob and UL_download_glob above. |
202 |
204 |
203 proc rename_master_download_file {target} { # rename after download |
205 proc rename_DL_download_file {target} { # rename after download |
204 global master_download_glob; |
206 global DL_download_glob; |
205 |
207 |
206 if {[string length $master_download_glob] == 0} {return} |
208 if {[string length $DL_download_glob] == 0} {return} |
207 set files [glob -nocomplain $master_download_glob]; |
209 set files [glob -nocomplain $DL_download_glob]; |
208 set nfiles [llength $files]; |
210 set nfiles [llength $files]; |
209 if {$nfiles == 0} { |
211 if {$nfiles == 0} { |
210 if {![file exists $target]} { |
212 if {![file exists $target]} { |
211 error {can't find downloaded master file}; |
213 error {can't find downloaded DL file}; |
212 } |
214 } |
213 return; |
215 return; |
214 } |
216 } |
215 if {$nfiles > 1} { |
217 if {$nfiles > 1} { |
216 send_user {WARNING: Multiple files downloaded from master --- rename, backup, check manually!}; |
218 send_user {WARNING: Multiple files downloaded from DL --- rename, backup, check manually!}; |
217 } |
219 } |
218 if {![string equal [lindex $files end] $target]} { |
220 if {![string equal [lindex $files end] $target]} { |
219 exec mv [lindex $files end] $target; |
221 exec mv [lindex $files end] $target; |
220 } |
222 } |
221 } |
223 } |
222 |
224 |
223 proc rename_slave_download_file {target} { # rename after download |
225 proc rename_UL_download_file {target} { # rename after download |
224 global slave_download_glob; |
226 global UL_download_glob; |
225 |
227 |
226 if {[string length $slave_download_glob] == 0} {return} |
228 if {[string length $UL_download_glob] == 0} {return} |
227 set files [glob -nocomplain $slave_download_glob]; |
229 set files [glob -nocomplain $UL_download_glob]; |
228 set nfiles [llength $files]; |
230 set nfiles [llength $files]; |
229 if {$nfiles == 0} { |
231 if {$nfiles == 0} { |
230 if {![file exists $target]} { |
232 if {![file exists $target]} { |
231 error {can't find downloaded slave file}; |
233 error {can't find downloaded UL file}; |
232 } |
234 } |
233 return; |
235 return; |
234 } |
236 } |
235 if {$nfiles > 1} { |
237 if {$nfiles > 1} { |
236 send_user {WARNING: Multiple files downloaded from slave --- rename, backup, check manually!}; |
238 send_user {WARNING: Multiple files downloaded from UL --- rename, backup, check manually!}; |
237 } |
239 } |
238 if {![string equal [lindex $files end] $target]} { |
240 if {![string equal [lindex $files end] $target]} { |
239 exec mv [lindex $files end] $target; |
241 exec mv [lindex $files end] $target; |
240 } |
242 } |
241 } |
243 } |