Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean-Luc Shaw
LogGen_windows
Commits
6b2588b4
Commit
6b2588b4
authored
May 11, 2018
by
unknown
Browse files
First commit after modification to make run on windows 7.
parent
3f96f345
Changes
3
Hide whitespace changes
Inline
Side-by-side
LogGen.pl
View file @
6b2588b4
#!/usr/bin/perl
# DEPENDENCIES
use
GPS::
NMEA
;
# http://search.cpan.org/dist/perl-GPS/NMEA.pm
require
"
./
sub_cruiseinfo.pl
"
;
require
"
./
sub_getgps.pl
"
;
require
"
sub_cruiseinfo.pl
"
;
require
"
sub_getgps.pl
"
;
# HEADER AND INSTRUCTIONS
print
"
========== ========== ========== LogGen ========== ========== ==========
\
n
\n
"
;
print
"
========== ========== ========== LogGen ========== ========== ==========
\
r\n\r
\n
"
;
# ACQUIRE CRUISE INFORMATION
# cruise name
print
"
>> Enter cruise name :
"
;
chop
(
$name
=
<
STDIN
>
)
;
print
"
\n
"
;
print
"
\
r\
n
"
;
# set cruise directory
print
"
>> Enter cruise directory :
"
;
chop
(
$folder
=
<
STDIN
>
)
;
print
"
\n
"
;
# SETUP GPS
(
$gps
,
$gpson
,
$gpsport
,
$gpsbaud
)
=
sub_getgps
()
;
print
"
\r\n
"
;
# ASK FOR or READ CRUISE INFO
(
$ops
,
$sts
,
$numops
,
$numsts
,
$headerstring
,
$stslat
,
$stslon
)
=
sub_cruiseinfo
(
$name
,
$folder
,
$gpson
,
$gpsport
,
$gpsbaud
)
;
(
$ops
,
$sts
,
$
gps
,
$gpson
,
$
numops
,
$numsts
,
$headerstring
,
$stslat
,
$stslon
)
=
sub_cruiseinfo
()
;
# SET PRINTING FORMAT
$frmt
=
"
%6s;%10.5f;%10.5f;%20s;%s
\n
"
;
$frmt
=
"
%6s;%10.5f;%10.5f;%20s;%s
\
r\
n
"
;
# DISPLAY AVAILABLE STATIONS and OPERATIONS
print
"
>> AVAILABLE OPERATIONS ARE:
\n
";
foreach
$line
(
@ops
)
{
print
"
>>
$line
\n
";
}
print
"
>> ---
\
n
\n
"
;
print
"
>> PLANNED STATIONS ARE:
\n
";
foreach
$line
(
@sts
)
{
print
"
>>
$line
\n
";
}
print
"
>> ---
\
n
\n
"
;
print
"
>> AVAILABLE OPERATIONS ARE:
\
r\
n
";
foreach
$line
(
@ops
)
{
print
"
>>
$line
\
r\
n
";
}
print
"
>> ---
\
r\n\r
\n
"
;
print
"
>> PLANNED STATIONS ARE:
\
r\
n
";
foreach
$line
(
@sts
)
{
print
"
>>
$line
\
r\
n
";
}
print
"
>> ---
\
r\n\r
\n
"
;
# INITIAL VALUES
$pre
=
"
>
"
;
$cus
=
"
none
"
;
# DEFAULT START HEADER
print
"
=============================================================================================
\n
"
;
print
"
=====
$headerstring
=====
\n
"
;
print
"
=============================================================================================
\
n
\n
>
"
;
print
"
=============================================================================================
\
r\
n
"
;
print
"
=====
$headerstring
=====
\
r\
n
"
;
print
"
=============================================================================================
\
r\n\r
\n
>
"
;
# RUNNING LOOP TO ADD TO CRUISE DATA FILE
while
(
<
STDIN
>
)
{
...
...
@@ -66,8 +63,8 @@ while (<STDIN>) {
if
(
$ew
=~
/W/i
)
{
$lon
*=-
1
;
}
}
else
{
# if no gps is used be we are on station, these coordinates a written
$lon
=
%
stslon
{
$cus
}
;
$lat
=
%
stslat
{
$cus
}
;
$lon
=
$
stslon
{
$cus
}
;
$lat
=
$
stslat
{
$cus
}
;
}
# THIS IS THE EXIT COMMAND
...
...
@@ -80,38 +77,38 @@ while (<STDIN>) {
$cus
=
$line
[
1
]
;
$pre
=
"
>>
"
;
if
(
not
$gpson
)
{
$lon
=
%
stslon
{
$cus
}
;
$lat
=
%
stslat
{
$cus
}
;
$lon
=
$
stslon
{
$cus
}
;
$lat
=
$
stslat
{
$cus
}
;
}
print
"
$pre
\t\t
NOW RECORDING STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\n
$pre
"
;
print
"
$pre
\t\t
NOW RECORDING STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\
r\
n
$pre
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$line
[
1
]
;
}
elsif
(
$cus
=~
/$line[1]/
)
{
# case : we are currently at this station
$cus
=
"
none
"
;
print
"
$pre
\t\t\t
END OF STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\n
>
\
n
>
\n
>
"
;
print
"
$pre
\t\t\t
END OF STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\
r\
n
>
\
r\n
>
\r
\n
>
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$line
[
1
]
;
$pre
=
"
>
"
;
}
else
{
# case : we are currently at a different station
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$cus
;
print
"
$pre
\t\t\t
END OF STATION
\t
$cus
,
\t\t\t
TIME :
$mmddHHMM
\n
>
\
n
>
\n
"
;
print
"
$pre
\t\t\t
END OF STATION
\t
$cus
,
\t\t\t
TIME :
$mmddHHMM
\
r\
n
>
\
r\n
>
\r
\n
"
;
$cus
=
$line
[
1
]
;
if
(
not
$gpson
)
{
$lon
=
%
stslon
{
$cus
}
;
$lat
=
%
stslat
{
$cus
}
;
$lon
=
$
stslon
{
$cus
}
;
$lat
=
$
stslat
{
$cus
}
;
}
print
"
$pre
\t\t
NOW RECORDING STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\n
$pre
"
;
print
"
$pre
\t\t
NOW RECORDING STATION
\t
$line
[1],
\t\t\t
TIME :
$mmddHHMM
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\
r\
n
$pre
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$line
[
1
]
;
}
}
# THIS IS A NEW LEG ENTRY
elsif
(
$line
[
0
]
=~
/lg/
)
{
$cul
++
;
print
"
>
\t
NOW RECORDING LEG
$cul
\n
>
"
;
print
"
>
\t
NOW RECORDING LEG
$cul
\
r\
n
>
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$cul
;
}
...
...
@@ -119,9 +116,9 @@ while (<STDIN>) {
elsif
(
$line
[
0
]
=~
/op/
)
{
foreach
$op
(
@ops
)
{
if
(
$line
[
1
]
=~
/$op/
)
{
print
"
$pre
\t\t\t
OPERATION
\t\t
$line
[1],
\t\t\t\t
TIME :
$mmddHHMM
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\n
$pre
"
;
print
"
$pre
\t\t\t
OPERATION
\t\t
$line
[1],
\t\t\t\t
TIME :
$mmddHHMM
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LON :
$lon
\
r\
n
"
;
print
"
$pre
\t\t\t\t\t\t\t\t\t\t
LAT :
$lat
\
r\
n
$pre
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$line
[
1
]
;
}
}
...
...
@@ -129,12 +126,12 @@ while (<STDIN>) {
# THIS IS A COMMENT ENTRY
elsif
(
$line
[
0
]
=~
/cm/
)
{
print
"
$pre
\t\t\t
COMMENT :
$line
[1]
\n
$pre
"
;
print
"
$pre
\t\t\t
COMMENT :
$line
[1]
\r
\n
$pre
"
;
printf
OUT
$frmt
,
$line
[
0
],
$lat
,
$lon
,
$isotime
,
$line
[
1
]
;
}
# UNRECOGNIZED INPUT
else
{
print
"
$pre
UNDEFINED INPUT
\n
$pre
"
;}
else
{
print
"
$pre
UNDEFINED INPUT
\r
\n
$pre
"
;}
}
...
...
readme.md
0 → 100644
View file @
6b2588b4
HEARDER INFO for .out files
LINE 1 : Cruise info
LINE 2 : Cruise folder path
LINE 3 : GPS feature on or off (1 or 0)
LINE 4 : GPS serial port name
LINE 5 : GPS serial port baud rate
LINE 6 : Number of operation types (N)
LINE 7 : First operation type
LINE 7+N : Last operation type
LINE 7+N+1 : Number of stations (M)
LINE 7+N+2 : First station name;station latitude;station longitude
LINE 7+N+2+M : Last station name;station latitude;station longitude
LINE 7+N+3+M : Sequential current leg number
LINE 7+N+4+M : Column titles
LINE 7+N+5+M : Start of data entries
COLUMN DEFINITIONS
COL 0 = entry type (station,operation,comment) (string)
COL 1 = latitude in decimal degrees (float)
COL 2 = longitude in decimal degrees (float)
COL 3 = time in ISOXXXX standard yyyy-mm-ddTHH:MM:SSZ (string)
COL 4 = entry value (station name, ..., comment) (string)
sub_cruiseinfo.pl
View file @
6b2588b4
sub
sub_cruiseinfo
{
$name
=
$_
[
0
]
;
$folder
=
$_
[
1
]
;
# does this cruise already have a mission log?
if
(
-
e
"
$folder
/LogGen/
$name
.out
")
{
# Open the file handle to append
# Get the stations
# Get the operations
if
(
-
e
"
$folder
\\
LogGen
\\
$name
.out
")
{
# Open the file for reading
open
(
OUT
,"
$folder
\\
LogGen
\\
$name
.out
")
||
die
("
EXIT!! : Did not find LogGen folder or cruise folder
\n
")
;
# Read header and store in an array
while
(
<
OUT
>
)
{
if
(
$_
!~
/\#/
)
{
last
;}
chop
(
$_
)
;
$str
=
substr
$_
,
2
;
push
(
@header
,
$str
)
;
}
close
(
OUT
)
;
$gpson
=
$header
[
2
]
;
$gpsport
=
$header
[
3
]
;
$gpsbaud
=
$header
[
4
]
;
$numops
=
$header
[
5
]
;
# Get the operations
for
(
$ii
=
0
;
$ii
<
$numops
;
$ii
++
)
{
push
(
@ops
,
$header
[
6
+
$ii
])
;
}
$numsts
=
$header
[
6
+
$numops
]
;
# Get the stations and their coordinates
for
(
$ii
=
0
;
$ii
<
$numsts
;
$ii
++
)
{
@hl
=
split
(
/;/
,
$header
[
6
+
$numops
+
1
+
$ii
])
;
push
(
@sts
,
$hl
[
0
])
;
$stslon
{
$hl
[
0
]}
=
$hl
[
2
]
;
$stslat
{
$hl
[
0
]}
=
$hl
[
1
]
;
}
$stslon
{"
none
"}
=
"
NaN
"
;
$stslat
{"
none
"}
=
"
NaN
"
;
$headerstring
=
"
Continuing operations log for
$name
cruise
"
;
#Close the file handle and open for appending
close
(
OUT
)
;
open
(
OUT
,"
>>
$folder
\\
LogGen
\\
$name
.out
")
||
die
("
EXIT!! : Did not find LogGen folder or cruise folder
\n
")
;
}
else
{
# this cruise does not already have an output file
# MANAGE FILE HANDLES
# create and open the outfile handle
open
(
OUT
,"
>
$folder
/
LogGen
/
$name
.out
")
||
die
("
EXIT!! : Did not find LogGen folder or cruise folder
\n
")
;
open
(
OUT
,"
>
$folder
\\
LogGen
\\
$name
.out
")
||
die
("
EXIT!! : Did not find LogGen folder or cruise folder
\n
")
;
print
"
>> Enter operations, end with CTRL-d :
"
;
# operations to be conducted
...
...
@@ -37,6 +69,10 @@ sub sub_cruiseinfo {
}
print
"
\n
"
;
# Ask for gps and connect if needed
(
$gps
,
$gpson
,
$gpsport
,
$gpsbaud
)
=
sub_getgps
()
;
# Manually enter GPS values for stations if no GPS is used
if
(
not
$gpson
)
{
for
(
$ii
=
0
;
$ii
<
$numsts
;
$ii
++
)
{
...
...
@@ -61,7 +97,7 @@ sub sub_cruiseinfo {
for
(
$ii
=
0
;
$ii
<
$numsts
;
$ii
++
)
{
print
OUT
"
\
#
$sts
[
$ii
];
$stslat
{
$sts
[
$ii
]};
$stslon
{
$sts
[
$ii
]}
\n
"
;
}
print
OUT
"
\
# 0
\n
"
;
$cul
=
0
;
@coltitles
=
("
\
#type
","
l
ong
itude
","
l
at
itude
","
yyyy-mm-ddTHH:MM:SSZ
","
value
")
;
@coltitles
=
("
\
#type
","
l
at
itude
","
l
ong
itude
","
yyyy-mm-ddTHH:MM:SSZ
","
value
")
;
printf
OUT
"
%5s;%10s;%10s;%20s;%s
\n
",
@coltitles
;
$headerstring
=
"
Starting operations log for
$name
cruise
"
;
...
...
@@ -69,7 +105,7 @@ sub sub_cruiseinfo {
}
# RETURN NEEDED VALUES
return
(
\
@ops
,
\
@sts
,
$numops
,
$numsts
,
$headerstring
,
\
%stslat
,
\
%stslon
)
;
return
(
\
@ops
,
\
@sts
,
$
gps
,
$gpson
,
$
numops
,
$numsts
,
$headerstring
,
\
%stslat
,
\
%stslon
)
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment