/**
* 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
"; // 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 = '
| Nombre Local | Tipo de Red | Clave | LLave_W | Puerto | Publicar | "; for (i = 0, t = Cantidad; i < t; ++i) { var publicar = ""+Publicar[i].Publicar +""; if(Publicar[i].Publicar == false) {publicar = ""+Publicar[i].Publicar +"";} if((Publicar[i].TipoRed != "emacenter") && (Publicar[i].TipoRed != "emacentergugler")) { TablaHTML += " |
|---|---|---|---|---|---|---|
| "+Publicar[i].Nombre+" | "+Publicar[i].TipoRed+" | SI | NO | N/A | "+publicar+" | |
| "+Publicar[i].Nombre+" | "+Publicar[i].TipoRed+" | N/A | "+tienellave+" | "+(Publicar[i].Puerto || "N/A")+" | "+publicar+" |
| Tipo de Red | |||||
|---|---|---|---|---|---|
| "; TablaHTML += " | |||||
| Configuracion de la Red | |||||
'; TablaHTML += ' | |||||
'; $('#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 += '
| Nº | '; TablaHTML += 'Fecha_Registro | '; TablaHTML += 'Temp. Int. | '; TablaHTML += 'Hum. Int | '; if(lugar == 0) {TablaHTML += 'Temp. Ext. | '; TablaHTML += 'Hum. Ext. | '; TablaHTML += 'Punto. Roc. | '; TablaHTML += 'Luz int. | '; TablaHTML += 'Rayos UV | '; TablaHTML += 'Viento Vel. | '; TablaHTML += 'Viento Raf. | '; TablaHTML += 'Viento Dir. | '; TablaHTML += 'Viento DirN. | '; TablaHTML += 'Presión Abs. | '; TablaHTML += 'Presión Rel. | '; TablaHTML += 'Luvia Act. | '; TablaHTML += 'Luvia Hora | '; TablaHTML += 'Luvia Dia | '; TablaHTML += 'Luvia Total | ';} TablaHTML += '
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| '+ j + ' | '; TablaHTML += ''+ RegistroDiario[j].fecha +' | '; TablaHTML += ''+ RegistroDiario[j].temperatura_interna +' | '; TablaHTML += ''+ RegistroDiario[j].humedad_interna +' | '; if(lugar == 0) { TablaHTML += ''+ RegistroDiario[j].temperatura_externa +' | '; TablaHTML += ''+ RegistroDiario[j].humedad_externa +' | '; TablaHTML += ''+ RegistroDiario[j].punto_de_rocio +' | '; TablaHTML += ''+ RegistroDiario[j].luxer_intencidad +' | '; TablaHTML += ''+ RegistroDiario[j].luxer_uv +' | '; TablaHTML += ''+ RegistroDiario[j].viento_velocidad +' | '; TablaHTML += ''+ RegistroDiario[j].viento_rafagas +' | '; TablaHTML += ''+ RegistroDiario[j].viento_direccion +' | '; TablaHTML += ''+ RegistroDiario[j].viento_direccion_nombre +' | '; TablaHTML += ''+ RegistroDiario[j].presion_absoluta +' | '; TablaHTML += ''+ RegistroDiario[j].presion_relativa +' | '; TablaHTML += ''+ RegistroDiario[j].lloviendo +' | '; TablaHTML += ''+ RegistroDiario[j].lluvia_acu_hora +' | '; TablaHTML += ''+ RegistroDiario[j].lluvia_acu_diaria +' | '; TablaHTML += ''+ RegistroDiario[j].lluvia_acumulado_total +' | '; } TablaHTML += '
| Nº | '; TablaHTML += 'Fecha_Registro | '; if(lugar == 0) {TablaHTML += 'Temp. Ext. | '; TablaHTML += 'Hum. Ext. | '; TablaHTML += 'Punto. Roc. | '; TablaHTML += 'Luz int. | '; TablaHTML += 'Rayos UV | '; TablaHTML += 'Viento Vel. | '; TablaHTML += 'Viento Raf. | '; TablaHTML += 'Viento Dir. | '; TablaHTML += 'Viento DirN. | '; TablaHTML += 'Presión Abs. | '; TablaHTML += 'Presión Rel. | '; TablaHTML += 'Luvia Act. | '; TablaHTML += 'Luvia Hora | '; TablaHTML += 'Luvia Dia | '; TablaHTML += 'Luvia Semanal | '; TablaHTML += 'Luvia Mensual | '; TablaHTML += 'Luvia Anual | '; TablaHTML += 'Luvia Total | ';} else{ TablaHTML += 'Temp. Int. | '; TablaHTML += 'Hum. Int | '; } TablaHTML += '
|---|
| Nº | '; TablaHTML += 'Fecha_Registro | '; TablaHTML += 'Nivel | '; TablaHTML += 'Tipo | '; TablaHTML += 'Mensaje | '; TablaHTML += '
|---|---|---|---|---|
| 0 | 0 | 0 | INFO | Tanque diario vacio |
| '+ i + ' | '; TablaHTML += ''+ registros[i].substring(0,19) +' | '; TablaHTML += ''+registros[i].substring(22,23) +' | '; TablaHTML += ''+Resultado[0] +' | '; TablaHTML += ''+Resultado[1] +' | '; TablaHTML += '