var sync_plots = { humidity_plot : new PlotterClas("wind", "humidity_plot", [0,30]), } var sync_weather = { // set_data: function(data_) { //See data_: http://127.0.0.1:5030/eicdata/ajax/?&action=data_state&id=2016-12-01 //if (data_.ACK) { var res = sync_weather.tuned_state(data_, ' '); document.getElementById('plc').innerHTML = res; var res = sync_weather.tuned_weather(data_, ' '); document.getElementById('global').innerHTML = res; //var res = sync_weather.object_to_tree(data_, ' '); //document.getElementById('refresh').innerHTML = res; sync_plots.humidity_plot.refresh_list([data_[0].fields.updated , data_[0].fields.wind]); //} }, tuned_state: function(data) { data = data[0]; res ='

PLC

' res +=''; if (data.is_safe == true) { res += sync_weather.get_success("is_safe", data.is_safe); } else { res += sync_weather.get_warning("is_safe", data.is_safe); } res += sync_weather.get_success("plc_mode", data.plc_mode); res += sync_weather.get_success("plc_timeout", data.plc_timeout); res += "
"; return res }, tuned_weather: function(data) { data = data[0].fields; res ='

Weather

' res +=''; if (data.global_status == "OK") { res += sync_weather.get_success("global_status", data.global_status); } else { res += sync_weather.get_warning("global_status", data.global_status); } res += sync_weather.get_success("updated", data.updated); res += sync_weather.get_success("humidity", data.humidity); res += sync_weather.get_success("pressure", data.pressure); res += sync_weather.get_success("rain", data.rain); res += sync_weather.get_success("temperature", data.temperature); res += sync_weather.get_success("wind", data.wind); res += sync_weather.get_success("wind_dir", data.wind_dir); res += "
"; return res }, // alert alert-success get_success: function(name, value) {return ''+name+': '+value+'';}, get_warning: function(name, value) {return ''+name+': '+value+'';}, setTimeout:function(){ //alert("change"); Async.status.timeout = document.getElementById('timer_select').value * 1000; }, object_to_tree: function(argObject, level) { var msg = ''; for (var propertyName in argObject) { if (typeof argObject[propertyName] == 'object'){ msg += '

' + level + propertyName + ': (' + typeof argObject[propertyName] + ')

'; msg += this.object_to_tree(argObject[propertyName], level + '-- '); } else if (typeof argObject[propertyName] == 'function'){ msg += '

' + level + propertyName + ': (' + typeof argObject[propertyName] + ')

'; } else { msg += '

' + level + propertyName + ': (' + typeof argObject[propertyName] + ') ' + argObject[propertyName] + '

'; } } return msg } }