Commit f199093a authored by Jean-Luc Shaw's avatar Jean-Luc Shaw

Still need to write preset station coordinates to outfile. Perhaps using an indexed array.

parent b5a8ec81
...@@ -21,13 +21,13 @@ chop($folder = <STDIN>) ; ...@@ -21,13 +21,13 @@ chop($folder = <STDIN>) ;
print "\n" ; print "\n" ;
# SETUP GPS # SETUP GPS
$gps = sub_getgps() ; ($gps,$gpson,$gpsport,$gpsbaud) = sub_getgps() ;
# ASK FOR or READ CRUISE INFO # ASK FOR or READ CRUISE INFO
($ops,$sts,$numops,$numsts,$headerstring) = sub_cruiseinfo($name,$folder) ; ($ops,$sts,$numops,$numsts,$headerstring) = sub_cruiseinfo($name,$folder,$gpson,$gpsport,$gpsbaud) ;
# SET PRINTING FORMAT # SET PRINTING FORMAT
$frmt = " \%4s \%.4f \%.4f \%4s \%2s \%2s \%2s \%2s \%2s \%s\n" ; $frmt = "%6s;%10.5f;%10.5f;%20s;%s\n" ;
# DISPLAY AVAILABLE STATIONS and OPERATIONS # DISPLAY AVAILABLE STATIONS and OPERATIONS
print ">> AVAILABLE OPERATIONS ARE:\n"; print ">> AVAILABLE OPERATIONS ARE:\n";
...@@ -37,8 +37,12 @@ print ">> PLANNED STATIONS ARE:\n"; ...@@ -37,8 +37,12 @@ print ">> PLANNED STATIONS ARE:\n";
foreach $line (@sts) { print ">> $line\n"; } foreach $line (@sts) { print ">> $line\n"; }
print ">> ---\n\n" ; print ">> ---\n\n" ;
$pre = ">" ; # INITIAL VALUES
$cus = "none" ; $pre = ">" ;
$cus = "none" ;
$culon = "NaN" ;
$culat = "NaN" ;
# DEFAULT START HEADER # DEFAULT START HEADER
print "=============================================================================================\n" ; print "=============================================================================================\n" ;
...@@ -55,9 +59,19 @@ while (<STDIN>) { ...@@ -55,9 +59,19 @@ while (<STDIN>) {
@time = localtime ; @time = localtime ;
$time[4]++ ; $time[5]+=1900 ; $time[4]++ ; $time[5]+=1900 ;
$mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4], @time[3], @time[2], @time[1] ; $mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4], @time[3], @time[2], @time[1] ;
$isotime = sprintf "%s-%02s-%02sT%02s:%02s:%02sZ",reverse @time[0..5] ;
# POLL GPS FOR COORDINATES # POLL GPS FOR COORDINATES
($ns,$lat,$ew,$lon) = $gps->get_position ; if ($gpson) {
# if gps is used, actual values are written
($ns,$lat,$ew,$lon) = $gps->get_position ;
if ($ns =~ /S/i) { $lat*=-1 ; }
if ($ew =~ /W/i) { $lon*=-1 ; }
} else {
# if no gps is used be we are on station, these coordinates a written
$lon = $culon ;
$lat = $culat ;
}
# THIS IS THE EXIT COMMAND # THIS IS THE EXIT COMMAND
if ( $line[0] =~ /exit/) {last;} if ( $line[0] =~ /exit/) {last;}
...@@ -71,28 +85,29 @@ while (<STDIN>) { ...@@ -71,28 +85,29 @@ while (<STDIN>) {
print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ; print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ;
printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ; printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ;
} elsif ($cus =~ /$line[1]/) { # case : we are currently at this station } elsif ($cus =~ /$line[1]/) { # case : we are currently at this station
$cus = "none" ; $cus = "none" ;
print "$pre\t\t\tEND OF STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n>\n>\n> " ; 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] ; printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ;
$pre = ">" ; $pre = ">" ;
} else { # case : we are currently at a different station } else { # case : we are currently at a different station
printf OUT $frmt,$line[0],reverse @time[0..5],$cus ; printf OUT $frmt,$line[0],$lat,$lon,$isotime,$cus ;
print "$pre\t\t\tEND OF STATION\t $cus,\t\t\t TIME : $mmddHHMM\n>\n>\n" ; print "$pre\t\t\tEND OF STATION\t $cus,\t\t\t TIME : $mmddHHMM\n>\n>\n" ;
$cus = $line[1] ; $cus = $line[1] ;
print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ; print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ;
printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ; printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ;
} }
} }
# THIS IS A NEW LEG ENTRY # THIS IS A NEW LEG ENTRY
elsif ($line[0] =~ /lg/) { elsif ($line[0] =~ /lg/) {
$cul++ ; $cul++ ;
print ">\tNOW RECORDING LEG $cul\n> " ; print ">\tNOW RECORDING LEG $cul\n> " ;
printf OUT $frmt,$line[0],$lat,$lon,$isotime,$cul ;
} }
# THIS IS AN OPERATION ENTRY # THIS IS AN OPERATION ENTRY
...@@ -102,6 +117,7 @@ while (<STDIN>) { ...@@ -102,6 +117,7 @@ while (<STDIN>) {
print "$pre\t\t\tOPERATION\t\t$line[1],\t\t\t\tTIME : $mmddHHMM\n" ; print "$pre\t\t\tOPERATION\t\t$line[1],\t\t\t\tTIME : $mmddHHMM\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ;
print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ;
printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ;
} }
} }
} }
...@@ -109,6 +125,7 @@ while (<STDIN>) { ...@@ -109,6 +125,7 @@ while (<STDIN>) {
# THIS IS A COMMENT ENTRY # THIS IS A COMMENT ENTRY
elsif ($line[0] =~ /cm/) { elsif ($line[0] =~ /cm/) {
print "$pre\t\t\tCOMMENT : $line[1] \n$pre " ; print "$pre\t\t\tCOMMENT : $line[1] \n$pre " ;
printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ;
} }
# UNRECOGNIZED INPUT # UNRECOGNIZED INPUT
......
...@@ -32,21 +32,37 @@ sub sub_cruiseinfo { ...@@ -32,21 +32,37 @@ sub sub_cruiseinfo {
while (<STDIN>) { while (<STDIN>) {
chop($_) ; chop($_) ;
push(@sts,$_) ; push(@sts,$_) ;
push(@stslon,"NaN") ;
push(@stslat,"NaN") ;
print ">> : " ; print ">> : " ;
$numsts++ ; $numsts++ ;
} }
print "\n" ;
# Manually enter GPS values for stations if no GPS is used
if (not $gpson) {
for ($ii=0;$ii<$numsts;$ii++) {
print ">> Enter lon;lat of station $sts[$ii] (pm180) : " ;
chop($line = <STDIN>) ;
($stslon[$ii],$stslat[$ii]) = split(/;/,$line) ;
}
}
print "\n\n\n" ; print "\n\n\n" ;
# print header to outputfile # print header to outputfile
print OUT "\# $name\n" ; print OUT "\# $name\n" ;
print OUT "\# $folder\n" ; print OUT "\# $folder\n" ;
print OUT "\# $gpson\n" ;
print OUT "\# $gpsport\n" ;
print OUT "\# $gpsbaud\n" ;
print OUT "\# $numops\n" ; print OUT "\# $numops\n" ;
for ($ii=0;$ii<$numops;$ii++) { print OUT "\# $ops[$ii]\n" ; } for ($ii=0;$ii<$numops;$ii++) { print OUT "\# $ops[$ii]\n" ; }
print OUT "\# $numsts\n" ; print OUT "\# $numsts\n" ;
for ($ii=0;$ii<$numsts;$ii++) { print OUT "\# $sts[$ii]\n" ; } for ($ii=0;$ii<$numsts;$ii++) { print OUT "\# $sts[$ii];$stslat[ii];$stslon[ii]\n" ; }
print OUT "\# 0\n" ; print OUT "\# 0\n" ;
$cul = 0 ; $cul = 0 ;
print OUT "\# Type lon lat yyyy mm dd HH MM SS Name\n" ; @coltitles = ("\#type","longitude","latitude","yyyy-mm-ddTHH:MM:SSZ","value") ;
printf OUT "%5s;%10s;%10s;%20s;%s\n",@coltitles ;
$headerstring = "Starting operations log for $name cruise" ; $headerstring = "Starting operations log for $name cruise" ;
......
...@@ -9,16 +9,19 @@ sub sub_getgps { ...@@ -9,16 +9,19 @@ sub sub_getgps {
print ">> Baud rate...? : " ; print ">> Baud rate...? : " ;
chop($gpsbaud = <STDIN>) ; chop($gpsbaud = <STDIN>) ;
print "\n" ; print "\n" ;
$gpson = 1 ;
} else {
$gpson = 0 ;
}
$gps = new GPS::NMEA( 'Port' => "$gpsport", $gps = new GPS::NMEA( 'Port' => "$gpsport",
'Baud' => $gpsbaud, 'Baud' => $gpsbaud,
); );
$gpson = 1 ;
} else {
$gpson = 0 ;
$gpsport = "NaN" ;
$gpsbaud = "NaN" ;
$gps = "NaN" ;
}
return $gps ; return ($gps,$gpson,$gpsport,$gpsbaud) ;
} }
1; 1;
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