Stateflow |
 |
Condition Statements
You sometimes want transitions or actions associated with transitions to take place only if a given condition is true. Conditions are placed within square brackets ([]
). The following are some guidelines for defining and using conditions:
- The condition expression must be a Boolean expression of some kind that evaluates to either true (1) or false (0).
- The condition expression can consist of any of the following:
- Boolean operators that make comparisons between data and numeric values
- A function that returns a Boolean value
- 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.
|
- The condition expression should not call a function that causes the Stateflow diagram to change state or modify any variables.
- Boolean expressions can be grouped using & for expressions with AND relationships and | for expressions with OR relationships.
- Assignment statements are not valid condition expressions.
- Unary increment and decrement actions are not valid condition expressions.
| Directed Event Broadcasting | | Using Temporal Logic |  |