14 # Jun 18, 2004: - BUG: could not handle stn 008 |
14 # Jun 18, 2004: - BUG: could not handle stn 008 |
15 # Jan 25, 2005: - BUG: bbabble could not be in relative path (on MacOSX) |
15 # Jan 25, 2005: - BUG: bbabble could not be in relative path (on MacOSX) |
16 # Feb 14, 2006: - BUG: log files were written to bin dir |
16 # Feb 14, 2006: - BUG: log files were written to bin dir |
17 # Oct 4, 2006: - adapted to older expect version |
17 # Oct 4, 2006: - adapted to older expect version |
18 # Oct 28, 2006: - allowed for lrb downcasing filenames |
18 # Oct 28, 2006: - allowed for lrb downcasing filenames |
19 # Nov 6, 2006: - BUG: error when master download finished much before slave |
19 # Nov 6, 2006: - BUG: error when DL download finished much before UL |
20 # Nov 19, 2008: - added version |
20 # Nov 19, 2008: - added version |
21 # Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect |
21 # Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect |
22 # - libBB.expect -> libRDI.expect |
22 # - libBB.expect -> libRDI.expect |
23 # Aug 26, 2010: - added support for ymodem_download_cmd |
23 # Aug 26, 2010: - added support for ymodem_download_cmd |
24 # Dec 1, 2010: - BUG: ymodem_receive_cmd instead of ymodem_download_cmd |
24 # Dec 1, 2010: - BUG: ymodem_receive_cmd instead of ymodem_download_cmd |
25 # Nov 10, 2013: - added directory listing before download |
25 # Nov 10, 2013: - added directory listing before download |
|
26 # Jul 3, 2020: - expunged master/slave terminology |
26 |
27 |
27 #---------------------------------------------------------------------- |
28 #---------------------------------------------------------------------- |
28 # Setup |
29 # Setup |
29 #---------------------------------------------------------------------- |
30 #---------------------------------------------------------------------- |
30 |
31 |
54 set_color; |
55 set_color; |
55 send_user "Connecting to instruments..."; |
56 send_user "Connecting to instruments..."; |
56 wait_for_startup; |
57 wait_for_startup; |
57 reset_two_instruments; |
58 reset_two_instruments; |
58 |
59 |
59 select_master 0; send_user "\n"; list_dir; |
60 select_DL 0; send_user "\n"; list_dir; |
60 select_slave; send_user "\n"; list_dir; |
61 select_UL; send_user "\n"; list_dir; |
61 |
62 |
62 #---------------------------------------------------------------------- |
63 #---------------------------------------------------------------------- |
63 # Get Station Number & Carry Out Sanity Check |
64 # Get Station Number & Carry Out Sanity Check |
64 #---------------------------------------------------------------------- |
65 #---------------------------------------------------------------------- |
65 |
66 |
66 send_user "\nGetting station number..."; |
67 send_user "\nGetting station number..."; |
67 select_master; |
68 select_DL; |
68 set master_deployment_name [get_deployment_name]; |
69 set DL_deployment_name [get_deployment_name]; |
69 if {[scan $master_deployment_name $master_deployment_name_fmt master_stn] != 1} { |
70 if {[scan $DL_deployment_name $DL_deployment_name_fmt DL_stn] != 1} { |
70 send_error "$master_deployment_name $master_deployment_name_fmt"; |
71 send_error "$DL_deployment_name $DL_deployment_name_fmt"; |
71 error "Can't get station number of master"; |
72 error "Can't get station number of DL"; |
72 } |
73 } |
73 select_slave; set slave_deployment_name [get_deployment_name]; |
74 select_UL; set UL_deployment_name [get_deployment_name]; |
74 set slave_deployment_name [get_deployment_name]; |
75 set UL_deployment_name [get_deployment_name]; |
75 if {[scan $slave_deployment_name $slave_deployment_name_fmt slave_stn] != 1} { |
76 if {[scan $UL_deployment_name $UL_deployment_name_fmt UL_stn] != 1} { |
76 error "Can't get station number of slave"; |
77 error "Can't get station number of UL"; |
77 } |
78 } |
78 if {$master_stn != $slave_stn} { |
79 if {$DL_stn != $UL_stn} { |
79 select_master; put_to_sleep; select_slave; put_to_sleep; |
80 select_DL; put_to_sleep; select_UL; put_to_sleep; |
80 error "Master/slave stations disagree"; |
81 error "DL/UL stations disagree"; |
81 } |
82 } |
82 set stn [format $stn_format $master_stn]; |
83 set stn [format $stn_format $DL_stn]; |
83 send_user "\[$stn\]"; |
84 send_user "\[$stn\]"; |
84 |
85 |
85 set cast_dir [format %s/%s $raw_dir $stn]; |
86 set cast_dir [format %s/%s $raw_dir $stn]; |
86 if {![file isdirectory $cast_dir]} { |
87 if {![file isdirectory $cast_dir]} { |
87 select_master; put_to_sleep; select_slave; put_to_sleep; |
88 select_DL; put_to_sleep; select_UL; put_to_sleep; |
88 error "cast directory $cast_dir does not exist!"; |
89 error "cast directory $cast_dir does not exist!"; |
89 } |
90 } |
90 regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble; |
91 regsub {^[^/]} [exec which bbabble] "[exec pwd]/&" bbabble; |
91 if {$argc == 1} { # override download directory |
92 if {$argc == 1} { # override download directory |
92 set cast_dir [lindex $argv 0]; |
93 set cast_dir [lindex $argv 0]; |
93 if {![file isdir $cast_dir]} {exec mkdir $cast_dir} |
94 if {![file isdir $cast_dir]} {exec mkdir $cast_dir} |
94 } |
95 } |
95 |
96 |
96 cd $cast_dir; |
97 cd $cast_dir; |
97 if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} { |
98 if {[llength [glob -nocomplain {*.[0-9][0-9][0-9]}]] > 0} { |
98 select_master; put_to_sleep; select_slave; put_to_sleep; |
99 select_DL; put_to_sleep; select_UL; put_to_sleep; |
99 error "cast directory [pwd] contains RDI data files!"; |
100 error "cast directory [pwd] contains RDI data files!"; |
100 } |
101 } |
101 |
102 |
102 send \004; |
103 send \004; |
103 |
104 |
104 #---------------------------------------------------------------------- |
105 #---------------------------------------------------------------------- |
105 # Download Data |
106 # Download Data |
106 #---------------------------------------------------------------------- |
107 #---------------------------------------------------------------------- |
107 |
108 |
108 regsub {.*/} $argv0 {} basename; |
109 regsub {.*/} $argv0 {} basename; |
109 start_logging [format %s_%03d.log $basename $master_stn]; |
110 start_logging [format %s_%03d.log $basename $DL_stn]; |
110 |
111 |
111 spawn $bbabble -msy $ymodem_receive_cmd $tty0 $tty1; |
112 spawn $bbabble -msy $ymodem_receive_cmd $tty0 $tty1; |
112 wait_for_startup; |
113 wait_for_startup; |
113 |
114 |
114 send_user "\nSaving hardware configurations..."; |
115 send_user "\nSaving hardware configurations..."; |
115 select_master; save_hardware_config [format %s000.LOG $master_deployment_name]; |
116 select_DL; save_hardware_config [format %s000.LOG $DL_deployment_name]; |
116 resume_logging [format %s_%03d.log $basename $master_stn]; |
117 resume_logging [format %s_%03d.log $basename $DL_stn]; |
117 select_slave; save_hardware_config [format %s000.LOG $slave_deployment_name]; |
118 select_UL; save_hardware_config [format %s000.LOG $UL_deployment_name]; |
118 resume_logging [format %s_%03d.log $basename $master_stn]; |
119 resume_logging [format %s_%03d.log $basename $DL_stn]; |
119 |
120 |
120 send_user "\nStarting parallel downloads..."; |
121 send_user "\nStarting parallel downloads..."; |
121 select_master; start_download; |
122 select_DL; start_download; |
122 select_slave; start_download; |
123 select_UL; start_download; |
123 |
124 |
124 # NB: slave is assumed to download faster => finish it first, coz otherwise |
125 # NB: UL is assumed to download faster => finish it first, coz otherwise |
125 # it may auto-sleep and cause problems later on |
126 # it may auto-sleep and cause problems later on |
126 |
127 |
127 send_user "\n"; |
128 send_user "\n"; |
128 set_color 1; log_user 1; wait_for_download_finish $master_stn $download_timeout; |
129 set_color 1; log_user 1; wait_for_download_finish $DL_stn $download_timeout; |
129 log_user 0; set_color; |
130 log_user 0; set_color; |
130 send_user "\nPutting slave to sleep..."; put_to_sleep; send_user "\n"; |
131 send_user "\nPutting UL to sleep..."; put_to_sleep; send_user "\n"; |
131 |
132 |
132 toggle_instrument; |
133 toggle_instrument; |
133 set_color 0; log_user 1; wait_for_download_finish $master_stn $download_timeout; |
134 set_color 0; log_user 1; wait_for_download_finish $DL_stn $download_timeout; |
134 log_user 0; set_color; |
135 log_user 0; set_color; |
135 send_user "\nPutting master to sleep..."; ensure_sleep; send_user "\n"; |
136 send_user "\nPutting DL to sleep..."; ensure_sleep; send_user "\n"; |
136 |
137 |
137 #---------------------------------------------------------------------- |
138 #---------------------------------------------------------------------- |
138 # Check and Backup Data |
139 # Check and Backup Data |
139 #---------------------------------------------------------------------- |
140 #---------------------------------------------------------------------- |
140 |
141 |
141 send_user "\nChecking data files...\n"; |
142 send_user "\nChecking data files...\n"; |
142 set_color 0; check_data [format %s000.000 [format $master_deployment_name_fmt $master_stn]]; |
143 set_color 0; check_data [format %s000.000 [format $DL_deployment_name_fmt $DL_stn]]; |
143 set_color 1; check_data [format %s000.000 [format $slave_deployment_name_fmt $slave_stn]]; |
144 set_color 1; check_data [format %s000.000 [format $UL_deployment_name_fmt $UL_stn]]; |
144 set_color; |
145 set_color; |
145 |
146 |
146 send_user "Backing up data files..."; |
147 send_user "Backing up data files..."; |
147 backup_master_data $master_stn; |
148 backup_DL_data $DL_stn; |
148 backup_slave_data $master_stn; |
149 backup_UL_data $DL_stn; |
149 |
150 |
150 send_user "\nDone\n" |
151 send_user "\nDone\n" |