author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Fri, 07 Jan 2011 23:25:51 +0000 | |
changeset 10 | 5873914adea7 |
parent 5 | f41d45fe7ae9 |
child 12 | 5e67754f6457 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/expect -f |
2 |
#====================================================================== |
|
3 |
# L A D C P 2 |
|
4 |
# doc: Wed Mar 10 22:23:52 2004 |
|
5 | 5 |
# dlm: Fri Dec 10 14:28:20 2010 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
5 | 7 |
# uE-Info: 70 34 NIL 0 0 72 2 2 8 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# HISTORY: |
|
11 |
# Mar 10, 2004: - created |
|
12 |
# Mar 12, 2004: - released |
|
13 |
# Mar 21, 2004: - added automatic station numbering |
|
14 |
# - unified prompts |
|
15 |
# Mar 24, 2004: - doubled station-number-entry timeout |
|
16 |
# Jun 18, 2004: - BUG: station 008 bombed on octal digit |
|
17 |
# Feb 14, 2006: - BUG: log files were written to bin dir |
|
18 |
# Oct 4, 2006: - adapted to older version of expect |
|
19 |
# Oct 31, 2007: - BUG: wrong default on non-empty memory |
|
20 |
# Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) |
|
21 |
# Nov 19, 2008: - added version |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
22 |
# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
23 |
# - libBB.expect -> libRDI.expect |
5 | 24 |
# Dec 10, 2010: - allow restarting a cast with same number |
0 | 25 |
|
26 |
#---------------------------------------------------------------------- |
|
27 |
# Setup |
|
28 |
#---------------------------------------------------------------------- |
|
29 |
||
30 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
31 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
32 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 33 |
source $path; |
34 |
||
35 |
print_version; |
|
36 |
||
37 |
if {$argc == 0} { |
|
38 |
set ask 1; |
|
39 |
if {[file isfile .last_stn]} { |
|
40 |
set stn [expr [exec cat .last_stn] + 1]; |
|
41 |
set stnstr [format $stn_format $stn]; |
|
42 |
if {[affirm "Use station number $stnstr? (y/N) " 10]} { |
|
43 |
set ask 0; |
|
44 |
} |
|
45 |
} |
|
46 |
if {$ask == 1} { |
|
47 |
set stn [input_int "Station number = "]; |
|
48 |
set stnstr [format $stn_format $stn]; |
|
49 |
} |
|
50 |
} else { |
|
51 |
set stn [lindex $argv 0]; |
|
52 |
set stnstr [format $stn_format $stn]; |
|
53 |
} |
|
54 |
||
55 |
if ![file isdirectory $raw_dir] { |
|
56 |
error "directory $raw_dir does not exist"; |
|
57 |
} |
|
5 | 58 |
|
0 | 59 |
set cast_dir [format %s/%s $raw_dir $stnstr]; |
60 |
if [file isdirectory $cast_dir] { |
|
5 | 61 |
if {![affirm "WARNING: data directory $cast_dir exists --- are you sure station number $stnstr is ok? (y/N) " 10]} { |
62 |
send_error "$argv0 aborted\n"; |
|
63 |
exit 0; |
|
64 |
} |
|
65 |
set attempt 1; # rename |
|
66 |
while {[file isdirectory $cast_dir.aborted$attempt]} { |
|
67 |
set attempt [expr $attempt + 1]; |
|
68 |
} |
|
69 |
exec mv $cast_dir $cast_dir.aborted$attempt; |
|
70 |
send_user "data directory $cast_dir renamed to $cast_dir.aborted$attempt\n" |
|
0 | 71 |
} |
5 | 72 |
|
0 | 73 |
set prev_cast_dir [format %s/$stn_format $raw_dir [expr $stn - 1]]; |
74 |
if {![file isdirectory $prev_cast_dir]} { |
|
5 | 75 |
if {![affirm "WARNING: previous-station data directory $prev_cast_dir does not exist --- are you sure station number $stnstr is ok? (y/N) " 10]} { |
0 | 76 |
send_error "$argv0 aborted\n"; |
77 |
exit 0; |
|
78 |
} |
|
79 |
} |
|
80 |
||
81 |
#---------------------------------------------------------------------- |
|
82 |
# Deploy LADCP |
|
83 |
#---------------------------------------------------------------------- |
|
84 |
||
85 |
set_color; |
|
86 |
send_user "Connecting to instruments..."; |
|
87 |
spawn bbabble -ms $tty0 $tty1; |
|
88 |
wait_for_startup; |
|
89 |
reset_two_instruments; |
|
90 |
if {![memory_empty]} { |
|
91 |
if {![affirm "\nWARNING: Memory is not empty; continue anyway? (y/N) " 10]} { |
|
92 |
send_user "Putting instruments to sleep..."; |
|
93 |
select_master 0; put_to_sleep; |
|
94 |
select_slave; put_to_sleep; |
|
95 |
send_user "\nDone\n"; |
|
96 |
exit; |
|
97 |
} |
|
98 |
} else { |
|
99 |
send_user "\n"; |
|
100 |
} |
|
101 |
||
102 |
exec mkdir $cast_dir; |
|
103 |
exec cp $master_cmd_file $cast_dir; |
|
104 |
exec cp $slave_cmd_file $cast_dir; |
|
105 |
exec echo $stn > .last_stn; |
|
106 |
cd $cast_dir; |
|
107 |
||
108 |
if {![file isfile $master_cmd_file]} { |
|
109 |
error "Failed to copy $master_cmd_file to [pwd]"; |
|
110 |
} |
|
111 |
if {![file isfile $slave_cmd_file]} { |
|
112 |
error "Failed to copy $slave_cmd_file to [pwd]"; |
|
113 |
} |
|
114 |
||
115 |
regsub {.*/} $argv0 {} basename; |
|
116 |
start_logging [format %s_%s.log $basename $stnstr]; |
|
117 |
||
118 |
send_user "Resetting instruments to factory defaults..."; |
|
119 |
select_master 0; load_factory_defaults; |
|
120 |
select_slave; load_factory_defaults; |
|
121 |
||
122 |
send_user "\nSetting instrument clocks..."; |
|
123 |
set_computer_time; |
|
124 |
select_master 0; set_instrument_clock; |
|
125 |
select_slave; set_instrument_clock; |
|
126 |
||
127 |
send_user "\nSetting deployment names..."; |
|
128 |
select_master; set_deployment_name [format $master_deployment_name_fmt $stn]; |
|
129 |
select_slave; set_deployment_name [format $slave_deployment_name_fmt $stn]; |
|
130 |
||
131 |
send_user "\nUploading command files"; |
|
132 |
select_slave 0; |
|
133 |
upload_file $slave_cmd_file [format %s_log $slave_cmd_file] "[format $slave_deployment_name_fmt $stn].hwconfig"; |
|
134 |
resume_logging [format %s_%s.log $basename $stnstr]; |
|
135 |
select_master; |
|
136 |
upload_file $master_cmd_file [format %s_log $master_cmd_file] "[format $master_deployment_name_fmt $stn].hwconfig"; |
|
137 |
||
138 |
send_user "\nDone\n"; |
|
139 |