our $ld = {};
our @last10minsr = ();
our @last5daysh = ();
+our $windmins = 2; # no of minutes of wind data for the windrose
+our $histdays = 5; # no of days of (half)hour data to search for main graph
+our $updatepermin = 60 / 2.5; # no of updates per minute
our $loop_count; # how many LOOPs we have done, used as start indicator
$c->send($ld->{lasthour_h}) if exists $ld->{lasthour_h};
$c->send($ld->{lastmin_h}) if exists $ld->{lastmin_h};
- # send the 5 days worth of data to the graph
- say "last10min = " . scalar @last10minsr . " last5day = " . scalar @last5daysh;
- $c->send($_) for @last10minsr;
- $c->send($_) for @last5daysh;
-
# disable timeout
$c->inactivity_timeout(3615);
my $tnow = time;
my $dayno = int ($tnow/86400);
-@last5daysh = grab_history(SMGLog->new("day"), "h", $tnow-(86400*5), $_) for ($dayno-4, $dayno-3, $dayno-2, $dayno-1, $dayno);
-@last10minsr = map {my ($t, $js) = split(/\s/, $_, 2); $js} grab_history(SMGLog->new("debug"), "r", $tnow-(60*3), $dayno);
+for (my $i = 0-$histdays; $i < 0; ++$i ) {
+ push @last5daysh, grab_history(SMGLog->new("day"), "h", $tnow-(86400*$histdays), $dayno+$i+1);
+}
+@last10minsr = map {my ($t, $js) = split(/\s/, $_, 2); $js} grab_history(SMGLog->new("debug"), "r", $tnow-(60*$windmins), $dayno);
+dbg sprintf("last5days = %d last10mins = %d", scalar @last5daysh, scalar @last10minsr);
our $dlog = SMGLog->new("day");
dbg "before next tick";
Mojo::IOLoop->next_tick(sub { loop() });
dbg "before app start";
+app->secrets([qw(Here's something that's really seakrett)]);
app->start;
dbg "after app start";
} else {
my $o = gen_hash_diff($ld->{last_h}, \%h);
if ($o) {
+ $o->{Dir} ||= $h{Dir};
+ $o->{Wind} ||= $h{Wind};
+ $o->{Dir} += 0;
+ $o->{Wind} += 0;
$s = genstr($ts, 'r', $o);
push @last10minsr, $s;
- shift @last10minsr if @last10minsr > 240;
+ shift @last10minsr while @last10minsr > ($windmins * $updatepermin);
}
else {
dbg "loop rec not changed" if isdbg 'chan';