summaryrefslogtreecommitdiff
path: root/ebus-datastore/ebus
diff options
context:
space:
mode:
Diffstat (limited to 'ebus-datastore/ebus')
-rw-r--r--ebus-datastore/ebus/web_static/heizung.html12
-rw-r--r--ebus-datastore/ebus/web_static/src/ebus_heizung.js222
2 files changed, 234 insertions, 0 deletions
diff --git a/ebus-datastore/ebus/web_static/heizung.html b/ebus-datastore/ebus/web_static/heizung.html
new file mode 100644
index 0000000..065e031
--- /dev/null
+++ b/ebus-datastore/ebus/web_static/heizung.html
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="static/css/stylesheet.css" />
+ <script src="static/lib/jquery-1.6.2/jquery-1.6.2.min.js"></script>
+ <script src="static/lib/flot-0.7/jquery.flot.js"></script>
+ <script src="static/lib/flot-0.7/jquery.flot.selection.js"></script>
+ <script src="static/src/ebus_heizung.js"></script>
+ </head>
+ <body>
+ <div id="ebusgraph" style="width:1500px; height:800px;"></div>
+ </body>
+</html>
diff --git a/ebus-datastore/ebus/web_static/src/ebus_heizung.js b/ebus-datastore/ebus/web_static/src/ebus_heizung.js
new file mode 100644
index 0000000..039854d
--- /dev/null
+++ b/ebus-datastore/ebus/web_static/src/ebus_heizung.js
@@ -0,0 +1,222 @@
+// vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=javascript
+var d = new Object();
+d.ms = 1;
+d.sec = 1000*d.ms;
+d.min = 60 * d.sec;
+d.hour = 60 * d.min;
+d.day = 24 * d.hour;
+d.week = 7 * d.day;
+d.month = 30.5 * d.day;
+d.now = new Date().getTime();
+
+var timeToUTC = function(d) { return d - new Date().getTimezoneOffset() * 60 * 1000; }
+var timeToLocal = function(d) { return d + new Date().getTimezoneOffset() * 60 * 1000; }
+
+$(document).ready(function(){
+ var from = d.now - 0.8*d.day;
+ var to = d.now;
+ var fromOverview = d.now - 15*d.day;
+ var toOverview = d.now;
+ var datasetDetail = []
+ var datasetOverview = [];
+ var plotOverview = null;
+ var plotDetail = null;
+ var indexFound = null;
+ /*var sensorConfigList = [
+ {"sensorname":"heizkreisregler9.solarDaten.tempKollektor",
+ "description":"Kollektortemperatur",
+ "show":true,
+ "color":"#f30000"},
+ {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur",
+ "description":"Kessel Temperatur",
+ "show":true,
+ "color":"#283074"},
+ {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar",
+ "description":"Warmwasser Solar",
+ "show":true,
+ "color":"#f0ff4c"},
+ {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur",
+ "description":"Aussentemperatur",
+ "show":true,
+ "fill":true,
+ "color":"black"}, //#84b500
+ {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur",
+ "description":"Boilertemperatur",
+ "show":true,
+ "color":"#48b4ff"},
+ ];*/
+ var sensorConfigList = [
+ {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur",
+ "description":"Boilertemperatur",
+ "show":true,
+ "color":"yellow"},
+ {"sensorname":"heizkreisregler9.solarDaten.tempKollektor",
+ "description":"Kollektortemperatur",
+ "show":true,
+ "color":"red"},
+ {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur",
+ "description":"Aussentemperatur",
+ "show":true,
+ "color":"green"}
+ ];
+ var pickSensorConfig = function(sensorname) {
+ var sensorConfigFound;
+ $.each(sensorConfigList, function(i,sensorConfig) {
+ if (sensorConfig.sensorname == sensorname) {
+ sensorConfigFound = sensorConfig;
+ return false;
+ }
+ });
+ return sensorConfigFound;
+ }
+ var replot = function() {
+ plotDetail = $.plot($("#ebusgraph"),
+ datasetDetail,
+ {
+ xaxis: { mode: "time", min: timeToUTC(from), max:timeToUTC(to) },
+ yaxis: { min: -16, max: 100 },
+ legend: { show : true}
+ });
+ };
+ var replotOverview = function() {
+ if (plotOverview == null) {
+ plotOverview = $.plot($("#overview"),
+ datasetOverview,
+ { // options
+ series: {
+ lines: { show: true, lineWidth: 1 },
+ shadowSize: 0
+ },
+ xaxis: { mode: "time", min: timeToUTC(fromOverview), max:timeToUTC(toOverview) },
+ yaxis: { ticks: [], min: -26, max: 100, autoscaleMargin: 0.1 },
+ legend: { show: false },
+ selection: { mode: "x" }
+ });
+ } else {
+ plotOverview.setData(datasetOverview);
+ plotOverview.draw();
+ }
+ plotOverview.setSelection({xaxis: {'from': from, 'to': to}}, true);
+ };
+ var plotSensor = function(sensorConfig) {
+ plotSensorDetail(sensorConfig);
+ plotSensorOverview(sensorConfig);
+ };
+ var unplotSensor = function(sensorname) {
+ unplotSensorDetail(sensorname);
+ unplotSensorOverview(sensorname);
+ };
+ var plotSensorDetail = function(sensorConfig) {
+ $.getJSON("sensor/"+escape(sensorConfig.sensorname)+"/"+timeToLocal(from)+"/"+timeToLocal(to),
+ function(response) {
+ if (!response.error) {
+ response.data = response.data.map(function(d) {
+ return [ timeToUTC(d[0]), d[1] ];
+ });
+ if (sensorConfig.mapFunc) {
+ response.data = response.data.map( sensorConfig.mapFunc )
+ }
+ datasetDetail.push({'data':response['data'],
+ 'userData':sensorConfig.sensorname,
+ 'label':sensorConfig.description,
+ 'color':sensorConfig.color,
+ 'shadowSize':0,
+ 'lines':{ 'fill':0.7,'lineWidth':4}
+ });
+ replot();
+ } else {
+ alert("Fehler: " + response["error"]);
+ }
+ });
+ };
+
+ var unplotSensorDetail = function(sensorname) {
+ $.each(datasetDetail, function(i, sensor) {
+ if (sensor.userData == sensorname) {
+ datasetDetail.splice(i,1);
+ replot();
+ return false;
+ }
+ });
+ };
+
+ var plotSensorOverview = function(sensorConfig) {
+ $.getJSON("avg/"+escape(sensorConfig.sensorname)+"/"+timeToLocal(fromOverview)+"/"+timeToLocal(toOverview),
+ function(response) {
+ if (!response.error) {
+ response.data = response.data.map(function(d) {
+ return [ timeToUTC(d[0]), d[1] ];
+ });
+ if (sensorConfig.mapFunc) {
+ response.data = response.data.map( sensorConfig.mapFunc)
+ }
+ datasetOverview.push({'data':response['data'],
+ 'label':sensorConfig.sensorname,
+ 'color':sensorConfig.color});
+ replotOverview();
+ } else {
+ alert("Overview Fehler: " + response["error"]);
+ }
+ });
+
+ };
+ var unplotSensorOverview = function(sensorname) {
+ $.each(datasetOverview, function(i, sensor) {
+ if (sensor.label == sensorname) {
+ datasetOverview.splice(i,1);
+ replotOverview();
+ return false;
+ }
+ });
+ }
+
+ $("#overview").bind("plotselected", function (event, ranges) {
+ range_from = Math.round(ranges.xaxis.from);
+ range_to = Math.round(ranges.xaxis.to);
+ // max selection range
+ if (range_to - range_from > d.month) {
+ // reset selection
+ plotOverview.setSelection({xaxis: {'from': from, 'to': to}}, true);
+ return;
+ } else {
+ from = timeToLocal( range_from );
+ to = timeToLocal( range_to );
+ }
+ sensors = [];
+ for (elem in datasetOverview) {
+ sensor = datasetDetail[elem]["userData"];
+ sensors.push(sensor);
+ }
+ datasetDetail =[];
+ for (i in sensors) {
+ plotSensorDetail(pickSensorConfig(sensors[i]));
+ }
+ });
+
+ $.each(sensorConfigList, function(i,sensorConfig) {
+ var pickerDiv = $("<div>").attr("id","pick_"+sensorConfig.sensorname.replace(/\./g,"_"))
+ .addClass("picker")
+ .appendTo("#sensorpicker");
+
+ var pickerCheckbox = $("<input>").attr("type","checkbox")
+ .appendTo(pickerDiv);
+ pickerDiv.append($("<span>").text( sensorConfig.description + " (" + sensorConfig.sensorname + ")") );
+ if (sensorConfig.show) {
+ //Plot
+ plotSensor(sensorConfig);
+ $(pickerCheckbox).attr("checked","checked");
+ }
+ });
+ // TODO http://people.iola.dk/olau/flot/examples/annotating.html
+
+
+ $('.picker input').click( function() {
+ var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,".");
+ if ($(this).is(":checked")) {
+ if (typeof console != "undefined") console.log(sensorname);
+ plotSensor(pickSensorConfig(sensorname));
+ } else {
+ unplotSensor(sensorname);
+ }
+ });
+});