-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoolDown.pl
executable file
·37 lines (29 loc) · 1.06 KB
/
coolDown.pl
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
#!/usr/bin/env perl
use cycleSprinklers;
use weatherLib;
use dateLib;
use sprinklerConfig;
$SIG{'INT'} = 'terminationHandler';
$SIG{'ABRT'} = 'terminationHandler';
$SIG{'TERM'} = 'terminationHandler';
$SIG{'SEGV'} = 'terminationHandler';
my $time = time;
my $currentConditions = getCurrentConditions();
if ( isRaining($currentConditions) ) {
die getDateString($time), " - Cond: $currentConditions - Rain: No Sprinklers\n";
}
print getDateString($time), " - Current:$currentConditions\n";
my $currentTemperature = getCurrentTemperature();
if ( $currentTemperature < $sprinklerConfig::coolDownThreshold ) {
die getDateString($time), " - Temp: $currentTemperature - Cool: No Sprinklers\n";
}
my $cyclesToWater = 1;
print getDateString($time), " - Current:$currentTemperature > Threshold: ", $sprinklerConfig::coolDownThreshold, " - Cool Down $cyclesToWater\n";
&cycleSprinklers($cyclesToWater);
$time = time;
print getDateString($time), " - stopping\n";
sub terminationHandler {
print "Termination Signal Received - stopping\n";
turnSprinklersOff();
exit(-10);
}