From 5e2950a4553de86887cdee8127c6f894a6b55bc6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 26 Jun 2011 22:08:53 +0200 Subject: [PATCH] some small changes for sensor consmuption (closes #72) --- htdocs/frontend/index.html | 7 ++++--- htdocs/frontend/javascripts/entity.js | 10 ++++------ htdocs/frontend/javascripts/options.js | 2 +- lib/Interpreter/SensorInterpreter.php | 6 +++++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/htdocs/frontend/index.html b/htdocs/frontend/index.html index 419e8c5..f60a404 100644 --- a/htdocs/frontend/index.html +++ b/htdocs/frontend/index.html @@ -20,12 +20,13 @@ + - + + - - + diff --git a/htdocs/frontend/javascripts/entity.js b/htdocs/frontend/javascripts/entity.js index 8afd4ff..b8c342a 100644 --- a/htdocs/frontend/javascripts/entity.js +++ b/htdocs/frontend/javascripts/entity.js @@ -218,7 +218,7 @@ Entity.prototype.getDOMRow = function(parent) { $('#entity-' + entity.uuid + ((parent) ? '.child-of-entity-' + parent.uuid : '') + ' input[type=checkbox]') .attr('checked', state); entity.active = state; - }); + }, true); // recursive! vz.wui.drawPlot(); }) @@ -287,11 +287,9 @@ Entity.prototype.updateDOMRow = function() { $('.last', row) .text(vz.wui.formatNumber(this.data.tuples.last()[1], true) + this.definition.unit); - if (this.definition.interpreter == 'Volkszaehler\\Interpreter\\MeterInterpreter') { // sensors have no consumption - $('.consumption', row) - .text(vz.wui.formatNumber(this.data.consumption, true) + this.definition.unit + 'h') - .attr('title', vz.wui.formatNumber(this.data.consumption * (year/delta), true) + this.definition.unit + 'h' + '/Jahr'); - } + $('.consumption', row) + .text(vz.wui.formatNumber(this.data.consumption, true) + this.definition.unit + 'h') + .attr('title', vz.wui.formatNumber(this.data.consumption * (year/delta), true) + this.definition.unit + 'h' + '/Jahr'); if (this.cost) { $('.cost', row) diff --git a/htdocs/frontend/javascripts/options.js b/htdocs/frontend/javascripts/options.js index e20418c..5a12af7 100644 --- a/htdocs/frontend/javascripts/options.js +++ b/htdocs/frontend/javascripts/options.js @@ -66,7 +66,7 @@ vz.options.plot = { hoverable: true, autoHighlight: false } -} +}; vz.options.saveCookies = function() { for (var key in vz.options) { diff --git a/lib/Interpreter/SensorInterpreter.php b/lib/Interpreter/SensorInterpreter.php index 52c94c2..675ea55 100644 --- a/lib/Interpreter/SensorInterpreter.php +++ b/lib/Interpreter/SensorInterpreter.php @@ -73,7 +73,8 @@ class SensorInterpreter extends Interpreter { */ public function getAverage() { if ($consumption = $this->getConsumption()) { - return (3600 * 1000 * $consumption) / ($this->last[0] - $this->first[0]); + $delta = $this->last[0] - $this->first[0]; + return (3600 * 1000 * $consumption) / $delta; } else { // prevents division by zero return 0; @@ -108,6 +109,9 @@ class SensorInterpreter extends Interpreter { $last = $next; $next = $data->next(); } + + $this->first = reset($tuples); + $this->last = end($tuples); return $tuples; }