added display for the current value to the frontend (side-by-side to max., min. and avg.)
This commit is contained in:
parent
28d409f145
commit
627813ac35
8 changed files with 37 additions and 0 deletions
|
@ -73,6 +73,7 @@
|
|||
<th>Min.</th>
|
||||
<th>Max.</th>
|
||||
<th>Avg.</th>
|
||||
<th>Curr.</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
|
@ -294,6 +294,7 @@ vz.entities.show = function() {
|
|||
.append($('<td>').addClass('min')) // min
|
||||
.append($('<td>').addClass('max')) // max
|
||||
.append($('<td>').addClass('average')) // avg
|
||||
.append($('<td>').addClass('current')) // curr
|
||||
.append($('<td>') // operations
|
||||
.addClass('ops')
|
||||
.append($('<input>')
|
||||
|
@ -364,6 +365,7 @@ vz.entities.loadData = function() {
|
|||
.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));
|
||||
$('#entity-' + entity.uuid + ' .average').text(entity.data.average);
|
||||
$('#entity-' + entity.uuid + ' .current').text(entity.data.current);
|
||||
}
|
||||
}, vz.drawPlot, 'data')
|
||||
);
|
||||
|
|
|
@ -137,6 +137,20 @@ class AggregatorInterpreter implements InterpreterInterface {
|
|||
return ($sum / count($this->channelInterpreter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Just a passthrough to the channel interpreters
|
||||
*
|
||||
* @return float current value
|
||||
*/
|
||||
public function getCurrent() {
|
||||
$current = 0;
|
||||
|
||||
foreach ($this->channelInterpreter as $interpreter) {
|
||||
$current = $interpreter->getCurrent();
|
||||
}
|
||||
return ($current($this->channelInterpreter));
|
||||
}
|
||||
|
||||
/*
|
||||
* Getter & setter
|
||||
*/
|
||||
|
|
|
@ -34,5 +34,6 @@ interface InterpreterInterface {
|
|||
function getMin();
|
||||
function getMax();
|
||||
function getAverage();
|
||||
function getCurrent();
|
||||
function getEntity();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,14 @@ class MeterInterpreter extends Interpreter {
|
|||
//return $this->getConsumption() / ($this->to - $this->from) / 1000; // return W
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
* @todo reimplement according to new env
|
||||
*/
|
||||
public function getCurrent() {
|
||||
//return $this->getConsumption() / ($this->to - $this->from) / 1000; // return W
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw pulses to power conversion
|
||||
*
|
||||
|
|
|
@ -81,6 +81,15 @@ class SensorInterpreter extends Interpreter {
|
|||
return (float) $this->conn->fetchColumn('SELECT AVG(value) FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to), array($this->channel->getId()), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the average value from the database
|
||||
* @internal doesn't fits the SQL standard
|
||||
* @return float
|
||||
*/
|
||||
public function getCurrent() {
|
||||
return (float) $this->conn->fetchColumn('SELECT value FROM data WHERE channel_id = ?' . parent::buildDateTimeFilterSQL($this->from, $this->to). ' ORDER BY timestamp DESC', array($this->channel->getId()), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo possible and/or required?
|
||||
* @return float
|
||||
|
|
|
@ -224,6 +224,7 @@ class JSON extends View {
|
|||
'min' => $interpreter->getMin(),
|
||||
'max' => $interpreter->getMax(),
|
||||
'average' => $interpreter->getAverage(),
|
||||
'current' => $interpreter->getCurrent(),
|
||||
'tuples' => $data
|
||||
);
|
||||
}
|
||||
|
|
|
@ -219,6 +219,7 @@ class XML extends View {
|
|||
$xmlData->appendChild($this->xmlDoc->createElement('min', $interpreter->getMin()));
|
||||
$xmlData->appendChild($this->xmlDoc->createElement('max', $interpreter->getMax()));
|
||||
$xmlData->appendChild($this->xmlDoc->createElement('average', $interpreter->getAverage()));
|
||||
$xmlData->appendChild($this->xmlDoc->createElement('current', $interpreter->getCurrent()));
|
||||
$xmlData->appendChild($xmlTuples);
|
||||
|
||||
$this->xmlRoot->appendChild($xmlData);
|
||||
|
|
Loading…
Add table
Reference in a new issue