Obsidean_VM/04-SIDEL/06 - E5.007363 - Modifica O.../Source/source/Input_CheckFlowMetersSta.md

6.4 KiB

FUNCTION "Input_CheckFlowMetersSta" : Void
{ S7_Optimized_Access := 'FALSE' }
AUTHOR : 'Author'
FAMILY : TASK2
NAME : 'Name'
VERSION : 1.0
   VAR_TEMP 
      WaterFlow_State : Int;
      WaterTot_State : Int;
      Syrup1Flow_State : Int;
      CO2Flow_State : Int;
      ProductFlow_State : Int;
      ProductTot_State : Int;
   END_VAR


BEGIN
	
	
	#WaterFlow_State    := BYTE_TO_INT("Profibus_Variables".gFTN301_Flow_State);
	#WaterTot_State     := BYTE_TO_INT("Profibus_Variables".gFTN301_Tot_State);
	#Syrup1Flow_State   := BYTE_TO_INT("Profibus_Variables".gFTP302_Flow_State);
	#CO2Flow_State      := BYTE_TO_INT("Profibus_Variables".gFTM303_Flow_State);
	#ProductFlow_State  := BYTE_TO_INT("Profibus_Variables".gVFM_ProductFlow_State);
	#ProductTot_State   := BYTE_TO_INT("Profibus_Variables".gVFM_ProductTot_State);
	
	IF "HMI_Blender_Parameters".Processor_Options.Blender_OPT._WaterPromass THEN 
	    CASE #WaterFlow_State OF
	        16#53:  
	          "gFTN301_EPD" := TRUE ;
	          "gFTN301_Fault" := FALSE ;
	          
	        16#64:
	            IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" THEN
	                "gFTN301_EPD" := TRUE ;
	            END_IF;
	            "gFTN301_Fault" := FALSE ;
	
	        16#80: 
	            "gFTN301_EPD":= FALSE ;
	            "gFTN301_Fault" := FALSE ;
	 
	        16#9C: 
	            "gFTN301_EPD" := FALSE ;
	            "gFTN301_Fault" := FALSE ;
	            
	        16#78:
	            "gFTN301_EPD" := FALSE;
	            "gFTN301_Fault" := FALSE;
	            
	    ELSE:
	        "gFTN301_Fault" := TRUE ;
	            "gFTN301_EPD" := FALSE ;
	    END_CASE;
	ELSE
	    CASE #WaterFlow_State OF
	        16#47:
	            IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" THEN
	                "gFTN301_EPD" := TRUE ;
	            END_IF;
	            "gFTN301_Fault" := FALSE ;
	
	        16#80:   
	            "gFTN301_EPD" := FALSE ;
	            "gFTN301_Fault" := FALSE ;
	         
	        16#4F: 
	            "gFTN301_EPD" := FALSE ;
	            "gFTN301_Fault" := FALSE ;
	    ELSE:
	        CASE #WaterTot_State OF
	            16#03:
	                "gFTN301_Fault" := FALSE ;
	                "gFTN301_EPD" := FALSE ;
	
	            16#47:
	                IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" THEN
	                    "gFTN301_EPD" := TRUE ;
	                END_IF;
	                "gFTN301_Fault" := FALSE ;
	       // ELSE:
	            "gFTN301_Fault" := TRUE ;
	            "gFTN301_EPD" := FALSE ;//
	            
	            16#00:
	            "gFTN301_Fault" := FALSE;
	            "gFTN301_EPD" := FALSE;
	        END_CASE;
	    END_CASE;
	END_IF;
	
	IF "Blender_Variables_Pers".gWaterRecipe THEN
	   "gFTP302_Fault" := FALSE ;
	   "gFTP302_EPD" := FALSE ;
	ELSE
	    CASE #Syrup1Flow_State  OF
	        16#43:
	            "gFTP302_EPD" := TRUE ;
	            "gFTP302_Fault" := FALSE ;
	
	        16#53:
	            "gFTP302_EPD" := TRUE ;
	            "gFTP302_Fault" := FALSE ;
	
	        16#64: 
	            "gFTP302_EPD" := TRUE ;
	            "gFTP302_Fault" := FALSE ;
	            
	        16#78:
	            IF "gBlenderBlending" OR "Procedure_Variables".FTP302Line_Preparation.Latch THEN
	                "gFTP302_EPD" := TRUE;
	                "gFTP302_Fault" := FALSE;
	            END_IF;
	        16#80:
	            "gFTP302_EPD" := FALSE ;
	            "gFTP302_Fault" := FALSE ;
	
	        16#9C:
	            "gFTP302_EPD" := FALSE ;
	            "gFTP302_Fault" := FALSE ;
	    ELSE:
	        "gFTP302_Fault" := FALSE ;
	            "gFTP302_EPD" := FALSE ;
	    END_CASE;
	END_IF;
	
	CASE #CO2Flow_State OF
	    16#43:
	        "gFTM303_EPD" := TRUE ;
	        "gFTM303_Fault" := FALSE ;
	
	    16#53:
	        "gFTM303_EPD" := TRUE ;
	        "gFTM303_Fault" := FALSE ;
	
	    16#64:
	        "gFTM303_EPD" := TRUE ;
	        "gFTM303_Fault" := FALSE ;
	
	    16#80:   
	        "gFTM303_EPD" := FALSE ;
	        "gFTM303_Fault" := FALSE ;
	
	    16#9C:  
	        "gFTM303_EPD" := FALSE ;
	        "gFTM303_Fault" := FALSE ;
	ELSE:
	        "gFTM303_Fault" := TRUE ;
	        "gFTM303_EPD" := FALSE ;
	END_CASE;
	
	IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" AND "Procedure_Variables".BlendFill_StartUp.Done THEN
	    CASE #ProductFlow_State OF
	        16#47:
	            IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" AND "Procedure_Variables".BlendFill_StartUp.Done THEN
	                "gProductVFM_EPD" := TRUE ;
	            END_IF;
	            "gProductVFM_Fault" := FALSE ;
	        16#80:   
	            "gProductVFM_EPD" := FALSE ;
	            "gProductVFM_Fault" := FALSE ;
	    ELSE:
	        CASE #ProductTot_State OF
	            16#47:
	                IF "gBlenderBlending" AND NOT ("System_RunOut_Variables".FastChangeOverActivated AND "Procedure_Variables".Syr_RunOut.Done) AND NOT "gBlenderCIPMode" AND "Procedure_Variables".BlendFill_StartUp.Done THEN
	                    "gProductVFM_EPD" := TRUE ;
	                END_IF;
	                "gProductVFM_Fault" := FALSE ;
	        ELSE:
	            "gProductVFM_Fault" := TRUE ;
	            "gProductVFM_EPD" := FALSE ;
	        END_CASE;
	    END_CASE;
	ELSE
	    "gProductVFM_Fault" := FALSE ;
	    "gProductVFM_EPD" := FALSE ;
	END_IF;
	
	IF "HMI_Blender_Parameters".Processor_Options.Blender_OPT._Simulation OR "gBlenderCIPMode" OR "HMI_Blender_Parameters".Processor_Options.Blender_OPT._FlowMeterType THEN
	    "gFTN301_Fault" := FALSE ;
	    "gFTN301_EPD" := FALSE ;
	    "gFTP302_Fault" := FALSE ;
	    "gFTP302_EPD" := FALSE ;
	    "gProductVFM_Fault" := FALSE ;
	    "gProductVFM_EPD" := FALSE ;
	END_IF;
	
	IF "HMI_Blender_Parameters".Processor_Options.Blender_OPT._Simulation OR "gBlenderCIPMode" OR NOT "HMI_Blender_Parameters".Processor_Options.Blender_OPT._CarboPresent OR "HMI_Blender_Parameters".Processor_Options.Blender_OPT._FlowMeterType THEN
	    "gFTM303_Fault" := FALSE ;
	    "gFTM303_EPD" := FALSE ;
	END_IF;
	
	
END_FUNCTION