Commit 12e7b467 authored by Jean-Luc Shaw's avatar Jean-Luc Shaw

Writing text to output.

parent b5cf52ac
#!/usr/bin/perl
# DEPENDENCIES
use GPS::NMEA ; # http://search.cpan.org/dist/perl-GPS/NMEA.pm
# HEADER AND INSTRUCTIONS
print "========== ========== ========== LogGen ========== ========== ==========\n\n" ;
......@@ -28,24 +30,45 @@ if (-e "$folder/LogGen/$name.out") {
print ">> Enter operations, end with CTRL-d : " ;
# operations to be conducted
$numops = 0 ;
while ( <STDIN> ) {
chop($_) ;
push(@ops,$_) ;
print ">> : " ;
$numops++ ;
}
print "\n" ;
# stations to be visited
$numsts = 0 ;
print ">> Enter stations names, end with CTRL-d : " ;
while (<STDIN>) {
chop($_) ;
push(@sts,$_) ;
print ">> : " ;
$numsts++ ;
}
print "\n\n\n" ;
# print header to outputfile
print OUT "\# $name\n" ;
print OUT "\# $folder\n" ;
print OUT "\# $numops\n" ;
for ($ii=0;$ii<$numops;$ii++) { print OUT "\# $ops[$ii]\n" ; }
print OUT "\# $numsts\n" ;
for ($ii=0;$ii<$numsts;$ii++) { print OUT "\# $sts[$ii]\n" ; }
print OUT "\# 0\n" ;
$cul = 0 ;
print OUT "\# Type lon lat yyyy mm dd HH MM SS Name\n" ;
$headerstring = "Starting operations log for $name cruise" ;
}
# SET PRINTING FORMAT
$frmt = " \%4s \%.4f \%.4f \%4s \%2s \%2s \%2s \%2s \%2s \%s\n" ;
# DISPLAY AVAILABLE STATIONS and OPERATIONS
print ">> AVAILABLE OPERATIONS ARE:\n";
......@@ -55,27 +78,24 @@ print ">> PLANNED STATIONS ARE:\n";
foreach $line (@sts) { print ">> $line\n"; }
print ">> ---\n\n" ;
# DEFAULT START HEADER
print "======================================================================================================\n" ;
print "===== START =====\n" ;
print "======================================================================================================\n\n" ;
print "> LEG 001\n> " ;
$pre = ">" ;
$cus = "none" ;
$cul = "1" ;
# DEFAULT START HEADER
print "=============================================================================================\n" ;
print "===== $headerstring =====\n" ;
print "=============================================================================================\n\n> " ;
# RUNNING LOOP TO ADD TO CRUISE DATA FILE
while (<STDIN>) {
# POLL COMPUTER FOR TIME
@time = localtime ;
$mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4]+1, @time[3], @time[2], @time[1] ;
$time[4]++ ; $time[5]+=1900 ;
$mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4], @time[3], @time[2], @time[1] ;
# POLL GPS FOR COORDINATES
chop( $_ ) ;
@line = split( "=", $_ ) ;
......@@ -90,18 +110,27 @@ while (<STDIN>) {
$cus = $line[1] ;
$pre = ">>" ;
print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n$pre " ;
printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ;
} elsif ($cus =~ /$line[1]/) { # case : we are currently at this station
$cus = "none" ;
print "$pre\t\t\tEND OF STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n>\n>\n> " ;
printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ;
$pre = ">" ;
} else { # case : we are currently at a different station
printf OUT $frmt,$line[0],reverse @time[0..5],$cus ;
print "$pre\t\t\tEND OF STATION\t $cus,\t\t\t TIME : $mmddHHMM\n>\n>\n" ;
$cus = $line[1] ;
print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n$pre " ;
printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ;
}
}
# THIS IS A NEW LEG ENTRY
elsif ($line[0] =~ /lg/) {
$cul++ ;
print ">\tNOW RECORDING LEG $cul\n> " ;
}
# THIS IS AN OPERATION ENTRY
elsif ($line[0] =~ /op/) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment