StateMachineTemplateState Method (String, StateMachineActionCallback, StateMachineActionCallback, StateMachineDoActionCallback) |
Namespace: StaMa
public void State( string name, StateMachineActionCallback entryAction, StateMachineActionCallback exitAction, StateMachineDoActionCallback doAction )
Exception | Condition |
---|---|
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. |
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.