filled display for "average" for meters

This commit is contained in:
Justin Otherguy 2011-01-08 01:43:16 +01:00
parent 66abec39f7
commit b5f7ffcf35
2 changed files with 12 additions and 13 deletions

View file

@ -357,15 +357,21 @@ vz.entities.loadData = function() {
// update entity table
// TODO add units
if (entity.data.min && entity.data.max && entity.data.min) {
if (entity.data.min) {
$('#entity-' + entity.uuid + ' .min')
.text(entity.data.min.value)
.attr('title', $.plot.formatDate(new Date(entity.data.min.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames));
}
if (entity.data.max) {
$('#entity-' + entity.uuid + ' .max')
.text(entity.data.max.value)
.attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames));
.attr('title', $.plot.formatDate(new Date(entity.data.max.timestamp), '%d. %b %h:%M:%S', vz.options.plot.xaxis.monthNames));
}
if (entity.data.average) {
$('#entity-' + entity.uuid + ' .average').text(entity.data.average);
$('#entity-' + entity.uuid + ' .last').text(entity.data.last);
}
if (entity.data.last) {
$('#entity-' + entity.uuid + ' .last').text(entity.data.last)
}
}, vz.drawPlot, 'data')
);

View file

@ -41,16 +41,9 @@ class MeterInterpreter extends Interpreter {
* @todo reimplement according to new env
*/
public function getConsumption() {
/*$sql = 'SELECT SUM(value) AS count
FROM data
WHERE
channel_id = ' . (int) $this->id . ' &&
' . self::buildTimeFilterSQL($this->from, $this->to) . '
GROUP BY channel_id';
$sql = 'SELECT COUNT(*) FROM `data` WHERE `channel_id` = ' . $this->channel->getId() . parent::buildDateTimeFilterSQL($this->from, $this->to);
$result = $this->dbh->query($sql)->rewind();
return $result['count'] / $this->resolution / 1000; // returns Wh*/
return $this->conn->fetchColumn($sql, array($this->channel->getId()), 0)*$this->channel->getProperty('resolution'); // return Wh
}
/**
@ -90,7 +83,7 @@ class MeterInterpreter extends Interpreter {
* @todo reimplement according to new env
*/
public function getAverage() {
//return $this->getConsumption() / ($this->to - $this->from) / 1000; // return W
return $this->getConsumption() / ($this->to - $this->from) * 1000; // return W
}
/**