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:
@@ -23,7 +23,7 @@ TYPE E_PackMLState :
|
||||
UNSUSPENDING := 14,
|
||||
RESETTING := 15,
|
||||
COMPLETING := 16,
|
||||
COMPLETE := 17
|
||||
COMPLETED := 17
|
||||
) DINT := STOPPED;
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
12
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLa.TcDUT
Normal file
12
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLa.TcDUT
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PMLa" Id="{16746b45-38ff-4f58-95c8-eb6734adb976}">
|
||||
<Declaration><![CDATA[TYPE ST_PMLa :
|
||||
STRUCT
|
||||
astProductData : ARRAY[0..(GVL_PackML_Conf.MAX_PRODUCT_DATA-1)] OF ST_PackML_ProductData;
|
||||
diStopReason : DINT;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
26
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLc.TcDUT
Normal file
26
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLc.TcDUT
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PMLc" Id="{5cf4c850-57ba-42f8-9986-b146207e1b2f}">
|
||||
<Declaration><![CDATA[TYPE ST_PMLc :
|
||||
STRUCT
|
||||
eUnitMode : E_PackMLUnitMode;
|
||||
xUnitModeChangeRequest : BOOL;
|
||||
rMachSpeed : REAL;
|
||||
eCntrlCmd : E_PackMLCmd;
|
||||
xCmdChangeRequest : BOOL;
|
||||
|
||||
// Parameters
|
||||
astParameterReal : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamREAL;
|
||||
astParameterString : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamSTRING;
|
||||
astParameterLReal : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamLREAL;
|
||||
astParameterDInt : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamDINT;
|
||||
|
||||
// Recipe data
|
||||
diSelectedRecipe : DINT;
|
||||
xRecipeChangeRequest : BOOL;
|
||||
astRecipe : ARRAY[0..(GVL_PackML_Conf.MAX_RECIPES_PER_UNIT - 1)] OF ST_PackMLRecipe;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
14
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLs.TcDUT
Normal file
14
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PMLs.TcDUT
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PMLs" Id="{dace328e-4599-42b5-ac3b-2a705ec8e2f3}">
|
||||
<Declaration><![CDATA[TYPE ST_PMLs :
|
||||
STRUCT
|
||||
eUnitModeCurrent : E_PackMLUnitMode;
|
||||
eStateCurrent : E_PackMLState;
|
||||
rMachSpeed : REAL;
|
||||
rCurMachSpeed : REAL;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
14
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PackMLPI.TcDUT
Normal file
14
PLC/LibraryCandidates/PackML/DUTs/PackTags/ST_PackMLPI.TcDUT
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLPI" Id="{e7198eb6-2cd3-41c0-be59-e7dbcf10a569}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLPI :
|
||||
STRUCT
|
||||
astParameterReal : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamREAL;
|
||||
astParameterString : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamSTRING;
|
||||
astParameterLReal : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamLREAL;
|
||||
astParameterDInt : ARRAY[0..(GVL_PackML_Conf.MAX_PARAMS-1)] OF ST_PackMLParamDINT;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLParamDINT" Id="{f9801bf5-a73d-450f-b9fc-a5d8229e4946}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLParamDINT :
|
||||
STRUCT
|
||||
diID : DINT;
|
||||
sName : STRING;
|
||||
sUnit : STRING(6);
|
||||
Value : DINT;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLParamLREAL" Id="{195fabe8-44c0-43ec-8434-75e38b68efb7}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLParamLREAL :
|
||||
STRUCT
|
||||
diID : DINT;
|
||||
sName : STRING;
|
||||
sUnit : STRING(6);
|
||||
Value : LREAL;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLParamREAL" Id="{373303ba-9979-4979-a439-c899a36baa12}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLParamREAL :
|
||||
STRUCT
|
||||
diID : DINT;
|
||||
sName : STRING;
|
||||
sUnit : STRING(6);
|
||||
Value : REAL;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLParamSTRING" Id="{85353d3e-e4c9-4e83-857e-8ce7ed43abaf}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLParamSTRING :
|
||||
STRUCT
|
||||
diID : DINT;
|
||||
sName : STRING;
|
||||
sUnit : STRING(6);
|
||||
Value : STRING;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLRecipe" Id="{b453a4b5-bb40-4669-97f2-8d8ab8d3dc26}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLRecipe :
|
||||
STRUCT
|
||||
diID : DINT;
|
||||
sName : STRING;
|
||||
rPrimaryQty : REAL;
|
||||
stProcessVariables : ST_PackMLPI;
|
||||
stIngredients : ST_PackMLPI;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackML_ProductData" Id="{2af30e31-0927-41d2-9df4-7ed222070c13}">
|
||||
<Declaration><![CDATA[TYPE ST_PackML_ProductData :
|
||||
STRUCT
|
||||
diProcessedCount : DINT;
|
||||
diDefectiveCount : DINT;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<DUT Name="ST_PackMLStateMachineConfig" Id="{ced5a276-0ad8-4ce9-8d27-4b268a010876}">
|
||||
<Declaration><![CDATA[TYPE ST_PackMLStateMachineConfig :
|
||||
STRUCT
|
||||
xClearingDisabled : BOOL;
|
||||
// xStoppedDisabled : BOOL;
|
||||
xStartingDisabled : BOOL;
|
||||
// xIdleDisabled : BOOL;
|
||||
xSuspededDisabled : BOOL;
|
||||
// xExecuteDisabled : BOOL;
|
||||
xStoppingDisabled : BOOL;
|
||||
xAbortingDisabled : BOOL;
|
||||
// xAbortedDisabled : BOOL;
|
||||
xHoldingDisabled : BOOL;
|
||||
xHeldDisabled : BOOL;
|
||||
xUnholdingDisabled : BOOL;
|
||||
xSuspendingDisabled : BOOL;
|
||||
xUnsuspendingDisabled : BOOL;
|
||||
xResettingDisabled : BOOL;
|
||||
xCompletingDisabled : BOOL;
|
||||
xCompletedDisabled : BOOL;
|
||||
END_STRUCT
|
||||
END_TYPE
|
||||
]]></Declaration>
|
||||
</DUT>
|
||||
</TcPlcObject>
|
||||
@@ -1,244 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_PackMLStateMachine" Id="{784ceb84-1721-424f-89d1-422a24198e57}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_PackMLStateMachine
|
||||
VAR_INPUT
|
||||
eMode : E_PackMLUnitMode;
|
||||
eCmd : E_PackMLCmd;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
eState : E_PackMLState;
|
||||
eCurrentMode : E_PackMLUnitMode;
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR
|
||||
// Internal mode
|
||||
_eMode : E_PackMLUnitMode;
|
||||
|
||||
// Internal state
|
||||
_eState : E_PackMLState;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Check for mode switch
|
||||
IF eMode <> _eMode THEN
|
||||
// Only allow mode switch in stopped state
|
||||
// or in aborted state when target mode ist manual mode
|
||||
IF (_eState = E_PackMLState.STOPPED) OR (_eState = E_PackMLState.ABORTED AND eMode = E_PackMLUnitMode.MANUAL) THEN
|
||||
_eMode := eMode;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
|
||||
// Base state machine
|
||||
CASE _eState OF
|
||||
E_PackMLState.STOPPING:
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.STOPPED:
|
||||
IF eCmd = E_PackMLCmd.RESET THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.RESETTING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.IDLE:
|
||||
IF eCmd = E_PackMLCmd.START THEN
|
||||
_eState := E_PackMLState.STARTING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.STARTING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.EXECUTE:
|
||||
IF eCmd = E_PackMLCmd.SUSPEND THEN
|
||||
_eState := E_PackMLState.SUSPENDING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.HOLD THEN
|
||||
_eState := E_PackMLState.HOLDING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.SUSPENDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.SUSPENDED:
|
||||
IF eCmd = E_PackMLCmd.UNSUSPEND THEN
|
||||
_eState := E_PackMLState.UNSUSPENDING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.UNSUSPENDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.HOLDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.HELD:
|
||||
IF eCmd = E_PackMLCmd.UNHOLD THEN
|
||||
_eState := E_PackMLState.UNHOLDING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.UNHOLDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.COMPLETING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.COMPLETE:
|
||||
IF eCmd = E_PackMLCmd.RESET THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.ABORTED:
|
||||
IF eCmd = E_PackMLCmd.CLEAR THEN
|
||||
_eState := E_PackMLState.CLEARING;
|
||||
END_IF
|
||||
|
||||
E_PackMLState.CLEARING:
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
END_IF
|
||||
|
||||
ELSE
|
||||
;
|
||||
END_CASE
|
||||
|
||||
// Copy internal state value to fb output
|
||||
eState := _eState;
|
||||
eCurrentMode := _eMode;]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="M_StateComplete" Id="{e2f1bae5-5059-4baa-8ba2-8dfa58d439e5}">
|
||||
<Declaration><![CDATA[METHOD M_StateComplete
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[CASE _eState OF
|
||||
E_PackMLState.STOPPING:
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
|
||||
E_PackMLState.RESETTING:
|
||||
_eState := E_PackMLState.IDLE;
|
||||
|
||||
E_PackMLState.STARTING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.EXECUTE:
|
||||
_eState := E_PackMLState.COMPLETING;
|
||||
|
||||
E_PackMLState.SUSPENDING:
|
||||
_eState := E_PackMLState.SUSPENDED;
|
||||
|
||||
E_PackMLState.UNSUSPENDING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.HOLDING:
|
||||
_eState := E_PackMLState.HELD;
|
||||
|
||||
E_PackMLState.UNHOLDING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.COMPLETING:
|
||||
_eState := E_PackMLState.COMPLETE;
|
||||
|
||||
E_PackMLState.ABORTING:
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
|
||||
E_PackMLState.CLEARING:
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_CASE
|
||||
|
||||
eState := _eState;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
11
PLC/LibraryCandidates/PackML/GVL_PackML_Conf.TcGVL
Normal file
11
PLC/LibraryCandidates/PackML/GVL_PackML_Conf.TcGVL
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<GVL Name="GVL_PackML_Conf" Id="{b46d8e14-5a19-467d-bb78-56321e43ef47}">
|
||||
<Declaration><![CDATA[{attribute 'qualified_only'}
|
||||
VAR_GLOBAL CONSTANT
|
||||
MAX_PARAMS : UINT := 10;
|
||||
MAX_PRODUCT_DATA : UINT := 10;
|
||||
MAX_RECIPES_PER_UNIT : UINT := 5;
|
||||
END_VAR]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -3,39 +3,90 @@
|
||||
<POU Name="FB_PackMLGeneric" Id="{f562a10e-01bc-407d-9fc0-2837d13c10b1}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_PackMLGeneric IMPLEMENTS I_UnitState
|
||||
VAR_INPUT
|
||||
// Mode from superior unit
|
||||
eModeCmd : E_PackMLUnitMode;
|
||||
|
||||
// Command for new state from superior unit
|
||||
eCmd : E_PackMLCmd;
|
||||
stCommand : ST_PMLc;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
// Current mode of unit
|
||||
eMode : E_PackMLUnitMode;
|
||||
// Unit status
|
||||
stStatus : ST_PMLs;
|
||||
|
||||
// Current state of unit
|
||||
eState : E_PackMLState;
|
||||
|
||||
// xInvalidModeCmd : BOOL;
|
||||
// Admin data
|
||||
stAdmin : ST_PMLa;
|
||||
END_VAR
|
||||
VAR
|
||||
// State machine handler
|
||||
_fbStateMachine : FB_PackMLStateMachine;
|
||||
_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[_fbStateMachine(
|
||||
eMode:= eMode,
|
||||
eCmd:= eCmd,
|
||||
eState=> _eState,
|
||||
<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 _eState OF
|
||||
CASE stStatus.eStateCurrent OF
|
||||
E_PackMLState.CLEARING:
|
||||
M_Clearing();
|
||||
|
||||
@@ -84,16 +135,13 @@ CASE _eState OF
|
||||
E_PackMLState.COMPLETING:
|
||||
M_Completing();
|
||||
|
||||
E_PackMLState.COMPLETE:
|
||||
E_PackMLState.COMPLETED:
|
||||
M_Complete();
|
||||
|
||||
ELSE
|
||||
|
||||
;
|
||||
END_CASE
|
||||
|
||||
// Copy internal flags to output
|
||||
eState := _eState;]]></ST>
|
||||
END_CASE]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="M_Aborted" Id="{db1a684f-e4e1-4d89-a3aa-9b9dfde0508c}">
|
||||
<Declaration><![CDATA[METHOD M_Aborted
|
||||
@@ -176,7 +224,11 @@ eState := _eState;]]></ST>
|
||||
<Declaration><![CDATA[METHOD M_StateComplete
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[_fbStateMachine.M_StateComplete();]]></ST>
|
||||
<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}">
|
||||
428
PLC/LibraryCandidates/PackML/POUs/FB_PackMLStateMachine.TcPOU
Normal file
428
PLC/LibraryCandidates/PackML/POUs/FB_PackMLStateMachine.TcPOU
Normal file
@@ -0,0 +1,428 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1">
|
||||
<POU Name="FB_PackMLStateMachine" Id="{784ceb84-1721-424f-89d1-422a24198e57}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[FUNCTION_BLOCK FB_PackMLStateMachine
|
||||
VAR_INPUT
|
||||
eMode : E_PackMLUnitMode;
|
||||
eCmd : E_PackMLCmd;
|
||||
|
||||
stConfig : ST_PackMLStateMachineConfig;
|
||||
END_VAR
|
||||
VAR_OUTPUT
|
||||
eState : E_PackMLState;
|
||||
eCurrentMode : E_PackMLUnitMode;
|
||||
xError : BOOL;
|
||||
END_VAR
|
||||
VAR
|
||||
// Internal mode
|
||||
_eMode : E_PackMLUnitMode;
|
||||
|
||||
// Internal state
|
||||
_eState : E_PackMLState;
|
||||
|
||||
// Rerun state machine
|
||||
_xRerunSM : BOOL;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[// Check for mode switch
|
||||
IF eMode <> _eMode THEN
|
||||
// Only allow mode switch in stopped state
|
||||
// or in aborted state when target mode ist manual mode
|
||||
IF (_eState = E_PackMLState.STOPPED) OR (_eState = E_PackMLState.ABORTED AND eMode = E_PackMLUnitMode.MANUAL) THEN
|
||||
_eMode := eMode;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
REPEAT
|
||||
_xRerunSM := FALSE;
|
||||
|
||||
// Base state machine
|
||||
CASE _eState OF
|
||||
E_PackMLState.STOPPING:
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.STOPPED:
|
||||
IF eCmd = E_PackMLCmd.RESET THEN
|
||||
IF (NOT stConfig.xResettingDisabled)THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.IDLE;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.RESETTING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
|
||||
E_PackMLState.IDLE:
|
||||
IF eCmd = E_PackMLCmd.START THEN
|
||||
IF (NOT stConfig.xStartingDisabled) THEN
|
||||
_eState := E_PackMLState.STARTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.STARTING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
|
||||
E_PackMLState.EXECUTE:
|
||||
IF eCmd = E_PackMLCmd.SUSPEND AND (NOT stConfig.xSuspededDisabled) THEN
|
||||
IF (NOT stConfig.xSuspendingDisabled) THEN
|
||||
_eState := E_PackMLState.SUSPENDING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.SUSPENDED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.HOLD AND (NOT stConfig.xHeldDisabled) THEN
|
||||
IF (NOT stConfig.xHoldingDisabled) THEN
|
||||
_eState := E_PackMLState.HOLDING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.HELD;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.COMPLETE THEN
|
||||
IF (NOT stConfig.xCompletedDisabled)THEN
|
||||
IF (NOT stConfig.xCompletingDisabled) THEN
|
||||
_eState := E_PackMLState.COMPLETING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.COMPLETED;
|
||||
END_IF
|
||||
ELSE
|
||||
IF (NOT stConfig.xResettingDisabled) THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.IDLE;
|
||||
END_IF
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.SUSPENDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.SUSPENDED:
|
||||
IF eCmd = E_PackMLCmd.UNSUSPEND THEN
|
||||
IF (NOT stConfig.xUnsuspendingDisabled) THEN
|
||||
_eState := E_PackMLState.UNSUSPENDING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
END_IF
|
||||
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.HOLD AND (NOT stConfig.xHeldDisabled) THEN
|
||||
IF (NOT stConfig.xHoldingDisabled) THEN
|
||||
_eState := E_PackMLState.HOLDING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.HELD;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.UNSUSPENDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.HOLDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.HELD:
|
||||
IF eCmd = E_PackMLCmd.UNHOLD THEN
|
||||
IF (NOT stConfig.xUnholdingDisabled) THEN
|
||||
_eState := E_PackMLState.UNHOLDING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.UNHOLDING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.COMPLETING:
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.COMPLETED:
|
||||
IF eCmd = E_PackMLCmd.RESET THEN
|
||||
IF (NOT stConfig.xResettingDisabled)THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.IDLE;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.STOP THEN
|
||||
IF (NOT stConfig.xStoppingDisabled) THEN
|
||||
_eState := E_PackMLState.STOPPING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.ABORTED:
|
||||
IF eCmd = E_PackMLCmd.CLEAR THEN
|
||||
IF (NOT stConfig.xClearingDisabled) THEN
|
||||
_eState := E_PackMLState.CLEARING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.CLEARING:
|
||||
IF eCmd = E_PackMLCmd.ABORT THEN
|
||||
IF (NOT stConfig.xAbortingDisabled) THEN
|
||||
_eState := E_PackMLState.ABORTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
ELSE
|
||||
;
|
||||
END_CASE
|
||||
|
||||
UNTIL (NOT _xRerunSM)
|
||||
END_REPEAT
|
||||
|
||||
|
||||
|
||||
// Copy internal state value to fb output
|
||||
eState := _eState;
|
||||
eCurrentMode := _eMode;]]></ST>
|
||||
</Implementation>
|
||||
<Method Name="M_StateComplete" Id="{e2f1bae5-5059-4baa-8ba2-8dfa58d439e5}">
|
||||
<Declaration><![CDATA[METHOD M_StateComplete
|
||||
VAR_INPUT
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[CASE _eState OF
|
||||
E_PackMLState.STOPPING:
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
|
||||
E_PackMLState.RESETTING:
|
||||
_eState := E_PackMLState.IDLE;
|
||||
|
||||
E_PackMLState.STARTING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.SUSPENDING:
|
||||
_eState := E_PackMLState.SUSPENDED;
|
||||
|
||||
E_PackMLState.UNSUSPENDING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.HOLDING:
|
||||
_eState := E_PackMLState.HELD;
|
||||
|
||||
E_PackMLState.UNHOLDING:
|
||||
_eState := E_PackMLState.EXECUTE;
|
||||
|
||||
E_PackMLState.COMPLETING:
|
||||
IF (NOT stConfig.xCompletedDisabled)THEN
|
||||
_eState := E_PackMLState.COMPLETED;
|
||||
ELSE
|
||||
IF (NOT stConfig.xResettingDisabled) THEN
|
||||
_eState := E_PackMLState.RESETTING;
|
||||
ELSE
|
||||
_eState := E_PackMLState.IDLE;
|
||||
END_IF
|
||||
END_IF
|
||||
|
||||
E_PackMLState.ABORTING:
|
||||
_eState := E_PackMLState.ABORTED;
|
||||
|
||||
E_PackMLState.CLEARING:
|
||||
_eState := E_PackMLState.STOPPED;
|
||||
END_CASE
|
||||
|
||||
eState := _eState;]]></ST>
|
||||
</Implementation>
|
||||
</Method>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
Reference in New Issue
Block a user