Commit f199093a1111e27a182d37622a38fc142fab31d9
1 parent
b5a8ec81
Exists in
master
Still need to write preset station coordinates to outfile. Perhaps using an indexed array.
Showing
3 changed files
with
53 additions
and
17 deletions
Show diff stats
LogGen.pl
... | ... | @@ -21,13 +21,13 @@ chop($folder = <STDIN>) ; |
21 | 21 | print "\n" ; |
22 | 22 | |
23 | 23 | # SETUP GPS |
24 | -$gps = sub_getgps() ; | |
24 | +($gps,$gpson,$gpsport,$gpsbaud) = sub_getgps() ; | |
25 | 25 | |
26 | 26 | # ASK FOR or READ CRUISE INFO |
27 | -($ops,$sts,$numops,$numsts,$headerstring) = sub_cruiseinfo($name,$folder) ; | |
27 | +($ops,$sts,$numops,$numsts,$headerstring) = sub_cruiseinfo($name,$folder,$gpson,$gpsport,$gpsbaud) ; | |
28 | 28 | |
29 | 29 | # SET PRINTING FORMAT |
30 | -$frmt = " \%4s \%.4f \%.4f \%4s \%2s \%2s \%2s \%2s \%2s \%s\n" ; | |
30 | +$frmt = "%6s;%10.5f;%10.5f;%20s;%s\n" ; | |
31 | 31 | |
32 | 32 | # DISPLAY AVAILABLE STATIONS and OPERATIONS |
33 | 33 | print ">> AVAILABLE OPERATIONS ARE:\n"; |
... | ... | @@ -37,8 +37,12 @@ print ">> PLANNED STATIONS ARE:\n"; |
37 | 37 | foreach $line (@sts) { print ">> $line\n"; } |
38 | 38 | print ">> ---\n\n" ; |
39 | 39 | |
40 | -$pre = ">" ; | |
41 | -$cus = "none" ; | |
40 | +# INITIAL VALUES | |
41 | +$pre = ">" ; | |
42 | +$cus = "none" ; | |
43 | +$culon = "NaN" ; | |
44 | +$culat = "NaN" ; | |
45 | + | |
42 | 46 | |
43 | 47 | # DEFAULT START HEADER |
44 | 48 | print "=============================================================================================\n" ; |
... | ... | @@ -55,9 +59,19 @@ while (<STDIN>) { |
55 | 59 | @time = localtime ; |
56 | 60 | $time[4]++ ; $time[5]+=1900 ; |
57 | 61 | $mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4], @time[3], @time[2], @time[1] ; |
62 | + $isotime = sprintf "%s-%02s-%02sT%02s:%02s:%02sZ",reverse @time[0..5] ; | |
58 | 63 | |
59 | 64 | # POLL GPS FOR COORDINATES |
60 | - ($ns,$lat,$ew,$lon) = $gps->get_position ; | |
65 | + if ($gpson) { | |
66 | + # if gps is used, actual values are written | |
67 | + ($ns,$lat,$ew,$lon) = $gps->get_position ; | |
68 | + if ($ns =~ /S/i) { $lat*=-1 ; } | |
69 | + if ($ew =~ /W/i) { $lon*=-1 ; } | |
70 | + } else { | |
71 | + # if no gps is used be we are on station, these coordinates a written | |
72 | + $lon = $culon ; | |
73 | + $lat = $culat ; | |
74 | + } | |
61 | 75 | |
62 | 76 | # THIS IS THE EXIT COMMAND |
63 | 77 | if ( $line[0] =~ /exit/) {last;} |
... | ... | @@ -71,28 +85,29 @@ while (<STDIN>) { |
71 | 85 | print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ; |
72 | 86 | print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; |
73 | 87 | print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; |
74 | - printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ; | |
88 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ; | |
75 | 89 | |
76 | 90 | } elsif ($cus =~ /$line[1]/) { # case : we are currently at this station |
77 | 91 | $cus = "none" ; |
78 | 92 | print "$pre\t\t\tEND OF STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n>\n>\n> " ; |
79 | - printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ; | |
93 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ; | |
80 | 94 | $pre = ">" ; |
81 | 95 | |
82 | 96 | } else { # case : we are currently at a different station |
83 | - printf OUT $frmt,$line[0],reverse @time[0..5],$cus ; | |
97 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$cus ; | |
84 | 98 | print "$pre\t\t\tEND OF STATION\t $cus,\t\t\t TIME : $mmddHHMM\n>\n>\n" ; |
85 | 99 | $cus = $line[1] ; |
86 | 100 | print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n" ; |
87 | 101 | print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; |
88 | 102 | print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; |
89 | - printf OUT $frmt,$line[0],reverse @time[0..5],$line[1] ; | |
103 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ; | |
90 | 104 | } |
91 | 105 | } |
92 | 106 | # THIS IS A NEW LEG ENTRY |
93 | 107 | elsif ($line[0] =~ /lg/) { |
94 | 108 | $cul++ ; |
95 | 109 | print ">\tNOW RECORDING LEG $cul\n> " ; |
110 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$cul ; | |
96 | 111 | } |
97 | 112 | |
98 | 113 | # THIS IS AN OPERATION ENTRY |
... | ... | @@ -102,6 +117,7 @@ while (<STDIN>) { |
102 | 117 | print "$pre\t\t\tOPERATION\t\t$line[1],\t\t\t\tTIME : $mmddHHMM\n" ; |
103 | 118 | print "$pre\t\t\t\t\t\t\t\t\t\tLON : $lon\n" ; |
104 | 119 | print "$pre\t\t\t\t\t\t\t\t\t\tLAT : $lat\n$pre " ; |
120 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ; | |
105 | 121 | } |
106 | 122 | } |
107 | 123 | } |
... | ... | @@ -109,6 +125,7 @@ while (<STDIN>) { |
109 | 125 | # THIS IS A COMMENT ENTRY |
110 | 126 | elsif ($line[0] =~ /cm/) { |
111 | 127 | print "$pre\t\t\tCOMMENT : $line[1] \n$pre " ; |
128 | + printf OUT $frmt,$line[0],$lat,$lon,$isotime,$line[1] ; | |
112 | 129 | } |
113 | 130 | |
114 | 131 | # UNRECOGNIZED INPUT | ... | ... |
sub_cruiseinfo.pl
... | ... | @@ -32,21 +32,37 @@ sub sub_cruiseinfo { |
32 | 32 | while (<STDIN>) { |
33 | 33 | chop($_) ; |
34 | 34 | push(@sts,$_) ; |
35 | + push(@stslon,"NaN") ; | |
36 | + push(@stslat,"NaN") ; | |
35 | 37 | print ">> : " ; |
36 | 38 | $numsts++ ; |
37 | 39 | } |
40 | + print "\n" ; | |
41 | + | |
42 | + # Manually enter GPS values for stations if no GPS is used | |
43 | + if (not $gpson) { | |
44 | + for ($ii=0;$ii<$numsts;$ii++) { | |
45 | + print ">> Enter lon;lat of station $sts[$ii] (pm180) : " ; | |
46 | + chop($line = <STDIN>) ; | |
47 | + ($stslon[$ii],$stslat[$ii]) = split(/;/,$line) ; | |
48 | + } | |
49 | + } | |
38 | 50 | print "\n\n\n" ; |
39 | 51 | |
40 | 52 | # print header to outputfile |
41 | 53 | print OUT "\# $name\n" ; |
42 | 54 | print OUT "\# $folder\n" ; |
55 | + print OUT "\# $gpson\n" ; | |
56 | + print OUT "\# $gpsport\n" ; | |
57 | + print OUT "\# $gpsbaud\n" ; | |
43 | 58 | print OUT "\# $numops\n" ; |
44 | 59 | for ($ii=0;$ii<$numops;$ii++) { print OUT "\# $ops[$ii]\n" ; } |
45 | 60 | print OUT "\# $numsts\n" ; |
46 | - for ($ii=0;$ii<$numsts;$ii++) { print OUT "\# $sts[$ii]\n" ; } | |
61 | + for ($ii=0;$ii<$numsts;$ii++) { print OUT "\# $sts[$ii];$stslat[ii];$stslon[ii]\n" ; } | |
47 | 62 | print OUT "\# 0\n" ; |
48 | 63 | $cul = 0 ; |
49 | - print OUT "\# Type lon lat yyyy mm dd HH MM SS Name\n" ; | |
64 | + @coltitles = ("\#type","longitude","latitude","yyyy-mm-ddTHH:MM:SSZ","value") ; | |
65 | + printf OUT "%5s;%10s;%10s;%20s;%s\n",@coltitles ; | |
50 | 66 | |
51 | 67 | $headerstring = "Starting operations log for $name cruise" ; |
52 | 68 | ... | ... |
sub_getgps.pl
... | ... | @@ -9,16 +9,19 @@ sub sub_getgps { |
9 | 9 | print ">> Baud rate...? : " ; |
10 | 10 | chop($gpsbaud = <STDIN>) ; |
11 | 11 | print "\n" ; |
12 | - $gpson = 1 ; | |
13 | - } else { | |
14 | - $gpson = 0 ; | |
15 | - } | |
16 | 12 | $gps = new GPS::NMEA( 'Port' => "$gpsport", |
17 | 13 | 'Baud' => $gpsbaud, |
18 | 14 | ); |
15 | + $gpson = 1 ; | |
16 | + } else { | |
17 | + $gpson = 0 ; | |
18 | + $gpsport = "NaN" ; | |
19 | + $gpsbaud = "NaN" ; | |
20 | + $gps = "NaN" ; | |
21 | + } | |
19 | 22 | |
20 | 23 | |
21 | - return $gps ; | |
24 | + return ($gps,$gpson,$gpsport,$gpsbaud) ; | |
22 | 25 | } |
23 | 26 | |
24 | 27 | 1; | ... | ... |