fixed timestamp in ms related issues

This commit is contained in:
Justin Otherguy 2010-09-18 01:48:59 +02:00
parent be732fa729
commit 8e59225369
4 changed files with 18 additions and 24 deletions

View file

@ -31,6 +31,7 @@ namespace Volkszaehler\Interpreter;
*
*/
use Volkszaehler;
use Volkszaehler\Util;
class MeterInterpreter extends Interpreter {
@ -130,11 +131,12 @@ class MeterInterpreter extends Interpreter {
$delta = $next[0] - $last[0];
return array(
(int) ($next[0] - $delta / 2), // timestamp
//(int) ($next[0] - $delta / 2), // timestamp
(float) ($next[0] - $delta / 2), // timestamp
$next[1] * (3600000 / (($this->channel->getProperty('resolution')->getValue() / 1000) * $delta)), // value
(isset($next[2])) ? $next[2] : 1
);
}
}
?>
?>

View file

@ -138,9 +138,11 @@ class JSON extends View {
foreach ($data as $reading) {
$jsonData[] = array(
(int) $reading[0],
//(int) $reading[0],
(float) $reading[0],
(float) round($reading[1], View::PRECISSION),
(int) $reading[2]
//(int) $reading[2]
(float) $reading[2]
);
}
@ -163,4 +165,4 @@ class JSON extends View {
public function setPadding($padding) { $this->padding = $padding; }
}
?>
?>

View file

@ -364,7 +364,8 @@ function getData() {
$('#debug').append('<a href="../backend/index.php/data/'+myUUID+'/format/json/from/'+myWindowStart+'/to/'+myWindowEnd+'">json</a>');
// load json data with given time window
$.getJSON("../backend/index.php/data/" + myUUID + '/format/json/from/'+myWindowStart+'/to/'+myWindowEnd, function(j){
//$.getJSON("../backend/index.php/data/" + myUUID + '/format/json/from/'+myWindowStart+'/to/'+myWindowEnd, function(j){
$.getJSON("../backend/index.php/data/" + myUUID + '?from='+myWindowStart+'&to='+myWindowEnd, function(j){
data = j;
$('#debug').empty().append(data.toSource());
// then show/reload the chart
@ -376,18 +377,6 @@ function getData() {
return false;
}
function showInfos() {
$('#ChartPlot').hide();
$('#ChartInfo').show();
$('#ChartInfo').empty();
for(var i=0;i<data.channels.length;i++) {
$('#ChartInfo').append(data.channels[i]['description']+' (Aufl&ouml;sung:'+data.channels[i]['resolution']+'imp/kWh) Momentanverbrauch: Min: Max:<br>');
}
}
function showChart() {
var jqData = new Array();
@ -421,7 +410,8 @@ function showChart() {
// power (moving average) gray line
//series_chart.push({showLabel:false,color:'#808080'})
jqData.push(json2jqplot(data.channels[i].data));
//jqData.push(json2jqplot(data.channels[i].data));
jqData.push(data.channels[i].data);
}
jqOptions.axes = {
yaxis:{autoscale:true, min:0, label:"Leistung (Watt)", tickOptions:{formatString:'%.3f'},labelRenderer: $.jqplot.CanvasAxisLabelRenderer},
@ -454,14 +444,14 @@ function showChart() {
});*/
}
function json2jqplot(raw) {
/*function json2jqplot(raw) {
for(i=0;i<raw.length;i++) {
raw[i][0] *= 1000;
raw[i][1] /= 1000;
//raw[i][0] *= 1;
//raw[i][1] /= 1;
}
return raw;
}
}*/
function generateAxisTicks() {

View file

@ -61,7 +61,7 @@ function calcMyWindowStart() {
//var windowInterval = f.window.value.substring(1);
var windowInterval = "MONTH"; // we want to display 1 day (for now)
myWindowStart.setMonth(myWindowStart.getMonth()-windowSize);
myWindowStart.setMonth(myWindowStart.getMonth()-windowSize);
return myWindowStart.getTime();
}