summaryrefslogtreecommitdiff
path: root/ebus/webapp/static
diff options
context:
space:
mode:
Diffstat (limited to 'ebus/webapp/static')
-rw-r--r--ebus/webapp/static/src/ebus.js58
1 files changed, 37 insertions, 21 deletions
diff --git a/ebus/webapp/static/src/ebus.js b/ebus/webapp/static/src/ebus.js
index ad98d91..ae6ab29 100644
--- a/ebus/webapp/static/src/ebus.js
+++ b/ebus/webapp/static/src/ebus.js
@@ -7,18 +7,32 @@ $(document).ready(function(){
var plotOverview = null;
var plotDetail = null;
var indexFound = null;
- var sensorList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true},
- {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true},
- {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false},
- {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":true},
- {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true}];
+ var sensorList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true, "color":"#f30000"},
+ {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true, "color":"#283074"},
+ {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false, "color":"#f0ff4c"},
+ {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":true, "color":"#84b500"},
+ {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true, "color":"#48b4ff"}];
+ var pickSensorConfig = function(sensorname) {
+ $.each(sensorList, function(i,sensorconfig) {
+ var sensor_found;
+ if (sensorconfig.sensorname == sensorname) {
+ sensorconfig_found = sensorconfig;
+ return false;
+ } else {
+ sensorconfig_found = false;
+ }
+ });
+ return sensorconfig_found;
+ }
var replot = function() {
if (plotDetail == null) {
plotDetail = $.plot($("#ebusgraph"),
datasetDetail,
{
xaxis: { mode: "time"},
+ yaxis: { min: -10, max: 100 },
legend: { show : true}
+
});
} else {
plotDetail.setData(datasetDetail);
@@ -46,20 +60,21 @@ $(document).ready(function(){
}
plotOverview.setSelection({xaxis: {'from': from*1000, 'to': to*1000}}, true);
};
- var plotSensor = function(sensorname) {
- plotSensorDetail(sensorname);
- plotSensorOverview(sensorname);
+ var plotSensor = function(sensorconfig) {
+ plotSensorDetail(sensorconfig);
+ plotSensorOverview(sensorconfig);
};
var unplotSensor = function(sensorname) {
unplotSensorDetail(sensorname);
unplotSensorOverview(sensorname);
};
- var plotSensorDetail = function(sensorname) {
- $.getJSON("sensor/"+escape(sensorname)+"/"+from+"/"+to,
+ var plotSensorDetail = function(sensorconfig) {
+ $.getJSON("sensor/"+escape(sensorconfig.sensorname)+"/"+from+"/"+to,
function(response) {
if (response['data']) {
datasetDetail.push({'data':response['data'],
- 'label':sensorname});
+ 'label':sensorconfig.sensorname,
+ 'color':sensorconfig.color});
replot();
} else {
alert("Fehler: " + response["error"]);
@@ -77,12 +92,13 @@ $(document).ready(function(){
});
};
- var plotSensorOverview = function(sensorname) {
- $.getJSON("sensor_cached/"+escape(sensorname)+"/"+fromOverview, //+"/"+to,
+ var plotSensorOverview = function(sensorconfig) {
+ $.getJSON("sensor_cached/"+escape(sensorconfig.sensorname)+"/"+fromOverview, //+"/"+to,
function(response) {
if (response['data']) {
datasetOverview.push({'data':response['data'],
- 'label':sensorname});
+ 'label':sensorconfig.sensorname,
+ 'color':sensorconfig.color});
replotOverview();
} else {
alert("Overview Fehler: " + response["error"]);
@@ -122,17 +138,17 @@ $(document).ready(function(){
}
});
- $.each(sensorList, function(i,sensorname) {
- var pickerDiv = $("<div>").attr("id","pick_"+sensorname.sensorname.replace(/\./g,"_"))
+ $.each(sensorList, 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(sensorname.sensorname);
- if (sensorname.show) {
+ $(pickerDiv).append(sensorconfig.sensorname);
+ if (sensorconfig.show) {
//Plot
- plotSensor(sensorname.sensorname);
+ plotSensor(sensorconfig);
$(pickerCheckbox).attr("checked","checked");
}
});
@@ -141,8 +157,8 @@ $(document).ready(function(){
$('.picker input').click( function() {
var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,".");
- if ($(this).is(":checked")) {
- plotSensor(sensorname);
+ if ($(this).is(":checked")) {
+ plotSensor(pickSensorConfig(sensorname));
} else {
unplotSensor(sensorname);
}