FUNCTION_BLOCK "FB15990_ZC_FAT_DI"
TITLE = FB15990_ZC_FAT_DI
{ S7_Optimized_Access := 'TRUE' }
AUTHOR : ABH
FAMILY : ZeusControl
VERSION : 1.0
//Bloque de funcion para pruebas de entradas digitales
   VAR_INPUT 
      ByteEntrada { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : DInt := 0;   // Direccion Byte entrada
      Area { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Int := 0;   // 0= Input / 1= Output / 2= Marcas / 3= DB / 4= Periferia
   END_VAR

   VAR_OUTPUT 
      Input_0 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 0
      Input_1 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 1
      Input_2 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 2
      Input_3 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 3
      Input_4 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 4
      Input_5 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 5
      Input_6 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 6
      Input_7 { S7_HiddenAssignment := 'HideIfNoParamAssigned'} : Bool;   // Bit 7
   END_VAR

   VAR_TEMP 
      t_Area : Byte;
      t_Input : Byte;
   END_VAR

   VAR CONSTANT 
      INPUT : Byte := 16#81;   // Input
      OUTPUT : Byte := 16#82;   // Output
      MARCAS : Byte := 16#83;   // Marcas
      "DB" : Byte := 16#84;   // DB
      PERIFERIA : Byte := 16#1;   // Entrada de periferia (solo S7-1500)
   END_VAR


BEGIN
	REGION DESCRIPCION
	(*
	###### (C)Copyright ZeusControl 2023 - 2023
	
	---
	### Información del Sistema
	| Hardware Compatible | Entorno de Ingeniería |
	|---------------------|-----------------------|
	| PLC serie 1200/1500 | TIA Portal 18         |
	
	---
	> **Restricciones:** Ninguna.
	
	---
	### Descripción Funcional
	
	Función para el forzado de las entradas digitales para las pruebas FAT de los cuadros.
	
	---
	### Dependencias Requeridas
	| Tipo | Elementos |
	|------|-----------|
	| FC   | - |
	| FB   | - |
	| DB   | - |
	| UDT  | - |
	
	---
	### Historial de Cambios
	| Versión  | Fecha      | Técnico | Cambios |
	|----------|------------|---------|---------|
	| 01.00.00 | 12.09.2023 | (ABH)   | Primera version. |
	*)
	END_REGION DESCRIPCION
	
	
	//  ==========================================================================================================
	REGION GESTION_TIPO
	    
	    //  Gestion de tipo
	    CASE #Area OF
	        0:
	            #t_Area := #INPUT;
	        1:
	            #t_Area := #OUTPUT;
	        2:
	            #t_Area := #MARCAS;
	        3:
	            #t_Area := #DB;
	        4:
	            #t_Area := #PERIFERIA;
	            
	        ELSE
	            #t_Area := #INPUT;
	    END_CASE;
	    
	END_REGION GESTION_TIPO
	
	
	//  ==========================================================================================================
	REGION LECTURA
	    
	    //  Lectura de BYTE de entradas
	    #t_Input := PEEK_BYTE(area := #t_Area, dbNumber := 0, byteOffset := #ByteEntrada);
	    
	END_REGION LECTURA
	
	
	//  ==========================================================================================================
	REGION SALIDAS
	    
	    //  Gestion de salidas
	    #Input_0 := #t_Input.%X0;
	    #Input_1 := #t_Input.%X1;
	    #Input_2 := #t_Input.%X2;
	    #Input_3 := #t_Input.%X3;
	    #Input_4 := #t_Input.%X4;
	    #Input_5 := #t_Input.%X5;
	    #Input_6 := #t_Input.%X6;
	    #Input_7 := #t_Input.%X7;
	    
	END_REGION SALIDAS
	
END_FUNCTION_BLOCK

