author | A.M. Thurnherr <athurnherr@yahoo.com> |
Fri, 03 Jul 2020 10:25:08 -0400 | |
changeset 12 | 5e67754f6457 |
parent 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 |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
5 |
# dlm: Fri Jul 3 10:16:21 2020 |
0 | 6 |
# (c) 2004 A.M. Thurnherr |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
7 |
# uE-Info: 21 40 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 |
5 | 20 |
# Dec 10, 2010: - allow restarting a cast with same number |
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
21 |
# Jul 3, 2020: - expunged master/slave terminology |
0 | 22 |
|
23 |
#---------------------------------------------------------------------- |
|
24 |
# Setup |
|
25 |
#---------------------------------------------------------------------- |
|
26 |
||
27 |
log_user 0; |
|
4
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
28 |
source CRUISE_SETUP.expect; |
fda11de1826e
version left on Poseidon at end of P403
A.M. Thurnherr <ant@ldeo.columbia.edu>
parents:
0
diff
changeset
|
29 |
regsub {dir1} [exec which dir1] {libRDI.expect} path; |
0 | 30 |
source $path; |
31 |
||
32 |
print_version; |
|
33 |
||
34 |
if {$argc == 0} { |
|
35 |
set ask 1; |
|
36 |
if {[file isfile .last_stn]} { |
|
37 |
set stn [expr [exec cat .last_stn] + 1]; |
|
38 |
set stnstr [format $stn_format $stn]; |
|
39 |
if {[affirm "Use station number $stnstr? (y/N) " 10]} { |
|
40 |
set ask 0; |
|
41 |
} |
|
42 |
} |
|
43 |
if {$ask == 1} { |
|
44 |
set stn [input_int "Station number = "]; |
|
45 |
set stnstr [format $stn_format $stn]; |
|
46 |
} |
|
47 |
} else { |
|
48 |
set stn [lindex $argv 0]; |
|
49 |
set stnstr [format $stn_format $stn]; |
|
50 |
} |
|
51 |
||
52 |
if ![file isdirectory $raw_dir] { |
|
53 |
error "directory $raw_dir does not exist"; |
|
54 |
} |
|
5 | 55 |
|
0 | 56 |
set cast_dir [format %s/%s $raw_dir $stnstr]; |
57 |
if [file isdirectory $cast_dir] { |
|
5 | 58 |
if {![affirm "WARNING: data directory $cast_dir exists --- are you sure station number $stnstr is ok? (y/N) " 10]} { |
59 |
send_error "$argv0 aborted\n"; |
|
60 |
exit 0; |
|
61 |
} |
|
62 |
set attempt 1; # rename |
|
63 |
while {[file isdirectory $cast_dir.aborted$attempt]} { |
|
64 |
set attempt [expr $attempt + 1]; |
|
65 |
} |
|
66 |
exec mv $cast_dir $cast_dir.aborted$attempt; |
|
67 |
send_user "data directory $cast_dir renamed to $cast_dir.aborted$attempt\n" |
|
0 | 68 |
} |
5 | 69 |
|
0 | 70 |
set prev_cast_dir [format %s/$stn_format $raw_dir [expr $stn - 1]]; |
71 |
if {![file isdirectory $prev_cast_dir]} { |
|
5 | 72 |
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 | 73 |
send_error "$argv0 aborted\n"; |
74 |
exit 0; |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
#---------------------------------------------------------------------- |
|
79 |
# Deploy LADCP |
|
80 |
#---------------------------------------------------------------------- |
|
81 |
||
82 |
set_color; |
|
83 |
send_user "Connecting to instrument..."; |
|
84 |
spawn bbabble -ms $tty0; |
|
85 |
wait_for_startup; |
|
86 |
reset_instrument; |
|
87 |
if {![memory_empty]} { |
|
88 |
if {![affirm "\nWARNING: Memory is not empty; continue anyway? (y/N) " 10]} { |
|
89 |
send_user "Putting instrument to sleep..."; |
|
90 |
put_to_sleep; |
|
91 |
send_user "\nDone\n"; |
|
92 |
exit; |
|
93 |
} |
|
94 |
} else { |
|
95 |
send_user "\n"; |
|
96 |
} |
|
97 |
||
98 |
exec mkdir $cast_dir; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
99 |
exec cp $DL_cmd_file $cast_dir; |
0 | 100 |
exec echo $stn > .last_stn; |
101 |
cd $cast_dir; |
|
102 |
||
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
103 |
if {![file isfile $DL_cmd_file]} { |
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
104 |
error "Failed to copy $DL_cmd_file to [pwd]"; |
0 | 105 |
} |
106 |
||
107 |
||
108 |
regsub {.*/} $argv0 {} basename; |
|
109 |
start_logging [format %s_%s.log $basename $stnstr]; |
|
110 |
||
111 |
send_user "Resetting instrument to factory defaults..."; |
|
112 |
load_factory_defaults; |
|
113 |
||
114 |
send_user "\nSetting instrument clock..."; |
|
115 |
set_computer_time; |
|
116 |
set_instrument_clock; |
|
117 |
||
118 |
send_user "\nSetting deployment name..."; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
119 |
set_deployment_name [format $DL_deployment_name_fmt $stn]; |
0 | 120 |
|
121 |
send_user "\nUploading command file"; |
|
12
5e67754f6457
V1.6: no more master/slave terminology
A.M. Thurnherr <athurnherr@yahoo.com>
parents:
5
diff
changeset
|
122 |
upload_file $DL_cmd_file [format %s_log $DL_cmd_file] "[format $DL_deployment_name_fmt $stn].hwconfig"; |
0 | 123 |
|
124 |
send_user "\nDone\n"; |