function SetNoiseDataWaiting(){ var resetBtn = document.getElementById("noiseStuff"); resetBtn.disabled = true; resetBtn.innerHTML = '
' } function setNoiseWaiting(){ // document.getElementById("infobtnNoise").classList.add('loaderN'); // console.log("arrived") // document.getElementById("infobtnNoise").classList.remove('infobtn'); // var resetBtn = document.getElementById("infobtnNoise"); // resetBtn.disabled = true; // resetBtn.innerHTML = '
' } var Sensor = { id:"49368" } function getNoiseData(sensorid) { console.log("arrive") Sensor.id = sensorid console.log(Sensor.id) try { $.ajax({ type: "GET", url: NoiseRealTimeUrl, data: Sensor }).done(function (newdata) { convertdata(newdata); }); function convertdata(data) { flow = data; console.log(flow) for (var i = 0; i<= flow[0].sensordatavalues.length -1; i++){ if (flow[0].sensordatavalues[i].value_type == "noise_LAeq"){ document.getElementById("noise_laeq").innerHTML = flow[0].sensordatavalues[i].value; } else if(flow[0].sensordatavalues[i].value_type == "noise_LA_min") { document.getElementById("noise_lamin").innerHTML = flow[0].sensordatavalues[i].value; } else if(flow[0].sensordatavalues[i].value_type == "noise_LA_max") { document.getElementById("noise_lamax").innerHTML = flow[0].sensordatavalues[i].value; } } var resetBtn = document.getElementById("noiseStuff"); resetBtn.disabled = true; resetBtn.innerHTML = "Get Noise Data" } return flow } catch (err) { console.log('loading Gas Values from DB failed!'); } } function noisemap(areatime){ var StreetD = false; var StreetN = false; var RailD = false; var RailN = false; if (areatime == "offS"){ StreetD = false; StreetN = false; } else if (areatime == "offR") { RailD = false; RailN = false; } else if (areatime == "Streetday") { StreetD = true; StreetN = false; RailD = false; RailN = false; } else if (areatime == "Streetnight") { StreetD = false; StreetN = true; RailD = false; RailN = false; } else if (areatime == "Railday") { StreetD = false; StreetN = false; RailD = true; RailN = false; } else if (areatime == "Railnight") { StreetD = false; StreetN = false; RailD = false; RailN = true; } var layerStreetD = ["Streetday"] var layerStreetN = ["Streetnight"] var layerRailD = ["Railday"] var layerRailN = ["Railnight"] var layers = framework.getLayers(); for (var i = 0; i< layers.length; i++) { var layer = layers[i]; if(layerStreetD.indexOf(layer.name) >= 0){ layer.activate(StreetD); } else if (layerStreetN.indexOf(layer.name) >= 0){ layer.activate(StreetN); } else if (layerRailD.indexOf(layer.name) >= 0){ layer.activate(RailD); } else if (layerRailN.indexOf(layer.name) >= 0){ layer.activate(RailN); } } } function noisesens(status){ var layerOn = ["NoiseLocation"] var layerTwo = ["NoiseLocation53627"] var layerThree = ["NoiseLocation29212"] var layers = framework.getLayers(); for (var i = 0; i< layers.length; i++) { var layer = layers[i]; if(layerOn.indexOf(layer.name) >= 0){ if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } else if(layerTwo.indexOf(layer.name) >= 0){ if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } else if(layerThree.indexOf(layer.name) >= 0) { if(status == "on"){ layer.activate(true); } else if (status == "off"){ layer.activate(false); } } } } let histNoise function HistNoiseData(Sensor) { try { $.ajax({ async: true, type: "POST", url: getNoiseHistUrl, data: "", }).done(function (histwinddata) { convertdata(histwinddata); }); function convertdata(histwinddt) { histNoise = histwinddt; console.log(histNoise[0]); showgraphNoise(); } } catch (err) { console.log('-> function gethistWind() failed!\n' + err); } } function showgraphNoise(){ var i; var noise_LA_max = 0 var noise_LA_maxnumb = 0 var noise_LA_min = 0 var noise_LAeq = 0 var datas = [] var datasMin = [] var dataseq = [] console.log(histNoise.length) var sDay = new Date('1995-12-17T03:24:00'); for (i = 0; i < histNoise.length; i++) { // new Date(histNoise[i].timestamp) datas.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LA_max)}) datasMin.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LA_min)}) dataseq.push({x: new Date(histNoise[i].timestamp).getTime(), y: parseFloat(histNoise[i].noise_LAeq)}) // console.log(histNoise[i].timestamp) // console.log(new Date(histNoise[i].timestamp)) // if (sameDay(sDay,new Date(histNoise[i].timestamp))){ // noise_LA_max = noise_LA_max + parseFloat(histNoise[i].noise_LA_max) // noise_LA_min = noise_LA_min + parseFloat(histNoise[i].noise_LA_min) // noise_LAeq = noise_LAeq + parseFloat(histNoise[i].noise_LAeq) // noise_LA_maxnumb = noise_LA_maxnumb + 1 // // console.log(noise_LA_maxnumb) // } else if (noise_LA_maxnumb != 0){ // var valuestuff = noise_LA_max / noise_LA_maxnumb // var valuemin = noise_LA_min / noise_LA_maxnumb // var valueeq = noise_LAeq / noise_LA_maxnumb // console.log(sDay.getFullYear() +"-"+(parseInt(sDay.getMonth()) + 1 )+"-"+sDay.getHours()) // datas.push({x: new Date(sDay).getTime(), y: parseFloat(valuestuff.toFixed(2))}) // datasMin.push({x: new Date(sDay).getTime(), y: parseFloat(valuemin.toFixed(2))}) // dataseq.push({x: new Date(sDay).getTime(), y: parseFloat(valueeq.toFixed(2))}) // noise_LA_max = 0 // noise_LA_min = 0 // noise_LAeq = 0 // noise_LA_maxnumb = 0 // } // sDay = new Date(histNoise[i].timestamp) } console.log(dataseq) console.log("--------") console.log([{ x: new Date('2018-02-12').getTime(), y: 76 }, { x: new Date('2018-02-12').getTime(), y: 76 }]) var options = { chart: { type: "area", height: 300, foreColor: "#999", stacked: false, dropShadow: { enabled: true, enabledSeries: [0], top: -2, left: 2, blur: 5, opacity: 0.06 } }, colors: ['#7F0000','#00E396', '#0090FF'], stroke: { curve: "smooth", width: 3 }, dataLabels: { enabled: false }, series: [{ name: 'Noise_LA_max', data: datas }, { name: 'Noise_LAeq', data: dataseq }, { name: 'Noise_LA_min', data: datasMin }], markers: { size: 0, strokeColor: "#fff", strokeWidth: 3, strokeOpacity: 1, fillOpacity: 1, hover: { size: 6 } }, xaxis: { type: "datetime", labels: { datetimeUTC: false }, axisBorder: { show: false }, axisTicks: { show: false } }, yaxis: { labels: { offsetX: 14, offsetY: -5 }, tooltip: { enabled: true } }, grid: { padding: { left: -5, right: 5 } }, tooltip: { x: { format: "dd MMM yyyy" }, }, legend: { position: 'top', horizontalAlign: 'left' }, fill: { type: 'gradient', gradient: { shadeIntensity: 1, inverseColors: false, opacityFrom: 0.5, opacityTo: 0, stops: [0, 90, 100] }, } }; document.getElementById("chartNoise").innerHTML = ""; var chart = new ApexCharts(document.querySelector("#chartNoise"), options); // document.getElementById("infobtnNoise").classList.add('infobtn'); // document.getElementById("infobtnNoise").classList.remove('loaderN'); console.log("end") chart.render(); } function sameDay(d1, d2) { console.log(d1.getFullYear() + " // " + d1.getMonth() + " // " + d1.getDate() + " // " + d1.getHours()) console.log(d2.getFullYear() + " // " + d2.getMonth() + " // " + d2.getDate() + " // " + d2.getHours()) return d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate() && d1.getHours() === d2.getHours(); }