| Stateflow User's Guide | ![]() |
Transition Action Types
In State Action Types, you see how Stateflow attaches actions to the label for a state. Stateflow also attaches actions to a transition through its label. Transitions can have different action types, which include event triggers, conditions, condition actions, and transition actions. The actions for transitions are assigned to an action type using label notation with the following general format:
The following example shows examples of transition action types:
Event Triggers
In transition label syntax, event triggers appear first as the name of an event. They have no distinguishing special character to separate them from other actions in a transition label. In the example in Transition Action Types, both transitions from state A have event triggers. The transition from state A to state B has the event trigger event2 and the transition from state A to state C has the event trigger event1.
Event triggers specify an event that causes the transition to be taken, provided the condition, if specified, is true. Specifying an event is optional. The absence of an event indicates that the transition is taken upon the occurrence of any event. Multiple events are specified using the OR logical operator (|).
Conditions
In transition label syntax, conditions are Boolean expressions enclosed in square brackets ([]). In the example in Transition Action Types, the transition from state A to state C has the condition temp > 50.
A condition is a Boolean expression to specify that a transition occurs given that the specified expression is true. The following are some guidelines for defining and using conditions:
The in(state_name)condition function that is evaluated as true when the state specified as the argument is active. The full state name, including any ancestor states, must be specified to avoid ambiguity.
Note
A chart cannot use the In condition function to trigger actions based on the activity of states in other charts.
|
Condition Actions
In transition label syntax, condition actions follow the transition condition and are enclosed in curly braces ({}). In the example in Transition Action Types, the transition from state A to state B has the condition action func(), a function call.
Condition actions are executed as soon as the condition is evaluated as true, but before the transition destination has been determined to be valid. If no condition is specified, an implied condition evaluates to true and the condition action is executed.
Transition Actions
In transition label syntax, transition actions are preceded with a forward slash (/). In the example in Transition Action Types, the transition from state A to state B has the transition action data1 = 5.
Transition actions are executed when the transition is actually taken. They are executed after the transition destination has been determined to be valid, and the condition, if specified, is true. If the transition consists of multiple segments, the transition action is only executed when the entire transition path to the final destination is determined to be valid.
| State Action Types | Example of Action Type Execution | ![]() |
© 1994-2005 The MathWorks, Inc.