1482 lines
76 KiB
JavaScript
1482 lines
76 KiB
JavaScript
/**
|
|
* Archivo de funciones general o soporte para la interfaz grafica GUI de EMA Libre.
|
|
*
|
|
* Contiene un conjunto de funciones que brindan soporte al sistema EMA.
|
|
*
|
|
* LICENSE: This file is part of EMA Libre.
|
|
* EMA Libre is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* EMA Libre is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with EMA Libre. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* @copyright Copyright (c) 2019 GUGLER (https://www.gugler.com.ar)
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL License
|
|
* @version 3.0
|
|
* @link https://www.gugler.com.ar
|
|
* @since File available since Release 3.0
|
|
*/
|
|
|
|
// VARIABLES GENERALES
|
|
|
|
var fsconf = require('fs'); // Libreria para para poder almacenar/leer archivos en disco(funcion leer/guardar Conf.)
|
|
var Sube = "<img src='../gui_common/img/clima/sube.webp' title='"; // Imagen cuando sube una lectura, la misma se completa con la tendencia.
|
|
var Baja = "<img src='../gui_common/img/clima/baja.webp' title='"; // Imagen cuando baja una lectura, la misma se completa con la tendencia.
|
|
var Igual = "<img src='../gui_common/img/clima/igual.webp'>"; // Imagen cuando no hay cambios.
|
|
var icono_control_true = '../gui_common/img/ok.webp'; // Imagen de Control TRUE
|
|
var icono_control_false = '../gui_common/img/no.webp'; // Imagen de Control FALSE
|
|
var icono_control_neutro = '../gui_common/img/neutro.webp'; // Imagen de Control NEUTRO - ALERT
|
|
const version_nwjs = process.versions['nw']; // Version de NWJS
|
|
const plataforma = process.platform;
|
|
const arquitectura = process.arch;
|
|
var AnteriorViento = false;
|
|
// Version de Modulos
|
|
const ver = process.versions;
|
|
var versiones = '<ol class="list-group">';
|
|
$.each(ver, function(i, item) { if(i == 'nw' || i == 'chromium' || i =='node'|| i == 'v8' ) versiones += '<li class="list-group-item list-group-item-info"><span class="badge badge-primary badge-pill"><small>'+i +'</small>: '+'</span><small>'+item+ '</small></li>';});
|
|
versiones += '</ol>'
|
|
|
|
|
|
// El constructor por defecto de Map para transforar (clave-valor)
|
|
|
|
var mapaDatosArray = [ ["rf.temp_out", "Temperatura Externa"],
|
|
["rf.temp_in", "Temperatura Interna"],
|
|
["rf.hum_out", "Humedad Externa"],
|
|
["rf.hum_in", "Humedad Interna"],
|
|
["rf.lux", "Luxer"],
|
|
["rf.uv", "Rayos Ultravioletas"],
|
|
["rf.wind_dir", "Dirección del Viento"],
|
|
["rf.wind_gust", "Rafagas de Vientos"],
|
|
["rf.wind_ave", "Vientos"],
|
|
["rf.abs_pressure", "Presion Atmosferica Relativa"],
|
|
["rf.rel_pressure", "Presion Atmosferica Absoluta"],
|
|
["rf.rain", "Lluvia"]
|
|
];
|
|
var mapaDatos = new Map(mapaDatosArray);
|
|
|
|
|
|
// Se inicializan variables globales
|
|
var tendenciaTE = Igual; var tendenciaR = Igual;
|
|
var tendenciaTI=Igual;var tendenciaPA = Igual;
|
|
var tendenciaPR = Igual; var tendenciaLI = Igual;
|
|
var tendenciaHE = Igual; var tendenciaHI = Igual;
|
|
var tendenciaPDR=Igual;var result = "";var gtempint;
|
|
var ghumint; var gviento;var gviento1; var EstadoEMA_Control;
|
|
// **********************Funciones Generales de la GUI ***************************************************
|
|
|
|
async function EstadoMenuInicio()
|
|
{
|
|
try{
|
|
// Inicio automatico y audio para el menu de inicio
|
|
var audiomenu = '-';
|
|
var autoactivado = '-';
|
|
if(configGeneralEMA.ConfGeneral.Audio) { audiomenu = 'Activado';}else{ audiomenu = 'Desactivado';}
|
|
if(configGeneralEMA.ConfGeneral.inicio_automatico) { autoactivado = 'Activado';}else{ autoactivado = 'Desactivado';}
|
|
$('#audiomenu').html(audiomenu);
|
|
$('#autoactivado').html(autoactivado);
|
|
audiomenu=null;autoactivado=null;
|
|
// Se calcula la Cantidad y tamaño de los Tanques y Debug
|
|
if (fsconf.existsSync("logs/registro_diario.log"))
|
|
{var estadoarchivoTD = fsconf.statSync("logs/registro_diario.log");
|
|
var TamanioenMegaTD = (estadoarchivoTD.size)/ 1000000.0;
|
|
$('#tamanio_diario').html(TamanioenMegaTD.toFixed(2) + ' Mb');
|
|
estadoarchivoTD=null;TamanioenMegaTD=null;
|
|
}else{$('#tamanio_diario').html('No Existe');}
|
|
if (fsconf.existsSync("logs/TanquePendientes.log"))
|
|
{var estadoarchivoTP = fsconf.statSync("logs/TanquePendientes.log");
|
|
var TamanioenMegaTP = (estadoarchivoTP.size)/ 1000000.0;
|
|
$('#tamanio_pendiente').html(TamanioenMegaTP.toFixed(2) + ' Mb');
|
|
estadoarchivoTP=null;TamanioenMegaTP=null;
|
|
}else{$('#tamanio_pendiente').html('No_Existe');}
|
|
if (fsconf.existsSync("logs/debug.log"))
|
|
{var estadoarchivoD = fsconf.statSync("logs/debug.log");
|
|
var TamanioenMegaD = (estadoarchivoD.size)/ 1000000.0;
|
|
if (TamanioenMegaD >= configGeneralEMA.ConfGeneral.debugTamanio) { HABLA(0, 'Se depura automaticamente el archivo de debug.',"info");}
|
|
$('#tamanio_debug').html(TamanioenMegaD.toFixed(2) + ' Mb');
|
|
estadoarchivoD=null;TamanioenMegaD=null;
|
|
}else{$('#tamanio_debug').html('No_Existe');}
|
|
//Datos Generales
|
|
$('#inombre').html(configGeneralEMA.ConfGeneral.NombreEstacion);
|
|
$('#botoniniciar').attr("disabled",true);
|
|
$('#botondetener').attr("disabled",true)
|
|
$('#iso').html(plataforma + " (" + arquitectura + ")");
|
|
$('#imodo').html(configGeneralEMA.ConfGeneral.Modo);
|
|
if(configGeneralEMA.ConfGeneral.Modo != 'Visor') // Se consulta el modo (Recolector o Visor)
|
|
{
|
|
if(configGeneralEMA.ConfGeneral.Modo === 'Recolector_USB') // Modo Recolector USB
|
|
{
|
|
EMA.EstadoUSB(function(EstadoUSB)
|
|
{
|
|
EstadoEMA_Control = EMA.Estado();
|
|
if(EstadoEMA_Control[0])
|
|
{
|
|
$("#img_estado").attr("src",icono_control_true);$('#estado').html("En Linea");
|
|
$('#botoniniciar').attr("disabled",true);
|
|
$('#botondetener').attr("disabled",false);
|
|
if(EstadoUSB){
|
|
$('#iusb').html("USB conectado");$("#img_estacion").attr("src",icono_control_true);
|
|
$("#img_detalle").attr("src",icono_control_true);$("#img_mensaje").attr("src",icono_control_true);
|
|
}
|
|
else{$("#img_estacion").attr("src",icono_control_false);$('#iusb').html("USB no conectado");
|
|
$("#img_mensaje").attr("src",icono_control_false);$('#mensaje').html("Conecte el USB.");
|
|
$("#img_detalle").attr("src",icono_control_false);$('#mensajedetalle').html("Verifique / Conecte la estacion USB.");
|
|
}
|
|
|
|
}else{
|
|
$("#img_estado").attr("src",icono_control_neutro);$('#estado').html("Fuera de Linea");
|
|
if(EstadoUSB){
|
|
$('#iusb').html("USB conectado");$("#img_estacion").attr("src",icono_control_true);
|
|
$("#img_detalle").attr("src",icono_control_true);$("#img_mensaje").attr("src",icono_control_true);
|
|
$('#mensaje').html("Encienda EMA Libre");
|
|
$('#botoniniciar').attr("disabled",false);
|
|
}
|
|
else{$("#img_estacion").attr("src",icono_control_false);$('#iusb').html("USB no conectado");
|
|
$('#botoniniciar').attr("disabled",true);
|
|
$("#img_mensaje").attr("src",icono_control_false);$('#mensaje').html("Conecte el USB.");
|
|
$("#img_detalle").attr("src",icono_control_false);$('#mensajedetalle').html(EstadoEMA_Control[1]);
|
|
}
|
|
}
|
|
EstadoUSB=null;
|
|
});
|
|
}else{ // Modo Recolector por IP/WIFI
|
|
EstadoEMA_Control = EMA.Estado();
|
|
if(EstadoEMA_Control[0])
|
|
{
|
|
$("#img_estado").attr("src",icono_control_true);$('#estado').html("En Linea");
|
|
$('#botoniniciar').attr("disabled",true);
|
|
$('#botondetener').attr("disabled",false);
|
|
$('#iusb').html("Recolectado por IP");$("#img_estacion").attr("src",icono_control_true);
|
|
$('#mensaje').html("Recolectado por IP");$("#img_mensaje").attr("src",icono_control_true);
|
|
$("#img_detalle").attr("src",icono_control_true);
|
|
MensajeR = "Recolectando de " + configGeneralEMA.ConfGeneral.IP + ":" + configGeneralEMA.ConfGeneral.Puerto + configGeneralEMA.ConfGeneral.Ruta;
|
|
;$('#mensajedetalle').html(MensajeR);
|
|
}else{
|
|
MensajeR = "Al iniciar comenzara a recoletar en " + configGeneralEMA.ConfGeneral.IP + ":" + configGeneralEMA.ConfGeneral.Puerto + configGeneralEMA.ConfGeneral.Ruta;
|
|
$('#mensaje').html("Encienda EMA Libre");
|
|
$('#botoniniciar').attr("disabled",false);
|
|
$('#botondetener').attr("disabled",true);
|
|
$("#img_estacion").attr("src",icono_control_neutro);$('#iusb').html("Estación Wifi/IP sin recepción");
|
|
$("#img_mensaje").attr("src",icono_control_neutro);$('#mensaje').html("Encienda EMA Libre.");
|
|
$("#img_estado").attr("src",icono_control_neutro);$('#estado').html("Fuera de Linea");
|
|
$("#img_detalle").attr("src",icono_control_neutro);$('#mensajedetalle').html(MensajeR);
|
|
}
|
|
}
|
|
}else{ // Modo Visor Control
|
|
$('#iusb').html("Por Llave Lectura");
|
|
if($( "#signal" ).hasClass( "parpadea" ))
|
|
{
|
|
$('#estado').html("En Linea");
|
|
$("td#barralateral").css("background-color","#11881161");
|
|
$("#img_estado").attr("src",icono_control_true);
|
|
$('#botoniniciar').attr("disabled",true);
|
|
$('#botondetener').attr("disabled",false);
|
|
$("#img_detalle").attr("src",icono_control_true);$('#mensajedetalle').html("Obteniendo registros.");
|
|
}else{
|
|
$('#estado').html("Fuera de Linea");
|
|
$("td#barralateral").css("background-color","#ff000030");
|
|
$("#img_detalle").attr("src",icono_control_false);$('#mensajedetalle').html("Encienda EMA Libre.");
|
|
$("#img_estado").attr("src",icono_control_neutro);
|
|
$('#botoniniciar').attr("disabled",false);
|
|
$('#botondetener').attr("disabled",true);
|
|
}
|
|
if(configGeneralEMA.ConfGeneral.Llave_R != ''){
|
|
$("#img_mensaje").attr("src",icono_control_true);
|
|
$("#img_estacion").attr("src",icono_control_true);
|
|
$('#mensaje').html("Utilizando llave (EMA Center)");
|
|
}else{ $("#img_estado").attr("src",icono_control_false);
|
|
$("#img_mensaje").attr("src",icono_control_false);$('#mensaje').html("Ingrese la Llave de Lectura.");
|
|
$("#img_detalle").attr("src",icono_control_false);$('#mensajedetalle').html("Ingrese la Llave de Lectura.");
|
|
}
|
|
}
|
|
return false;
|
|
}catch (ex) {console.log(ex);}
|
|
};
|
|
|
|
async function MuestraRegistroActual(parpadeo,click)
|
|
{
|
|
if(UltimoReg)
|
|
{
|
|
if(parpadeo){$('#fecha').addClass( "parpadea" );}
|
|
$('#fecha').html(UltimoReg.fecha);
|
|
if(typeof Ant_UltimoReg == 'undefined'){Ant_UltimoReg = UltimoReg;} //para la primera carga del anterior
|
|
//Conversion de UV a Texto
|
|
var texto_uv = 0;
|
|
var x = UltimoReg.luxer_uv;
|
|
switch (true) {
|
|
case x > -1 && x <= 2: texto_uv = "Bajo";break;
|
|
case x > 2 && x <= 5: texto_uv = "Moderado";break;
|
|
case x > 5 && x <= 7: texto_uv = "Alto";break;
|
|
case x > 7 && x <= 10: texto_uv = "Muy Alto";break;
|
|
case x > 11: texto_uv = "Extremo";break;
|
|
}
|
|
x = null;
|
|
//Calculo de Sensacion Termina
|
|
var ST = (13.12+(0.6215 * UltimoReg.temperatura_externa )- (11.37* (UltimoReg.viento_velocidad^0.16))+((0.3965*UltimoReg.temperatura_externa) * (UltimoReg.viento_velocidad^0.16))).toFixed(2);
|
|
//Variables del Sistema Metrico
|
|
if(configGeneralEMA.ConfGeneral.SistemaMetrico == "SI"){var TEMP_S = " ºC"; var TEMP_MULT = 1;var TEMP_POND = 0;}else{var TEMP_S = " ºF";var TEMP_MULT = 9/5;var TEMP_POND = 32;};
|
|
//Muestra Interior (Temperatura y Humedad)
|
|
if(($('#interior').hasClass('active') && typeof click === "undefined") || (click === 'interior'))
|
|
{
|
|
//***Temperatura Interna
|
|
if (UltimoReg.temperatura_interna != Ant_UltimoReg.temperatura_interna){ if (UltimoReg.temperatura_interna > Ant_UltimoReg.temperatura_interna ) {tendenciaTI = Sube + (Ant_UltimoReg.temperatura_interna*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S +"|| Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Sube+"'>";}else{tendenciaTI = Baja+(Ant_UltimoReg.temperatura_interna*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S + " || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Baja+"'>";}}else {result = Igual;}
|
|
$('#temp_int').html((UltimoReg.temperatura_interna*TEMP_MULT+TEMP_POND).toFixed(1) + TEMP_S + tendenciaTI);$('#temp_int_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#temp_int_max').html((UltimoReg.temperatura_interna_max_dia*TEMP_MULT+TEMP_POND).toFixed(1) + TEMP_S);
|
|
$('#temp_int_min').html((UltimoReg.temperatura_interna_min_dia*TEMP_MULT+TEMP_POND).toFixed(1) + TEMP_S);
|
|
//*** humedad interna
|
|
if (UltimoReg.humedad_interna != Ant_UltimoReg.humedad_interna){ if (UltimoReg.humedad_interna > Ant_UltimoReg.humedad_interna ) {tendenciaHI = Sube + Ant_UltimoReg.humedad_interna+"% || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Sube+"'>";}else{tendenciaHI = Baja+Ant_UltimoReg.humedad_interna+"% || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Baja+"'>";}}else {result = Igual;}
|
|
$('#hum_int').html(UltimoReg.humedad_interna + " % " + tendenciaHI);$('#hum_int_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#hum_int_max').html(UltimoReg.humedad_interna_max_dia + " %" );
|
|
$('#hum_int_min').html(UltimoReg.humedad_interna_min_dia + " %" );
|
|
}
|
|
//Muestra Exterior
|
|
if(($('#exterior').hasClass('active') && typeof click === "undefined") || (click === 'exterior'))
|
|
{
|
|
//CALCULO DE TENDENCIAS Y MUESTRA REGISTRO
|
|
//***Temperatura Externa
|
|
if (UltimoReg.temperatura_externa != Ant_UltimoReg.temperatura_externa){ if (UltimoReg.temperatura_externa > Ant_UltimoReg.temperatura_externa ) {tendenciaTE = Sube + (Ant_UltimoReg.temperatura_externa*TEMP_MULT+TEMP_POND).toFixed(2)+ TEMP_S +" || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Sube+"'>";}else{tendenciaTE = Baja+(Ant_UltimoReg.temperatura_externa*TEMP_MULT+TEMP_POND).toFixed(2)+ TEMP_S +" || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Baja+"'>";}}else {result = Igual;}
|
|
$('#temp_ext').html((UltimoReg.temperatura_externa*TEMP_MULT+TEMP_POND).toFixed(1)+ TEMP_S + tendenciaTE);$('#temp_ext_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#temp_ext_max').html((UltimoReg.temperatura_externa_max_dia *TEMP_MULT+TEMP_POND).toFixed(1) + TEMP_S);
|
|
$('#temp_ext_min').html((UltimoReg.temperatura_externa_min_dia *TEMP_MULT+TEMP_POND).toFixed(1) + TEMP_S);
|
|
|
|
//*** Punto de Rocio
|
|
if (UltimoReg.punto_de_rocio != Ant_UltimoReg.punto_de_rocio){ if(UltimoReg.punto_de_rocio > Ant_UltimoReg.punto_de_rocio ) {tendenciaPDR = Sube + (Ant_UltimoReg.punto_de_rocio*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S +"|| Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Sube;}else{tendenciaPDR = Baja + (Ant_UltimoReg.punto_de_rocio*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S +" || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Baja +"'>";}}else {result = Igual;}
|
|
$('#punto_ext').html((UltimoReg.punto_de_rocio*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S + tendenciaPDR);$('#punto_ext_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#punto_ext_max').html((UltimoReg.punto_de_rocio_max_dia*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S);
|
|
$('#punto_ext_min').html((UltimoReg.punto_de_rocio_min_dia*TEMP_MULT+TEMP_POND).toFixed(2) + TEMP_S);
|
|
//*** humedad Externa
|
|
if (UltimoReg.humedad_externa != Ant_UltimoReg.humedad_externa){ if (UltimoReg.humedad_externa > Ant_UltimoReg.humedad_externa ) {tendenciaHE = Sube + Ant_UltimoReg.humedad_externa+"% || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Sube+"'>";}else{tendenciaHE = Baja+Ant_UltimoReg.humedad_externa+"% || Fecha: "+ Ant_UltimoReg.fecha +"'>";result = Baja+"'>";}}else {result = Igual;}
|
|
$('#hum_ext').html(UltimoReg.humedad_externa + " % " + tendenciaHE);$('#hum_ext_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#hum_ext_max').html(UltimoReg.humedad_externa_max_dia + " %" );
|
|
$('#hum_ext_min').html(UltimoReg.humedad_externa_min_dia + " %" );
|
|
//*** Intenciadad Luz
|
|
if(UltimoReg.luxer_intencidad != null)
|
|
{
|
|
if (UltimoReg.luxer_intencidad != Ant_UltimoReg.luxer_intencidad){ if (UltimoReg.luxer_intencidad > Ant_UltimoReg.luxer_intencidad ) {tendenciaLI = Sube + Ant_UltimoReg.luxer_intencidad + " Lux || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Sube;}else{tendenciaLI = Baja + Ant_UltimoReg.luxer_intencidad+" Lux || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Baja +"'>";}}else {result = Igual;}
|
|
$('#luxer_ext').html(UltimoReg.luxer_intencidad + " lux " + tendenciaLI);$('#luxer_ext_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#luxer_ext_max').html((UltimoReg.luxer_intencidad_max_dia*0.001).toFixed(2) + " Klux" );
|
|
$('#luxer_ext_min').html((UltimoReg.luxer_intencidad_min_dia*0.001).toFixed(2) + " Klux" );
|
|
}else{
|
|
$('#luxer_ext').html('S/D');
|
|
$('#luxer_ext_min').html('S/D');
|
|
$('#luxer_ext_max').html('S/D');
|
|
}
|
|
//*** Rayos UV
|
|
if(UltimoReg.luxer_uv != null)
|
|
{
|
|
if (UltimoReg.luxer_uv != Ant_UltimoReg.luxer_uv){ if(UltimoReg.luxer_uv > Ant_UltimoReg.luxer_uv ) {tendenciaR = Sube + Ant_UltimoReg.luxer_uv +" UV || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Sube;}else{tendenciaR = Baja + Ant_UltimoReg.luxer_uv+" UV || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Baja +"'>";}}else {result = Igual;}
|
|
$('#rayos_ext').html(UltimoReg.luxer_uv + " uv / " +texto_uv + " " + tendenciaR);$('#rayos_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#rayos_ext_max').html(UltimoReg.luxer_uv_max_dia + " uv" );
|
|
$('#rayos_ext_min').html(UltimoReg.luxer_uv_min_dia + " uv" );
|
|
}else{
|
|
$('#rayos_ext').html('S/D');
|
|
$('#rayos_ext_min').html('S/D');
|
|
$('#rayos_ext_max').html('S/D');
|
|
}
|
|
//*** Presion Absoluta
|
|
if (UltimoReg.presion_absoluta != Ant_UltimoReg.presion_absoluta){ if(UltimoReg.presion_absoluta > Ant_UltimoReg.presion_absoluta ) {tendenciaPA = Sube + Ant_UltimoReg.presion_absoluta +" hpa || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Sube;}else{tendenciaPA = Baja + Ant_UltimoReg.presion_absoluta+" hpa || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Baja +"'>";}}else {result = Igual;}
|
|
$('#presiona_ext').html(UltimoReg.presion_absoluta + " hpa " +tendenciaPA);$('#presiona_ext_img').html(result);
|
|
//*** Presion Relativa
|
|
if (UltimoReg.presion_relativa != Ant_UltimoReg.presion_relativa){ if(UltimoReg.presion_relativa > Ant_UltimoReg.presion_relativa ) {tendenciaPR = Sube + Ant_UltimoReg.presion_relativa +" hpa || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Sube;}else{tendenciaPR = Baja + Ant_UltimoReg.presion_relativa+" hpa || Fecha: "+ Ant_UltimoReg.fecha +"'>";result=Baja +"'>";}}else {result = Igual;}
|
|
$('#presionr_ext').html(UltimoReg.presion_relativa + " hpa " + tendenciaPR);$('#presionr_ext_img').html(result);
|
|
//*** Maximos y Minimos
|
|
$('#presionr_ext_max').html(UltimoReg.presion_relativa_max_dia + " hpa" );
|
|
$('#presionr_ext_min').html(UltimoReg.presion_relativa_min_dia + " hpa" );
|
|
//*** Acumulados Lluvia ----> No tiene tendencias.
|
|
$('#lloviendo_ext').html(UltimoReg.lloviendo + "mm");
|
|
$('#totalacuhora_ext').html(UltimoReg.lluvia_acu_hora + "mm");
|
|
$('#totalacudia_ext').html(UltimoReg.lluvia_acu_diaria + "mm");
|
|
$('#totalL_ext').html(UltimoReg.lluvia_acumulado_total + "mm");
|
|
}
|
|
// Se guarda el registro anterior
|
|
Ant_UltimoReg = UltimoReg;
|
|
// Se actualiza los ToolTips
|
|
//$(document).ready(function(){$('[data-toggle="tooltip"]').tooltip();});
|
|
}
|
|
result=null;parpadeo=null;texto_uv=null;ST=null;
|
|
TEMP_S = null; TEMP_MULT = null;TEMP_POND = null;
|
|
};
|
|
|
|
async function RegistroPublicado()
|
|
{
|
|
var redesPub = EMA.UltimoPublicado();
|
|
//Mostrar redes Publicadas
|
|
if(redesPub){
|
|
var redespublicadashtml = "";
|
|
for (var key in redesPub)
|
|
{
|
|
if(redesPub[key].estado === true){
|
|
redespublicadashtml += "<span class='badge badge-pill badge-success' title='Publicado Correctamente'>"+redesPub[key].red +": "+redesPub[key].fecha.substring(10,19)+"</span><br>";
|
|
}else{
|
|
if(redesPub[key].estado == 'No enviado'){
|
|
redespublicadashtml += "<span class='badge badge-noinformado' title='No se envia, la red informa 5 minutos de espera.'>"+redesPub[key].red +": "+redesPub[key].fecha.substring(10,19)+"</span><br>";
|
|
}else{
|
|
if(redesPub[key].estado == 'Esperar'){
|
|
redespublicadashtml += "<span class='badge badge-light parpadea' title='"+redesPub[key].error+"'>"+redesPub[key].red +" "+redesPub[key].fecha.substring(10,19)+"</span><br>";
|
|
}else{
|
|
if(redesPub[key].error == "Detenido")
|
|
{redespublicadashtml += "<span class='badge badge-warning parpadea' title='"+redesPub[key].error+"'>"+redesPub[key].red +": "+redesPub[key].fecha.substring(10,19)+"</span><br>";
|
|
}else{redespublicadashtml += "<span class='badge badge-danger parpadea' title='"+redesPub[key].error+"'>"+redesPub[key].red +": "+redesPub[key].fecha.substring(10,19)+"</span><br>";}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
document.getElementById("RedesMet").innerHTML = redespublicadashtml;
|
|
}else{
|
|
document.getElementById("RedesMet").innerHTML = "<span class='badge badge-info' title='No hay datos publicados recientemente'>Sin datos</span><br>";
|
|
}
|
|
redesPub = null;redespublicadashtml = null;key = null;
|
|
};
|
|
|
|
async function ClimaActual()
|
|
{
|
|
// Se obtiene el estado actual del clima
|
|
var SALIDA_ENTRADA = "";var LLUEVE = 0; var NOCHE_DIA = 1;
|
|
//if( UltimoReg.lloviendo > 0){LLUEVE = '1'; }else{LLUEVE = '0';} // LLUEVE?
|
|
LLUEVE = (UltimoReg?.lloviendo ?? 0) > 0 ? '1' : '0';
|
|
if( UltimoReg.luxer_intencidad > 0){ NOCHE_DIA = '1'; }else{NOCHE_DIA = '0';} // DIA o NOCHE?
|
|
if( (UltimoReg.luxer_intencidad > UltimoReg.luxer_intencidad_1hs) && (UltimoReg.luxer_intencidad > 0 && UltimoReg.luxer_intencidad < 800)){ SALIDA_ENTRADA = '_1.gif';} // ALBA?
|
|
if( (UltimoReg.luxer_intencidad < UltimoReg.luxer_intencidad_1hs) && (UltimoReg.luxer_intencidad > 0 && UltimoReg.luxer_intencidad < 800)){ SALIDA_ENTRADA = '_0.gif';} // OCASO?
|
|
//Icono central
|
|
var image = document.createElement("IMG");image.alt = "Clima Actual";image.setAttribute("height", "96px");image.setAttribute("width", "96px");image.setAttribute('class', 'photo');
|
|
if(SALIDA_ENTRADA != ""){image.src="../gui_common/img/clima/1_0_clima" + SALIDA_ENTRADA; //ver de agregar ALBA Y OCASO con lluvia
|
|
}else{image.src="../gui_common/img/clima/" + NOCHE_DIA +"_" + LLUEVE + "_clima" + SALIDA_ENTRADA +".webp";}
|
|
$('#clima').html(image);
|
|
//Fondo de la aplicacion
|
|
if( LLUEVE == 1){HABLA(0,"Se registra lluvia","info");
|
|
if( NOCHE_DIA == 1){$("body").attr('class', 'dia_lluvia');}else{ $("body").attr('class', 'noche_lluvia');}
|
|
}else{if( NOCHE_DIA == 1){$("body").attr('class', 'dia');}else{ $("body").attr('class', 'noche');}}
|
|
// Hay cambios
|
|
if(UltimoReg.cambio === true && configGeneralEMA.ConfGeneral.notificar_cambios === true){
|
|
var cambiosCarpincho = '';
|
|
// Obteniendo todas las claves del JSON
|
|
let contador = 0;
|
|
for (var clave in UltimoReg.diferencia){
|
|
if(configGeneralEMA.ConfGeneral.Modo != 'Recolector_IP') // Modo Recolector USB
|
|
{ if (UltimoReg.diferencia.hasOwnProperty(clave)) {cambiosCarpincho += ' ' + mapaDatos.get(clave) + '.'; }
|
|
}else{ // Modo Recolector por IP/WIFI
|
|
if (contador === 0) {cambiosCarpincho += clave;}else{cambiosCarpincho += ', ' + clave;}
|
|
}
|
|
contador++;
|
|
}
|
|
cambiosCarpincho += ".";
|
|
if (typeof cambiosCarpincho !== 'undefined' && cambiosCarpincho !== '') HABLA(0, 'Hay cambios de ' + cambiosCarpincho ,"info");
|
|
}
|
|
// Se borran las variables
|
|
SALIDA_ENTRADA=null;NOCHE_DIA=null;LLUEVE=null;image=null;
|
|
}
|
|
|
|
async function Graficos(click)
|
|
{
|
|
//Graficos Interior (Temperatura y Humedad)
|
|
if(($('#interior').hasClass('active') && typeof click === "undefined" && $("#gtemp_int").length) || (click === 'interior'))
|
|
{
|
|
if(UltimoReg){var Tint = (UltimoReg.temperatura_interna || 0)}else{var Tint = 0;}
|
|
RGraph.ObjectRegistry.clear(gtemp_int);
|
|
gtempint = new RGraph.Thermometer({
|
|
id: 'gtemp_int',
|
|
min: 0,
|
|
max: 100,
|
|
value: Tint,
|
|
options: {
|
|
labelsCount:10,
|
|
labelsValue:false,
|
|
valueLabelDecimals: 2,
|
|
textSize:6,
|
|
textColor: 'white',
|
|
scaleVisible: true,
|
|
textAccessible: false
|
|
}
|
|
}).grow();
|
|
//color en gradiente
|
|
var grad = gtempint.context.createLinearGradient(0,50,0,350);
|
|
grad.addColorStop(0., 'Maroon');
|
|
grad.addColorStop(0.85, 'red');
|
|
grad.addColorStop(1, 'LightSalmon');
|
|
gtempint.set({colors: [grad]}).draw();
|
|
if(UltimoReg){var Hint = (UltimoReg.humedad_interna || 0);}else{var Hint=0;}
|
|
RGraph.ObjectRegistry.clear(ghum_int);
|
|
ghumint = new RGraph.Thermometer({
|
|
id: 'ghum_int',
|
|
min: 0,
|
|
max: 100,
|
|
value: Hint,
|
|
options: {
|
|
textSize:6,
|
|
textColor: 'white',
|
|
labelsCount:10,
|
|
labelsValue:false,
|
|
scaleVisible: true,
|
|
colors: ['blue'],
|
|
textAccessible: false
|
|
}
|
|
}).grow();
|
|
//color en gradiente
|
|
var grad2 = ghumint.context.createLinearGradient(0,50,0,350);
|
|
grad2.addColorStop(0, 'Navy');
|
|
grad2.addColorStop(0.85, 'Blue');
|
|
grad2.addColorStop(1, 'Aqua');
|
|
ghumint.set({colors: [grad2]}).draw();
|
|
grad2=null;Hint=null;Tint=null;grad=null;
|
|
}else{gtempint=null;ghumint=null;yaxis=null}
|
|
|
|
//Graficos Exterior (Viento Direccion y Viento Velocidad/Rafagas)
|
|
if(($('#exterior').hasClass('active') && typeof click === "undefined" && $("#gviento_vel").length) || (click === 'exterior'))
|
|
{
|
|
//Viento Velocidad/Rafagas
|
|
if(configGeneralEMA.ConfGeneral.SistemaMetrico == "SI")
|
|
{
|
|
if(UltimoReg){var TvientoR = (UltimoReg.viento_rafagas || 0.0);
|
|
var Tviento = UltimoReg.viento_velocidad || 0.0;
|
|
var unidad = "Km";
|
|
var ponderador = 1;}else{var TvientoR = 0; var Tviento = 0; var unidad = "Km";var ponderador = 1;}
|
|
}else{
|
|
if(UltimoReg){var TvientoR = ((UltimoReg.viento_rafagas/3.6)*2.2369) || 0.0;
|
|
var Tviento = ((UltimoReg.viento_velocidad/3.6)*2.2369) || 0.0;
|
|
TvientoR = TvientoR.toFixed(2);
|
|
Tviento = Tviento.toFixed(2);
|
|
var ponderador = 0.6213712;
|
|
var unidad = "mp"; }
|
|
else{ var TvientoR = 0;var Tviento = 0;var unidad = "mp";var ponderador = 0.6213712;}
|
|
}
|
|
if(UltimoReg){var x = UltimoReg.viento_rafagas || 0.0;}else{var x = 0;}
|
|
switch (true) {
|
|
case x > -1 && x <= 1: viento_escala = "Calmo";break;
|
|
case x > 1 && x <= 5: viento_escala = "Aire Ligero (Ventolina)";break;
|
|
case x > 5 && x <= 11: viento_escala = "Brisa Muy Débil (Flojito)";break;
|
|
case x > 11 && x <= 19: viento_escala = "Brisa Ligera (Flojo)";break;
|
|
case x > 19 && x <= 28: viento_escala = "Brisa Moderada (Bonancible)";break;
|
|
case x > 28 && x <= 38: viento_escala = "Brisa Fresca (Fresquito)";break;
|
|
case x > 38 && x <= 49: viento_escala = "Brisa Fuerte (Fresco)";break;
|
|
case x > 49 && x <= 61: viento_escala = "Viento Fuerte (Frescachón)";break;
|
|
case x > 61 && x <= 74: viento_escala = "Viento Duro (Temporal)";break;
|
|
case x > 74 && x <= 88: viento_escala = "Viento Muy Duro (Temporal Fuerte)";break;
|
|
case x > 88 && x <= 102: viento_escala = "Temporal (Temporal Duro)";break;
|
|
case x > 102 && x <= 117: viento_escala = "Borrasca (Temporal Muy Duro)";break;
|
|
case x > 117: viento_escala = "Huracán (Temporal huracanado)";break;
|
|
}
|
|
$('#escala_vientos').html(viento_escala + "<sup style='color:blue'>1</sup>");
|
|
RGraph.ObjectRegistry.clear(gviento_vel);
|
|
gviento1 = new RGraph.Gauge({
|
|
id: 'gviento_vel',
|
|
min: 0,
|
|
max: 140 * ponderador,
|
|
value: [Tviento,TvientoR],
|
|
options: {
|
|
scaleDecimals: 0,
|
|
tickmarksSmall: 50,
|
|
tickmarksBig: 5,
|
|
valuetext: true,
|
|
titleTop: 'Viento y Rafagas \n '+Tviento +' / '+TvientoR,
|
|
titleTopSize: 6,
|
|
textSize: 9,
|
|
margin: 0,
|
|
titleBottom: unidad,
|
|
colorsRanges:[[0, 28*ponderador, 'green'],[28*ponderador, 56*ponderador,'yellow'],[56*ponderador, 84*ponderador,'#FFBF00'],[84*ponderador, 112*ponderador, '#FA8258'],[112*ponderador, 140*ponderador, 'red']],
|
|
textAccessible: false
|
|
}
|
|
}).grow();
|
|
|
|
//Para el span de Vientos Exterior
|
|
if(UltimoReg){
|
|
$('#viento_vel_max').html((((UltimoReg.viento_velocidad_max_dia||0))*ponderador).toFixed(2));
|
|
$('#viento_rafag_max').html(((UltimoReg.viento_rafagas_max_dia||0)*ponderador).toFixed(2));
|
|
$('#viento_vel').html(((UltimoReg.viento_velocidad||0)*ponderador).toFixed(2)+unidad);
|
|
$('#viento_vel_rafag').html(((UltimoReg.viento_rafagas||0)*ponderador).toFixed(2)+unidad);}
|
|
//Viento Direccion
|
|
|
|
if(UltimoReg){
|
|
var Tvientodir = UltimoReg.viento_direccion || 0;
|
|
var Tvientonombre = UltimoReg.viento_direccion_nombre || 'N/A';
|
|
}else{var Tvientodir = 0; var Tvientonombre = 'N/A';}
|
|
x = Tvientodir;
|
|
viento_direccion = x;
|
|
$('#escala_direccion').html('Vientos del ' + Tvientonombre +' ('+Tvientodir +'º)');
|
|
RGraph.ObjectRegistry.clear(gviento_dir);
|
|
//Imagen de Fondo
|
|
new RGraph.Drawing.Image({
|
|
id: 'gviento_dir',
|
|
x: 15,
|
|
y: 15,
|
|
src: '../gui_common/img/brujula.webp',
|
|
options: {
|
|
width: 200,
|
|
height: 200
|
|
}
|
|
}).draw();
|
|
gviento = new RGraph.Odometer({
|
|
id: 'gviento_dir',
|
|
min: 0,
|
|
max: 360,
|
|
value: Tvientodir,
|
|
options: {
|
|
border:false,
|
|
colorsGreenColor: 'rgba(0,0,0,0)',
|
|
colorsYellowColor: 'rgba(0,0,0,0)',
|
|
colorsRedColor: 'rgba(0,0,0,0)',
|
|
backgroundColor: 'rgba(0,0,0,0)',
|
|
backgroundBorder: 'rgba(0,0,0,0)',
|
|
backgroundLinesColor: 'rgba(0,0,0,0)',
|
|
tickmarksBigColor: 'rgba(0,0,0,0)',
|
|
textColor: 'rgba(0,0,0,0)',
|
|
needleColor: '#ddd',
|
|
tickmarks: false,
|
|
needleHead: true,
|
|
radius:99,
|
|
// needleTail: true,
|
|
needleType: 'pointer',
|
|
// needleWidth: 4,
|
|
needleThickness: 1
|
|
}
|
|
}).grow();
|
|
if(UltimoReg){var x = UltimoReg.viento_direccion_prom_dia || 0;}else{var x=0;}
|
|
var VientoDireccionProm = '';
|
|
// direccion del viento por nombre promedio
|
|
switch (true) {
|
|
case x == 0:
|
|
VientoDireccionProm= 'Norte';
|
|
break;
|
|
case x > 0 && x < 90:
|
|
VientoDireccionProm= 'Nordeste';
|
|
break;
|
|
case x == 90:
|
|
VientoDireccionProm= 'Este';
|
|
break;
|
|
case x > 90 && x < 180:
|
|
VientoDireccionProm= 'Sudeste';
|
|
break;
|
|
case x == 180:
|
|
VientoDireccionProm= 'Sur';
|
|
break;
|
|
case x > 180 && x < 270:
|
|
VientoDireccionProm= 'Sudoeste';
|
|
break;
|
|
case x == 270:
|
|
VientoDireccionProm= 'Oeste';
|
|
break;
|
|
case x > 270 && x < 360:
|
|
VientoDireccionProm= 'Noroeste';
|
|
break;
|
|
default:
|
|
VientoDireccionProm= '-';
|
|
}
|
|
//Para el span de Exterior
|
|
if(UltimoReg){
|
|
$('#viento_dir').html(Tvientodir+'º');
|
|
$('#viento_dir_nom').html(Tvientonombre||0);
|
|
$('#viento_dir_prom').html(UltimoReg.viento_direccion_prom_dia || 0 +'º');
|
|
$('#viento_dir_nom_prom').html(VientoDireccionProm);}
|
|
delete(TvientoR);delete(Tviento);delete(x);delete(Tvientodir);delete(Tvientonombre);delete(Tvientonombre);
|
|
}else{ gviento1=undefined;gviento=undefined;}
|
|
click = null;
|
|
}
|
|
|
|
function ListarRedes()
|
|
{
|
|
//Se listan la redes configuradas
|
|
var Publicar = configGeneralEMA.ConfPublicador;
|
|
var Cantidad = Publicar.length;
|
|
//Se arma la Tabla
|
|
var TablaHTML = "<table class='table bordered'>";
|
|
TablaHTML += " <thead><th>Nombre Local</th><th> Tipo de Red</th><th>Clave</th><th>LLave_W</th><th>Puerto</th><th>Publicar</th><th></th></thead>";
|
|
for (i = 0, t = Cantidad; i < t; ++i)
|
|
{
|
|
var publicar = "<span class='badge badge-success'>"+Publicar[i].Publicar +"</span>";
|
|
if(Publicar[i].Publicar == false) {publicar = "<span class='badge badge-danger'>"+Publicar[i].Publicar +"</span>";}
|
|
if((Publicar[i].TipoRed != "emacenter") && (Publicar[i].TipoRed != "emacentergugler"))
|
|
{
|
|
TablaHTML += "<tr><td><b>"+Publicar[i].Nombre+"</b></td><td>"+Publicar[i].TipoRed+"</td><td><span class='badge badge-success'>SI</span></td><td><span class='badge badge-danger'>NO</span></td><td><span class='badge badge-default'>N/A</span></td><td>"+publicar+"</td><td><select onchange='MenuRedes("+i+")' title='Accion' id='Red_activa_"+i+"' name='Red_activa' class='selectpicker show-tick' data-width='fit' data-style='btn-primary'>";
|
|
if(Publicar[i].Publicar == true) {TablaHTML += "<option value='NoPublicar'>No Publicar</option>"}else{TablaHTML += "<option value='Publicar'>Publicar</option>"};
|
|
TablaHTML += "<option value='Modificar'>Modificar</option><option value='Eliminar'>Eliminar</option><option value='SitioOficial'>Sitio Oficial</option></select></td></tr>";
|
|
}else{
|
|
if(Publicar[i].Llave_W != ''){var tienellave = "SI";}else{var tienellave ="NO";}
|
|
TablaHTML += "<tr><td><b>"+Publicar[i].Nombre+"</b></td><td>"+Publicar[i].TipoRed+"</td><td><span class='badge badge-default'>N/A</span></td><td><span class='badge badge-success'>"+tienellave+"</span></td><td><span class='badge badge-default'>"+(Publicar[i].Puerto || "N/A")+"</span></td><td>"+publicar+"</td><td><select onchange='MenuRedes("+i+")' title='Accion' id='Red_activa_"+i+"' name='Red_activa' class='selectpicker show-tick' data-width='fit' data-style='btn-primary'>";
|
|
if(Publicar[i].Publicar == true) {TablaHTML += "<option value='NoPublicar'>No Publicar</option>"}else{TablaHTML += "<option value='Publicar'>Publicar</option>"};
|
|
TablaHTML += "<option value='Modificar'>Modificar</option><option value='Eliminar'>Eliminar</option><option value='SitioOficial'>Sitio Oficial</option></select></td></tr>";
|
|
}
|
|
}
|
|
TablaHTML += "</table>";
|
|
//Se renderizan los botones
|
|
BotonHTML = '<button id="botonguardar" type="button" class="btn btn-sm btn-success" onclick="MenuGUI(\'redes_alta\')" role="button">Alta de una Red</button>';
|
|
$('#redesconfiguradas').html(TablaHTML);
|
|
$('#BotonRed').html(BotonHTML);
|
|
for (i = 0, t = Cantidad; i < t; ++i)
|
|
{$('#Red_activa_'+i).selectpicker('render');}
|
|
Publicar=null;Cantidad=null;TablaHTML=null;tieneusuario=null;tienellave=null;
|
|
}
|
|
|
|
function MenuSelectRed()
|
|
{
|
|
if(($('#Tipo_Red').val() == "emacenter") || ($('#Tipo_Red').val() == "emacentergugler"))
|
|
{
|
|
$('#EmaConfAlta').attr("disabled",false);$('#EmaConfAlta').show();
|
|
$('#EmaConfAlta2').hide();$('#EmaConfAlta2').attr("disabled",true);
|
|
$('#EmaConfAlta3').hide();$('#EmaConfAlta3').attr("disabled",true);
|
|
$('#EmaConfAlta4').attr("disabled",true);$('#EmaConfAlta4').hide();
|
|
$('#EmaConfAlta5').attr("disabled",true);$('#EmaConfAlta5').hide();
|
|
if($('#Tipo_Red').val() == "emacenter"){$('#EmaConfAlta4').attr("disabled",false);$('#EmaConfAlta4').show();
|
|
$('#EmaConfAlta5').attr("disabled",false);$('#EmaConfAlta5').show();
|
|
}
|
|
}else{
|
|
if($('#Tipo_Red').val() == "openweathermap") {$('#EmaConfAlta6').attr("disabled",false);$('#EmaConfAlta6').show();
|
|
$('#EmaConfAlta7').attr("disabled",false);$('#EmaConfAlta7').show();
|
|
$('#EmaConfAlta8').attr("disabled",false);$('#EmaConfAlta8').show();
|
|
$('#EmaConfAlta9').attr("disabled",false);$('#EmaConfAlta9').show();
|
|
}else{
|
|
$('#EmaConfAlta6').attr("disabled",true);$('#EmaConfAlta6').hide();
|
|
$('#EmaConfAlta7').attr("disabled",true);$('#EmaConfAlta7').hide();
|
|
$('#EmaConfAlta8').attr("disabled",true);$('#EmaConfAlta8').hide();
|
|
$('#EmaConfAlta9').attr("disabled",true);$('#EmaConfAlta9').hide();
|
|
}
|
|
$('#EmaConfAlta').attr("disabled",true);
|
|
$('#EmaConfAlta').hide();
|
|
$('#EmaConfAlta2').attr("disabled",false);$('#EmaConfAlta2').show();
|
|
$('#EmaConfAlta3').attr("disabled",false);$('#EmaConfAlta3').show();
|
|
$('#EmaConfAlta4').attr("disabled",true);$('#EmaConfAlta4').hide();
|
|
$('#EmaConfAlta5').attr("disabled",true);$('#EmaConfAlta5').hide();
|
|
}
|
|
}
|
|
|
|
function MenuRedes(red)
|
|
{
|
|
switch ($('#Red_activa_'+red).val()) {
|
|
case 'Eliminar':
|
|
// SE PREGUNTA SI ESTA SEGURO
|
|
HABLA(0,'¿Esta seguro de eliminar<br> la red <b>'+ configGeneralEMA.ConfPublicador[red].Nombre +'</b>?',"success");
|
|
$(document).off('click', '.notifyjs-foo-base .no'); // Se elimina el evento si existe
|
|
$(document).off('click', '.notifyjs-foo-base .yes'); // Se elimina el evento si existe
|
|
$.notify.addStyle('foo', {
|
|
html:
|
|
"<div style='background:#ff00003b;'>" +
|
|
"<div class='clearfix'>" +
|
|
"<div class='title' data-notify-html='title'></div>" +
|
|
"<div class='buttons' style='margin-top:10px; text-align:center;width:100%;'>" +
|
|
"<button class='btn btn-secondary btn-sm no'>Cancelar</button> " +
|
|
"<button class='btn btn-danger btn-sm yes'>Confirmar</button>" +
|
|
"</div>" +
|
|
"</div>" +
|
|
"</div>"
|
|
});
|
|
|
|
// --- Mostrar notificación ---
|
|
$("#carpincho_img").notify({
|
|
title: '¿Está seguro de eliminar la red <b>' + configGeneralEMA.ConfPublicador[red].Nombre + '</b>?'
|
|
}, {
|
|
position: "right middle",
|
|
style: 'foo',
|
|
autoHide: false,
|
|
clickToHide: false
|
|
});
|
|
|
|
$(document).on('click', '.notifyjs-foo-base .no', function() {
|
|
//RESPONDE NO
|
|
ListarRedes();
|
|
$(this).trigger('notify-hide');
|
|
});
|
|
$(document).on('click', '.notifyjs-foo-base .yes', function() {
|
|
//RESPONDE SI
|
|
configGeneralEMA.ConfPublicador.splice(red, 1); // elimina la red seleccionada
|
|
GuardarConf();
|
|
ListarRedes();
|
|
$(this).trigger('notify-hide');
|
|
});
|
|
break;
|
|
case 'Publicar':
|
|
HABLA(0,"Cambio de estado de la red '"+configGeneralEMA.ConfPublicador[red].Nombre + "', ahora se publica!!. ","success");
|
|
configGeneralEMA.ConfPublicador[red].Publicar = true; // cambia el estado de la red
|
|
GuardarConf();
|
|
ListarRedes();
|
|
break;
|
|
case 'NoPublicar':
|
|
HABLA(0,"Cambio de estado de la red '"+configGeneralEMA.ConfPublicador[red].Nombre + "', ahora no se publica!!. ","warn");
|
|
configGeneralEMA.ConfPublicador[red].Publicar = false; // cambia el estado de la red
|
|
GuardarConf();
|
|
ListarRedes();
|
|
break;
|
|
case 'Modificar': FormModificar(red);
|
|
break;
|
|
|
|
case 'SitioOficial':
|
|
let tipored = configGeneralEMA.ConfPublicador[red].TipoRed;
|
|
tipored = tipored.toLowerCase();
|
|
let url = '';
|
|
switch (tipored) {
|
|
case 'openweathermap':
|
|
url = 'https://openweathermap.org/';
|
|
break;
|
|
case 'wow':
|
|
url = 'https://wow.metoffice.gov.uk/';
|
|
break;
|
|
case 'windguru':
|
|
url = 'https://www.windguru.cz/';
|
|
break;
|
|
case 'windy':
|
|
url = 'https://www.windy.com/';
|
|
break;
|
|
case 'awekas':
|
|
url = 'https://www.awekas.at/';
|
|
break;
|
|
case 'wunderground':
|
|
url = 'https://www.wunderground.com/';
|
|
break;
|
|
case 'pws':
|
|
url = 'https://www.pwsweather.com/';
|
|
break;
|
|
case 'emacenter':
|
|
url = 'https://emacenter.gugler.com.ar/';
|
|
break;
|
|
case 'emacentergugler':
|
|
url = 'https://emacenter.gugler.com.ar/';
|
|
break;
|
|
|
|
default:
|
|
HABLA(0, "No se encontró el sitio oficial para la red '" + tipored + "'", "warn");
|
|
return;
|
|
}
|
|
if (url !== '') {
|
|
const openExternal = require('nw.gui').Shell.openExternal;
|
|
openExternal(url);
|
|
HABLA(0, "Abriendo sitio oficial de '" + tipored + "'.", "info");
|
|
}
|
|
ListarRedes();
|
|
break;
|
|
}
|
|
}
|
|
|
|
function ModificarRedes(red)
|
|
{
|
|
HABLA(0,"Se modificó la red " + $('#Nombre').val(),"success");
|
|
var TIPORED = $('#Tipo_Red').val();
|
|
configGeneralEMA.ConfPublicador[red].Nombre = $('#Nombre').val();
|
|
configGeneralEMA.ConfPublicador[red].TipoRed = TIPORED;
|
|
configGeneralEMA.ConfPublicador[red].Publicar = true;
|
|
configGeneralEMA.ConfPublicador[red].Usuario = $('#Usuario').val();
|
|
configGeneralEMA.ConfPublicador[red].Password = $('#Password').val();
|
|
delete configGeneralEMA.ConfPublicador[red].Llave_W;
|
|
delete configGeneralEMA.ConfPublicador[red].Server;
|
|
delete configGeneralEMA.ConfPublicador[red].Puerto;
|
|
if(TIPORED == 'emacentergugler')
|
|
{
|
|
delete configGeneralEMA.ConfPublicador[red].Usuario;
|
|
delete configGeneralEMA.ConfPublicador[red].Password;
|
|
configGeneralEMA.ConfPublicador[red].Llave_W = $('#LLaveW').val();
|
|
}
|
|
if(TIPORED == 'emacenter')
|
|
{
|
|
delete configGeneralEMA.ConfPublicador[red].Usuario;
|
|
delete configGeneralEMA.ConfPublicador[red].Password;
|
|
configGeneralEMA.ConfPublicador[red].Server = $('#Servidor').val();
|
|
configGeneralEMA.ConfPublicador[red].Puerto = $('#Puerto').val();
|
|
configGeneralEMA.ConfPublicador[red].Llave_W = $('#LLaveW').val();
|
|
}
|
|
GuardarConf();
|
|
ListarRedes();
|
|
}
|
|
function GuardarRed()
|
|
{
|
|
HABLA(0,"Se dío de alta una nueva red " + $('#Nombre').val(),"success");
|
|
var TIPORED = $('#Tipo_Red').val();
|
|
switch (TIPORED) {
|
|
case 'emacentergugler':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "emacentergugler",
|
|
Publicar: true,
|
|
Llave_W: $('#LLaveW').val()
|
|
};
|
|
break;
|
|
case 'emacenter':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "emacenter",
|
|
Publicar: true,
|
|
Llave_W: $('#LLaveW').val(),
|
|
Server: $('#Servidor').val(),
|
|
Puerto: $('#Puerto').val()
|
|
};
|
|
break;
|
|
case 'pws':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "pws",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'wunderground':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "wunderground",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'awekas':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "awekas",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'windy':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "windy",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'windguru':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "windguru",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'wow':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "wow",
|
|
Publicar: true,
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
case 'openweathermap':
|
|
var RegistroJSON = {
|
|
Nombre: $('#Nombre').val(),
|
|
TipoRed: "openweathermap",
|
|
Publicar: true,
|
|
keyapi: 'a2895a47d6297fa4a5a5684df1eb3400',
|
|
Usuario: $('#Usuario').val(),
|
|
Password: $('#Password').val()
|
|
};
|
|
break;
|
|
default:
|
|
console.log('No Existe la red metorologica: ' + Parametros[0][0]);
|
|
}
|
|
configGeneralEMA.ConfPublicador.push(RegistroJSON);
|
|
delete(RegistroJSON);delete(TIPORED);
|
|
GuardarConf();
|
|
MenuGUI('redes');
|
|
}
|
|
function FormModificar(red)
|
|
{
|
|
$('#Tipo_Red').val(configGeneralEMA.ConfPublicador[red].TipoRed);
|
|
var TablaHTML = "<h4>Modificación de Red</h4>";
|
|
TablaHTML += "<table class='table table-striped'>";
|
|
TablaHTML += "<thead><tr align='center'><th colspan='6'>Tipo de Red</th></tr></thead>";
|
|
TablaHTML += "<tr><td colspan='6' align='left'>";
|
|
TablaHTML += "<select id='Tipo_Red' name='Tipo_Red' onchange='MenuSelectRed();' class='selectpicker show-tick' data-width='fit' data-style='btn-primary'>";
|
|
TablaHTML += "<optgroup label='RED EMACENTER'>";
|
|
TablaHTML += "<option value='emacentergugler'>Gugler EmaCenter - Gugler</option>";
|
|
TablaHTML += "<option value='emacenter'>Emacenter Personalizada</option></optgroup>";
|
|
TablaHTML += "<optgroup label='OTRAS REDES' ><option value='pws'>PWS - Personal Weather Stations</option><option value='wunderground'>WU - Weather Underground</option> <option value='windguru'>WG - WindGuru</option><option value='awekas'>AW - AWEKAS</option><option value='windy'>WINDY</option><option value='wow'>WOW - Met Office</option></optgroup>";
|
|
TablaHTML += "</select></td></tr>";
|
|
TablaHTML += "<thead><tr align='center'><th colspan='6'>Configuracion de la Red</th></tr></thead>";
|
|
TablaHTML += '<tr align="center" >';
|
|
TablaHTML += '<td align="center"><label class="control-label">Nombre</label><br><input type="text" class="btn btn-primary" id="Nombre" placeholder="Nombre" maxlength="15" size="18" value='+configGeneralEMA.ConfPublicador[red].Nombre +'>';
|
|
TablaHTML += '<td id="EmaConfAlta2" style="display: none;" align="center"><label class="control-label">Usuario</label><br><input type="text" class="btn btn-primary" id="Usuario" placeholder="Usuario" maxlength="130" size="20" value='+configGeneralEMA.ConfPublicador[red].Usuario +'>';
|
|
TablaHTML += '<td id="EmaConfAlta3" style="display: none;" align="center"><label class="control-label">Contraseña</label><br><input type="text" class="btn btn-primary" id="Password" placeholder="Password" maxlength="40" size="20" value='+configGeneralEMA.ConfPublicador[red].Password +'>';
|
|
TablaHTML += '<td id="EmaConfAlta4" style="display: none;" align="center"><label class="control-label">Servidor</label><br><input type="text" class="btn btn-primary" id="Servidor" placeholder="Servidor" maxlength="80" size="30" value='+configGeneralEMA.ConfPublicador[red].Server +'>';
|
|
TablaHTML += '<td id="EmaConfAlta5" style="display: none;" align="center"><label class="control-label">Puerto</label><br><input type="text" class="btn btn-primary" id="Puerto" placeholder="Puerto" maxlength="5" size="6" value='+ (configGeneralEMA.ConfPublicador[red].Puerto || 'N/A') +'>';
|
|
TablaHTML += '<td id="EmaConfAlta" style="display: none;" align="center"><label class="control-label">LLave de Escritura</label><br><input type="text" class="btn btn-primary" id="LLaveW" placeholder="LLave" maxlength="36" size="37" value='+configGeneralEMA.ConfPublicador[red].Llave_W +'>';
|
|
TablaHTML += '</tr>';
|
|
TablaHTML += "</table>";
|
|
BotonHTML = '<button id="botonguardar" class="btn btn-sm btn-success" onclick="ModificarRedes('+red+')" >Guardar Modificación</button>';
|
|
BotonHTML += '<br><p align="left"> <button id="botonguardar" class="btn btn-sm btn-primary" onclick="ListarRedes()" >Volver</button></p>';
|
|
$('#redesconfiguradas').html(TablaHTML);
|
|
$('#BotonRed').html(BotonHTML);
|
|
$('#Tipo_Red').val(configGeneralEMA.ConfPublicador[red].TipoRed);
|
|
MenuSelectRed();
|
|
$('#Tipo_Red').selectpicker('render');
|
|
TablaHTML=null;
|
|
}
|
|
|
|
function VerHistoricoT(lugar)
|
|
{
|
|
$('#exterior').html("");
|
|
$('#interior').html("");
|
|
var ubicacion = "";
|
|
if(lugar == 0){ubicacion = 'exterior'}else{ubicacion='interior';}
|
|
var seleccion = document.getElementById(ubicacion);
|
|
$( seleccion ).load( "./view/modelo_historico.html", function(datosArchivo)
|
|
{
|
|
$("#botonhistorico").attr("onclick","MenuGUI('"+ubicacion+"');");
|
|
$("#cantidadH").attr("onchange","VerHistorico("+lugar+");");
|
|
VerHistorico(lugar);
|
|
lugar = null;ubicacion=null;seleccion=null;
|
|
});
|
|
}
|
|
|
|
// FUNCIONES DE ESCRITURA EN DISCO
|
|
|
|
function GuardarConf(origen)
|
|
{
|
|
if (origen == 'conf'){
|
|
//Se Setean los campos
|
|
HABLA(0,"Se almacenó correctamente la configuración", "success");
|
|
configGeneralEMA.ConfGeneral.NombreEstacion = $('#NombreEstacion').val();
|
|
configGeneralEMA.ConfEmail.Servicio = $('#Tipo_SMTP').val();
|
|
if($('#Tipo_SMTP').val() == "Deshabilitado"){configGeneralEMA.ConfEmail.ActivarCorreos = false;}else{configGeneralEMA.ConfEmail.ActivarCorreos = true;}
|
|
configGeneralEMA.ConfEmail.Usuario = $('#Usuario_SMTP').val();
|
|
configGeneralEMA.ConfEmail.Password = $('#Contrasenia_SMTP').val();
|
|
configGeneralEMA.ConfEmail.Server = $('#Server_SMTP').val();
|
|
configGeneralEMA.ConfEmail.Puerto = $('#Puerto_SMTP').val();
|
|
configGeneralEMA.ConfEmail.ReceptorEmail = $('#Email_receptor').val();
|
|
configGeneralEMA.ConfGeneral.Tiempo_de_Recoleccion = parseInt($('#Tiempo_de_Recoleccion').val());
|
|
configGeneralEMA.ConfGeneral.debug = parseInt($('#Debug').val());
|
|
configGeneralEMA.ConfGeneral.UTC = parseInt($('#utc').val());
|
|
configGeneralEMA.ConfGeneral.SistemaMetrico = $('#SistemaMetrico').val();
|
|
configGeneralEMA.ConfGeneral.Modo = $('#Modo').val();
|
|
configGeneralEMA.ConfGeneral.IP = $('#r_ip').val();
|
|
configGeneralEMA.ConfGeneral.Puerto = $('#r_puerto').val();
|
|
configGeneralEMA.ConfGeneral.Ruta = $('#r_path').val();
|
|
configGeneralEMA.ConfGeneral.Llave_R = $('#Llave_R').val();
|
|
configGeneralEMA.ConfGeneral.debugTamanio = parseInt($('#debugMB').val());
|
|
if($('#inicio_auto').val() == "Activado"){configGeneralEMA.ConfGeneral.inicio_automatico = true;}else{configGeneralEMA.ConfGeneral.inicio_automatico = false;}
|
|
if($('#notificar_cambios').val() == "Activado"){configGeneralEMA.ConfGeneral.notificar_cambios = true;}else{configGeneralEMA.ConfGeneral.notificar_cambios = false;}
|
|
if($('#audio').val() == "Activado"){configGeneralEMA.ConfGeneral.Audio = true;}else{configGeneralEMA.ConfGeneral.Audio = false;}
|
|
configGeneralEMA.ConfGeneral.audioVoces = $('#vocesAudio').val();
|
|
}
|
|
//Se almacenan los campos
|
|
var configuracion_nueva = '// Configuraciones generales de EMA RECOLECTOR' + '\n\n';
|
|
configuracion_nueva += 'module.exports = ';
|
|
configuracion_nueva += JSON.stringify(configGeneralEMA, null, ' ');
|
|
configuracion_nueva += ';';
|
|
fsconf.writeFile('./conf/ConfiguracionGeneral.js', configuracion_nueva, function(err) {
|
|
if( err ){
|
|
HABLA(0,"Upps, existió un problema intentando almacenar la configuración", "warn");
|
|
EMA.RegistrarLog("0|CORE|Upps, existió un problema intentando almacenar la configuración.");
|
|
}
|
|
else{
|
|
EMA.Reconfigurar();
|
|
EMA.RegistrarLog("0|CORE|Se almaceno correctamente la configuración");
|
|
}
|
|
});
|
|
};
|
|
|
|
function PurgarP(origen)
|
|
{
|
|
fsconf.writeFile('./logs/TanquePendientes.log', JSON.stringify([], null, 4),{encoding: 'utf8', autoClose: true}, function(err)
|
|
{
|
|
EMA.RegistrarLog("1|PURGADO|Archivo de Pendientes");
|
|
if (err) { EMA.RegistrarLog('0|ERROR|Depurando archivo registro de logs :' + err); }
|
|
});
|
|
|
|
HABLA(0,"Purgado - Se purgo correctamente el tanque de pendiente", "success");
|
|
$('#tamanio_pendiente').html('0.00');
|
|
$('#cantidad_pendiente').html('0');
|
|
}
|
|
|
|
function PurgarD(origen)
|
|
{
|
|
fsconf.writeFile('./logs/debug.log', '',{encoding: 'utf8', autoClose: true}, function(err)
|
|
{
|
|
EMA.RegistrarLog("1|PURGADO|Archivo de Debug");
|
|
if (err) { EMA.RegistrarLog('0|ERROR|Depurando archivo registro de logs :' + err); }
|
|
});
|
|
HABLA(0,"Purgado - Se purgo correctamente el archivo de debug", "success");
|
|
$('#cantidad_debug').html('0');
|
|
$('#tamanio_debug').html('0.00');
|
|
}
|
|
|
|
// FUNCIONES DE LECTURA EN DISCO
|
|
|
|
function VerHistorico(lugar)
|
|
{
|
|
document.getElementById("mostrarregistrosH").style.display = "none";
|
|
document.getElementById("actualizando").style.display = "block";
|
|
$('#botonresfrescar').attr("disabled",true);
|
|
if(['Recolector_USB', 'Recolector_IP'].includes(configGeneralEMA.ConfGeneral.Modo)) // se comprueba el modo se encuentra en Recolector
|
|
{
|
|
fsconf.readFile('./logs/registro_diario.log', {encoding: 'utf8', autoClose: true},function (err, data)
|
|
{ if (err) throw err;
|
|
var TablaHTML = '';
|
|
TablaHTML += '<table id="MiTablaH" class="display" style="width:100%" >';
|
|
TablaHTML += '<thead>';
|
|
TablaHTML += '<tr>';
|
|
TablaHTML += '<th style="text-align:center;">Nº</th>';
|
|
TablaHTML += '<th style="text-align:center;">Fecha_Registro</th>';
|
|
TablaHTML += '<th style="text-align:center;">Temp. Int.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Hum. Int</th>';
|
|
if(lugar == 0) {TablaHTML += '<th style="text-align:center;">Temp. Ext.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Hum. Ext.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Punto. Roc.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luz int.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Rayos UV</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Vel.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Raf.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Dir.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento DirN.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Presión Abs.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Presión Rel.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Act.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Hora</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Dia</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Total</th>';}
|
|
TablaHTML += '</tr>';
|
|
TablaHTML += '</thead>';
|
|
TablaHTML += '<tbody>';
|
|
if(data.length < 100)
|
|
{
|
|
$('#mostrarregistros').html("| Info: Registro diario.");
|
|
}
|
|
else{
|
|
var RegistroDiario = JSON.parse(data);
|
|
var CantRegistros = RegistroDiario.length;
|
|
$('#cantregH').html("Total Registros: " + CantRegistros);
|
|
var CantidadRegistrosInicio = CantRegistros - $('#cantidadH').val();
|
|
if(CantidadRegistrosInicio < 0){CantidadRegistrosInicio=0;HABLA(0,"El filtro supera la cantidad de registros totales, por lo que se muestran todos", "info");}
|
|
for (j=CantidadRegistrosInicio; j < CantRegistros; ++j){
|
|
TablaHTML += '<tr>';
|
|
TablaHTML += '<td style="text-align:center;">'+ j + '</td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].fecha +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].temperatura_interna +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].humedad_interna +'</small></td>';
|
|
if(lugar == 0) {
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].temperatura_externa +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].humedad_externa +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].punto_de_rocio +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].luxer_intencidad +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].luxer_uv +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].viento_velocidad +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].viento_rafagas +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].viento_direccion +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].viento_direccion_nombre +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].presion_absoluta +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].presion_relativa +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].lloviendo +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].lluvia_acu_hora +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].lluvia_acu_diaria +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ RegistroDiario[j].lluvia_acumulado_total +'</small></td>';
|
|
}
|
|
TablaHTML += '</tr>';
|
|
}
|
|
|
|
}
|
|
TablaHTML += '</tbody>';
|
|
TablaHTML += '</table>';
|
|
MostrarTabla(TablaHTML,'mostrarregistrosH','MiTablaH');
|
|
RegistroDiario.length=0;
|
|
TablaHTML=null;RegistroDiario=null;
|
|
});
|
|
}else{ //MODO Visor
|
|
var TablaHTML = '';
|
|
TablaHTML += '<table id="MiTablaH" class="display" style="width:100%" >';
|
|
TablaHTML += '<thead>';
|
|
TablaHTML += '<tr>';
|
|
TablaHTML += '<th style="text-align:center;">Nº</th>';
|
|
TablaHTML += '<th style="text-align:center;">Fecha_Registro</th>';
|
|
if(lugar == 0) {TablaHTML += '<th style="text-align:center;">Temp. Ext.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Hum. Ext.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Punto. Roc.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luz int.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Rayos UV</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Vel.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Raf.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento Dir.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Viento DirN.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Presión Abs.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Presión Rel.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Act.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Hora</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Dia</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Semanal</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Mensual</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Anual</th>';
|
|
TablaHTML += '<th style="text-align:center;">Luvia Total</th>';}
|
|
else{
|
|
TablaHTML += '<th style="text-align:center;">Temp. Int.</th>';
|
|
TablaHTML += '<th style="text-align:center;">Hum. Int</th>';
|
|
}
|
|
TablaHTML += '</tr>';
|
|
TablaHTML += '</thead>';
|
|
TablaHTML += '<tbody>';
|
|
$('#mostrarregistrosH').html(TablaHTML);
|
|
var cantreg=$('#cantidadH').val();
|
|
if(cantreg > 7000){HABLA(0,"El modo visor el maximo de registro es 10000","info"); var cantreg = 10000;}
|
|
$(document).ready(function()
|
|
{
|
|
var i = 0;
|
|
$.ajax({
|
|
url: 'https://emacenter.gugler.com.ar/api/get/'+configGeneralEMA.ConfGeneral.Llave_R+'/?cant='+cantreg,
|
|
method: 'get',
|
|
dataType: 'json',
|
|
success: function (data)
|
|
{
|
|
if(lugar == 0) {
|
|
$('#MiTablaH').DataTable( {
|
|
dom: 'Bfrtip',
|
|
buttons: ['copy','csv'],
|
|
pageLength: 5,
|
|
scrollX: true,
|
|
scrollCollapse: true,
|
|
lengthChange: false,
|
|
ordering: true,
|
|
destroy:true,
|
|
data: data.registros,
|
|
initComplete: function(settings, json) {
|
|
document.getElementById("mostrarregistrosH").style.display = "block";
|
|
document.getElementById("actualizando").style.display = "none";
|
|
$('#cantregH').html("Total Registros: " + cantreg);
|
|
},
|
|
language: {
|
|
url: "../gui_common/css/Spanish.json"
|
|
},
|
|
|
|
columns: [
|
|
|
|
{"data": function (data) {
|
|
i++;
|
|
return i;
|
|
}},
|
|
{"data": function (data) {
|
|
var db = new Date(data.fecha);
|
|
var minutos = db.getMinutes() ; if(minutos <= 9) {minutos = '0' + minutos};
|
|
var hora = db.getHours(); if(hora <= 9) {hora = '0' + hora};
|
|
var mes = db.getMonth() + 1; if(mes <= 9) {mes = '0'+ mes};
|
|
var dia= db.getDate();if(dia <= 9) {dia = '0'+ dia};
|
|
var segundo = db.getSeconds();if(segundo <= 9) {segundo = '0'+ segundo};
|
|
var fecha = dia + "/" + mes + "/" + db.getFullYear() + " " + hora + ':'+minutos + ':' + segundo;
|
|
return fecha;
|
|
}},
|
|
{"data": "temperatura_externa" },
|
|
{"data": "humedad_externa" },
|
|
{"data": "punto_de_rocio" },
|
|
{"data": "luxer_intencidad" },
|
|
{"data": "luxer_uv" },
|
|
{"data": "viento_velocidad" },
|
|
{"data": "viento_rafagas" },
|
|
{"data": "viento_direccion" },
|
|
{"data": "viento_direccion_nombre" },
|
|
{"data": "presion_absoluta" },
|
|
{"data": "presion_relativa" },
|
|
{"data": "lluvia_actual" },
|
|
{"data": "lluvia_acumulado_hora" },
|
|
{"data": "lluvia_acumulado_diario" },
|
|
{"data": "lluvia_acumulado_semanal" },
|
|
{"data": "lluvia_acumulado_mensual" },
|
|
{"data": "lluvia_acumulado_anual" },
|
|
{"data": "lluvia_acumulado_total" }
|
|
]
|
|
});
|
|
}else{
|
|
$('#MiTablaH').DataTable( {
|
|
dom: 'Bfrtip',
|
|
buttons: ['copy','csv'],
|
|
pageLength: 5,
|
|
scrollCollapse: true,
|
|
lengthChange: false,
|
|
ordering: true,
|
|
destroy:true,
|
|
data: data.registros,
|
|
initComplete: function(settings, json) {
|
|
document.getElementById("mostrarregistrosH").style.display = "block";
|
|
document.getElementById("actualizando").style.display = "none";
|
|
$('#cantregH').html("Total Registros: " + cantreg);
|
|
},
|
|
language: {
|
|
url: "../gui_common/css/Spanish.json"
|
|
},
|
|
|
|
columns: [
|
|
|
|
{"data": function (data) {
|
|
i++;
|
|
return i;
|
|
}},
|
|
{"data": function (data) {
|
|
var db = new Date(data.fecha);
|
|
var minutos = db.getMinutes() ; if(minutos <= 9) {minutos = '0' + minutos};
|
|
var hora = db.getHours(); if(hora <= 9) {hora = '0' + hora};
|
|
var mes = db.getMonth() + 1; if(mes <= 9) {mes = '0'+ mes};
|
|
var dia= db.getDate();if(dia <= 9) {dia = '0'+ dia};
|
|
var segundo = db.getSeconds();if(segundo <= 9) {segundo = '0'+ segundo};
|
|
var fecha = dia + "/" + mes + "/" + db.getFullYear() + " " + hora + ':'+minutos + ':' + segundo;
|
|
return fecha;
|
|
}},
|
|
{"data": function (data) { return data.temperatura_interna;}},
|
|
{"data": function (data) { return data.humedad_interna;}}
|
|
]
|
|
});
|
|
}
|
|
},
|
|
error: function () {
|
|
|
|
document.getElementById("actualizandoH").style.display = "none";
|
|
$('#botonresfrescar').attr("disabled",false);
|
|
$('#cantregH').html("Total Registros: 0");
|
|
HABLA(0,"No se pudo obtener datos de EMA Center, verifique la llave de lectura o el servidor.", "error");
|
|
},
|
|
});
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
function VerRegistrosLog(select)
|
|
{
|
|
TablaHTML=null;registros=null;
|
|
document.getElementById("actualizando").style.display = "block";
|
|
document.getElementById("mostrarregistrosLogs").style.display = "none";
|
|
fsconf.readFile('./logs/debug.log', {encoding: 'utf8', autoClose: true}, function (err, data)
|
|
{ if (err) throw err;
|
|
var TablaHTML = '';
|
|
TablaHTML += '<table id="MiTabla" class="display" style="width:100%;" >';
|
|
TablaHTML += '<thead>';
|
|
TablaHTML += '<tr> ';
|
|
TablaHTML += '<th style="text-align:center;">Nº</th>';
|
|
TablaHTML += '<th style="text-align:center;">Fecha_Registro</th>';
|
|
TablaHTML += '<th style="text-align:center;">Nivel</th>';
|
|
TablaHTML += '<th style="text-align:left;">Tipo</th>';
|
|
TablaHTML += '<th style="text-align:left;">Mensaje</th>';
|
|
TablaHTML += '</tr>';
|
|
TablaHTML += '</thead>';
|
|
TablaHTML += '<tbody>';
|
|
if(data.length < 100)
|
|
{$('#mostrarregistrosLogs').html("<tr><td>0</td><td>0</td><td>0</td><td>INFO</td><td>Tanque diario vacio</td></tr>");}
|
|
else{
|
|
var registros = data.split('\n');
|
|
if(select != false){
|
|
$('#cantreg').html("Total Registros: " + registros.length);
|
|
if(registros.length<100){var totalselect = 1000;}else{var totalselect = registros.length;}
|
|
var HTML_SELECT = '<select id="cantidad" name="cantidad" style="width: 70px" onchange="VerRegistrosLog(false)">';
|
|
HTML_SELECT +='<option value="'+(totalselect/100).toFixed(0)+'" selected>'+(totalselect/100).toFixed(0)+'</option>';
|
|
if((totalselect/90) < registros.length) HTML_SELECT +='<option value="'+(totalselect/90).toFixed(0)+'">'+(totalselect/90).toFixed(0)+'</option>';
|
|
if((totalselect/80) < registros.length) HTML_SELECT +='<option value="'+(totalselect/80).toFixed(0)+'">'+(totalselect/80).toFixed(0)+'</option>';
|
|
if((totalselect/70) < registros.length) HTML_SELECT +='<option value="'+(totalselect/70).toFixed(0)+'">'+(totalselect/70).toFixed(0)+'</option>';
|
|
if((totalselect/60) < registros.length) HTML_SELECT +='<option value="'+(totalselect/60).toFixed(0)+'">'+(totalselect/60).toFixed(0)+'</option>';
|
|
if((totalselect/50) < registros.length) HTML_SELECT +='<option value="'+(totalselect/50).toFixed(0)+'">'+(totalselect/50).toFixed(0)+'</option>';
|
|
if((totalselect/40) < registros.length) HTML_SELECT +='<option value="'+(totalselect/40).toFixed(0)+'">'+(totalselect/40).toFixed(0)+'</option>';
|
|
if((totalselect/30) < registros.length) HTML_SELECT +='<option value="'+(totalselect/30).toFixed(0)+'">'+(totalselect/30).toFixed(0)+'</option>';
|
|
if((totalselect/20) < registros.length) HTML_SELECT +='<option value="'+(totalselect/20).toFixed(0)+'">'+(totalselect/20).toFixed(0)+'</option>';
|
|
if((totalselect/10) < registros.length) HTML_SELECT +='<option value="'+(totalselect/10).toFixed(0)+'">'+(totalselect/10).toFixed(0)+'</option>';
|
|
if((totalselect/5) < registros.length) HTML_SELECT +='<option value="'+(totalselect/5).toFixed(0)+'">'+(totalselect/5).toFixed(0)+'</option>';
|
|
HTML_SELECT +='<option value="'+registros.length+'">'+registros.length+'</option></select>';
|
|
$('#select').html(HTML_SELECT);
|
|
HTML_SELECT = null;
|
|
}
|
|
var CantidadRegistrosInicio = registros.length - $('#cantidad').val();
|
|
if(CantidadRegistrosInicio < 0){CantidadRegistrosInicio=0; HABLA(0,"El filtro supera la cantidad de registros totales, por lo que se muestran todos", "info");}
|
|
var Registro ='';
|
|
var Resultado ='';
|
|
for (var i=CantidadRegistrosInicio; i < registros.length - 1; ++i)
|
|
{
|
|
|
|
Registro = registros[i].substring(24,999);
|
|
Resultado = Registro.split("|");
|
|
TablaHTML += '<tr>';
|
|
TablaHTML += '<td style="text-align:center;">'+ i + '</td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+ registros[i].substring(0,19) +'</small></td>';
|
|
TablaHTML += '<td style="text-align:center;"><small>'+registros[i].substring(22,23) +'</small></td>';
|
|
TablaHTML += '<td style="text-align:left;"><small>'+Resultado[0] +'</small></td>';
|
|
TablaHTML += '<td style="text-align:left;"><small>'+Resultado[1] +'</small></td>';
|
|
TablaHTML += '</tr>';
|
|
}
|
|
Resultado = null;Registro=null;registros=null;
|
|
}
|
|
TablaHTML += '</tbody>';
|
|
TablaHTML += '</table>';
|
|
MostrarTabla(TablaHTML,'mostrarregistrosLogs','MiTabla');
|
|
TablaHTML=null;
|
|
});
|
|
}
|
|
|
|
async function MostrarTabla(DATOS,DIV,TABLA)
|
|
{
|
|
$('#'+DIV).empty();
|
|
$('#'+DIV).html(DATOS);
|
|
const tabla = $('#'+TABLA).DataTable(
|
|
{
|
|
dom: 'Bfrtip',
|
|
buttons: ['copy','csv'],
|
|
pageLength: 8,
|
|
scrollX: true,
|
|
responsive:true,
|
|
autoWidth: false,
|
|
//scrollCollapse: true,
|
|
//lengthChange: false,
|
|
//ordering: true,
|
|
destroy:true,
|
|
//order: [[ 0, "desc" ]],
|
|
/*fixedHeader: {
|
|
header: true,
|
|
footer: true
|
|
},*/
|
|
initComplete: function(settings, json) {
|
|
//console.log('Termino datatable');
|
|
document.getElementById(DIV).style.display = "block";
|
|
document.getElementById("actualizando").style.display = "none";
|
|
$('.buttons-csv').removeClass('btn-default').addClass('btn-primary');
|
|
$('.buttons-csv span').text('💾 Exportar CSV');
|
|
$('.buttons-copy').removeClass('btn-default').addClass('btn-secondary');
|
|
$('.buttons-copy span').text(' 📋 Copiar al portapeles');
|
|
// Ajusta las columnas después de mostrar la tabla
|
|
setTimeout(function() {
|
|
tabla.columns.adjust();
|
|
}, 300);
|
|
},
|
|
language: {url: "../gui_common/css/Spanish.json"}
|
|
});
|
|
DATOS = null;
|
|
TABLA = null;
|
|
return true;
|
|
}
|
|
|
|
async function graficoEstadisticas()
|
|
{
|
|
// GRAFICO DEL TIEMPO CHARTJS
|
|
document.getElementById("grafico").style.display = "none";
|
|
document.getElementById("actualizando").style.display = "block";
|
|
|
|
//Se genera el grafico normal
|
|
if(['Recolector_USB', 'Recolector_IP'].includes(configGeneralEMA.ConfGeneral.Modo)) // se comprueba el modo se encuentra en Recolector
|
|
{
|
|
|
|
fsconf.readFile('./logs/registro_diario.log', {
|
|
encoding: 'utf8',
|
|
autoClose: true
|
|
}, (err, data) => {
|
|
if (err) {
|
|
EMA.RegistrarLog("1|ERROR|Error al intentar leer el registro diario para generar el grafico estadistico.");
|
|
} else {
|
|
var db = new Date();
|
|
var mes = db.getMonth() + 1; if(mes <= 9) {mes = '0'+ mes};
|
|
var dia= db.getDate();if(dia <= 9) {dia = '0'+ dia};
|
|
var fecha = dia + "/" + mes + "/" + db.getFullYear();
|
|
db = null;mes=null;dia=null;
|
|
var paraPendientes = fsconf.readFileSync('./logs/debug.log', 'utf8');
|
|
var paraPendientes = paraPendientes.split('\n');
|
|
var paraPendientesALM = paraPendientes.filter(function(datos) {var Resultado = datos.split("|"); return (Resultado[1] == 'PENDIENTE_ALM' && fecha == datos.substring(0,10)); });
|
|
var paraPendientesPUB = paraPendientes.filter(function(datos) {var Resultado = datos.split("|"); return (Resultado[1] == 'PENDIENTE_PUB' && fecha == Resultado[2].substring(15,25)); });
|
|
var CantiddPendientesAlmacenados = paraPendientesALM.length;
|
|
var CantiddPendientesPublicados = paraPendientesPUB.length;
|
|
paraPendientes = null;paraPendientesPUB = null; paraPendientesALM = null; fecha = null;
|
|
var RegistroDiarioTmp = JSON.parse(data);
|
|
var CantRegistros = RegistroDiarioTmp.length;
|
|
// console.log(CantRegistros);
|
|
if(CantRegistros > 1)
|
|
{
|
|
delete RegistroDiarioTmp['fechaISO'];
|
|
delete RegistroDiarioTmp['fechaUTC'];
|
|
delete RegistroDiarioTmp['luxer_intencidad_1hs'];
|
|
delete RegistroDiarioTmp['viento_direccion_nombre'];
|
|
delete RegistroDiarioTmp['lluvia_acu_diaria'];
|
|
delete RegistroDiarioTmp['temperatura_interna_max_dia'];
|
|
delete RegistroDiarioTmp['temperatura_interna_min_dia'];
|
|
delete RegistroDiarioTmp['humedad_interna_max_dia'];
|
|
delete RegistroDiarioTmp['humedad_interna_min_dia'];
|
|
delete RegistroDiarioTmp['temperatura_externa_max_dia'];
|
|
delete RegistroDiarioTmp['temperatura_externa_min_dia'];
|
|
delete RegistroDiarioTmp['humedad_externa_max_dia'];
|
|
delete RegistroDiarioTmp['humedad_externa_min_dia'];
|
|
delete RegistroDiarioTmp['punto_de_rocio_max_dia'];
|
|
delete RegistroDiarioTmp['punto_de_rocio_min_dia'];
|
|
delete RegistroDiarioTmp['luxer_intencidad_max_dia'];
|
|
delete RegistroDiarioTmp['luxer_intencidad_min_dia'];
|
|
delete RegistroDiarioTmp['luxer_uv_max_dia'];
|
|
delete RegistroDiarioTmp['luxer_uv_min_dia'];
|
|
delete RegistroDiarioTmp['presion_relativa_max_dia'];
|
|
delete RegistroDiarioTmp['presion_relativa_min_dia'];
|
|
delete RegistroDiarioTmp['viento_direccion_prom_dia'];
|
|
delete RegistroDiarioTmp['viento_velocidad_max_dia'];
|
|
delete RegistroDiarioTmp['viento_rafagas_max_dia'];
|
|
RegistroDiarioConCambios = [];
|
|
for (var j = 0; j < CantRegistros; j++) {
|
|
if ( RegistroDiarioTmp[j].cambio == true) RegistroDiarioConCambios.push(RegistroDiarioTmp[j]);
|
|
}
|
|
|
|
delete RegistroDiarioConCambios['diferencia'];
|
|
// Se generan los datos para el grafico
|
|
var fecha_maxima = RegistroDiarioConCambios[RegistroDiarioConCambios.length-1].fecha;
|
|
var labels = RegistroDiarioConCambios.map(function(e) { return e.fecha.substring(11, 16) || 0;});
|
|
var tmp_Ext = RegistroDiarioConCambios.map(function(e) { return e.temperatura_externa || 0;});
|
|
var hum_Ext = RegistroDiarioConCambios.map(function(e) { return e.humedad_externa || 0;});
|
|
var tmp_Int = RegistroDiarioConCambios.map(function(e) { return e.temperatura_interna || 0;});
|
|
var hum_Int = RegistroDiarioConCambios.map(function(e) { return e.humedad_interna || 0;});
|
|
var vientos = RegistroDiarioConCambios.map(function(e) { return e.viento_velocidad || 0;});
|
|
var vinetosRaf = RegistroDiarioConCambios.map(function(e) { return e.viento_rafagas || 0;});
|
|
var UV = RegistroDiarioConCambios.map(function(e) { return e.luxer_uv || 0;});
|
|
var Luxer = RegistroDiarioConCambios.map(function(e) { return e.luxer_intencidad || 0;});
|
|
var Lluvia = RegistroDiarioConCambios.map(function(e) { return e.lluvia_acu_hora || 0;});
|
|
var presionRel = RegistroDiarioConCambios.map(function(e) { return e.presion_relativa || 0;});
|
|
var validacion = RegistroDiarioConCambios.map(function(e) { return (e.estado_validacion_ant) || 0;});
|
|
var puntorocio = RegistroDiarioConCambios.map(function(e) { return e.punto_de_rocio || 0;});
|
|
// GRAFICO RESUMEN CON RGRAPH
|
|
var resumenLabels = [
|
|
'Temp.Ext', 'Hum.Ext', 'Temp.Int', 'Hum.Int', 'Viento', 'Lluvia', 'Pres.Rel', 'UV', 'Luxer', 'Pto.Rocío', 'Valid.'
|
|
];
|
|
var resumenData = [
|
|
tmp_Ext[tmp_Ext.length-1] || 0,
|
|
hum_Ext[hum_Ext.length-1] || 0,
|
|
tmp_Int[tmp_Int.length-1] || 0,
|
|
hum_Int[hum_Int.length-1] || 0,
|
|
vientos[vientos.length-1] || 0,
|
|
Lluvia[Lluvia.length-1] || 0,
|
|
presionRel[presionRel.length-1] || 0,
|
|
UV[UV.length-1] || 0,
|
|
Luxer[Luxer.length-1] || 0,
|
|
puntorocio[puntorocio.length-1] || 0,
|
|
validacion[validacion.length-1] || 0
|
|
];
|
|
|
|
|
|
window._GraphInicioChart = new RGraph.Bar({
|
|
id: 'graph_inicio',
|
|
data: resumenData,
|
|
options: {
|
|
colors: ['#1e90ff','#00b894','#fdcb6e','#e17055','#636e72','#00bfff','#6c5ce7','#fd79a8','#ffeaa7','#fab1a0','#636e72'],
|
|
backgroundGrid: true,
|
|
xaxisLabels: resumenLabels,
|
|
yaxis: true,
|
|
yaxisLabelsCount: 5,
|
|
marginLeft: 50,
|
|
marginBottom: 60,
|
|
marginTop: 40,
|
|
marginRight: 20,
|
|
title: 'Resumen Últimos Valores',
|
|
titleBold: true
|
|
}
|
|
}).draw();
|
|
// document.getElementById("actualizando").style.display = "none";
|
|
//console.log("Grafico resumen generado con RGraph.");
|
|
//console.table(resumenLabels);
|
|
// console.table(resumenData);
|
|
|
|
}else{
|
|
return false
|
|
//document.getElementById("inicio_estadisticas").innerHTML = "<h2> No hay registros para procesar .. </h2>";
|
|
//document.getElementById("grafico").innerHTML = "<h2> No hay registros para procesar .. </h2>";
|
|
//document.getElementById("actualizando").style.display = "none";
|
|
}
|
|
}
|
|
});
|
|
|
|
}else{ //MODO Visor
|
|
return false;
|
|
//document.getElementById("inicio_estadisticas").innerHTML = "<h2> Las estadisticas solo en modo recolector. </h2>";
|
|
//document.getElementById("grafico").innerHTML = "<h2> Gráficos de estadisticas solo en modo recolector. </h2>";
|
|
//document.getElementById("actualizando").style.display = "none";
|
|
}
|
|
} |