diff options
Diffstat (limited to 'ebus')
-rw-r--r-- | ebus/webapp/__init__.py | 2 | ||||
-rw-r--r-- | ebus/webapp/static/ebus.js | 55 | ||||
-rw-r--r-- | ebus/webapp/static/index.html | 45 | ||||
-rw-r--r-- | ebus/webapp/static/main.css | 5 |
4 files changed, 71 insertions, 36 deletions
diff --git a/ebus/webapp/__init__.py b/ebus/webapp/__init__.py index bd78033..d65e2d1 100644 --- a/ebus/webapp/__init__.py +++ b/ebus/webapp/__init__.py @@ -64,7 +64,7 @@ def sensor_data_fromto(name,startdate,enddate): v.append([int((time.mktime(value.timestamp.timetuple())+time.altzone*-1)*1000),value.value_int]) elif value.value_string != None: v.append([int((time.mktime(value.timestamp.timetuple())+time.altzone*-1)*1000),value.value_string]) - return json.dumps(v) + return {'data':v, 'error':None} # rechnet zeit so um wie Javascript diff --git a/ebus/webapp/static/ebus.js b/ebus/webapp/static/ebus.js new file mode 100644 index 0000000..dc86cda --- /dev/null +++ b/ebus/webapp/static/ebus.js @@ -0,0 +1,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 +});
\ No newline at end of file diff --git a/ebus/webapp/static/index.html b/ebus/webapp/static/index.html index 1decced..e883ee4 100644 --- a/ebus/webapp/static/index.html +++ b/ebus/webapp/static/index.html @@ -1,37 +1,12 @@ <html> - <head> - <link rel="stylesheet" type="text/css" href="/static/main.css" /> - <script src="/static/jquery-1.6.2.min.js"></script> - <script src="/static/jquery.flot.js"></script> - <script> - $(document).ready(function(){ - var from = Math.round(new Date().getTime()/1000) - 3*24*60*60; //86400; - var to = Math.round(new Date().getTime()/1000); - var dataset = [] - var replot = function() { - $.plot($("#ebusgraph"), dataset, { xaxis: { mode: "time"}}); - }; - var plotSensor = function(sensorname) { - $.getJSON("/sensor_cached/"+escape(sensorname)+"/"+from, //+"/"+to, - function(response) { - if (response['data']) { - data = response['data']; - dataset.push({'data':data,'label':sensorname}); - replot(); - } else { - alert("Fehler: " + response["error"]); - } - }); - } - plotSensor("heizkreisregler9.solarDaten.tempKollektor"); - plotSensor("heizkreisregler9.solarDaten.tempWarmwasserSolar"); - plotSensor("heizkreisregler10.betriebsdatenRegler1.kesselTemperatur"); - plotSensor("feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur"); - // TODO http://people.iola.dk/olau/flot/examples/annotating.html - }); - </script> - </head> - <body> - <div id="ebusgraph"></div> - </body> + <head> + <link rel="stylesheet" type="text/css" href="/static/main.css" /> + <script src="/static/jquery-1.6.2.min.js"></script> + <script src="/static/jquery.flot.js"></script> + <script src="/static/ebus.js"></script> + </head> + <body> + <div id="ebusgraph"></div> + <div id="overview"></div> + </body> </html> diff --git a/ebus/webapp/static/main.css b/ebus/webapp/static/main.css index 2b28643..57cd1cd 100644 --- a/ebus/webapp/static/main.css +++ b/ebus/webapp/static/main.css @@ -8,3 +8,8 @@ body { width:100%; height:500px; } + +#overview { + width:100%; + height:80px; +} |