Table of Contents

IUnitStateMachine

Namespace
ZApplication

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

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

Properties

StateAsString

PROPERTY StateAsString : ZCore.ZString

Property Value

ZString

Methods

IsTransitionAllowed

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.

METHOD IsTransitionAllowed (
 state : INT) : BOOL

Inputs

state INT

state in which a transition is planned

Returns

BOOL

SetState

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.

METHOD SetState (
 state : UnitStateMachineState) : BOOL

Inputs

state UnitStateMachineState

enumeration which defines the Zeugwerk Template standard states

Returns

BOOL

State

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

METHOD State () : UnitStateMachineState

Returns

UnitStateMachineState

StateDecoded

Map a state enumeration to strings.

METHOD StateDecoded (
 state : INT) : ZCore.ZString

Inputs

state INT

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

Returns

ZString

TransitionAsync

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.

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

Inputs

startToken IStartToken

state UnitStateMachineState

enumeration which defines the Zeugwerk Template standard states

Returns

BOOL