1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
$(document).ready(function(){
var from = Math.round(new Date().getTime()/1000) - 24*60*60; //86400;
var fromOverview = Math.round(new Date().getTime()/1000) - 30*24*60*60; //86400;
var to = Math.round(new Date().getTime()/1000);
var datasetDetail = []
var datasetOverview = [];
var plotOverview = null;
var plotDetail = null;
var replot = function() {
if (plotDetail == null) {
plotDetail = $.plot($("#ebusgraph"),
datasetDetail,
{
xaxis: { mode: "time"},
legend: { show : true}
});
} else {
plotDetail.setData(datasetDetail);
plotDetail.draw();
plotDetail.setupGrid(); // redraw legend
}
};
var replotOverview = function() {
if (plotOverview == null) {
plotOverview = $.plot($("#overview"),
datasetOverview,
{ // options
series: {
lines: { show: true, lineWidth: 1 },
shadowSize: 0
},
xaxis: { mode: "time" },
yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
selection: { mode: "x" }
});
} else {
plotOverview.setData(datasetOverview);
plotOverview.draw();
}
plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
};
var plotSensor = function(sensorname) {
plotSensorDetail(sensorname);
plotSensorOverview(sensorname);
};
var unplotSensor = function(sensorname) {
unplotSensorDetail(sensorname);
unplotSensorOverview(sensorname);
};
var plotSensorDetail = function(sensorname) {
$.getJSON("sensor/"+escape(sensorname)+"/"+from+"/"+to,
function(response) {
if (response['data']) {
datasetDetail.push({'data':response['data'],
'label':sensorname});
replot();
} else {
alert("Fehler: " + response["error"]);
}
});
};
var unplotSensorDetail = function(sensorname) {
};
var plotSensorOverview = function(sensorname) {
$.getJSON("sensor_cached/"+escape(sensorname)+"/"+fromOverview, //+"/"+to,
function(response) {
if (response['data']) {
datasetOverview.push({'data':response['data'],
'label':null});
replotOverview();
} else {
alert("Overview Fehler: " + response["error"]);
}
});
};
$("#overview").bind("plotselected", function (event, ranges) {
range_from = Math.round(ranges.xaxis.from / 1000);
range_to = Math.round(ranges.xaxis.to / 1000);
if (range_to - range_from > 4 * 24 * 60 * 60) {
plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
return;
} else {
from = range_from;
to = range_to;
}
sensors = [];
for (elem in datasetOverview) {
sensor = datasetDetail[elem]["label"];
sensors.push(sensor);
}
datasetDetail =[];
for (i in sensors) {
plotSensorDetail(sensors[i]);
}
});
plotSensor("heizkreisregler9.solarDaten.tempKollektor");
//ausreisser// plotSensor("heizkreisregler9.solarDaten.tempWarmwasserSolar");
plotSensor("heizkreisregler10.betriebsdatenRegler1.kesselTemperatur");
plotSensor("feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur");
// TODO http://people.iola.dk/olau/flot/examples/annotating.html
$('#button').click(function() {
$.each(datasetDetail, function(i, sensor) {
if (datasetDetail[i].label == "heizkreisregler9.solarDaten.tempKollektor") {
datasetDetail.splice(i,1);
replot();
}
});
});
});
|