Click or drag to resize
StaMaStateMachineTemplateState Method (String, StateMachineActionCallback, StateMachineActionCallback, StateMachineDoActionCallback)
Creates a State instance and starts the definition the State's substructure and contents.

Namespace: StaMa
Assembly: StaMa (in StaMa.dll) Version: 2.3.1.7
Syntax
public void State(
	string name,
	StateMachineActionCallback entryAction,
	StateMachineActionCallback exitAction,
	StateMachineDoActionCallback doAction
)

Parameters

name
Type: SystemString
The name of the State to be created. Must be unique within the StateMachineTemplate.
entryAction
Type: StaMaStateMachineActionCallback
A StateMachineActionCallback delegate that will be called when a StateMachine enters the State. May be null if no entry action is specified.
exitAction
Type: StaMaStateMachineActionCallback
A StateMachineActionCallback delegate that will be called when a StateMachine leaves the the State. May be null if no exit action is specified.
doAction
Type: StaMaStateMachineDoActionCallback
The StateMachineDoActionCallback delegate that defines the perpetual action to be executed while the StateMachine is in this State. May be null if no do action is specified.
Exceptions
ExceptionCondition
ArgumentException The doAction is valid, but do actions are not enabled for this StateMachineTemplate. To enable do actions, please create the StateMachineTemplate instance with the StateMachineOptions.UseDoActions flag specified at the constructor.
ArgumentNullException The name is null or empty.
ArgumentOutOfRangeException The name is not a valid identifier for a State: The identifier of a State must start with a character followed by nonspace characters or digits.
ArgumentOutOfRangeException The name is not a unique: A State with the same name already exists within the StateMachineTemplate instance.
StateMachineException A syntax error was detected with this or the preceeding Region, EndRegion, State, EndState or Transition statements.
Remarks

This method must be used paired with an StateMachineTemplate.EndState statement.

An enclosed StateMachineTemplate.Transition Overload statement adds a Transition emanating from this State.

Each pair of enclosed StateMachineTemplate.Region(String, Boolean) ... EndRegion statements will add a hierarchical sub-Region to the State.

The doAction is executed whenever the StateMachine.SendTriggerEvent method is called, therein after every individual state change or once, in case no state change occurred.

Do-actions can e.g. be used to run digital open or closed control loop algorithms for binary or continuous values when a state machine is regularly triggered in a cycle. Opposed to this, event driven state machines are only sporadically triggered when events occur or timers elapse, thus they don't benefit from do-actions.

See Also