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

Initial commit. Still need to implement writing to the outfile, formatting...

Initial commit. Still need to implement writing to the outfile, formatting comments, suppressing STDIN for comments, and writing operations and stations to the file header before we can call this functionnal. It is also still pretty ugly.
parents
#!/usr/bin/perl
# HEADER AND INSTRUCTIONS
print "========== ========== ========== LogGen ========== ========== ==========\n\n" ;
# ACQUIRE CRUISE INFORMATION
# cruise name
print ">> Enter cruise name : " ;
chop($name = <STDIN>) ;
print "\n" ;
# set cruise directory
print ">> Enter cruise directory : " ;
chop($folder = <STDIN>) ;
print "\n" ;
# 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
} 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") ;
print ">> Enter operations, end with CTRL-d : " ;
# operations to be conducted
while ( <STDIN> ) {
chop($_) ;
push(@ops,$_) ;
print ">> : " ;
}
print "\n" ;
# stations to be visited
print ">> Enter stations names, end with CTRL-d : " ;
while (<STDIN>) {
chop($_) ;
push(@sts,$_) ;
print ">> : " ;
}
print "\n\n\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" ;
# DEFAULT START HEADER
print "======================================================================================================\n" ;
print "===== START =====\n" ;
print "======================================================================================================\n\n" ;
print "> LEG 001\n> " ;
$pre = ">" ;
$cus = "none" ;
$cul = "1" ;
# RUNNING LOOP TO ADD TO CRUISE DATA FILE
while (<STDIN>) {
@time = localtime ;
$mmddHHMM = sprintf "%02d/%02d %02d:%02d", @time[4]+1, @time[3], @time[2], @time[1] ;
chop( $_ ) ;
@line = split( "=", $_ ) ;
# THIS IS THE EXIT COMMAND
if ( $_ =~ /exit/) {last;}
# THIS IS A STATION ENTRY
elsif ($line[0] =~ /st/) {
if ( $cus =~ /none/ ) { # case : we are currently off station
$cus = $line[1] ;
$pre = ">>" ;
print "$pre\t\tNOW RECORDING STATION\t $line[1],\t\t\t TIME : $mmddHHMM\n$pre " ;
} 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> " ;
$pre = ">" ;
} else { # case : we are currently at a different station
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 " ;
}
}
# THIS IS AN OPERATION ENTRY
elsif ($line[0] =~ /op/) {
foreach $op (@ops) {
if ($line[1] =~ /$op/) {
print "$pre\t\t\tOPERATION\t\t$line[1],\t\t\t\tTIME : $mmddHHMM\n$pre " ;
}
}
}
# THIS IS A COMMENT ENTRY
elsif ($line[0] =~ /cm/) {
print "$pre\t\t\tCOMMENT : $line[1] \n$pre " ;
}
# UNRECOGNIZED INPUT
else {print "$pre UNDEFINED INPUT \n$pre " ;}
}
# CLOSE FILE HANDLES
close(OUT) ;
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