API State - Krystian-L-Lis/Stage GitHub Wiki
#API #State
Type: Function
Description:
Searches an I_Entity
for an I_State
component matching the provided ID pattern.
Results:
-
Ok
– ReturnsI_State
. -
Err.NotFound
– Returnsnull
. -
Err.InvRef
– Returnsnull
. -
Err.Itf0
– Returnsnull
, incorrect interface.
Signature:
FUNCTION GetState : Result
VAR_INPUT
iEntity: I_Entity;
sTagId: Str;
iOut: REFERENCE TO I_State;
END_VAR
Type: Function
Description:
Searches an I_Entity
for an I_StateManager
component.
Results:
-
Ok
– ReturnsI_StateManager
. -
Err.NotFound
– Returnsnull
. -
Err.InvRef
– Returnsnull
. -
Err.Itf0
– Returnsnull
, incorrect interface.
Signature:
FUNCTION GetStateManager : Result
VAR_INPUT
iEntity: I_Entity;
iOut: REFERENCE TO I_StateManager;
END_VAR
Type: Function
Description:
Casts I_Component
to I_StateManager
.
Results:
-
Ok
– Successful cast. -
Err.Itf0
– Incorrect interface. -
Err.NoMatch
– No matching interface found.
Signature:
FUNCTION ICompToIStateMgr : Result
VAR_INPUT
iIn: I_Component;
iOut: REFERENCE TO I_StateManager;
END_VAR
Type: Function
Description:
Casts I_Component
to I_State
.
Results:
-
Ok
– Successful cast. -
Err.Itf0
– Incorrect interface. -
Err.NoMatch
– No matching interface found.
Signature:
FUNCTION ICompToIState : Result
VAR_INPUT
iIn : I_Component;
iOut : REFERENCE TO I_State;
END_VAR
Type: Interface
Extends: I_RawComponent
Description:
Manages the lifecycle and transitions of states within an entity. Supports queuing state change requests, triggering state transitions, and broadcasting state change events.
Type: Property
Accessors: Get
Description: Retrieves the currently active state.
Signature: PROPERTY Current : I_State
Type: Property
Accessors: Get
Description: Returns the owning entity.
Signature: PROPERTY Owner : I_Entity
Type: Property
Accessors: Get, Set
Description: Allows external assignment of a reference to this instance.
Signature: PROPERTY Proxy : REFERENCE TO I_StateManager
Example:
iSmgr: I_StateManager;
smgr: StateManager := (Proxy := iSmgr);
// Result: iSmgr <> 0
Type: Property
Accessors: Get
Description: Retrieves the state queued to become active.
Signature: PROPERTY Pretender : I_State
Type: Property
Accessors: Get
Description: Retrieves the last active state.
Signature: PROPERTY Previous : I_State
Type: Method
Description: Queues a request to transition to a given state.
Results:
-
Ok
– Request successfully queued. -
Err.Itf0
– Invalid state interface. -
Err.NoMatch
– State does not belong to same entity. -
Err.IncArg
– State is already queued.
Signature:
METHOD Request : Result
VAR_INPUT
iState : I_State;
END_VAR
Type: Function Block
Implements: I_StateManager
Description:
Implements state management including lifecycle, queuing, and transition handling.
Type: Property
Accessors: Get
From: I_StateManager
Description: Retrieves the currently active state.
Signature: PROPERTY Current : I_State
Type: Property
Accessors: Get
From: I_StateManager
Description: Returns the owning entity.
Signature: PROPERTY Owner : I_Entity
Type: Property
Accessors: Get
From: I_StateManager
Description: Retrieves the next state queued for transition.
Signature: PROPERTY Pretender : I_State
Type: Property
Accessors: Get
From: I_StateManager
Description: Returns the previously active state.
Signature: PROPERTY Previous : I_State
Type: Method
Accessors: Get
From: I_StateManager
Description: Queues a request to transition to a given state.
Results:
-
Ok
– Request successfully queued. -
Err.Itf0
– Invalid state interface. -
Err.NoMatch
– State does not belong to same entity. -
Err.IncArg
– State is already queued.
Signature:
METHOD Request : Result
VAR_INPUT
iState : I_State;
END_VAR
Type: Interface
Extends: I_RawComponent
Description:
Abstracts a state object and allows casting to I_Component
.
Type: Property
Accessors: Get
Description: Returns the entity that owns this state.
Signature: PROPERTY Owner : I_Entity
Type: Property
Accessors: Get
Description:
Returns the tag associated with this signal.
Signature: PROPERTY Tag : I_Tag
Type: Function Block
Implements: I_State
Description:
Provides base behaviour for representing and managing a system state.
Type: Property
Accessors: Get
From: I_State
Description: Returns the entity that owns this state.
Signature: PROPERTY Owner : I_Entity
Type: Property
Accessors: Get
From: I_State
Description: Accesses the I_Tag
associated with this state.
Signature: PROPERTY Tag : I_Tag
Type: Property
Accessors: Get, Set
Description: Allows external assignment of a reference to this instance.
Signature: PROPERTY Proxy : REFERENCE TO I_State
Example:
iState: I_State;
state: SomeState := (Proxy := iState);
// Result: iState <> 0
Type: Method
Access: Protected
Description: Determines whether the state can be activated. Default is TRUE
.
Signature: METHOD PROTECTED CanActivate : BOOL
Type: Method
Access: Protected
Description: Determines whether the state can be deactivated. Default is TRUE
.
Signature: METHOD PROTECTED CanDeactivate : BOOL
Type: Method
Access: Protected
Description: Executed when the state is entered.
Signature: METHOD PROTECTED OnEntry
Type: Method
Access: Protected
Description: Logic executed during state operation.
Signature: METHOD PROTECTED OnExecute
Type: Method
Access: Protected
Description: Executed when the state is exited.
Signature: METHOD PROTECTED OnExit