Table of Contents

IUnitStateMachine

Namespace
ZApplication
Extends
Inherited Properties
Inherited Methods
INTERFACE IUnitStateMachine EXTENDS ZCore.IUnmanagedObject, ZCore.IObject, ZCore.IError

This is an interface to the standard finite-state-machine of the Zeugwerk Template We have designed this standardized statemachine with predefined states which are defined in this UnitStateMachineState enumeration. There are also userdefined states possible by calling SetUserdefinedStateSequence and actions by calling SetUserdefinedActionSequence.

For more information on how to use the Zeugwerk Template Statemachine please read the doc here

Properties

StateAsString

PROPERTY StateAsString : ZCore.ZString

Property Value

ZString

Methods

IsTransitionAllowed

METHOD IsTransitionAllowed (
 [input] state : INT) : BOOL

The state machine controls all transitions and checks if a specific transition is allowed. When changing from one state to another, this method checks if this is allowed and returns TRUE. For example a direct change from state init to state automatic is not possible, in this case this method returns FALSE.

Inputs

state INT

state in which a transition is planned

Returns

BOOL

SetState

METHOD SetState (
 [input] state : UnitStateMachineState) : BOOL

This method can be used to force the statemachine into a specific state. In contrast to TransitionAsync the change is abruptly and will not stop an optionally already running sequence. In contrast to SetState this method only accepts states defined in UnitStateMachineState.

This method should only be used to set the initial state of the statemachine and not for controlling a sequential flow. For the later purpose, TransitionAsync should be used, which performs a "clean" transition from one state to another.

In the Zeugwerk Template this method is used to set the initial state to Boot.

Inputs

state UnitStateMachineState

enumeration which defines the Zeugwerk Template standard states

Returns

BOOL

State

METHOD State () : UnitStateMachineState

Return the current state index of the state machine. The method returns 0 if an invalid state has been set

Returns

UnitStateMachineState

StateDecoded

METHOD StateDecoded (
 [input] state : INT) : ZCore.ZString

Map a state enumeration to strings.

Inputs

state INT

state as definied with UnitStateMachineState or a userdefined state/action.

Returns

ZString

TransitionAsync

METHOD TransitionAsync (
 [input] startToken : ZCore.IStartToken,
 [input] state : UnitStateMachineState) : BOOL

This method is used to perform a "clean" transition from the current state of the statemachine to state, but only if the transition is allowed.

The state change is not performed instantly, but only in the next call of the Cyclic method, which is usually automatically called by an object manager or the parent of this object.

If the transition is successfully executed this method will return TRUE otherwise FALSE.

Inputs

startToken IStartToken
state UnitStateMachineState

enumeration which defines the Zeugwerk Template standard states

Returns

BOOL