summaryrefslogtreecommitdiff
path: root/ebus/webapp/static/ebus.js
blob: dc86cda2bab9634fbbd3b31984810b11f75c1ee0 (plain)
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
$(document).ready(function(){
    var from = Math.round(new Date().getTime()/1000) - 3*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 dataset = []
    var datasetOverview = [];
    var replot = function() {
	$.plot($("#ebusgraph"), 
	       dataset, 
	       { xaxis: { mode: "time"}});
    };
    var replotOverview = function() {
	$.plot($("#overview"),
	       datasetOverview,
	       {
		   series: {
		       lines: { show: true, lineWidth: 1 },
		       shadowSize: 0
		   },
		   xaxis: { mode: "time" },
		   yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 },
		   selection: { mode: "x" }
	       });
    };
    var plotSensor = function(sensorname) {
	$.getJSON("/sensor/"+escape(sensorname)+"/"+from+"/"+to,
		  function(response) {
		      if (response['data']) {
			  dataset.push({'data':response['data'],
					'label':sensorname});
			  replot();
		      } else {
			  alert("Fehler: " + response["error"]);
		      }
		  });
	$.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"]);
		      }
		  });
	
    };

    
    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
});