LogGen.pl 3.08 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/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) ;