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
12e7b467
Commit
12e7b467
authored
May 06, 2018
by
Jean-Luc Shaw
Browse files
Writing text to output.
parent
b5cf52ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
LogGen.pl
View file @
12e7b467
#!/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\t
NOW 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\t
END 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\t
END OF STATION
\t
$cus
,
\t\t\t
TIME :
$mmddHHMM
\n
>
\n
>
\n
"
;
$cus
=
$line
[
1
]
;
print
"
$pre
\t\t
NOW 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
"
>
\t
NOW RECORDING LEG
$cul
\n
>
"
;
}
# THIS IS AN OPERATION ENTRY
elsif
(
$line
[
0
]
=~
/op/
)
{
...
...
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