This commit is contained in:
2019-08-22 07:58:15 +02:00
parent 365795300d
commit ddd569e2b3
219 changed files with 0 additions and 72609 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,24 +0,0 @@
/*!
* IE10 viewport hack for Surface/desktop Windows 8 bug
* Copyright 2014-2017 The Bootstrap Authors
* Copyright 2014-2017 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
// See the Getting Started docs for more information:
// https://getbootstrap.com/getting-started/#support-ie10-width
(function () {
'use strict'
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement('style')
msViewportStyle.appendChild(
document.createTextNode(
'@-ms-viewport{width:auto!important}'
)
)
document.head.appendChild(msViewportStyle)
}
}())

View File

@@ -1,166 +0,0 @@
var hours = 24;
var granularity = '5m';
var end = 0;
var retention = 'monthly';
var graphdata = "https://bastart.spoton.cz/data/solar_monitor?range=24h&granularity=5m&end=0h&retention=monthly";
sol = new Dygraph(
document.getElementById("solar"),
graphdata
,{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis: true,
valueRange: [44.5,55]
},
y2 : {
drawGrid: false,
drawAxis: true,
independentTicks: true,
customBars: true,
valueRange: [0,1300]
}
},
rollPeriod: 3,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'P_solar': {
axis: 'y2',
color: '#ff5500'
},
'V_array': {
axis: 'y',
color: '#666'
}
},
ylabel: '<span style="color:#666;">Battery [V]</span>',
y2label: '<span style="color:#ff2200;">Power [W]</span>',
labelsDiv: 'solar_labels',
legend: 'always',
customBars: true
}
);
function refreshGraph(){
graphdata = "https://bastart.spoton.cz/data/solar_monitor?range=" + hours + "h&granularity=" + granularity + "&end=" + end + "h&retention=" + retention;
sol.updateOptions({'file': graphdata});
}
function setHours(hours_to_set){
hours = hours_to_set;
switch(hours){
case '1':
granularity = '10s';
retention = 'monthly';
break;
case '6':
granularity = '10s';
retention = 'monthly';
break;
case '12':
granularity = '2m';
retention = 'monthly';
break;
case '24':
granularity = '5m';
retention = 'monthly';
break;
case '168':
granularity = '15m';
retention = 'monthly';
break;
case '720':
granularity = '3h';
retention = 'yearly';
break;
case '8760':
granularity = '6h';
retention = 'yearly';
break;
case '87600':
granularity = '24h';
retention = 'yearly';
break;
default:
granularity = '5m';
retention = 'monthly';
}
end = 0;
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph();
}
function setBack(){
// range=1h -> range=2h&end=1h
disp_range = hours*1 - end*1;
hours = hours*1 + disp_range;
end = end*1 + disp_range;
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph();
}
function setForth(){
disp_range = hours*1 - end*1;
hours = hours*1 - disp_range;
if(hours < disp_range){
hours = disp_range;
}
end = end*1 - disp_range;
if(end < 0){
end = 0;
}
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph();
}
function getPageContents(callback,url,params) {
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari, SeaMonkey
xmlhttp=new XMLHttpRequest();
}
else{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(params!=null) {
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
} else {
xmlhttp.open("GET", url, true);
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback(xmlhttp.responseText);
}
}
xmlhttp.send(params);
}
counter = 0;
function refreshValues(){
fresh_vals_url = '/data/solar_realtime_data?type=json'
getPageContents(function(result){freshVals=JSON.parse(result);},
fresh_vals_url)
document.getElementById('timestamp').innerHTML = freshVals.time;
document.getElementById('array_voltage').innerHTML = freshVals.V_array;
document.getElementById('array_percent').innerHTML = freshVals.perc_array;
document.getElementById('charge_current').innerHTML = freshVals.ChCurr;
document.getElementById('solar_power').innerHTML = freshVals.Psol;
document.getElementById('pmax_day').innerHTML = freshVals.Pmax_day;
counter = counter + 5000;
if(counter >= 360000){
refreshGraph();
document.getElementById('graph_timestamp').innerHTML = freshVals.time;
counter = 0;
}
}
var intervalVal = setInterval(refreshValues, 5000);

View File

@@ -1,174 +0,0 @@
var hours = 24;
var granularity = '2m';
var end = 0;
var solcapdata = "https://bastart.spoton.cz/data/solcap_monitor?range=24h&granularity=2m&end=0h";
var cpumemdata = "https://bastart.spoton.cz/data/cpumem_monitor?range=24h&granularity=2m&end=0h";
solcap = new Dygraph(
// containing div
document.getElementById("solcap"),
// CSV or path to a CSV file.
solcapdata
,{
//labels: ['time','Solar','Capacitor'],
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,4.6]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,8.6],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Solar': {
axis: 'y',
color: '#888844',
fillGraph: true,
fillAlpha: 0.4
},
'Capacitor': {
axis: 'y2',
color: '#884444'
}
},
ylabel: '<span style="color:#888844;">Solar Irradiance</span>',
y2label: '<span style="color:#884444;">Capacitor [V]</span>',
labelsDiv: 'solcap_labels',
legend: 'always'
}
);
cpumem = new Dygraph(
// containing div
document.getElementById("cpumem"),
// CSV or path to a CSV file.
cpumemdata
,{
//labels: ['time','cpu','mem','disk'],
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,100]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,100],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Cpu': {
axis: 'y',
color: '#888844',
fillGraph: true,
fillAlpha: 0.4
},
'Mem': {
axis: 'y2',
color: '#884444'
},
'Disk': {
axis: 'y2',
color: '#448844'
}
},
ylabel: '<span style="color:#888844;">CPU [%]</span>',
y2label: '<span style="color:#884444;">MEM / DISK [%]</span>',
labelsDiv: 'cpumem_labels',
legend: 'always'
}
);
function refreshGraph(source){
graphdata = "https://bastart.spoton.cz/data/" + source + "?range=" + hours + "h&granularity=" + granularity + "&end=" + end + "h";
if(source == 'solcap_monitor'){
solcap.updateOptions({'file': graphdata});
}
if(source == 'cpumem_monitor'){
cpumem.updateOptions({'file': graphdata});
}
//document.getElementById('xxx').innerHTML = source;
//power.updateOptions({'file': graphdata});
}
function setHours(hours_to_set, target){
hours = hours_to_set;
switch(hours){
case '1':
granularity = '10s';
break;
case '6':
granularity = '2m';
break;
case '12':
granularity = '2m';
break;
case '24':
granularity = '5m';
break;
case '168':
granularity = '10m';
break;
case '720':
granularity = '1h';
break;
case '4320':
granularity = '6h';
break;
case '8640':
granularity = '1d';
break;
default:
granularity = '10m';
}
end = 0;
//document.getElementById('xxx').innerHTML = target;
refreshGraph(target);
}
function setBack(target){
// range=1h -> range=2h&end=1h
disp_range = hours*1 - end*1;
hours = hours*1 + disp_range;
end = end*1 + disp_range;
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph(target);
}
function setForth(target){
disp_range = hours*1 - end*1;
hours = hours*1 - disp_range;
if(hours < disp_range){
hours = disp_range;
}
end = end*1 - disp_range;
if(end < 0){
end = 0;
}
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph(target);
}

View File

@@ -1,375 +0,0 @@
//defaults
var default_granularity = '5m'; // needs to be specified as string, changes
var default_hours = 24; // int is OK, (h) hardcoded
var default_end = 0; // detto
var network_type='wlan0' // honestly, these two should be generated
var iot_type='Tea' // dynamically
var base_url = "https://bastart.spoton.cz/data/";
var counter = 0;
var tout = 5000; // fresh date refresh rate, in ms
var g_tout = 30000; // graph update rate, in ms
//initialize the uninitialized
var hours = new Object();
var granularity = new Object();
var end = new Object();
var graphdata = new Object();
var data = new Object();
// types match function names in python's Dynamic.py class
var types = Array('solcap_monitor',
'cpumem_monitor',
'network_monitor',
'esp_battery_monitor');
// Now let's set up the defaults and primary data sources, leter changed dynamically
var types_size = types.length;
for(var i=0; i<types_size; i++){
var type = types[i];
hours[type] = default_hours;
granularity[type] = default_granularity;
end[type] = default_end;
if(type == 'cpumem_monitor'){
hours[type] = 3;
granularity[type] = '1m';
}
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h";
if(type == 'network_monitor'){
hours[type] = 3;
granularity[type] = '1m';
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h&type=" + network_type;
}
if(type == 'esp_battery_monitor'){
hours[type] = 168;
granularity[type] = '1h';
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h&type=" + iot_type;
}
}
solcap = new Dygraph(
// containing div
document.getElementById("solcap"),
// CSV or path to a CSV file.
data["solcap_monitor"]
,{
//labels: ['time','Solar','Capacitor'],
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,4.6]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,8.6],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Solar': {
axis: 'y',
color: '#999',
fillGraph: true,
fillAlpha: 0.4
},
'Capacitor': {
axis: 'y2',
color: '#c11'
}
},
ylabel: '<span style="color:#999;">Solar Irradiance</span>',
y2label: '<span style="color:#c11;">Capacitor [V]</span>',
labelsDiv: 'solcap_labels',
legend: 'always'
}
);
cpumem = new Dygraph(
document.getElementById("cpumem"),
data['cpumem_monitor']
,{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,100]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,100],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Cpu': {
axis: 'y',
color: '#999',
fillGraph: true,
fillAlpha: 0.4
},
'Mem': {
axis: 'y2',
color: '#c11'
},
'Disk': {
axis: 'y2',
color: '#111'
}
},
ylabel: '<span style="color:#999;">CPU [%]</span>',
y2label: '<span style="color:#c11;">MEM</span> / <span style="color:#111;">DISK [%]</span>',
labelsDiv: 'cpumem_labels',
legend: 'always'
}
);
network = new Dygraph(
document.getElementById("network"),
data['network_monitor']
,{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
},
y2 : {
drawGrid: false,
drawAxis: true,
independentTicks: true
}
},
rollPeriod: 2,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Bin': {
axis: 'y',
color: '#000',
fillGraph: true,
fillAlpha: 0.1
},
'Bout': {
axis: 'y',
color: '#aaa',
fillGraph: true,
fillAlpha: 0.5
},
'Din': {
axis: 'y2',
color: '#ff5500'
},
'Dout': {
axis: 'y2',
color: '#ff5500'
},
'Ein': {
axis: 'y2',
color: '#ff2233',
fillAlpha: 0.5
},
'Eout': {
axis: 'y2',
color: '#ff2233',
fillAlpha: 0.5
}
},
ylabel: '<span style="color:#000;">kB/s</span>',
y2label: '<span style="color:#ff2233;">Drop / Error</span>',
labelsDiv: 'network_labels',
legend: 'always'
}
);
esp_battery = new Dygraph(
document.getElementById("esp_battery"),
data['esp_battery_monitor']
,{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [2.5,4.5]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [2.5,4.5],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'batt(Tea)': {
axis: 'y',
color: '#000',
fillGraph: true,
fillAlpha: 0.2
},
'batt_perc(Tea)': {
axis: 'y2',
color: '#000'
},
'batt_low(Tea)': {
axis: 'y2',
color: '#e00'
}
},
ylabel: '<span style="color:#000;">Battery (Tea) [V]</span>',
y2label: '<span style="color:#000;">Top [V]</span> / <span style="color:#e00;">Low [V]</span>',
labelsDiv: 'esp_battery_labels',
legend: 'always'
}
);
// re-draw graphs
function refreshGraph(source){
graphdata[source] = "https://bastart.spoton.cz/data/" + source + "?range=" + hours[source] + "h&granularity=" + granularity[source] + "&end=" + end[source] + "h";
if(source == 'solcap_monitor'){
solcap.updateOptions({'file': graphdata[source]});
}
if(source == 'cpumem_monitor'){
cpumem.updateOptions({'file': graphdata[source]});
}
if(source == 'esp_battery_monitor'){
graphdata[source] += "&type=" + iot_type;
esp_battery.updateOptions({'file': graphdata[source]});
}
if(source == 'network_monitor'){
graphdata[source] += "&type=" + network_type;
network.updateOptions({'file': graphdata[source]});
}
}
// here, target needs to match the python's dynamic class again
function setHours(hours_to_set, target){
hours[target] = hours_to_set;
switch(hours[target]){
case '1':
granularity[target] = '20s';
break;
case '6':
granularity[target] = '30s';
break;
case '12':
granularity[target] = '1m';
break;
case '24':
granularity[target] = '2m';
break;
case '168':
granularity[target] = '10m';
break;
case '720':
granularity[target] = '1h';
break;
case '4320':
granularity[target] = '3h';
break;
case '8640':
granularity[target] = '1d';
break;
default:
granularity[target] = '10m';
}
end[target] = 0;
refreshGraph(target);
}
// Functions for buttons to scale / move graphs
function setBack(target){
disp_range = hours[target]*1 - end[target]*1;
hours[target] = hours[target]*1 + disp_range;
end[target] = end[target]*1 + disp_range;
refreshGraph(target);
}
function setForth(target){
disp_range = hours[target]*1 - end[target]*1;
hours[target] = hours[target]*1 - disp_range;
if(hours[target] < disp_range){
hours[target] = disp_range;
}
end[target] = end[target]*1 - disp_range;
if(end[target] < 0){
end[target] = 0;
}
refreshGraph(target);
}
function getPageContents(callback,url,params) {
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari, SeaMonkey
xmlhttp=new XMLHttpRequest();
}
else{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(params!=null) {
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
} else {
xmlhttp.open("GET", url, true);
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback(xmlhttp.responseText);
}
}
xmlhttp.send(params);
}
function refreshValues(){
fresh_vals_url = '/data/status_realtime_data?type=json'
getPageContents(function(result){freshVals=JSON.parse(result);},
fresh_vals_url)
document.getElementById('timestamp').innerHTML = freshVals.time;
document.getElementById('sol_val').innerHTML = freshVals.iss_solar;
document.getElementById('cap_val').innerHTML = freshVals.iss_capacitor;
document.getElementById('cpu_val').innerHTML = freshVals.RasPI_cpu;
document.getElementById('mem').innerHTML = freshVals.RasPI_mem;
document.getElementById('disk').innerHTML = freshVals.RasPI_disk;
document.getElementById('net_in').innerHTML = freshVals.net.b_in;
document.getElementById('net_out').innerHTML = freshVals.net.b_out;
counter = counter + tout;
if(counter >= g_tout){
for(var i=0; i<types_size; i++){
var type = types[i];
refreshGraph(type);
}
document.getElementById('graph_timestamp').innerHTML = freshVals.time;
counter = 0;
}
}
var intervalVal = setInterval(refreshValues, tout);

View File

@@ -1,118 +0,0 @@
var hours = 168;
var granularity = '30m';
var end = 0;
var tea_temphumidata = "https://bastart.spoton.cz/data/usense_temphumi_monitor?range=168h&granularity=30m&end=0h&type=Tea";
tea_temphum = new Dygraph(
// containing div
document.getElementById("tea_temphum"),
// CSV or path to a CSV file.
tea_temphumidata
,{
//labels: ['time','Temperature','Humidity'],
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,40]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [20,80],
independentTicks: true
}
},
rollPeriod: 20,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'T(tea)': {
axis: 'y',
color: '#999',
fillGraph: true,
fillAlpha: 0.4
},
'Humi(tea)': {
axis: 'y2',
color: '#c11'
}
},
ylabel: '<span style="color:#999;">Temperature [&deg;C]</span>',
y2label: '<span style="color:#c11;">Humidity [%]</span>',
labelsDiv: 'tea_labels',
legend: 'always'
}
);
function refreshGraph(source){
//graphdata = "https://bastart.spoton.cz/data/" + source + "?range=" + hours + "h&granularity=" + granularity + "&end=" + end + "h&type=" + type;
if(source == 'usense_temphumi_monitor'){
type = "Tea"
graphdata = "https://bastart.spoton.cz/data/" + source + "?range=" + hours + "h&granularity=" + granularity + "&end=" + end + "h&type=" + type;
tea_temphum.updateOptions({'file': graphdata});
}
//document.getElementById('xxx').innerHTML = graphdata;
}
function setHours(hours_to_set, target){
hours = hours_to_set;
switch(hours){
case '6':
granularity = '10m';
break;
case '12':
granularity = '10m';
break;
case '24':
granularity = '10m';
break;
case '168':
granularity = '30m';
break;
case '720':
granularity = '1h';
break;
case '4320':
granularity = '3h';
break;
case '8640':
granularity = '12h';
break;
default:
granularity = '10m';
}
end = 0;
//document.getElementById('xxx').innerHTML = target;
refreshGraph(target);
}
function setBack(target){
// range=1h -> range=2h&end=1h
disp_range = hours*1 - end*1;
hours = hours*1 + disp_range;
end = end*1 + disp_range;
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph(target);
}
function setForth(target){
disp_range = hours*1 - end*1;
hours = hours*1 - disp_range;
if(hours < disp_range){
hours = disp_range;
}
end = end*1 - disp_range;
if(end < 0){
end = 0;
}
//document.getElementById('xxx').innerHTML = graphdata;
refreshGraph(target);
}

View File

@@ -1,414 +0,0 @@
//defaults
var default_granularity = '5m'; // needs to be specified as string, changes
var default_hours = 24; // int is OK, (h) hardcoded
var default_end = 0; // detto
var base_url = "https://bastart.spoton.cz/data/";
var counter = 0;
var tout = 5000; // fresh date refresh rate, in ms
var g_tout = 30000; // graph update rate, in ms
//initialize the uninitialized
var hours = new Object();
var granularity = new Object();
var end = new Object();
var graphdata = new Object();
var data = new Object();
// types match function names in python's Dynamic.py class
var types = Array('wind_monitor',
'temphumi_monitor',
'pressure_monitor',
'rrate_monitor');
// Now let's set up the defaults and primary data sources, leter changed dynamically
var types_size = types.length;
for(var i=0; i<types_size; i++){
var type = types[i];
hours[type] = default_hours;
granularity[type] = default_granularity;
end[type] = default_end;
if(type == 'wind_monitor'){
hours[type] = 12;
granularity[type] = '1m';
}
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h";
if(type == 'pressure_monitor'){
hours[type] = 168;
granularity[type] = '1h';
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h";
}
if(type == 'rrate_monitor'){
hours[type] = 168;
granularity[type] = '1h';
data[type] = base_url + type + "?range=" + hours[type] + "h&granularity=" + granularity[type] + "&end=" + default_end + "h";
}
}
wind = new Dygraph(
document.getElementById("wind"),
data['wind_monitor'],
{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,360],
independentTicks: true
}
},
rollPeriod: 5,
interactionModel: {},
connectSeparatedPoints: true,
series:{
'Speed': {
axis: 'y',
color: '#444444',
fillGraph: true,
fillAlpha: 0.4
},
'Gusts': {
axis: 'y',
color: '#ff5555'
},
'Direction': {
axis: 'y2',
color: '#999999'
}
},
ylabel: '<span style="color:#444444;">Speed<span style="color:#444444;"> / <span style="color:#ff5555;">Gusts</span> [km/h]',
y2label: '<span style="color:#999999;">Direction [&deg;]</span>',
labelsDiv: 'wind_labels',
legend: 'always'
}
);
temphumi_out = new Dygraph(
document.getElementById("temphumi"),
data['temphumi_monitor'],
{
axes : {
x : {
drawGrid: true,
drawAxis : false
},
y : {
drawGrid: false,
drawAxis : true,
},
y2 : {
drawGrid: false,
drawAxis: true,
independentTicks: true
}
},
rollPeriod: 5,
visibility: [false, true, false, true],
interactionModel: {},
connectSeparatedPoints: true,
series:{
'T(out)': {
axis: 'y',
color: '#705555',
fillGraph: true,
fillAlpha: 0.2
},
'T(ins)': {
axis: 'y',
color: '#705555',
fillGraph: true,
fillAlpha: 0.2
},
'Humi(out)': {
axis: 'y2',
color: '#222288'
},
'Humi(ins)': {
axis: 'y2',
color: '#222288'
}
},
ylabel: '<span style="color:#555555;">Outside [&deg;C]</span>',
y2label: '<span style="color:#222288;">Humidity [%]</span>',
labelsDiv: 'temphumi_labels',
legend: 'always'
}
);
temphumi_in = new Dygraph(
document.getElementById("temphumi_in"),
data['temphumi_monitor'],
{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [10,35]
},
y2 : {
drawGrid: false,
drawAxis: true,
independentTicks: true,
valueRange: [0,100]
}
},
rollPeriod: 5,
visibility: [true, false, true, false],
interactionModel: {},
connectSeparatedPoints: true,
series:{
'T(out)': {
axis: 'y',
color: '#705555',
fillGraph: true,
fillAlpha: 0.2
},
'T(ins)': {
axis: 'y',
color: '#705555',
fillGraph: true,
fillAlpha: 0.2
},
'Humi(out)': {
axis: 'y2',
color: '#222288'
},
'Humi(ins)': {
axis: 'y2',
color: '#222288'
}
},
ylabel: '<span style="color:#555555;">Inside [&deg;C]</span>',
y2label: '<span style="color:#222288;">Humidity [%]</span>',
labelsDiv: 'temphumi_labels_in',
legend: 'always'
}
);
pressure = new Dygraph(
document.getElementById("pressure"),
data['pressure_monitor'],
{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [970,1055]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [970,1055]
}
},
rollPeriod: 20,
interactionModel: {},
connectSeparatedPoints: true,
visibility: [true, false],
series:{
'Pressure': {
axis: 'y',
color: '#557070',
fillGraph: true,
fillAlpha: 0.5
},
'Pressure': {
axis: 'y2',
color: '#557070',
fillGraph: true,
fillAlpha: 0.5
}
},
ylabel: '<span style="color:#555555;">Pressure [hPa]</span>',
labelsDiv: 'pressure_labels',
legend: 'always'
}
);
rrate = new Dygraph(
document.getElementById("rrate"),
data['rrate_monitor'],
{
axes : {
x : {
drawGrid: true,
drawAxis : true
},
y : {
drawGrid: false,
drawAxis : true,
valueRange: [0,3]
},
y2 : {
drawGrid: false,
drawAxis: true,
valueRange: [0,3]
}
},
rollPeriod: 0,
interactionModel: {},
connectSeparatedPoints: true,
visibility: [true, true],
series:{
'Rrate': {
axis: 'y',
color: '#0055ff',
fillGraph: true,
fillAlpha: 0.5
},
'Rrate_max': {
axis: 'y2',
color: '#0000aa',
fillGraph: false
}
},
ylabel: '<span style="color:#555555;">Rain rate [mm/h]</span>',
labelsDiv: 'rrate_labels',
legend: 'always'
}
);
// Functions for buttons to scale / move graphs
function refreshGraph(source){
graphdata[source] = "https://bastart.spoton.cz/data/" + source + "?range=" + hours[source] + "h&granularity=" + granularity[source] + "&end=" + end[source] + "h";
if(source == 'wind_monitor'){
wind.updateOptions({'file': graphdata[source]});
}
if(source == 'temphumi_monitor'){
temphumi_out.updateOptions({'file': graphdata[source]});
temphumi_in.updateOptions({'file': graphdata[source]});
}
if(source == 'pressure_monitor'){
pressure.updateOptions({'file': graphdata[source]});
}
if(source == 'rrate_monitor'){
rrate.updateOptions({'file': graphdata[source]});
}
// TODO: adjust to update graph timestamps per click on ranges
// document.getElementById('g_tstamp_' + source).innerHTML = freshVals.time;
}
// here, target needs to match the python's dynamic class again
function setHours(hours_to_set, target){
hours[target] = hours_to_set;
switch(hours[target]){
case '1':
granularity[target] = '30s';
if(target == 'temphumi_monitor'){ granularity[target] = '2m';}
break;
case '6':
granularity[target] = '1m';
if(target == 'temphumi_monitor'){ granularity[target] = '2m';}
break;
case '12':
granularity[target] = '2m';
if(target == 'temphumi_monitor'){ granularity[target] = '2m';}
break;
case '24':
granularity[target] = '5m';
if(target == 'temphumi_monitor'){ granularity[target] = '2m';}
break;
case '168':
granularity[target] = '10m';
break;
case '720':
granularity[target] = '1h';
break;
case '4320':
granularity[target] = '12h';
break;
case '8640':
granularity[target] = '24h';
break;
default:
granularity[target] = default_granularity;
}
end[target] = 0;
refreshGraph(target);
}
// Functions for buttons to scale / move graphs
function setBack(target){
disp_range = hours[target]*1 - end[target]*1;
hours[target] = hours[target]*1 + disp_range;
end[target] = end[target]*1 + disp_range;
refreshGraph(target);
}
function setForth(target){
disp_range = hours[target]*1 - end[target]*1;
hours[target] = hours[target]*1 - disp_range;
if(hours[target] < disp_range){
hours[target] = disp_range;
}
end[target] = end[target]*1 - disp_range;
if(end[target] < 0){
end[target] = 0;
}
refreshGraph(target);
}
function getPageContents(callback,url,params) {
if (window.XMLHttpRequest){
// code for IE7+, Firefox, Chrome, Opera, Safari, SeaMonkey
xmlhttp=new XMLHttpRequest();
}
else{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if(params!=null) {
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
} else {
xmlhttp.open("GET", url, true);
}
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback(xmlhttp.responseText);
}
}
xmlhttp.send(params);
}
function refreshValues(){
fresh_vals_url = '/data/weather_realtime_data?type=json'
getPageContents(function(result){freshVals=JSON.parse(result);},
fresh_vals_url)
document.getElementById('timestamp').innerHTML = freshVals.time;
document.getElementById('w_speed_km').innerHTML = freshVals.wind.speed;
document.getElementById('w_speed_ms').innerHTML = freshVals.wind.speed_ms;
document.getElementById('w_dir').innerHTML = freshVals.wind.dir;
document.getElementById('w_gust_km').innerHTML = freshVals.wind.gust;
document.getElementById('w_gust_ms').innerHTML = freshVals.wind.gust_ms;
document.getElementById('w_dir_name').innerHTML = freshVals.wind.dir_name;
document.getElementById('out_temp').innerHTML = freshVals.temperature.out;
document.getElementById('in_temp').innerHTML = freshVals.temperature.in;
document.getElementById('current_pressure').innerHTML = freshVals.pressure;
document.getElementById('current_rrate').innerHTML = freshVals.rainrate;
counter = counter + tout;
if(counter >= g_tout){
for(var i=0; i<types_size; i++){
var type = types[i];
refreshGraph(type);
document.getElementById('g_tstamp_' + type).innerHTML = freshVals.time;
}
counter = 0;
}
}
var intervalVal = setInterval(refreshValues, tout);