15 KiB
15 KiB
// Block Type: FB
// Block Number: 1820
// Original Network Languages: LAD, STL
FUNCTION_BLOCK "System_Run_Out"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_STAT
mStepNum : Int;
mTimeStep : Int;
mTransition : Bool;
mReqONS : Bool;
mSystemRunOut_Abort : Bool;
mSystemRunOutInitONS : Bool;
mToggleLine : Bool;
mAuxToggleLine : Bool;
mSystemRunOutAux : Bool;
mSystemRunOutAux1 : Bool;
mSystemRunOut_AbortTONON : Bool;
mSwapSyrupLine_TONON : Bool;
mNextRecipeSel : Bool;
mEmptyString : String[32];
ProductAvailable : "ProductAvailable";
ProductPipeDrain : "ProductPipeDrain";
ProductPipeRunOut : "ProductPipeRunOut";
mSystemRunOut_AbortTON : "TON_TIME:v1.0";
mSwapSyrupLine_TON : "TON_TIME:v1.0";
mStep : Int;
mTime : Int;
mTransition_1 : Bool;
mNextRecipeNumber : Int;
mNextRecipeUpdate : Bool;
mNextRecipeBusy : Bool;
mNextRecipeUpdate_Aux : Bool;
mResetFP : Bool;
END_VAR
VAR_TEMP
mRET_VAL : Int;
mBusy : Bool;
mNextRecipeDB : "Any";
mRET_VAL_1 : Bool;
TUDT904 : "Recipe_Prod";
End_UDT904 : Byte;
Lenght_UDT904 : Int;
END_VAR
#_3S : Bool; // Auto-generated temporary
#_5S : Bool; // Auto-generated temporary
#TON_INSTANCE_28 : Bool; // Auto-generated temporary
#TON_INSTANCE_34 : Bool; // Auto-generated temporary
BEGIN
// Network 1: Qualifier (Original Language: LAD)
"System_RunOut_Variables"."System_RunOut"."Qualifier" := ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled" AND "gBlenderSuppliesOk" AND "gBlenderProdMode" AND "System_RunOut_Variables"."NextRecipeOk") OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled" AND "gBlenderSuppliesOk" AND "gBlenderProdMode" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe");
// Network 2: Request (Original Language: LAD)
// Edge Logic handled by Coil 26
"mReqONS" := "HMI_Variables_Cmd"."System_Run_Out"."CMD"."_SystemRunOutEnable"; // P_TRIG("HMI_Variables_Cmd"."System_Run_Out"."CMD"."_SystemRunOutEnable") - Mem: "mReqONS"
"System_RunOut_Variables"."System_RunOut"."Request" := "HMI_Variables_Cmd"."System_Run_Out"."CMD"."_SystemRunOutEnable" AND NOT "mReqONS";
"mReqONS" := "HMI_Variables_Cmd"."System_Run_Out"."CMD"."_SystemRunOutEnable"; // P_TRIG("HMI_Variables_Cmd"."System_Run_Out"."CMD"."_SystemRunOutEnable") - Mem: "mReqONS"
// Network 3: Enabled (Original Language: LAD)
"HMI_Variables_Status"."System_Run_Out"."SystemRunOutEnabled" := "System_RunOut_Variables"."System_RunOut"."Qualifier" AND "gBlenderProdMode" AND "System_RunOut_Variables"."System_RunOut"."Request" AND "HMI_Variables_Status"."System_Run_Out"."SystemRunOutEnabled";
// Network 4: DONT CHANGE THE POSITION IN ORDER TO PERFORM AT LEAST ONE CYCLE (Original Language: LAD)
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"System_RunOut_Variables"."FastChangeOverActivated" := FALSE;
END_IF;
// Network 5: Reset (Original Language: LAD)
"System_RunOut_Variables"."System_RunOut"."Reset" := ("System_RunOut_Variables"."System_RunOut"."Qualifier" AND "System_RunOut_Variables"."FastChangeOverActivated") OR ("System_RunOut_Variables"."System_RunOut"."Done" AND "System_RunOut_Variables"."FastChangeOverActivated");
// Network 6: Memories Reset (Original Language: LAD)
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"mStep" := 0;
"mTime" := 0;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"HMI_Variables_Status"."System_Run_Out"."SystemRunOutEnabled" := FALSE;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"mToggleLine" := FALSE;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"System_RunOut_Variables"."System_RunOut"."Done" := FALSE;
END_IF;
// PBox SymPy processed, logic in consumer
"mResetFP" := "System_RunOut_Variables"."System_RunOut"."Reset"; // P_TRIG("System_RunOut_Variables"."System_RunOut"."Reset") - Mem: "mResetFP"
IF "System_RunOut_Variables"."System_RunOut"."Reset" AND NOT "mResetFP" THEN
"mNextRecipeNumber" := 0;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" AND NOT "mResetFP" THEN
"HMI_Blender_Parameters"."Next_Recipe_Number" := 0;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" := FALSE;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"System_RunOut_Variables"."LoadNextRecipe" := FALSE;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"System_RunOut_Variables"."NextRecipeOk" := FALSE;
END_IF;
IF "System_RunOut_Variables"."System_RunOut"."Reset" THEN
"System_RunOut_Variables"."CheckNextRecipe" := FALSE;
END_IF;
// Network 7: Wait (Original Language: LAD)
"System_RunOut_Variables"."System_RunOut"."Wait" := "AUX FALSE";
// Network 8: Abort (Original Language: LAD)
// Pressing RESET Button AND THEN Press the Emergency Button, Cause System Run Out
// ABORT!!!!!
#TON_INSTANCE_28(IN := "gIN_ResetBtn", PT := T#5S); // TODO: Declarar #TON_INSTANCE_28 : TON;
"mSystemRunOut_Abort" := "gBlenderCIPMode" OR ("mSystemRunOut_AbortTONON" AND "gEmergencyPressed" AND #TON_INSTANCE_28.Q);
// Network 9: Latch (Original Language: LAD)
// Syrup Run Out Request Activate Sytem Run Out Sequences
"System_RunOut_Variables"."System_RunOut"."Latch" := ("System_RunOut_Variables"."System_RunOut"."Reset" AND "System_RunOut_Variables"."System_RunOut"."Done" AND "Procedure_Variables"."Syr_RunOut"."Request" AND "HMI_Variables_Status"."System_Run_Out"."SystemRunOutEnabled") OR ("System_RunOut_Variables"."System_RunOut"."Reset" AND "System_RunOut_Variables"."System_RunOut"."Done" AND "Procedure_Variables"."TM301_RunOut"."Request" AND "Blender_Variables_Pers"."gWaterRecipe" AND "HMI_Variables_Status"."System_Run_Out"."SystemRunOutEnabled");
// Network 10: Activated (Original Language: LAD)
"HMI_Alarms"."gH_Status" := "System_RunOut_Variables"."System_RunOut"."Latch";
IF "System_RunOut_Variables"."System_RunOut"."Latch" THEN
"System_RunOut_Variables"."FastChangeOverActivated" := TRUE;
END_IF;
// Network 11: Run Out Init (Original Language: LAD)
// Edge Logic handled by Coil 26
"mSystemRunOutInitONS" := "System_RunOut_Variables"."FastChangeOverActivated"; // P_TRIG("System_RunOut_Variables"."FastChangeOverActivated") - Mem: "mSystemRunOutInitONS"
"System_RunOut_Variables"."SystemRunOutInit" := "System_RunOut_Variables"."FastChangeOverActivated" AND NOT "mSystemRunOutInitONS";
"mSystemRunOutInitONS" := "System_RunOut_Variables"."FastChangeOverActivated"; // P_TRIG("System_RunOut_Variables"."FastChangeOverActivated") - Mem: "mSystemRunOutInitONS"
// Network 12: Running (Original Language: LAD)
"System_RunOut_Variables"."System_RunOut"."Running" := "System_RunOut_Variables"."System_RunOut"."Latch" AND "System_RunOut_Variables"."System_RunOut"."Wait";
// Network 13: Close Syrup Valves (Original Language: LAD)
IF "System_RunOut_Variables"."System_RunOut"."Request" OR ("gBlenderRinseMode" AND "System_RunOut_Variables"."FastChangeOverActivated") THEN
"System_RunOut_Variables"."CloseSyrupLineValves" := TRUE;
END_IF;
// Network 14: Close Syrup Valves (Original Language: LAD)
IF "Procedure_Variables"."FTP302Line_Preparation"."Request" OR "Procedure_Variables"."FTP302_StartUp"."Request" THEN
"System_RunOut_Variables"."CloseSyrupLineValves" := FALSE;
END_IF;
// Network 15: System Run Out Variables (Original Language: LAD)
"mAuxToggleLine" := ("HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine2Slctd" AND "mToggleLine") OR ("Procedure_Variables"."FTP302Line_Preparation"."Request" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_SwapSyrupLine" AND "mToggleLine" AND "System_RunOut_Variables"."FastChangeOverActivated");
// Network 16: System Run Out Variables (Original Language: LAD)
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" := FALSE;
END_IF;
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine2Slctd" := TRUE;
END_IF;
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"mToggleLine" := TRUE;
END_IF;
// Network 17: System Run Out Variables (Original Language: LAD)
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" := TRUE;
END_IF;
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine2Slctd" := FALSE;
END_IF;
IF "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "mToggleLine" AND "mAuxToggleLine" THEN
"mToggleLine" := TRUE;
END_IF;
// Network 18: Valve Line (Original Language: LAD)
"System_RunOut_Variables"."SyrupLine1_AVP364" := "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine1Slctd" AND "System_RunOut_Variables"."SyrupLine2_AVP365" AND "System_RunOut_Variables"."CloseSyrupLineValves" AND "gIN_SyrRoomOk";
// Network 19: Valve Line (Original Language: LAD)
"System_RunOut_Variables"."SyrupLine2_AVP365" := "HMI_Variables_Cmd"."GLOBAL_CMD"."_SyrLine2Slctd" AND "System_RunOut_Variables"."CloseSyrupLineValves" AND "gIN_SyrRoomOk" AND "System_RunOut_Variables"."SyrupLine1_AVP364";
// Network 20: System Run Not Selected (Original Language: LAD)
#TON_INSTANCE_34(IN := "AUX FALSE" AND "Blender_Variables_Pers"."gWaterRecipe" AND "System_RunOut_Variables"."SyrupLine2_AVP365" AND "System_RunOut_Variables"."SyrupLine1_AVP364", PT := T#3S); // TODO: Declarar #TON_INSTANCE_34 : TON;
"gSyrupLineNotSelected" := "gBlenderCIPMode" AND "System_RunOut_Variables"."CloseSyrupLineValves" AND "gWorkshopTest" AND #TON_INSTANCE_34.Q;
// Network 21: Product Available (Original Language: LAD)
"ProductAvailable"();
// Network 22: Product Pipe Drain (Original Language: LAD)
"ProductPipeDrain"();
// Network 23: Product Pipe Run Out (Original Language: LAD)
"ProductPipeRunOut"();
// Network 24: Rinse Step Sequence (Original Language: LAD)
"gSyrupQcoRinse" := ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled" AND "gSyrupQcoRinse" AND "Procedure_Variables"."Syr_RunOut"."Done" AND "Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone") OR ("HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled" AND "Blender_Variables_Pers"."gWaterRecipe" AND "Procedure_Variables"."Syr_RunOut"."Done" AND "Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" AND "System_RunOut_Variables"."FastChangeOverActivated");
// Network 25: IF CHANGE FROM WATER RECIPE TO SYRUP RECIPE FORCE RINSE COMPLETE (Original Language: LAD)
IF "HMI_Blender_Parameters"."Processor_Options"."Blender_OPT"."_FastChangeOverEnabled" AND "Blender_Variables_Pers"."gWaterRecipe" AND "gSyrupQcoRinse" AND "System_RunOut_Variables"."NextRecipeOk" AND "Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" AND "System_RunOut_Variables"."FastChangeOverActivated" THEN
"Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" := TRUE;
END_IF;
// Network 26: CHANGE OVER COMPLETED (Original Language: LAD)
"System_RunOut_Variables"."System_RunOut"."Done" := ("Blender_Variables_Pers"."gWaterRecipe" AND "System_RunOut_Variables"."System_RunOut"."Latch" AND "Procedure_Variables"."Blender_Rinse"."Done" AND "System_RunOut_Variables"."NextRecipeOk" AND "Procedure_Variables"."TM301_RunOut"."Done" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done") OR ("Blender_Variables_Pers"."gWaterRecipe" AND "System_RunOut_Variables"."System_RunOut"."Latch" AND "Procedure_Variables"."Blender_Rinse"."Done" AND "Procedure_Variables"."TM301_RunOut"."Done" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe") OR ("System_RunOut_Variables"."System_RunOut"."Latch" AND "Procedure_Variables"."Blender_Rinse"."Done" AND "System_RunOut_Variables"."NextRecipeOk" AND "Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" AND "Procedure_Variables"."TM301_RunOut"."Done" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done") OR ("System_RunOut_Variables"."System_RunOut"."Latch" AND "Procedure_Variables"."Blender_Rinse"."Done" AND "Procedure_Variables"."Syr_RunOut"."FastChangeOverRinseDone" AND "Procedure_Variables"."TM301_RunOut"."Done" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe");
// Network 27: LOAD NEXT RECIPE (Original Language: LAD)
IF "System_RunOut_Variables"."NextRecipeOk" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "System_RunOut_Variables"."LoadNextRecipe" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" AND "System_RunOut_Variables"."FastChangeOverActivated" THEN
"System_RunOut_Variables"."CheckNextRecipe" := TRUE;
END_IF;
IF "System_RunOut_Variables"."NextRecipeOk" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "System_RunOut_Variables"."LoadNextRecipe" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" AND "System_RunOut_Variables"."FastChangeOverActivated" THEN
"System_RunOut_Variables"."LoadNextRecipe" := FALSE;
END_IF;
IF "System_RunOut_Variables"."NextRecipeOk" AND "System_RunOut_Variables"."ProdPipe_RunOut"."Done" AND "System_RunOut_Variables"."LoadNextRecipe" AND "HMI_Variables_Cmd"."GLOBAL_CMD"."_EnableNextRecipe" AND "System_RunOut_Variables"."FastChangeOverActivated" THEN
"System_RunOut_Variables"."NextRecipeOk" := FALSE;
END_IF;
// Network 28: NEXT RECIPE MANAGEMENT (Original Language: STL)
// --- BEGIN STL Network 28 ---
A "HMI_Variables_Cmd".GLOBAL_CMD._EnableNextRecipe
JC M201
L 0
T "HMI_Blender_Parameters".Next_Recipe_Number
T "mNextRecipeNumber"
SET
R "mNextRecipeSel"
R "System_RunOut_Variables".CheckNextRecipe
R "System_RunOut_Variables".LoadNextRecipe
R "System_RunOut_Variables".NextRecipeOk
JU M299
M201: L "HMI_Blender_Parameters".Next_Recipe_Number
L 0
LE_I
R "mNextRecipeSel"
JCN M202
L 0
T "System_RunOut_Variables".gNext_Recipe._BottleShape
CALL _Call_?
CALL _Call_?
JU M299
M202: CALL "LIMIT_I"
L "mNextRecipeNumber"
L "HMI_Blender_Parameters".Next_Recipe_Number
NE_I
= "mNextRecipeUpdate"
A "mNextRecipeUpdate"
O "mNextRecipeBusy"
O "System_RunOut_Variables".CheckNextRecipe
JCN M299
T "mNextRecipeNumber"
L _ERR_CONST_
L _ERR_CONST_
SUB_D
SRD 3
T "Lenght_UDT904"
LAR1 _ERR_CONST_
L BYTE#16#10
T LocalB[AR1,P#0.0]
L BYTE#16#02
T LocalB[AR1,P#1.0]
L "Lenght_UDT904"
T LocalW[AR1,P#2.0]
L "mNextRecipeNumber"
L 400
ADD_I
T LocalW[AR1,P#4.0]
L P#DBX0.0
T LocalD[AR1,P#6.0]
CALL _Call_?
A "mNextRecipeBusy"
JC M299
CALL _Call_?
CALL _Call_?
L "System_RunOut_Variables".gNext_Recipe._Type
L 0
GT_I
A "mRET_VAL_1"
= "mNextRecipeSel"
A "System_RunOut_Variables".CheckNextRecipe
R "System_RunOut_Variables".CheckNextRecipe
S "System_RunOut_Variables".LoadNextRecipe
M299: NOP_0
// --- END STL Network 28 ---
END_FUNCTION_BLOCK