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

4.2 KiB

FUNCTION "RecipeCalculation" : Void
{ S7_Optimized_Access := 'FALSE' }
AUTHOR : 'Author'
NAME : 'Name'
VERSION : 1.0
   VAR_TEMP 
      mAuxONS_Q : Bool;
      mSyrPerc : Real;
   END_VAR


BEGIN
	
	
	"ONS_R"(Enable_ONS := "HMI_Variables_Cmd".Recipe.Page_Running,  
	    Aux_ONS := "mRecipeCalculationONS",
	    ONS_R => #mAuxONS_Q );  
	
	//Syrup Brix
	IF NOT "HMI_Variables_Cmd".Recipe.Get_current_Active_Recip AND "Blender_Variables_Pers".SyrupBrix_Aux<>"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix 
	    AND "HMI_Variables_Cmd".Recipe.Page_Running AND NOT #mAuxONS_Q THEN
	    (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupDensity := 100/(("HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix/1.589+100)-"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix);*)
	    "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupDensity := 100/(("HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix/REAL#1.589+100)-"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix);
	END_IF;
	
	IF "HMI_Variables_Cmd".Recipe.Page_Running THEN
	    "Blender_Variables_Pers".SyrupBrix_Aux := "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix ;
	END_IF ;
	
	// Prod Brix Offset - Prod Brix - Ratio
	IF "HMI_Recipe_Edit".Actual_Recipe_Parameters._Type = 2 THEN
	    IF "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix <> 0 AND "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupFactor <> 0 THEN
	        #mSyrPerc := ("HMI_Recipe_Edit".Actual_Recipe_Parameters._ProductBrix+"HMI_Recipe_Edit".Actual_Recipe_Parameters._ProdBrixOffset)/
	            ("HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix*"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupFactor) ;
	        "HMI_Recipe_Edit".Actual_Recipe_Parameters._Ratio := (1/#mSyrPerc-1)*"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupDensity ;
	    END_IF;
	END_IF;
	IF "HMI_Recipe_Edit".Actual_Recipe_Parameters._Type = 3 THEN
	    "HMI_Recipe_Edit".Actual_Recipe_Parameters._ProductBrix := "HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupBrix*"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupDensity/
	        ("HMI_Recipe_Edit".Actual_Recipe_Parameters._Ratio+"HMI_Recipe_Edit".Actual_Recipe_Parameters._SyrupDensity)+"HMI_Recipe_Edit".Actual_Recipe_Parameters._ProdBrixOffset ;
	END_IF;
	
	IF ("HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Vols * "Blender_Variables".gFirstProdExtraCO2Fact * "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Fact) > 0  THEN
	    "HMI_Variables_Status".Analog_Values.EqPressure := "Blender_Variables".gCO2EqPressure  (*"CO2EqPress"(i_CO2Vol := "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Vols * "Blender_Variables".gFirstProdExtraCO2Fact
	                                                                            * "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Fact ,
	                                                                  i_Temp   := "HMI_Recipe_Edit".Actual_Recipe_Parameters._SP_ProdTemp )*);
	ELSE
	    (* classic code: "HMI_Variables_Status".Analog_Values.EqPressure := 0.0;*)
	    "HMI_Variables_Status".Analog_Values.EqPressure := REAL#0.0;
	END_IF;
	
	IF "HMI_Blender_Parameters".Processor_Options.Blender_OPT._CO2_GAS2_Injection THEN
	    IF "HMI_Recipe_Edit".Actual_Recipe_Parameters._GAS2_Injection THEN
	        (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Vols := 0.0 ;*)
	        "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Vols := REAL#0.0 ;
	        (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Fact := 0.0 ;*)
	        "HMI_Recipe_Edit".Actual_Recipe_Parameters._CO2Fact := REAL#0.0 ;     
	    ELSE
	        (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Vols := 0.0 ;*)
	        "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Vols := REAL#0.0 ;
	        (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Fact := 0.0 ;*)
	        "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Fact := REAL#0.0 ;     
	    END_IF;
	ELSE
	    (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Vols := 0.0 ;*)
	    "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Vols := REAL#0.0 ;
	    (* classic code: "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Fact := 0.0 ;*)
	    "HMI_Recipe_Edit".Actual_Recipe_Parameters._Gas2Fact := REAL#0.0 ;     
	END_IF ;
	
	
END_FUNCTION