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 $updatepermin = 60 / 2.5; # no of updates per minute
our $loop_count; # how many LOOPs we have done, used as start indicator
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';
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;
}
}
};
name: 'Rainfall',
type: 'column',
yAxis: 1,
+ labels: {
+// enabled: true,
+// format: '{point.y:.1f}', // one decimal
+// rotation: -90,
+ overflow: 'justify'
+ },
data: [
<% $s = "";
for (@main::last5daysh) {
},
series: [ {
- type: 'column',
+ type: 'scatter',
name: 'Wind mph',
data: [
<% my ($d, $w);
pane: {
startAngle: 0,
- endAngle: 359,
+ endAngle: 360,
background: [{
backgroundColor: {
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
// the value axis
yAxis: {
min: 0,
- max: 360,
+ max: 359,
minorTickInterval: 'auto',
minorTickWidth: 1,
var conv = 2.23694;
- function fill_windrose(js, points) {
+ function fill_windrose(rr, 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));
}
- function fill_winddir(js) {
- var rr = js.r;
+ function fill_winddir(rr) {
var point = winddir.series[0].points[0];
point.update(rr.Dir);
}