0
|
1 |
#!/usr/bin/expect -f
|
|
2 |
#======================================================================
|
|
3 |
# E N D L A D C P 1
|
|
4 |
# doc: Wed Mar 10 22:23:52 2004
|
|
5 |
# dlm: Wed Nov 19 15:13:10 2008
|
|
6 |
# (c) 2004 A.M. Thurnherr
|
|
7 |
# uE-Info: 28 14 NIL 0 0 72 2 2 8 NIL ofnI
|
|
8 |
#======================================================================
|
|
9 |
|
|
10 |
# HISTORY:
|
|
11 |
# Apr 4, 2004: - adapted from [endladcp2]
|
|
12 |
# Jun 18, 2004: - BUG: could not handle station 008 (illegal octal digit)
|
|
13 |
# Jan 25, 2005: - BUG: bbabble could not be in relative path (on MacOSX)
|
|
14 |
# Feb 14, 2006: - BUG: log files were written to bin dir
|
|
15 |
# Oct 4, 2006: - adapted to older expect version
|
|
16 |
# Oct 28, 2006: - allowed for lrb downcasing filenames
|
|
17 |
# Nov 19, 2008: - added version
|
|
18 |
|
|
19 |
#----------------------------------------------------------------------
|
|
20 |
# Setup
|
|
21 |
#----------------------------------------------------------------------
|
|
22 |
|
|
23 |
log_user 0;
|
|
24 |
source DEFAULTS.expect;
|
|
25 |
regsub {dir1} [exec which dir1] {libBB.expect} path;
|
|
26 |
source $path;
|
|
27 |
|
|
28 |
print_version;
|
|
29 |
|
|
30 |
if ![file isdirectory $raw_dir] {
|
|
31 |
error "directory $raw_dir does not exist";
|
|
32 |
}
|
|
33 |
|
|
34 |
if {$argc != 0} {
|
|
35 |
if {![affirm "downloading files to directory [lindex $argv 0] --- ok (y/N)? " 10]} {
|
|
36 |
exit;
|
|
37 |
}
|
|
38 |
}
|
|
39 |
|
|
40 |
#----------------------------------------------------------------------
|
|
41 |
# Get Station Number
|
|
42 |
#----------------------------------------------------------------------
|
|
43 |
|
|
44 |
spawn bbabble -ms $tty0;
|
|
45 |
|
|
46 |
set_color;
|
|
47 |
send_user "Connecting to instrument...";
|
|
48 |
wait_for_startup;
|
|
49 |
reset_instrument;
|
|
50 |
|
|
51 |
send_user "\nGetting station number...";
|
|
52 |
set deployment_name [get_deployment_name];
|
|
53 |
if {[scan $deployment_name $master_deployment_name_fmt stn] != 1} {
|
|
54 |
send_error "$deployment_name $master_deployment_name_fmt";
|
|
55 |
error "Can't get station number";
|
|
56 |
}
|
|
57 |
set stnstr [format $stn_format $stn];
|
|
58 |
send_user "\[$stnstr\]";
|
|
59 |
|
|
60 |
set cast_dir [format %s/%s $raw_dir $stnstr];
|
|
61 |
if {![file isdirectory $cast_dir]} {
|
|
62 |
put_to_sleep;
|
|
63 |
error "cast directory $cast_dir does not exist!";
|
|
64 |
}
|
|
65 |
regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble;
|
|
66 |
|
|
67 |
if {$argc == 1} { # override download directory
|
|
68 |
set cast_dir [lindex $argv 0];
|
|
69 |
if {![file isdir $cast_dir]} {exec mkdir $cast_dir}
|
|
70 |
}
|
|
71 |
|
|
72 |
cd $cast_dir;
|
|
73 |
if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} {
|
|
74 |
put_to_sleep;
|
|
75 |
error "cast directory [pwd] contains RDI data files!";
|
|
76 |
}
|
|
77 |
|
|
78 |
send \004;
|
|
79 |
|
|
80 |
#----------------------------------------------------------------------
|
|
81 |
# Download Data
|
|
82 |
#----------------------------------------------------------------------
|
|
83 |
|
|
84 |
regsub {.*/} $argv0 {} basename;
|
|
85 |
start_logging [format %s_%s.log $basename $stnstr];
|
|
86 |
|
|
87 |
spawn $bbabble -ms $tty0;
|
|
88 |
wait_for_startup;
|
|
89 |
|
|
90 |
send_user "\nSaving hardware configuration...";
|
|
91 |
save_hardware_config [format %s000.LOG $deployment_name];
|
|
92 |
resume_logging [format %s_%s.log $basename $stnstr];
|
|
93 |
|
|
94 |
send_user "\nStarting download...";
|
|
95 |
start_download;
|
|
96 |
|
|
97 |
send_user "\n";
|
|
98 |
set_color 0;
|
|
99 |
log_user 1; wait_for_download_finish $stn $download_timeout; log_user 0;
|
|
100 |
set_color;
|
|
101 |
|
|
102 |
send_user "\nPutting instrument to sleep...";
|
|
103 |
put_to_sleep;
|
|
104 |
|
|
105 |
send_user "\nChecking data file...\n";
|
|
106 |
set_color 0;
|
|
107 |
check_data [format %s000.000 [format $master_deployment_name_fmt $stn]];
|
|
108 |
set_color;
|
|
109 |
|
|
110 |
send_user "Backing up data file...";
|
|
111 |
backup_master_data $stn;
|
|
112 |
|
|
113 |
send_user "\nDone\n"
|