projects
/
dweather.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
66549cb
)
fix windrose and other tarting
author
Dirk Koopman
<djk@tobit.co.uk>
Mon, 4 May 2015 13:33:45 +0000
(14:33 +0100)
committer
Dirk Koopman
<djk@tobit.co.uk>
Mon, 4 May 2015 13:33:45 +0000
(14:33 +0100)
loop.pl
patch
|
blob
|
history
templates/index.html.ep
patch
|
blob
|
history
diff --git
a/loop.pl
b/loop.pl
index fe9165779d3ac551e9b0a66a9ecb5b943e9f016b..e287ce5913b0370d0aa32345ac6348b42b343541 100755
(executable)
--- a/
loop.pl
+++ b/
loop.pl
@@
-42,8
+42,9
@@
our $WS = {}; # websocket connections
our $ld = {};
our @last10minsr = ();
our @last5daysh = ();
our $ld = {};
our @last10minsr = ();
our @last5daysh = ();
-our $windmins =
5
; # no of minutes of wind data for the windrose
+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 $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
our $loop_count; # how many LOOPs we have done, used as start indicator
@@
-164,6
+165,7
@@
our $dlog = SMGLog->new("day");
dbg "before next tick";
Mojo::IOLoop->next_tick(sub { loop() });
dbg "before app start";
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";
app->start;
dbg "after app start";
@@
-486,9
+488,13
@@
sub process
} else {
my $o = gen_hash_diff($ld->{last_h}, \%h);
if ($o) {
} 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;
$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';
}
else {
dbg "loop rec not changed" if isdbg 'chan';
diff --git
a/templates/index.html.ep
b/templates/index.html.ep
index cd8155ac915383febf006cc071da7048e00738d5..2dd444fe94f7404d6aa13e8ce7febd4385a9188d 100644
(file)
--- a/
templates/index.html.ep
+++ b/
templates/index.html.ep
@@
-72,23
+72,18
@@
if ("h" in js) {
fill_daychart(js, daychart_days);
}
if ("h" in js) {
fill_daychart(js, daychart_days);
}
- if ("r" in js) {
-// if (js.t > lastt + 15) {
- if ("Wind" in js.r) {
- lastwind = js.r.Wind;
- } else {
- js.r.Wind = lastwind;
- }
- if ("Dir" in js.r) {
- lastdir = js.r.dir;
- } else {
- js.r.Dir = lastdir;
- }
- lastt = js.t;
- fill_windrose(js, windrose_mins * 24);
-// }
- fill_windspeed(js);
- fill_winddir(js);
+ if ("r" in js || "m" in js) {
+ var rr;
+ rr = js.r || js.m;
+ if (!("Dir" in rr))
+ rr.Dir = lastdir;
+ if (!("Wind" in rr))
+ rr.Wind = lastwind;
+ fill_windrose(rr, windrose_mins * $updatespermin);
+ fill_windspeed(rr);
+ fill_winddir(rr);
+ lastwind = rr.Wind;
+ lastdir = rr.Dir;
}
}
};
}
}
};
@@
-188,6
+183,12
@@
name: 'Rainfall',
type: 'column',
yAxis: 1,
name: 'Rainfall',
type: 'column',
yAxis: 1,
+ labels: {
+// enabled: true,
+// format: '{point.y:.1f}', // one decimal
+// rotation: -90,
+ overflow: 'justify'
+ },
data: [
<% $s = "";
for (@main::last5daysh) {
data: [
<% $s = "";
for (@main::last5daysh) {
@@
-362,7
+363,7
@@
},
series: [ {
},
series: [ {
- type: '
column
',
+ type: '
scatter
',
name: 'Wind mph',
data: [
<% my ($d, $w);
name: 'Wind mph',
data: [
<% my ($d, $w);
@@
-505,7
+506,7
@@
pane: {
startAngle: 0,
pane: {
startAngle: 0,
- endAngle: 3
59
,
+ endAngle: 3
60
,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
@@
-539,7
+540,7
@@
// the value axis
yAxis: {
min: 0,
// the value axis
yAxis: {
min: 0,
- max: 3
60
,
+ max: 3
59
,
minorTickInterval: 'auto',
minorTickWidth: 1,
minorTickInterval: 'auto',
minorTickWidth: 1,
@@
-597,20
+598,18
@@
var conv = 2.23694;
var conv = 2.23694;
- function fill_windrose(
js
, points) {
+ function fill_windrose(
rr
, points) {
var p = windrose.series[0].data.length > points;
var p = windrose.series[0].data.length > points;
- var
rr = js.r
;
- windrose.series[0].addPoint(
[rr.Dir, Math.round(rr.Wind*conv)]
, true, p);
+ var
v = [rr.Dir, (rr.Wind*conv)]
;
+ windrose.series[0].addPoint(
v
, true, p);
}
}
- function fill_windspeed(js) {
- var rr = js.r;
+ function fill_windspeed(rr) {
var point = windspeed.series[0].points[0];
point.update(Math.round(rr.Wind*conv));
}
var point = windspeed.series[0].points[0];
point.update(Math.round(rr.Wind*conv));
}
- function fill_winddir(js) {
- var rr = js.r;
+ function fill_winddir(rr) {
var point = winddir.series[0].points[0];
point.update(rr.Dir);
}
var point = winddir.series[0].points[0];
point.update(rr.Dir);
}