#!/usr/bin/expect -f
#======================================================================
# C H E C K F I L E S 2
# doc: Wed Mar 10 22:23:52 2004
# dlm: Fri Jul 3 10:14:00 2020
# (c) 2004 A.M. Thurnherr
# uE-Info: 90 18 NIL 0 0 72 2 2 8 NIL ofnI
#======================================================================
# HISTORY:
# Jun 16, 2004: - copied from [endladcp2] to allow continuation after
# download ok
# Jun 27, 2004: - removed download dir override
# Feb 14, 2006: - BUG: log files were written to bin dir
# Oct 28, 2006: - adapted to old version expect (regsub)
# - allowed for lrb downcasing filenames
# Nov 19, 2008: - added version
# Aug 25, 2010: - DEFAULTS.expect -> CRUISE_SETUP.expect
# - libBB.expect -> libRDI.expect
# Jul 3, 2020: - expunged master/slave terminology
#----------------------------------------------------------------------
# Setup
#----------------------------------------------------------------------
log_user 0;
source CRUISE_SETUP.expect;
regsub {dir1} [exec which dir1] {libRDI.expect} path;
source $path;
print_version;
if ![file isdirectory $raw_dir] {
error "directory $raw_dir does not exist";
}
#----------------------------------------------------------------------
# Get Station Number
#----------------------------------------------------------------------
spawn bbabble -ms $tty0 $tty1;
set_color;
send_user "Connecting to instruments...";
wait_for_startup;
reset_two_instruments;
send_user "\nGetting station number...";
select_DL 0;
set DL_deployment_name [get_deployment_name];
if {[scan $DL_deployment_name $DL_deployment_name_fmt DL_stn] != 1} {
send_error "$DL_deployment_name $DL_deployment_name_fmt";
error "Can't get station number of DL";
}
select_UL; set UL_deployment_name [get_deployment_name];
set UL_deployment_name [get_deployment_name];
if {[scan $UL_deployment_name $UL_deployment_name_fmt UL_stn] != 1} {
error "Can't get station number of UL";
}
if {$DL_stn != $UL_stn} {
select_DL; put_to_sleep; select_UL; put_to_sleep;
error "DL/UL stations disagree";
}
set stn [format $stn_format $DL_stn];
send_user "\[$stn\]";
set cast_dir [format %s/%s $raw_dir $stn];
if {![file isdirectory $cast_dir]} {
select_DL; put_to_sleep; select_UL; put_to_sleep;
error "cast directory $cast_dir does not exist!";
}
cd $cast_dir;
send \004;
#----------------------------------------------------------------------
# Check & Backup Data
#----------------------------------------------------------------------
regsub {.*/} $argv0 {} tmp;
start_logging [format %s_%s.log $tmp $stn];
send_user "\nChecking data files...\n";
set_color 0; check_data [format %s000.000 [format $DL_deployment_name_fmt $DL_stn]];
set_color 1; check_data [format %s000.000 [format $UL_deployment_name_fmt $UL_stn]];
set_color;
send_user "Backing up data files...";
backup_DL_data $DL_stn;
backup_UL_data $UL_stn;
send_user "\nDone\n"