From 98300a7aa0f28b3b37885d60de17892da4e419e8 Mon Sep 17 00:00:00 2001 From: Jakob Hirsch Date: Thu, 17 Mar 2011 03:11:24 +0100 Subject: [PATCH] added "steps" display this should much better represent the output from s0 electricity meters and water meters, where we get one impuls per energy or volume unit and (more important) the time interval depends on the throughput. this does not make much sense for temperature, though. unfortunately, we have currently no means to select different chart types depending on the entity type. also, I had to change the backend to output the starting time of the interval (flot needs that) instead of the ending time, which changes the "lines" chart. but since this chart is wrong for electricity and water anyway, it doesn't realy matter, though. --- htdocs/frontend/index.html | 1 + htdocs/frontend/javascripts/options.js | 2 +- htdocs/frontend/javascripts/wui.js | 4 +++- lib/Interpreter/MeterInterpreter.php | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/frontend/index.html b/htdocs/frontend/index.html index 43f4db9..c34e272 100644 --- a/htdocs/frontend/index.html +++ b/htdocs/frontend/index.html @@ -106,6 +106,7 @@   + diff --git a/htdocs/frontend/javascripts/options.js b/htdocs/frontend/javascripts/options.js index ab7200f..8e9d6ad 100644 --- a/htdocs/frontend/javascripts/options.js +++ b/htdocs/frontend/javascripts/options.js @@ -30,7 +30,7 @@ vz.options = { backendUrl: '../backend.php', // TODO default backend, store backend urls in cookies tuples: 300, precission: 2, // TODO update from backend capabilities? - render: 'lines', + render: 'steps', refresh: false, defaultInterval: 24*60*60*1000, // 1 day timezoneOffset: -(new Date().getTimezoneOffset() * 60000) // TODO add option with timezone dropdown diff --git a/htdocs/frontend/javascripts/wui.js b/htdocs/frontend/javascripts/wui.js index 7e6bb9e..88b2f9d 100644 --- a/htdocs/frontend/javascripts/wui.js +++ b/htdocs/frontend/javascripts/wui.js @@ -102,6 +102,7 @@ vz.wui.init = function() { // plot rendering $('#render-lines').attr('checked', (vz.options.render == 'lines')); $('#render-points').attr('checked', (vz.options.render == 'points')); + $('#render-steps').attr('checked', (vz.options.render == 'steps')); $('input[name=render][type=radio]').change(function() { if ($(this).attr('checked')) { vz.options.render = $(this).val(); @@ -528,7 +529,8 @@ vz.wui.drawPlot = function () { $('#overlay').empty(); } - vz.options.plot.series.lines.show = (vz.options.render == 'lines'); + vz.options.plot.series.lines.show = (vz.options.render == 'lines' || vz.options.render == 'steps'); + vz.options.plot.series.lines.steps = (vz.options.render == 'steps'); vz.options.plot.series.points.show = (vz.options.render == 'points'); vz.plot = $.plot($('#flot'), data, vz.options.plot); diff --git a/lib/Interpreter/MeterInterpreter.php b/lib/Interpreter/MeterInterpreter.php index 8fc8ce8..06e9338 100644 --- a/lib/Interpreter/MeterInterpreter.php +++ b/lib/Interpreter/MeterInterpreter.php @@ -124,7 +124,7 @@ class MeterInterpreter extends Interpreter { return array( //($next[0] - $delta / 2), // timestamp in the middle - $next[0], // timestamp at the end + $last[0], // timestamp at the start $next[1] * (3600000 / (($this->resolution / 1000) * $delta)), // value $next[2] // num of pulses );