Obsidean_VM/04-SIDEL/00 - MASTER/Source/source/ProcedureSyrupLineMFMPrep.md

11 KiB

// Block Type: FB
// Block Number: 1810
// Original Network Languages: LAD, STL

FUNCTION_BLOCK "ProcedureSyrupLineMFMPrep"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1

VAR_STAT
  mStepNum : Int;
  mTimeStep : Int;
  Real_Time : Time;
  mTransition : Bool;
  mSyrLineMFMPrepONS : Bool;
  mSyrupLineManualDrainSR : Bool;
  mFTP302_PrepReqTPON : Bool;
  mFTP302_PrepReqTP1ON : Bool;
  mDelayON_StopPumpON : Bool;
  mDelayON_SyrupMinON : Bool;
  mDelayON_PumpStatusON : Bool;
  mHVP301_TONON : Bool;
  mFTP302_Prep_TimeOutON : Bool;
  mFTP302_PrepReqTP : "TP_TIME:v1.0";
  mFTP302_PrepReqTP1 : "TP_TIME:v1.0";
  mDelayON_StopPump : "TON_TIME:v1.0";
  mDelayON_SyrupMin : "TON_TIME:v1.0";
  mDelayON_PumpStatus : "TON_TIME:v1.0";
  mHVP301_TON : "TON_TIME:v1.0";
  mFTP302_Prep_TimeOut : "TON_TIME:v1.0";
END_VAR

VAR_TEMP
  mDummy : Bool;
  mAux1 : Real;
  mAux2 : Real;
  mTimeOutElapsed : Bool;
  mStopPumpP2 : Bool;
  mSyrMinLevel : Bool;
  mPumpP2Running : Bool;
  mWaterCountAcheaved : Bool;
  mSyrupLineManualDrained : Bool;
  mFuzzyNetOut : Bool;
  Out_Time_DI : DInt;
  Real_Time_S5 : S5Time;
  mProcSlctd : Bool;
  mFuzzyNetAdd1 : Real;
  mFuzzyNetAdd2 : Real;
  mFuzzyNetAdd3 : Real;
  mSyrBrixAux : Real;
  mSyrBrixAux_1 : Real;
  __PlcmigTempFillBits_40B0 : Array[0..7] of Bool;
END_VAR

  #_4S : Bool; // Auto-generated temporary
  #_4S_600MS : Bool; // Auto-generated temporary
  #_500MS : Bool; // Auto-generated temporary
  #_5S : Bool; // Auto-generated temporary
  #TON_INSTANCE_25 : Bool; // Auto-generated temporary
  #TON_INSTANCE_27 : Bool; // Auto-generated temporary
  #TON_INSTANCE_28 : Bool; // Auto-generated temporary
  #TON_INSTANCE_29 : Bool; // Auto-generated temporary
BEGIN

  // Network 1: Qualifier (Original Language: LAD)

  "Procedure_Variables"."FTP302Line_Preparation"."Qualifier" := ("gBlenderProdMode" AND "gBlenderSuppliesOk" AND "Blender_Variables_Pers"."gWaterRecipe" AND "gBlenderRinseMode") OR ("gBlenderProdMode" AND "gBlenderSuppliesOk" AND "Blender_Variables_Pers"."gWaterRecipe" AND "System_RunOut_Variables"."FastChangeOverActivated");

  // Network 2: Request (Original Language: LAD)

  "Procedure_Variables"."FTP302Line_Preparation"."Request" := ("mFTP302_PrepReqTP1ON" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch") OR ("HMI_Variables_Cmd"."Commands_From_HMI"."CMD_FTP302Line_Prep" AND "Procedure_Variables"."FTP302Line_Preparation"."Qualifier" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch");

  // Network 3: Reset (Original Language: LAD)

  // PBox SymPy processed, logic in consumer
  "mSyrLineMFMPrepONS" := "Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Request" AND "Procedure_Variables"."Blender_Run"."Latch" AND "System_RunOut_Variables"."FastChangeOverActivated"; // P_TRIG("Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Request" AND "Procedure_Variables"."Blender_Run"."Latch" AND "System_RunOut_Variables"."FastChangeOverActivated") - Mem: "mSyrLineMFMPrepONS"

  "Procedure_Variables"."FTP302Line_Preparation"."Reset" := "gBlenderCIPMode" OR ("gBlenderRinseMode" AND "System_RunOut_Variables"."FastChangeOverActivated");

  // Network 4: Reset (Original Language: LAD)

  IF "Procedure_Variables"."FTP302Line_Preparation"."Reset" THEN
    "mStepNum" := 0;
  END_IF;

  IF "Procedure_Variables"."FTP302Line_Preparation"."Reset" THEN
    "Procedure_Variables"."FTP302Line_Preparation"."Done" := FALSE;
  END_IF;

  IF "Procedure_Variables"."FTP302Line_Preparation"."Reset" THEN
    "mWaterCountAcheaved" := FALSE;
  END_IF;

  // Network 5: Wait (Original Language: LAD)

  "Procedure_Variables"."FTP302Line_Preparation"."Wait" := "HMI_Digital"."_PAL_S11"."Filtered" OR "HMI_Device"."PPP302"."Alarm";

  // Network 6: Latch (Original Language: LAD)

  "Procedure_Variables"."FTP302Line_Preparation"."Latch" := ("Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Request" AND "Procedure_Variables"."FTP302Line_Preparation"."Reset" AND "FirstScan") OR ("Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Reset" AND "FirstScan" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch");

  IF ("Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Request" AND "Procedure_Variables"."FTP302Line_Preparation"."Reset" AND "FirstScan") OR ("Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Procedure_Variables"."FTP302Line_Preparation"."Reset" AND "FirstScan" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch") THEN
    "HMI_Variables_Status"."Procedures"."BlenderStateNum" := 3;
  END_IF;

  // Network 7: Running (Original Language: LAD)

  "Procedure_Variables"."FTP302Line_Preparation"."Running" := "Procedure_Variables"."FTP302Line_Preparation"."Wait" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 8: #Out_Time_DI (Original Language: LAD)

  "mAux1" := "Blender_Variables"."gMinProduction" / 6.0;

  SEL_R(G := Ne("mAux1", 0.0), IN0 := 1.0, IN1 := "mAux1");

  "mAux2" := "HMI_Blender_Parameters"."ProcessSetup"."_SyrupRunOutLiters" * 1.5;

  "mAux1" := "mAux2" / "mAux1";

  // Network 9: Conversion in Real (Original Language: STL)
  //   #Out_Time_DI (DINT) converted in #Real_Time_S5 (Time) 
  //   Use  L#1000 IF  #Out_Time_DI  is in ms

  // --- BEGIN STL Network 9 ---
   
     	L	"Out_Time_DI"
     	L	DINT#1000
     	MUL_D
     	T	"Real_Time"
   
  // --- END STL Network 9 ---

  // Network 10: TimeOut On (Original Language: LAD)

  #TON_INSTANCE_27(IN := "Procedure_Variables"."FTP302Line_Preparation"."Latch", PT := "Real_Time"); // TODO: Declarar #TON_INSTANCE_27 : TON;

  "mFTP302_Prep_TimeOutON" := #TON_INSTANCE_27.Q;

  "mTimeOutElapsed" := "mFTP302_Prep_TimeOutON" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 11: DelayON_StopPump (Original Language: LAD)

  #TON_INSTANCE_29(IN := "gIN_SyrTank_MinLvl" AND "DI_Min_Syrup_Level", PT := T#4S_600MS); // TODO: Declarar #TON_INSTANCE_29 : TON;

  "mDelayON_StopPumpON" := #TON_INSTANCE_29.Q;

  "mStopPumpP2" := "gIN_SyrTank_MinLvl" AND "DI_Min_Syrup_Level" AND "mDelayON_StopPumpON";

  // Network 12: DelayON_SyrupMin (Original Language: LAD)

  #TON_INSTANCE_27(IN := "DI_Min_Syrup_Level", PT := T#500MS); // TODO: Declarar #TON_INSTANCE_27 : TON;

  "mSyrMinLevel" := "gIN_SyrTank_MinLvl" OR ("mDelayON_SyrupMinON" AND #TON_INSTANCE_27.Q);

  // Network 13: DelayON_PumpStatus (Original Language: LAD)

  #TON_INSTANCE_25(IN := "HMI_Device"."PPP302"."Out", PT := T#4S); // TODO: Declarar #TON_INSTANCE_25 : TON;

  "mPumpP2Running" := #TON_INSTANCE_25.Q;

  // Network 14: SyrupLineManualDrain (Original Language: LAD)

  #TON_INSTANCE_28(IN := "gIN_HVP301_Aux", PT := T#5S); // TODO: Declarar #TON_INSTANCE_28 : TON;

  // Network 15: HMI Variables Cmd (Original Language: LAD)

  "mSyrupLineManualDrained" := "gIN_HVP301_Aux" AND "mSyrupLineManualDrainSR" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 16: Count Limit (Original Language: LAD)

  IF "Procedure_Variables"."FTP302Line_Preparation"."Latch" THEN
    "Blender_Variables_Pers"."gSyrLinePrepCountInit" := "Profibus_Variables"."gFTP302_Tot";
  END_IF;

  // Network 17: Brix Threshold (Original Language: LAD)

  "mSyrBrixAux" := "HMI_Blender_Parameters"."Actual_Recipe_Parameters"."_SyrupBrix" * "HMI_Blender_Parameters"."ProcessSetup"."_PercSyrupBrixSyrStarUp";

  "mSyrBrixAux_1" := "mSyrBrixAux" / 100.0;

  "Blender_Constants"."gSugaredSyrupBrixThrsd" := "mSyrBrixAux_1";

  // Network 18: Fuzzy Net (Original Language: STL)

  // --- BEGIN STL Network 18 ---
   
     	O_BRACK
     	AN	"Blender_Variables_Pers".gSugarBeverage
     	A	"gPV_SyrDensOk"
     	A	"mPumpP2Running"
     	=	"__PlcmigTempFillBits_40B0"[0]
     	BLD	103
     	CALL	"SEL_R"
     	A	_Statusword_?
     	BRACKET
     	O_BRACK
     	A_BRACK
     	L	"Profibus_Variables".gFTP302_Brix
     	L	"HMI_Blender_Parameters".Actual_Recipe_Parameters._SyrupFactor
     	MUL_R
     	T	"mAux1"
     	AN	_Statusword_?
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	A_BRACK
     	L	"mAux1"
     	L	"Blender_Constants".gSugaredSyrupBrixThrsd
     	GT_R
     	BRACKET
     	A	"mPumpP2Running"
     	=	"__PlcmigTempFillBits_40B0"[0]
     	BLD	103
     	CALL	"SEL_R"
     	A	_Statusword_?
     	BRACKET
     	O_BRACK
     	A_BRACK
     	L	"Profibus_Variables".gFTP302_Tot
     	L	"Blender_Variables_Pers".gSyrLinePrepCountInit
     	SUB_R
     	T	"mAux1"
     	AN	_Statusword_?
     	SAVE
     	CLR
     	A	_Statusword_?
     	BRACKET
     	A_BRACK
     	L	"mAux1"
     	L	"HMI_Blender_Parameters".ProcessSetup._SyrupRunOutLiters
     	GE_R
     	BRACKET
     	=	"mWaterCountAcheaved"
     	A	"mWaterCountAcheaved"
     	A	"HMI_Device".PPP302.Out
     	=	"__PlcmigTempFillBits_40B0"[0]
     	BLD	103
     	CALL	"SEL_R"
     	A	_Statusword_?
     	BRACKET
     	=	"mDummy"
   
  // --- END STL Network 18 ---

  // Network 19: Fuzzy Net (Original Language: LAD)

  "mFuzzyNetAdd1" := "mFuzzyNetAdd1" + "mFuzzyNetAdd2";

  "mFuzzyNetAdd1" := "mFuzzyNetAdd1" + "mFuzzyNetAdd3";

  "mFuzzyNetOut" := "Procedure_Variables"."FTP302Line_Preparation"."Latch" AND ("mFuzzyNetAdd1" > 100.0);

  // Network 20: Opeartor Run Syrup Prep (Original Language: LAD)

  "HMI_Alarms"."gH_Message" := "gBlenderProdMode" AND "Procedure_Variables"."FTP302Line_Preparation"."Done" AND "Blender_Variables_Pers"."gWaterRecipe" AND "Procedure_Variables"."FTP302_StartUp"."Latch" AND "gBlenderRinseMode" AND "System_RunOut_Variables"."FastChangeOverActivated" AND "Procedure_Variables"."FTP302Line_Preparation"."Qualifier" AND "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 21: Syrup Tank Prep Running (Original Language: LAD)
  //   Syrup Tank Prep Running Message

  "HMI_Variables_Status"."Procedures"."TP301PrepRun" := "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 22: Syrup Tank Prep Running (Original Language: LAD)
  //   Syrup Tank Prep Running Message

  "HMI_Alarms"."gH_Status" := "Procedure_Variables"."FTP302_StartUp"."Latch" OR "Procedure_Variables"."FTP302Line_Preparation"."Latch";

  // Network 23: Syrup Preparation Sequence (Original Language: LAD)

  IF "Procedure_Variables"."FTP302Line_Preparation"."Running" THEN
    Syrup_Line_MFM_Prep_Seq(FuzzyNetOut := "mFuzzyNetOut", SyrupLineManualDrained := "mSyrupLineManualDrained", WaterCountAcheaved := "mWaterCountAcheaved", mStep := "mStepNum", mStopPumpP2 := "mStopPumpP2", mSyrMinLevel := "mDelayON_SyrupMinON", mTimer := "mTimeStep", mTransition := "mTransition");
  END_IF;

  // Network 24: Preparation Done (Original Language: LAD)

  "HMI_Variables_Status"."System_Run_Out"."TP301PrepDone" := "Procedure_Variables"."FTP302Line_Preparation"."Done";

END_FUNCTION_BLOCK