417 lines
12 KiB
XML
417 lines
12 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1">
|
|
<POU Name="FB_PackMLGeneric" Id="{f562a10e-01bc-407d-9fc0-2837d13c10b1}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK FB_PackMLGeneric
|
|
VAR_INPUT
|
|
stCommand : ST_PMLc;
|
|
END_VAR
|
|
VAR_OUTPUT
|
|
// Unit status
|
|
stStatus : ST_PMLs;
|
|
|
|
// Admin data
|
|
stAdmin : ST_PMLa;
|
|
END_VAR
|
|
VAR_IN_OUT
|
|
//stHMIInterface : ST_PackMLGenericHMIInterface;
|
|
END_VAR
|
|
VAR
|
|
// State machine handler
|
|
_fbStateMachine : FB_PackMLStateMachine;
|
|
|
|
// State machine config
|
|
_stSMConfig : ST_PackMLStateMachineConfig;
|
|
|
|
// Internal unit command
|
|
_eCmd : E_PackMLCmd;
|
|
|
|
// Internal unit mode
|
|
_eMode : E_PackMLUnitMode;
|
|
|
|
// Internal unit state
|
|
_eState : E_PackMLState;
|
|
|
|
// Last state
|
|
_eLastState : E_PackMLState;
|
|
|
|
// Current recipe
|
|
_stRecipe : ST_PackMLRecipe;
|
|
|
|
// Trigger for new command
|
|
_rtChangeCmdRequest : R_TRIG;
|
|
|
|
// Trigger for new mode
|
|
_rtChangeModeRequest : R_TRIG;
|
|
|
|
// Trigger change recipe
|
|
_rtChangeRecipeRequest : R_TRIG;
|
|
|
|
// State state machine variable
|
|
_iSSM : INT := 0;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Handle command change request
|
|
_rtChangeCmdRequest(CLK:= stCommand.xCmdChangeRequest);
|
|
|
|
IF _rtChangeCmdRequest.Q THEN
|
|
_eCmd := stCommand.eCntrlCmd;
|
|
END_IF
|
|
|
|
// Hande mode change request
|
|
_rtChangeModeRequest(CLK := stCommand.xUnitModeChangeRequest);
|
|
|
|
IF _rtChangeModeRequest.Q THEN
|
|
_eMode := stCommand.eUnitMode;
|
|
END_IF
|
|
|
|
// Handle recipe change rewuest
|
|
_rtChangeRecipeRequest(CLK := stCommand.xRecipeChangeRequest);
|
|
|
|
IF _rtChangeRecipeRequest.Q THEN
|
|
_stRecipe := stCommand.astRecipe[stCommand.diSelectedRecipe];
|
|
END_IF
|
|
|
|
// Call PackML state machine handler
|
|
_fbStateMachine(
|
|
eMode:= _eMode,
|
|
eCmd:= _eCmd,
|
|
stConfig := _stSMConfig,
|
|
eState=> stStatus.eStateCurrent,
|
|
eCurrentMode => stStatus.eUnitModeCurrent,
|
|
xError=> );
|
|
|
|
// Reset state state machine
|
|
IF _eLastState <> stStatus.eStateCurrent THEN
|
|
_iSSM := 0;
|
|
_eLastState := stStatus.eStateCurrent;
|
|
END_IF
|
|
|
|
|
|
// Call state method according to current state
|
|
CASE stStatus.eStateCurrent OF
|
|
E_PackMLState.CLEARING:
|
|
M_Clearing();
|
|
|
|
E_PackMLState.STOPPED:
|
|
M_Stopped();
|
|
|
|
E_PackMLState.STARTING:
|
|
M_Starting();
|
|
|
|
E_PackMLState.IDLE:
|
|
M_Idle();
|
|
|
|
E_PackMLState.SUSPENDED:
|
|
M_Suspended();
|
|
|
|
E_PackMLState.EXECUTE:
|
|
M_Execute();
|
|
|
|
E_PackMLState.STOPPING:
|
|
M_Stopping();
|
|
|
|
E_PackMLState.ABORTING:
|
|
M_Aborting();
|
|
|
|
E_PackMLState.ABORTED:
|
|
M_Aborted();
|
|
|
|
E_PackMLState.HOLDING:
|
|
M_Holding();
|
|
|
|
E_PackMLState.HELD:
|
|
M_Held();
|
|
|
|
E_PackMLState.UNHOLDING:
|
|
M_Unholding();
|
|
|
|
E_PackMLState.SUSPENDING:
|
|
M_Suspending();
|
|
|
|
E_PackMLState.UNSUSPENDING:
|
|
M_Unsuspending();
|
|
|
|
E_PackMLState.RESETTING:
|
|
M_Resetting();
|
|
|
|
E_PackMLState.COMPLETING:
|
|
M_Completing();
|
|
|
|
E_PackMLState.COMPLETED:
|
|
M_Complete();
|
|
|
|
ELSE
|
|
|
|
;
|
|
END_CASE]]></ST>
|
|
</Implementation>
|
|
<Folder Name="Commands" Id="{11740802-7551-418d-83f3-5b2d5c93c299}" />
|
|
<Folder Name="States" Id="{2cf25144-1e5c-4db8-ba57-9d98461c53ce}" />
|
|
<Action Name="A_HandleHMIOutput" Id="{73c47dbe-0382-4e83-8c9e-e4744dd66394}">
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Action>
|
|
<Method Name="M_Abort" Id="{a8ac7d94-0639-4bcc-b083-994135ce6951}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Abort : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF (stStatus.eStateCurrent <> E_PackMLState.ABORTED) AND (stStatus.eStateCurrent <> E_PackMLState.ABORTING) THEN
|
|
_eCmd := E_PackMLCmd.ABORT;
|
|
M_Abort := TRUE;
|
|
ELSE
|
|
M_Abort := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Aborted" Id="{db1a684f-e4e1-4d89-a3aa-9b9dfde0508c}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Aborted
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Aborting" Id="{928ad614-a3a7-4c6c-b1bc-55ae54e4c95f}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Aborting
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Clear" Id="{1ae1174f-acb8-4f8a-bc73-ec233f6637b2}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Clear : BOOL
|
|
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF stStatus.eStateCurrent = E_PackMLState.ABORTED THEN
|
|
_eCmd := E_PackMLCmd.CLEAR;
|
|
M_Clear := TRUE;
|
|
ELSE
|
|
M_Clear := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Clearing" Id="{1716cf1b-94c6-4995-8b3f-c7ebcf5727d3}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Clearing
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Complete" Id="{33df5dea-d83b-48e1-8898-d7c8e1f031bd}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Complete
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Completing" Id="{341608cb-1218-481f-929c-cb79602c11ab}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Completing
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Execute" Id="{2a469169-0eb2-43c9-be21-48909285ee44}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Execute
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Held" Id="{05b040b0-b1b9-4afd-81d0-88fc1f1a7f9b}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Held
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Hold" Id="{63908543-c84a-46a6-803b-0cd0a69ee040}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Hold : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF (stStatus.eStateCurrent = E_PackMLState.EXECUTE) OR (stStatus.eStateCurrent = E_PackMLState.SUSPENDED) THEN
|
|
_eCmd := E_PackMLCmd.HOLD;
|
|
M_Hold := TRUE;
|
|
ELSE
|
|
M_Hold := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Holding" Id="{519b03b3-2409-4b45-818f-535b3e16b22e}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Holding
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Idle" Id="{aa784f5c-7adf-4c9f-a414-65b10afd2772}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Idle
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Reset" Id="{9acdfbad-6477-4a07-aac5-b9a102467964}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Reset : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF stStatus.eStateCurrent = E_PackMLState.STOPPED THEN
|
|
_eCmd := E_PackMLCmd.RESET;
|
|
M_Reset := TRUE;
|
|
ELSE
|
|
M_Reset := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Resetting" Id="{4050ed6f-edbe-4c3e-ac42-919a37a47ea9}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Resetting
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Start" Id="{86eb6432-588a-4480-b09e-72e5733dc716}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Start : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF stStatus.eStateCurrent = E_PackMLState.IDLE THEN
|
|
_eCmd := E_PackMLCmd.RESET;
|
|
M_Start := TRUE;
|
|
ELSE
|
|
M_Start := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Starting" Id="{0059e7f6-5f2a-40e4-9d9b-652f221495a9}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Starting
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_StateComplete" Id="{0cf3625e-8009-4108-a9f4-d98c991f9930}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_StateComplete
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Reset state state machine
|
|
_iSSM := 0;
|
|
|
|
// Call state change in PackML state manager
|
|
_fbStateMachine.M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Stop" Id="{8beef0bf-5aa2-4644-ae54-6acbcdaacef4}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Stop : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF (stStatus.eStateCurrent <> E_PackMLState.ABORTED)
|
|
AND (stStatus.eStateCurrent <> E_PackMLState.ABORTING)
|
|
AND (stStatus.eStateCurrent <> E_PackMLState.CLEARING)
|
|
AND (stStatus.eStateCurrent <> E_PackMLState.STOPPING)
|
|
AND (stStatus.eStateCurrent <> E_PackMLState.STOPPED)
|
|
THEN
|
|
_eCmd := E_PackMLCmd.STOP;
|
|
M_Stop := TRUE;
|
|
ELSE
|
|
M_Stop := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Stopped" Id="{9f8a09cf-f3be-4d60-b5e4-cd9572fae88c}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Stopped
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Stopping" Id="{193565ef-cf20-428c-b726-e7c1b61375c5}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Stopping
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Suspend" Id="{a69941cd-31ee-44b4-9c8b-a7c774e40447}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Suspend : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF stStatus.eStateCurrent = E_PackMLState.EXECUTE THEN
|
|
_eCmd := E_PackMLCmd.SUSPEND;
|
|
M_Suspend := TRUE;
|
|
ELSE
|
|
M_Suspend := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Suspended" Id="{222c3ad7-f7d5-4773-8e98-863345472053}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Suspended
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Suspending" Id="{0f5d52e2-2a54-4ea9-a0c4-7f08229c4f21}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Suspending
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Unhold" Id="{6af8dbfd-0422-459a-b99f-09e9246d2621}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Unhold : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF (stStatus.eStateCurrent = E_PackMLState.HELD) THEN
|
|
_eCmd := E_PackMLCmd.UNSUSPEND;
|
|
M_Unhold := TRUE;
|
|
ELSE
|
|
M_Unhold := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Unholding" Id="{662dd054-329b-4e57-ba77-486f92af795a}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Unholding
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Unsuspend" Id="{ff6f4f4b-4bc6-47f7-a257-a2bcea2d6ae3}" FolderPath="Commands\">
|
|
<Declaration><![CDATA[METHOD M_Unsuspend : BOOL
|
|
VAR_INPUT
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[IF (stStatus.eStateCurrent = E_PackMLState.SUSPENDED) THEN
|
|
_eCmd := E_PackMLCmd.UNSUSPEND;
|
|
M_Unsuspend := TRUE;
|
|
ELSE
|
|
M_Unsuspend := FALSE;
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Method Name="M_Unsuspending" Id="{80fb11c4-916a-4f8f-9cf9-b9a2d51524a1}" FolderPath="States\">
|
|
<Declaration><![CDATA[METHOD PROTECTED M_Unsuspending
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[M_StateComplete();]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
</POU>
|
|
</TcPlcObject> |