Started kuka robot integration with hardware
- Modified PackML state machine to be able to disable unused states - Added PackTag datatypes for recipe handling - Started recipe parameter description in json file - Added schema file for recipe json - Added state machine drawing for packml
This commit is contained in:
277
PLC/LibraryCandidates/PackML/POUs/FB_PackMLGeneric.TcPOU
Normal file
277
PLC/LibraryCandidates/PackML/POUs/FB_PackMLGeneric.TcPOU
Normal file
@@ -0,0 +1,277 @@
|
||||
<?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 IMPLEMENTS I_UnitState
|
||||
VAR_INPUT
|
||||
stCommand : ST_PMLc;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
// Unit status
|
||||
stStatus : ST_PMLs;
|
||||
|
||||
// Admin data
|
||||
stAdmin : ST_PMLa;
|
||||
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>
|
||||
<Method Name="M_Aborted" Id="{db1a684f-e4e1-4d89-a3aa-9b9dfde0508c}">
|
||||
<Declaration><![CDATA[METHOD M_Aborted
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Aborting" Id="{928ad614-a3a7-4c6c-b1bc-55ae54e4c95f}">
|
||||
<Declaration><![CDATA[METHOD M_Aborting
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Clearing" Id="{1716cf1b-94c6-4995-8b3f-c7ebcf5727d3}">
|
||||
<Declaration><![CDATA[METHOD M_Clearing
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Complete" Id="{33df5dea-d83b-48e1-8898-d7c8e1f031bd}">
|
||||
<Declaration><![CDATA[METHOD M_Complete
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Completing" Id="{341608cb-1218-481f-929c-cb79602c11ab}">
|
||||
<Declaration><![CDATA[METHOD M_Completing
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Execute" Id="{2a469169-0eb2-43c9-be21-48909285ee44}">
|
||||
<Declaration><![CDATA[METHOD M_Execute
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Held" Id="{05b040b0-b1b9-4afd-81d0-88fc1f1a7f9b}">
|
||||
<Declaration><![CDATA[METHOD M_Held
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Holding" Id="{519b03b3-2409-4b45-818f-535b3e16b22e}">
|
||||
<Declaration><![CDATA[METHOD M_Holding
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Idle" Id="{aa784f5c-7adf-4c9f-a414-65b10afd2772}">
|
||||
<Declaration><![CDATA[METHOD M_Idle
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Resetting" Id="{4050ed6f-edbe-4c3e-ac42-919a37a47ea9}">
|
||||
<Declaration><![CDATA[METHOD M_Resetting
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Starting" Id="{0059e7f6-5f2a-40e4-9d9b-652f221495a9}">
|
||||
<Declaration><![CDATA[METHOD M_Starting
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_StateComplete" Id="{0cf3625e-8009-4108-a9f4-d98c991f9930}">
|
||||
<Declaration><![CDATA[METHOD 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_Stopped" Id="{9f8a09cf-f3be-4d60-b5e4-cd9572fae88c}">
|
||||
<Declaration><![CDATA[METHOD M_Stopped
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Stopping" Id="{193565ef-cf20-428c-b726-e7c1b61375c5}">
|
||||
<Declaration><![CDATA[METHOD M_Stopping
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Suspended" Id="{222c3ad7-f7d5-4773-8e98-863345472053}">
|
||||
<Declaration><![CDATA[METHOD M_Suspended
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Suspending" Id="{0f5d52e2-2a54-4ea9-a0c4-7f08229c4f21}">
|
||||
<Declaration><![CDATA[METHOD M_Suspending
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Unholding" Id="{662dd054-329b-4e57-ba77-486f92af795a}">
|
||||
<Declaration><![CDATA[METHOD M_Unholding
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
<Method Name="M_Unsuspending" Id="{80fb11c4-916a-4f8f-9cf9-b9a2d51524a1}">
|
||||
<Declaration><![CDATA[METHOD M_Unsuspending
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[M_StateComplete();]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
Reference in New Issue
Block a user