Primera version
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
DATA_BLOCK "DB7_TRZ"
|
||||
TITLE = DB7_TRAZA
|
||||
{ S7_Optimized_Access := 'TRUE' }
|
||||
AUTHOR : ABH
|
||||
FAMILY : ZeusControl
|
||||
VERSION : 1.0
|
||||
NON_RETAIN
|
||||
//Bloque de datos encargado de la trazabilidad.
|
||||
VAR RETAIN
|
||||
Gestion { S7_SetPoint := 'False'} : "UDT_ZC_TRZ_GESTION";
|
||||
Buffer { S7_SetPoint := 'False'} : Array[0.."N_MAX_TRAZA_BUFFER"] of "UDT_ZC_TRZ_DATOS";
|
||||
END_VAR
|
||||
|
||||
|
||||
BEGIN
|
||||
Gestion.HabilitacionGeneral := TRUE;
|
||||
Gestion.EstadoConexion := TRUE;
|
||||
Gestion.OrdenIniciar := FALSE;
|
||||
Gestion.HabilitarCategoria[0] := TRUE;
|
||||
Gestion.HabilitarCategoria[1] := TRUE;
|
||||
Gestion.HabilitarCategoria[2] := TRUE;
|
||||
Gestion.HabilitarCategoria[3] := TRUE;
|
||||
Gestion.HabilitarCategoria[4] := TRUE;
|
||||
Gestion.HabilitarCategoria[5] := TRUE;
|
||||
Gestion.HabilitarCategoria[6] := TRUE;
|
||||
Gestion.HabilitarCategoria[7] := TRUE;
|
||||
Gestion.HabilitarCategoria[8] := TRUE;
|
||||
Gestion.HabilitarCategoria[9] := TRUE;
|
||||
Gestion.HabilitarCategoria[10] := TRUE;
|
||||
Gestion.HabilitarCategoria[11] := TRUE;
|
||||
Gestion.HabilitarCategoria[12] := TRUE;
|
||||
Gestion.HabilitarCategoria[13] := TRUE;
|
||||
Gestion.HabilitarCategoria[14] := TRUE;
|
||||
Gestion.HabilitarCategoria[15] := TRUE;
|
||||
Gestion.HabilitarCategoria[16] := TRUE;
|
||||
Gestion.HabilitarCategoria[17] := TRUE;
|
||||
Gestion.HabilitarCategoria[18] := TRUE;
|
||||
Gestion.HabilitarCategoria[19] := TRUE;
|
||||
Gestion.HabilitarCategoria[20] := TRUE;
|
||||
Gestion.HabilitarCategoria[21] := TRUE;
|
||||
Gestion.HabilitarCategoria[22] := TRUE;
|
||||
Gestion.HabilitarCategoria[23] := TRUE;
|
||||
Gestion.HabilitarCategoria[24] := TRUE;
|
||||
Gestion.HabilitarCategoria[25] := TRUE;
|
||||
Gestion.HabilitarCategoria[26] := TRUE;
|
||||
Gestion.HabilitarCategoria[27] := TRUE;
|
||||
Gestion.HabilitarCategoria[28] := TRUE;
|
||||
Gestion.HabilitarCategoria[29] := TRUE;
|
||||
Gestion.HabilitarCategoria[30] := TRUE;
|
||||
Gestion.HabilitarCategoria[31] := TRUE;
|
||||
Gestion.Etapa := 0;
|
||||
Gestion.SP_Tiempo := 2;
|
||||
Gestion.TiempoActual := 0;
|
||||
Buffer[0].Registrar := 0;
|
||||
Buffer[0].Categoria := 0;
|
||||
Buffer[0].User := '';
|
||||
Buffer[1].Registrar := 0;
|
||||
Buffer[1].Categoria := 0;
|
||||
Buffer[1].User := '';
|
||||
|
||||
END_DATA_BLOCK
|
||||
|
||||
@@ -0,0 +1,411 @@
|
||||
FUNCTION "FC7_ZC_TRZ_GESTOR" : Void
|
||||
TITLE = FC7_GESTOR_TRAZA
|
||||
{ S7_Optimized_Access := 'TRUE' }
|
||||
AUTHOR : ABH
|
||||
FAMILY : ZeusControl
|
||||
VERSION : 2.0
|
||||
//Funcion para gestion de trazabilidad
|
||||
VAR_INPUT
|
||||
Pulso1Seg : Bool; // Pulso de 1 segundo
|
||||
END_VAR
|
||||
|
||||
VAR_TEMP
|
||||
for_i : Int; // Variable para bucles FOR
|
||||
t_PosicionRegistro : Int; // Posicion del registro encontrado en el buffer
|
||||
t_RegistroEncontrado : Bool; // Indicador de registro encontrado
|
||||
t_TextoGenerado : Bool; // Indicador de texto generado en todos los Scadas
|
||||
END_VAR
|
||||
|
||||
VAR CONSTANT
|
||||
REPOSO : Int := 0; // ETAPA EN REPOSO
|
||||
COMPROBACION_INICIAL : Int := 10; // ETAPA COMPROBACIONES INICIALES
|
||||
GENERAR_TEXTO : Int := 20; // ETAPA GENERAR TEXTO
|
||||
LANZAR_AVISO : Int := 30; // ETAPA LANZAR AVISO
|
||||
ESPERA : Int := 40; // ETAPA ESPERA
|
||||
BORRAR_TEXTO : Int := 50; // ETAPA BORRAR TEXTO
|
||||
QUITAR_AVISO : Int := 60; // ETAPA QUITAR AVISO
|
||||
BORRAR_DATOS : Int := 70; // ETAPA BORRAR DATOS
|
||||
END_VAR
|
||||
|
||||
|
||||
BEGIN
|
||||
REGION DESCRIPCION
|
||||
(*
|
||||
###### (C)Copyright ZeusControl 2022 - 2026
|
||||
|
||||
---
|
||||
### Información del Sistema
|
||||
| Hardware Compatible | Entorno de Ingeniería |
|
||||
|---------------------|-----------------------|
|
||||
| PLC serie 1200/1500 | TIA Portal 18 |
|
||||
|
||||
---
|
||||
> **Restricciones:** Ninguna.
|
||||
|
||||
---
|
||||
### Descripción Funcional
|
||||
|
||||
Función principal para la gestión de mensajes de trazabilidad y su envío estructurado a los sistemas de supervisión.
|
||||
|
||||
Las tareas que realiza son las siguientes:
|
||||
|
||||
- Búsqueda en orden inverso dentro del buffer para localizar y extraer el último registro con orden de registrar.
|
||||
- Transferencia del registro a variables de gestión estáticas, formateo de cadenas de tiempo y usuario, y liberación de la posición ocupada en el buffer.
|
||||
- Ejecución de la **Etapa Reposo**: Con un registro habilitado y conexión activa, lanza la orden de inicio de secuencia.
|
||||
- Ejecución de la **Etapa Comprobaciones Iniciales**: Valida que la categoría del evento se encuentre en los límites permitidos (forzando una categoría de usuario si excede el índice), limpia las confirmaciones previas y espera la actualización temporal.
|
||||
- Ejecución de la **Etapa Generar Texto**: Envía la orden de generación de textos a los SCADAs habilitados, transitando al recibir la confirmación de todos o al superar un tiempo de espera de seguridad.
|
||||
- Ejecución de la **Etapa Lanzar Aviso**: Activa la señal de aviso correspondiente a la categoría de la trazabilidad procesada.
|
||||
- Ejecución de la **Etapa Espera**: Retiene el aviso activo durante el tiempo configurado para garantizar su captura en los sistemas de supervisión.
|
||||
- Ejecución de la **Etapa Borrar Texto**: Lanza la orden de limpieza de textos en pantalla a todos los SCADAs.
|
||||
- Ejecución de la **Etapa Quitar Aviso**: Desactiva la señal de aviso y verifica mediante un tiempo corto que el evento ha caído.
|
||||
- Ejecución de la **Etapa Borrar Datos**: Inicializa por completo los valores, códigos y textos del aviso actual, regresando a la etapa de reposo.
|
||||
- Mapeo final de las activaciones de alarma a nivel de bit, agrupándolas en dos variables tipo `Word` para las 32 categorías y aplicando sus respectivas máscaras de habilitación individual.
|
||||
|
||||
---
|
||||
### Dependencias Requeridas
|
||||
| Tipo | Elementos |
|
||||
|------|-----------|
|
||||
| FC | - |
|
||||
| FB | - |
|
||||
| DB | `DB7_TRAZA` |
|
||||
| UDT | - |
|
||||
|
||||
---
|
||||
### Historial de Cambios
|
||||
| Versión | Fecha | Técnico | Cambios |
|
||||
|----------|------------|---------|---------|
|
||||
| 00.00.01 | 31.08.2022 | (ABH) | Primera version. |
|
||||
| 01.00.00 | 18.09.2023 | (ABH) | Se añade gestion de bits para 16 categorias. |
|
||||
| 02.00.00 | 25.03.2026 | (ABH) | Se eliminan `String`. Se añaden 32 categorias. Se añade gestion de generacion de textos para Scada. |
|
||||
*)
|
||||
END_REGION DESCRIPCION
|
||||
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION GESTION_TRAZA
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION GESTION_ULTIMO_REGISTRO
|
||||
|
||||
// Si la gestion esta habilitada, se busca el ultimo registro y se mueve a la variable de gestion de avisos para
|
||||
// los sistemas de supervision
|
||||
IF "DB7_TRZ".Gestion.HabilitacionGeneral AND #Pulso1Seg AND "DB7_TRZ".Gestion.Etapa = #REPOSO THEN
|
||||
|
||||
// Buscamos el ultimo registro
|
||||
FOR #for_i := "N_MAX_TRAZA_BUFFER" TO 0 BY -1 DO
|
||||
|
||||
// Registro encontrado
|
||||
IF "DB7_TRZ".Buffer[#for_i].Registrar = 1 THEN
|
||||
#t_PosicionRegistro := #for_i;
|
||||
#t_RegistroEncontrado := TRUE;
|
||||
EXIT;
|
||||
END_IF;
|
||||
|
||||
END_FOR;
|
||||
|
||||
|
||||
// Si hemos encontrado el registro, copiamos a variable estatica
|
||||
IF #t_RegistroEncontrado THEN
|
||||
|
||||
// Copiamos el los datos de la traza a variable estatica para tratarla
|
||||
"DB7_TRZ".Gestion.Aviso.Datos := "DB7_TRZ".Buffer[#t_PosicionRegistro];
|
||||
|
||||
// Quitamos el registro del buffer
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].Registrar := 0;
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].Categoria :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodInt_1 :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodInt_2 :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodInt_3 :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodInt_4 :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodInt_5 := 0;
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodReal_1 :=
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].CodReal_2 := 0.0;
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].TimeStamp := DTL#1970-01-01-00:00:00;
|
||||
"DB7_TRZ".Buffer[#t_PosicionRegistro].User := '';
|
||||
|
||||
END_IF;
|
||||
|
||||
END_IF;
|
||||
|
||||
END_REGION GESTION_ULTIMO_REGISTRO
|
||||
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION GESTION_ORDEN_INICIAR
|
||||
|
||||
// =============================================================================
|
||||
// Si existe registro a trazar, lanzamos la orden de iniciar la secuencia
|
||||
IF "DB7_TRZ".Gestion.Aviso.Datos.Registrar = 1 AND "DB7_TRZ".Gestion.Etapa = #REPOSO AND "DB7_TRZ".Gestion.EstadoConexion THEN
|
||||
|
||||
// Lanzamos la orden de iniciar la secuencia de registro
|
||||
"DB7_TRZ".Gestion.OrdenIniciar := TRUE;
|
||||
|
||||
END_IF;
|
||||
|
||||
END_REGION GESTION_ORDEN_INICIAR
|
||||
|
||||
END_REGION GESTION_TRAZA
|
||||
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION SECUENCIA_TRAZA
|
||||
|
||||
// En caso de deshabilitar la trazabilidad, ponemos el estado en borrar datos.
|
||||
IF NOT "DB7_TRZ".Gestion.HabilitacionGeneral AND "DB7_TRZ".Gestion.Etapa <> #REPOSO THEN
|
||||
"DB7_TRZ".Gestion.Etapa := #BORRAR_DATOS;
|
||||
END_IF;
|
||||
|
||||
// Gestion trazabilidad
|
||||
CASE "DB7_TRZ".Gestion.Etapa OF
|
||||
|
||||
// =============================================================================
|
||||
// Etapa reposo
|
||||
#REPOSO:
|
||||
REGION #REPOSO
|
||||
|
||||
// Con orden de iniciar, vamos a etapa comprobaciones iniciales
|
||||
IF "DB7_TRZ".Gestion.OrdenIniciar THEN
|
||||
"DB7_TRZ".Gestion.Etapa := #COMPROBACION_INICIAL;
|
||||
"DB7_TRZ".Gestion.OrdenIniciar := FALSE;
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
// =============================================================================
|
||||
// Etapa comprobaciones iniciales
|
||||
#COMPROBACION_INICIAL:
|
||||
REGION #COMPROBACION_INICIAL
|
||||
|
||||
// Si el registro actual no tiene orden de registrar, lo borramos yendo a etapa borrar datos
|
||||
IF "DB7_TRZ".Gestion.Aviso.Datos.Registrar = 0 THEN
|
||||
"DB7_TRZ".Gestion.Etapa := #BORRAR_DATOS;
|
||||
ELSE
|
||||
// Esperamos a que tenga los datos actualizados en scada/hmi
|
||||
IF #Pulso1Seg THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual += 1;
|
||||
IF "DB7_TRZ".Gestion.TiempoActual >= "DB7_TRZ".Gestion.SP_Tiempo THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
|
||||
// En caso de tener una categoria fuera de indices, formazos a categoria usuario
|
||||
IF "DB7_TRZ".Gestion.Aviso.Datos.Categoria < "TRZ_CAT_1_SYS" OR "DB7_TRZ".Gestion.Aviso.Datos.Categoria > "TRZ_CAT_32_USER" THEN
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.Categoria := "TRZ_CAT_32_USER";
|
||||
END_IF;
|
||||
|
||||
// Limpiamos las confirmaciones de texto generado por seguridad antes de esperar
|
||||
FOR #for_i := 0 TO "N_MAX_SCADA" DO
|
||||
"DB7_TRZ".Gestion.Aviso.TextoGenerado[#for_i] := FALSE;
|
||||
END_FOR;
|
||||
|
||||
"DB7_TRZ".Gestion.Etapa := #GENERAR_TEXTO;
|
||||
END_IF;
|
||||
END_IF;
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
// =============================================================================
|
||||
// Etapa generar texto
|
||||
#GENERAR_TEXTO:
|
||||
REGION #GENERAR_TEXTO
|
||||
|
||||
// Lanzamos la orden de generar textos a sistemas scada que esten habilitados
|
||||
FOR #for_i := 0 TO "N_MAX_SCADA" DO
|
||||
"DB7_TRZ".Gestion.Aviso.GenerarTexto[#for_i] := "DB7_TRZ".Gestion.Aviso.HabilitarHmiScada[#for_i];
|
||||
END_FOR;
|
||||
|
||||
// Activamos marca de texto generado OK desde Scada, antes de realizar las comprobaciones.
|
||||
#t_TextoGenerado := TRUE;
|
||||
|
||||
// Comprobamos si los Scadas estan habilitados y tenemos confirmacion de que el texto se ha generado correctamente
|
||||
FOR #for_i := 0 TO "N_MAX_SCADA" DO
|
||||
IF "DB7_TRZ".Gestion.Aviso.HabilitarHmiScada[#for_i] AND NOT "DB7_TRZ".Gestion.Aviso.TextoGenerado[#for_i] THEN
|
||||
#t_TextoGenerado := FALSE;
|
||||
END_IF;
|
||||
END_FOR;
|
||||
|
||||
|
||||
// Comprobacion de fin etapa
|
||||
IF #t_TextoGenerado THEN
|
||||
|
||||
// Tenemos confirmacion de todos los Scadas que han generado el texto correctamente
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
"DB7_TRZ".Gestion.Etapa := #LANZAR_AVISO;
|
||||
|
||||
// Reseteamos las ordenes de generar texto
|
||||
FOR #for_i := 0 TO "N_MAX_SCADA" DO
|
||||
"DB7_TRZ".Gestion.Aviso.GenerarTexto[#for_i] := FALSE;
|
||||
END_FOR;
|
||||
|
||||
ELSE
|
||||
|
||||
// Esperamos un tiempo de seguridad si no tenemos respuesta desde Scadas
|
||||
IF #Pulso1Seg THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual += 1;
|
||||
|
||||
IF "DB7_TRZ".Gestion.TiempoActual >= "DB7_TRZ".Gestion.SP_TiempoTexto THEN
|
||||
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
|
||||
// Reseteamos las ordenes de generar texto
|
||||
FOR #for_i := 0 TO "N_MAX_SCADA" DO
|
||||
"DB7_TRZ".Gestion.Aviso.GenerarTexto[#for_i] := FALSE;
|
||||
END_FOR;
|
||||
|
||||
"DB7_TRZ".Gestion.Etapa := #LANZAR_AVISO;
|
||||
END_IF;
|
||||
|
||||
END_IF;
|
||||
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
// =============================================================================
|
||||
// Etapa lanzar aviso
|
||||
#LANZAR_AVISO:
|
||||
REGION #LANZAR_AVISO
|
||||
|
||||
// Activamos orden de lanzar el aviso
|
||||
"DB7_TRZ".Gestion.Aviso.Aviso["DB7_TRZ".Gestion.Aviso.Datos.Categoria] := TRUE;
|
||||
"DB7_TRZ".Gestion.Etapa := #ESPERA;
|
||||
|
||||
END_REGION
|
||||
|
||||
// =============================================================================
|
||||
// Etapa espera
|
||||
#ESPERA:
|
||||
REGION #ESPERA
|
||||
|
||||
// Esperamos un tiempo para que el aviso se haya registrado en todos los sistemas de supervision
|
||||
IF #Pulso1Seg THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual += 1;
|
||||
IF "DB7_TRZ".Gestion.TiempoActual >= "DB7_TRZ".Gestion.SP_Tiempo THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
"DB7_TRZ".Gestion.Etapa := #BORRAR_TEXTO;
|
||||
END_IF;
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// Etapa borrar texto
|
||||
#BORRAR_TEXTO:
|
||||
REGION #BORRAR_TEXTO
|
||||
|
||||
// Lanzamos orden de borrar texto a todos los Scadas
|
||||
"DB7_TRZ".Gestion.Aviso.BorrarTexto := TRUE;
|
||||
|
||||
// Reseteamos los valores del aviso actual
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.Registrar := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_1 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_2 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_3 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_4 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_5 := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodReal_1 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodReal_2 := 0.0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.User := '';
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.TimeStamp := DTL#1970-01-01-00:00:00;
|
||||
|
||||
// Saltamos de etapa tras un tiempo
|
||||
IF #Pulso1Seg THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual += 1;
|
||||
IF "DB7_TRZ".Gestion.TiempoActual >= "DB7_TRZ".Gestion.SP_Tiempo THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.BorrarTexto := FALSE;
|
||||
"DB7_TRZ".Gestion.Etapa := #QUITAR_AVISO;
|
||||
END_IF;
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
// =============================================================================
|
||||
// Etapa quitar aviso
|
||||
#QUITAR_AVISO:
|
||||
REGION #QUITAR_AVISO
|
||||
|
||||
// Desactivamos el aviso
|
||||
"DB7_TRZ".Gestion.Aviso.Aviso["DB7_TRZ".Gestion.Aviso.Datos.Categoria] := FALSE;
|
||||
|
||||
// Saltamos de etapa tras un tiempo
|
||||
IF #Pulso1Seg THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual += 1;
|
||||
IF "DB7_TRZ".Gestion.TiempoActual >= 2 AND NOT "DB7_TRZ".Gestion.Aviso.Aviso["DB7_TRZ".Gestion.Aviso.Datos.Categoria] THEN
|
||||
"DB7_TRZ".Gestion.TiempoActual := 0;
|
||||
"DB7_TRZ".Gestion.Etapa := #BORRAR_DATOS;
|
||||
END_IF;
|
||||
END_IF;
|
||||
|
||||
END_REGION
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// Etapa borrar datos
|
||||
#BORRAR_DATOS:
|
||||
REGION #BORRAR_DATOS
|
||||
|
||||
// Reseteamos los valores del aviso actual
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.Registrar := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.Categoria := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_1 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_2 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_3 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_4 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodInt_5 := 0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodReal_1 :=
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.CodReal_2 := 0.0;
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.User := '';
|
||||
"DB7_TRZ".Gestion.Aviso.Datos.TimeStamp := DTL#1970-01-01-00:00:00;
|
||||
|
||||
"DB7_TRZ".Gestion.Etapa := #REPOSO;
|
||||
|
||||
END_REGION
|
||||
|
||||
END_CASE;
|
||||
|
||||
END_REGION SECUENCIA_TRAZA
|
||||
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION ACTIVACION_ALARMAS
|
||||
|
||||
// Activamos los avisos en WORD segun la categoria y su habilitacion
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X0 := "DB7_TRZ".Gestion.HabilitarCategoria[0] AND "DB7_TRZ".Gestion.Aviso.Aviso[0];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X1 := "DB7_TRZ".Gestion.HabilitarCategoria[1] AND "DB7_TRZ".Gestion.Aviso.Aviso[1];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X2 := "DB7_TRZ".Gestion.HabilitarCategoria[2] AND "DB7_TRZ".Gestion.Aviso.Aviso[2];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X3 := "DB7_TRZ".Gestion.HabilitarCategoria[3] AND "DB7_TRZ".Gestion.Aviso.Aviso[3];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X4 := "DB7_TRZ".Gestion.HabilitarCategoria[4] AND "DB7_TRZ".Gestion.Aviso.Aviso[4];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X5 := "DB7_TRZ".Gestion.HabilitarCategoria[5] AND "DB7_TRZ".Gestion.Aviso.Aviso[5];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X6 := "DB7_TRZ".Gestion.HabilitarCategoria[6] AND "DB7_TRZ".Gestion.Aviso.Aviso[6];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X7 := "DB7_TRZ".Gestion.HabilitarCategoria[7] AND "DB7_TRZ".Gestion.Aviso.Aviso[7];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X8 := "DB7_TRZ".Gestion.HabilitarCategoria[8] AND "DB7_TRZ".Gestion.Aviso.Aviso[8];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X9 := "DB7_TRZ".Gestion.HabilitarCategoria[9] AND "DB7_TRZ".Gestion.Aviso.Aviso[9];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X10 := "DB7_TRZ".Gestion.HabilitarCategoria[10] AND "DB7_TRZ".Gestion.Aviso.Aviso[10];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X11 := "DB7_TRZ".Gestion.HabilitarCategoria[11] AND "DB7_TRZ".Gestion.Aviso.Aviso[11];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X12 := "DB7_TRZ".Gestion.HabilitarCategoria[12] AND "DB7_TRZ".Gestion.Aviso.Aviso[12];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X13 := "DB7_TRZ".Gestion.HabilitarCategoria[13] AND "DB7_TRZ".Gestion.Aviso.Aviso[13];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X14 := "DB7_TRZ".Gestion.HabilitarCategoria[14] AND "DB7_TRZ".Gestion.Aviso.Aviso[14];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[0].%X15 := "DB7_TRZ".Gestion.HabilitarCategoria[15] AND "DB7_TRZ".Gestion.Aviso.Aviso[15];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X0 := "DB7_TRZ".Gestion.HabilitarCategoria[16] AND "DB7_TRZ".Gestion.Aviso.Aviso[16];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X1 := "DB7_TRZ".Gestion.HabilitarCategoria[17] AND "DB7_TRZ".Gestion.Aviso.Aviso[17];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X2 := "DB7_TRZ".Gestion.HabilitarCategoria[18] AND "DB7_TRZ".Gestion.Aviso.Aviso[18];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X3 := "DB7_TRZ".Gestion.HabilitarCategoria[19] AND "DB7_TRZ".Gestion.Aviso.Aviso[19];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X4 := "DB7_TRZ".Gestion.HabilitarCategoria[20] AND "DB7_TRZ".Gestion.Aviso.Aviso[20];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X5 := "DB7_TRZ".Gestion.HabilitarCategoria[21] AND "DB7_TRZ".Gestion.Aviso.Aviso[21];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X6 := "DB7_TRZ".Gestion.HabilitarCategoria[22] AND "DB7_TRZ".Gestion.Aviso.Aviso[22];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X7 := "DB7_TRZ".Gestion.HabilitarCategoria[23] AND "DB7_TRZ".Gestion.Aviso.Aviso[23];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X8 := "DB7_TRZ".Gestion.HabilitarCategoria[24] AND "DB7_TRZ".Gestion.Aviso.Aviso[24];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X9 := "DB7_TRZ".Gestion.HabilitarCategoria[25] AND "DB7_TRZ".Gestion.Aviso.Aviso[25];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X10 := "DB7_TRZ".Gestion.HabilitarCategoria[26] AND "DB7_TRZ".Gestion.Aviso.Aviso[26];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X11 := "DB7_TRZ".Gestion.HabilitarCategoria[27] AND "DB7_TRZ".Gestion.Aviso.Aviso[27];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X12 := "DB7_TRZ".Gestion.HabilitarCategoria[28] AND "DB7_TRZ".Gestion.Aviso.Aviso[28];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X13 := "DB7_TRZ".Gestion.HabilitarCategoria[29] AND "DB7_TRZ".Gestion.Aviso.Aviso[29];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X14 := "DB7_TRZ".Gestion.HabilitarCategoria[30] AND "DB7_TRZ".Gestion.Aviso.Aviso[30];
|
||||
"DB7_TRZ".Gestion.Aviso.AvisoWord[1].%X15 := "DB7_TRZ".Gestion.HabilitarCategoria[31] AND "DB7_TRZ".Gestion.Aviso.Aviso[31];
|
||||
|
||||
END_REGION ACTIVACION_ALARMAS
|
||||
|
||||
|
||||
END_FUNCTION
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
FUNCTION "FC8_ZC_TRZ_REGISTRO" : Void
|
||||
TITLE = FC8_TRAZA_REGISTRO
|
||||
{ S7_Optimized_Access := 'TRUE' }
|
||||
AUTHOR : ABH
|
||||
FAMILY : ZeusControl
|
||||
VERSION : 1.0
|
||||
//Funcion para almacenar una traza en el buffer de trazas.
|
||||
VAR_INPUT
|
||||
FechaHora {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL; // Fecha y hora actual
|
||||
Registrar : USInt; // Registrar trazabilidad
|
||||
Categoria : Int; // Categoria de trazabilidad
|
||||
User : String; // Usuario actual
|
||||
CodInt_1 : Int; // Codigo entero 1
|
||||
CodInt_2 : Int; // Codigo entero 2
|
||||
CodInt_3 : Int; // Codigo entero 3
|
||||
CodInt_4 : Int; // Codigo entero 4
|
||||
CodInt_5 : Int; // Codigo entero 5
|
||||
CodReal_1 : Real; // Codigo real 1
|
||||
CodReal_2 : Real; // Codigo real 2
|
||||
END_VAR
|
||||
|
||||
VAR_TEMP
|
||||
t_dummy : Int; // Variable temporal para su uso en programa
|
||||
END_VAR
|
||||
|
||||
|
||||
BEGIN
|
||||
REGION DESCRIPCION
|
||||
(*
|
||||
###### (C)Copyright ZeusControl 2022 - 2026
|
||||
|
||||
---
|
||||
### Información del Sistema
|
||||
| Hardware Compatible | Entorno de Ingeniería |
|
||||
|---------------------|-----------------------|
|
||||
| PLC serie 1200/1500 | TIA Portal 18 |
|
||||
|
||||
---
|
||||
> **Restricciones:** Ninguna.
|
||||
|
||||
---
|
||||
### Descripción Funcional
|
||||
|
||||
Función encargada de almacenar de forma secuencial un nuevo evento de trazabilidad dentro del buffer de registros.
|
||||
|
||||
Las tareas que realiza son las siguientes:
|
||||
|
||||
- Verifica que la gestión general de trazabilidad se encuentre habilitada en el sistema.
|
||||
- Desplaza el contenido actual del buffer de trazas una posición hacia abajo mediante la instrucción `MOVE_BLK_VARIANT`, liberando el primer índice.
|
||||
- Convierte la marca de tiempo de entrada (formato `DTL`) a una cadena de texto (`String`) haciendo uso de la función `FC15006_ZC_DTL_TO_STRING`.
|
||||
- Almacena los parámetros del nuevo registro (orden de registrar, marca de tiempo, categoría, códigos numéricos enteros y reales) en la posición inicial (índice 0) del buffer.
|
||||
- Valida la cadena de caracteres correspondiente al usuario: si se encuentra vacía, registra una cadena de espacios por defecto; en caso contrario, asigna el nombre de usuario proporcionado en la entrada.
|
||||
|
||||
---
|
||||
### Dependencias Requeridas
|
||||
| Tipo | Elementos |
|
||||
|------|-----------|
|
||||
| FC | `FC15006_ZC_DTL_TO_STRING` |
|
||||
| FB | - |
|
||||
| DB | `DB7_TRAZA` |
|
||||
| UDT | - |
|
||||
|
||||
---
|
||||
### Historial de Cambios
|
||||
| Versión | Fecha | Técnico | Cambios |
|
||||
|----------|------------|---------|---------|
|
||||
| 00.00.01 | 31.08.2022 | (ABH) | Primera version. |
|
||||
| 00.00.02 | 25.03.2026 | (ABH) | Se añade datos nuevos de UDT. |
|
||||
| 01.00.00 | 21.05.2026 | (ABH) | Se cambia la variable fechaactual de string a DTL. Se reduce el usuario actual a 15 caracteres. |
|
||||
*)
|
||||
END_REGION DESCRIPCION
|
||||
|
||||
|
||||
// ==========================================================================================================
|
||||
REGION GESTION_REGISTRO_TRAZA
|
||||
|
||||
// Si la trazabilidad esta habilitada
|
||||
IF "DB7_TRZ".Gestion.HabilitacionGeneral THEN
|
||||
|
||||
// Desplazamos los datos una posicion hacia abajo
|
||||
#t_dummy := MOVE_BLK_VARIANT(SRC := "DB7_TRZ".Buffer, COUNT := INT_TO_UDINT(("N_MAX_TRAZA_BUFFER")), SRC_INDEX := 0, DEST_INDEX := 1, DEST => "DB7_TRZ".Buffer);
|
||||
|
||||
// Guardamos el nuevo registro en la primera posicion
|
||||
"DB7_TRZ".Buffer[0].Registrar := #Registrar;
|
||||
"DB7_TRZ".Buffer[0].TimeStamp := #FechaHora;
|
||||
"DB7_TRZ".Buffer[0].Categoria := #Categoria;
|
||||
"DB7_TRZ".Buffer[0].CodInt_1 := #CodInt_1;
|
||||
"DB7_TRZ".Buffer[0].CodInt_2 := #CodInt_2;
|
||||
"DB7_TRZ".Buffer[0].CodInt_3 := #CodInt_3;
|
||||
"DB7_TRZ".Buffer[0].CodInt_4 := #CodInt_4;
|
||||
"DB7_TRZ".Buffer[0].CodInt_5 := #CodInt_5;
|
||||
"DB7_TRZ".Buffer[0].CodReal_1 := #CodReal_1;
|
||||
"DB7_TRZ".Buffer[0].CodReal_2 := #CodReal_2;
|
||||
IF #User = '' THEN
|
||||
"DB7_TRZ".Buffer[0].User := ' ';
|
||||
ELSE
|
||||
"DB7_TRZ".Buffer[0].User := #User;
|
||||
END_IF;
|
||||
|
||||
END_IF;
|
||||
|
||||
END_REGION GESTION_REGISTRO_TRAZA
|
||||
|
||||
|
||||
END_FUNCTION
|
||||
|
||||
Reference in New Issue
Block a user