author | A.M. Thurnherr <ant@ldeo.columbia.edu> |
Tue, 14 Sep 2010 13:34:39 -0400 | |
changeset 4 | fda11de1826e |
parent 0 | 648bde652211 |
child 5 | f41d45fe7ae9 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/expect -f |
2 |
#====================================================================== |
|
3 |
# L A D C P 1 |
|
4 |
# doc: Wed Mar 10 22:23:52 2004 |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
5 |
# dlm: Thu Aug 26 00:27:08 2010 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
7 |
# uE-Info: 27 39 NIL 0 0 72 2 2 8 NIL ofnI |
0 | 8 |
#====================================================================== |
9 |
||
10 |
# HISTORY: |
|
11 |
# Apr 4, 2004: - adapted from [ladcp2] |
|
12 |
# Jun 17, 2004: - BUG: bombed on station #008 (octal digit) |
|
13 |
# Feb 14, 2006: - BUG: log files were written to bin dir |
|
14 |
# Oct 28, 2006: - adapted to old version of expect |
|
15 |
# Oct 31, 2007: - BUG: wrong default on non-empty memory |
|
16 |
# Nov 19, 2008: - adapted to new firmware behavior (load_factory_defaults) |
|
17 |
# 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
|
18 |
# 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
|
19 |
# - libBB.expect -> libRDI.expect |
0 | 20 |
|
21 |
#---------------------------------------------------------------------- |
|
22 |
# Setup |
|
23 |
#---------------------------------------------------------------------- |
|
24 |
||
25 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
26 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
27 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 28 |
source $path; |
29 |
||
30 |
print_version; |
|
31 |
||
32 |
if {$argc == 0} { |
|
33 |
set ask 1; |
|
34 |
if {[file isfile .last_stn]} { |
|
35 |
set stn [expr [exec cat .last_stn] + 1]; |
|
36 |
set stnstr [format $stn_format $stn]; |
|
37 |
if {[affirm "Use station number $stnstr? (y/N) " 10]} { |
|
38 |
set ask 0; |
|
39 |
} |
|
40 |
} |
|
41 |
if {$ask == 1} { |
|
42 |
set stn [input_int "Station number = "]; |
|
43 |
set stnstr [format $stn_format $stn]; |
|
44 |
} |
|
45 |
} else { |
|
46 |
set stn [lindex $argv 0]; |
|
47 |
set stnstr [format $stn_format $stn]; |
|
48 |
} |
|
49 |
||
50 |
if ![file isdirectory $raw_dir] { |
|
51 |
error "directory $raw_dir does not exist"; |
|
52 |
} |
|
53 |
set cast_dir [format %s/%s $raw_dir $stnstr]; |
|
54 |
if [file isdirectory $cast_dir] { |
|
55 |
error "data directory $cast_dir already exists!"; |
|
56 |
} |
|
57 |
set prev_cast_dir [format %s/$stn_format $raw_dir [expr $stn - 1]]; |
|
58 |
if {![file isdirectory $prev_cast_dir]} { |
|
59 |
if {![affirm "WARNING: previous-station data directory $prev_cast_dir does not exist --- are you sure the station number $stnstr is ok? (y/N) " 10]} { |
|
60 |
send_error "$argv0 aborted\n"; |
|
61 |
exit 0; |
|
62 |
} |
|
63 |
} |
|
64 |
||
65 |
#---------------------------------------------------------------------- |
|
66 |
# Deploy LADCP |
|
67 |
#---------------------------------------------------------------------- |
|
68 |
||
69 |
set_color; |
|
70 |
send_user "Connecting to instrument..."; |
|
71 |
spawn bbabble -ms $tty0; |
|
72 |
wait_for_startup; |
|
73 |
reset_instrument; |
|
74 |
if {![memory_empty]} { |
|
75 |
if {![affirm "\nWARNING: Memory is not empty; continue anyway? (y/N) " 10]} { |
|
76 |
send_user "Putting instrument to sleep..."; |
|
77 |
put_to_sleep; |
|
78 |
send_user "\nDone\n"; |
|
79 |
exit; |
|
80 |
} |
|
81 |
} else { |
|
82 |
send_user "\n"; |
|
83 |
} |
|
84 |
||
85 |
exec mkdir $cast_dir; |
|
86 |
exec cp $master_cmd_file $cast_dir; |
|
87 |
exec echo $stn > .last_stn; |
|
88 |
cd $cast_dir; |
|
89 |
||
90 |
if {![file isfile $master_cmd_file]} { |
|
91 |
error "Failed to copy $master_cmd_file to [pwd]"; |
|
92 |
} |
|
93 |
||
94 |
||
95 |
regsub {.*/} $argv0 {} basename; |
|
96 |
start_logging [format %s_%s.log $basename $stnstr]; |
|
97 |
||
98 |
send_user "Resetting instrument to factory defaults..."; |
|
99 |
load_factory_defaults; |
|
100 |
||
101 |
send_user "\nSetting instrument clock..."; |
|
102 |
set_computer_time; |
|
103 |
set_instrument_clock; |
|
104 |
||
105 |
send_user "\nSetting deployment name..."; |
|
106 |
set_deployment_name [format $master_deployment_name_fmt $stn]; |
|
107 |
||
108 |
send_user "\nUploading command file"; |
|
109 |
upload_file $master_cmd_file [format %s_log $master_cmd_file] "[format $master_deployment_name_fmt $stn].hwconfig"; |
|
110 |
||
111 |
send_user "\nDone\n"; |