X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=raspberry-kiosk%2Fkiosk.js;h=420e5af709c0e32cb68a1e17694a4e50c319116f;hb=d9e249eb64a7006e4d8b729f5dce8dc538a3756f;hp=e9d4b6c65b8397434bb1f1b74c8bbd08daac92dd;hpb=5fa641471b4394c68f69fc7dded90871d52a4f2f;p=svn42.git diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index e9d4b6c..420e5af 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -44,7 +44,7 @@ function writeGooglePlusEvents(data, elem) ghtml += '

'+item.updated.substring(0,16).replace("T"," ")+'

'; ghtml += '

'+notetxt+'

'; if (noteimgs.length>0) - { + { var bigimglimit; ghtml += ''; if (noteimgs.length > 3) @@ -145,7 +145,7 @@ function loadCalendarKiosk() $.getJSON('/shmcache/grical_realraum.json', function(data){ var calhtml = ""; $.each(calendarItemEnhancer(data), function(index, itm) { - calhtml += '
  • '+itm.when+' - '+itm.title+'
  • '+"\n"; + calhtml += '
  • '+itm.when+' - '+itm.title+'
  • '+"\n"; }); calcontainer.innerHTML=''; }); @@ -165,6 +165,42 @@ function loadCalendarMainPage() } +function drawGauge(targetelem, label, temp, options) { + var data = google.visualization.arrayToDataTable([["Label", "Value"],[label,temp]]); + // Create and draw the visualization. + if (targetelem) + { + options["width"] = targetelem.getAttribute("width"); + options["height"] = targetelem.getAttribute("height"); + var chart = new google.visualization.Gauge(targetelem); + chart.draw(data, options); + } +} + +function drawLineGraph(targetelem, dataarray, options) { + if (dataarray) { + var data = google.visualization.arrayToDataTable(dataarray); + // Create and draw the visualization. + if (targetelem) + { + options["width"]= targetelem.getAttribute("width"); + options["height"]=targetelem.getAttribute("height"); + new google.visualization.LineChart(targetelem).draw(data, options); + } + } +} + +function loadAndDrawSensorData() { + $.getJSON("https://realraum.at/shmcache/r3sensors.json", function(data){ + drawLineGraph(document.getElementById('tempgooglegraph'), data["TempSensorUpdate"], + {curveType: "function", title: 'Temperature Sensors', colors: ['#FF0000','#CC0033','#660000','#CC3333'], chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ); + drawLineGraph(document.getElementById('lightgooglegraph'), data["IlluminationSensorUpdate"], + {curveType: "none", title: 'Illumination Sensors', vAxis: {maxValue: 1024, minValue:5}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ); + drawLineGraph(document.getElementById('movementgooglegraph'), data["MovementSensorUpdate"], + {curveType: "none", title: 'Movement Sensors', vAxis: {maxValue: 10, minValue:0}, chartArea:{left:32,top:20,width:"88%",height:"83%"}, legend: {position: "none"}} ); + }); +} + function writeAnwesenheitStatus(data) { var html=""; @@ -190,28 +226,30 @@ function writeAnwesenheitStatus(data) { anwesenheit_status_frontpage.innerHTML='
    '+data.status+'
    '; } - + if (data.sensors) { if (data.sensors.temperature) { - sensorstd+='Temperatur'; + sensorstd+='Temperatur'; $.each( data.sensors.temperature, function(s, sensorobj) { sensorstd+='
    '+sensorobj.location+': '+sensorobj.value.toFixed(2)+sensorobj.unit; + drawGauge(document.getElementById('tempgauge'), "Temp "+sensorobj.location, sensorobj.value, {redFrom: 33, redTo: 40, yellowFrom:29, yellowTo: 33, minorTicks: 4, min:0, max:40}); }); sensorstd+=''; } if (data.sensors.ext_illumination) { - sensorstd+='Licht'; + sensorstd+='Licht'; $.each( data.sensors.ext_illumination, function(s, sensorobj) { sensorstd+='
    '+sensorobj.location+': '+sensorobj.value; + drawGauge(document.getElementById('lightgauge'), "Licht "+sensorobj.location, sensorobj.value, {redFrom: 950, redTo: 1024,yellowFrom:0, yellowTo: 200,minorTicks: 4, min:0, max:1024}); }); sensorstd+=''; } if (data.sensors.door_locked) { - sensorstd+='Eingangstür'; + sensorstd+='Eingangstür'; $.each( data.sensors.door_locked, function(s, sensorobj) { var lockstatus="Auf"; if (sensorobj.value) { lockstatus = "Zu"; } @@ -221,7 +259,7 @@ function writeAnwesenheitStatus(data) } if (data.sensors.ext_door_ajar) { - sensorstd+='Türkontakt'; + sensorstd+='Türkontakt'; $.each( data.sensors.ext_door_ajar, function(s, sensorobj) { var lockstatus="Auf"; if (sensorobj.value) { lockstatus = "Zu"; } @@ -231,13 +269,13 @@ function writeAnwesenheitStatus(data) } if (data.sensors.ext_dust) { - sensorstd+='Staub'; + sensorstd+='Staub'; $.each( data.sensors.ext_dust, function(s, sensorobj) { sensorstd+='
    '+sensorobj.location+': '+sensorobj.value+sensorobj.unit+''; }); sensorstd+=''; - } + } if (sensorstd != "") { sensorshtml=''+sensorstd+'
    '; @@ -275,7 +313,7 @@ function highlightEntry(idx, color, value) if(value == 0) { if(idx%2 == 0) $('#upnext' + idx).css('background-color', 'white'); - else + else $('#upnext' + idx).css('background-color', '#E0E0E0'); } else { $('#upnext' + idx).css('background-color', color); @@ -350,7 +388,7 @@ function reloadImg(element) $(document).ready(function() { updateAnwesenheitStatus(); - setInterval("updateAnwesenheitStatus()", 10*1000); + setInterval("updateAnwesenheitStatus()", 10*1000); if (document.getElementById("dateclock")) { updateDateClock(new Date()); @@ -370,6 +408,11 @@ $(document).ready(function() { setInterval("updateSensors()",145*1000); } + if (document.getElementById("tempgooglegraph") || document.getElementById("lightgooglegraph")) + { + loadAndDrawSensorData(); + setInterval("loadAndDrawSensorData()",145*1000); + } if (document.getElementById("gplusevents")) { loadGooglePlusEvents();