X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=loop.pl;h=b0e430055b5cebe676ea338e091255938619502a;hb=ff9c8c8ded1b0ef402d75d968c07c15d6c4cbe1a;hp=bb28f1843e7372b2164aa90c7427ab2ae32b3b2f;hpb=feceb0bda28cea09e43b9497e38510ef404d5c4a;p=dweather.git diff --git a/loop.pl b/loop.pl index bb28f18..b0e4300 100755 --- a/loop.pl +++ b/loop.pl @@ -108,6 +108,12 @@ websocket '/weather' => sub { # send historical data $c->send($ld->{lasthour_h}) if exists $ld->{lasthour_h}; $c->send($ld->{lastmin_h}) if exists $ld->{lastmin_h}; + + # send the last 24 hour's worth of data to the graph + my $lg = SMGLog->new('day'); + my $tnow = time; + my $dayno = int($tnow/86400); + send_history($c, $lg, $tnow, $_) for ($dayno-1, $dayno); # disable timeout $c->inactivity_timeout(3615); @@ -128,7 +134,7 @@ websocket '/weather' => sub { $c->on(finish => sub { my ($c, $code, $reason) = @_; app->log->debug("WebSocket closed with status $code."); - dbg 'webwocket closed with status $code' if isdbg 'chan'; + dbg "websocket closed with status $code" if isdbg 'chan'; delete $WS->{$tx}; }); }; @@ -492,7 +498,7 @@ sub genstr my $h = shift; my $j = $json->encode($h); - my $tm = clocktime($ts, 1); + my $tm = clocktime($ts, $let eq 'r' ? 1 : 0); return qq|{"tm":"$tm","t":$ts,"$let":$j}|; } @@ -709,118 +715,21 @@ sub cycle_loop_data_files copy $datafn, "$datafn.o"; } -__DATA__ - -@@ index.html.ep -% my $url = url_for 'weather'; - - - - DWeather - - - - - - - - - - - - -

High View Weather

- - - -
-
-

- - - - - - - -
Time: - Sunrise: - Sunset: - Console Volts: - TX Battery OK: - -
Pressure: - Trend: - -
Temperature in: - Humidity: - -
Temperature out: - Min: @ - Max: @ - Humidity: - Dew Point: - -
Wind Direction: - Minute Avg: - Speed: - Minute Avg: - -
Rain 30mins: - Day: - 24hrs: - Month: - Year: -
-
-
-
-
- - - - - - +}