Detect Modeling Errors During Edit Time

The Stateflow® editor displays potential errors and warnings by highlighting objects in red or orange. The editor underlines syntax errors with a red wavy line. To see details and possible fixes, place your cursor over the object that is highlighted and click the error or warning badge. By fixing these issues when you design your charts, you avoid potential compile or run-time warnings and errors.

Enable the edit-time checking and syntax error highlighting through the Display > Error & Warnings check box.

Many edit-time checks have an associated diagnostic configuration parameter. To control the level of diagnostic action, open the Model Configuration Parameters dialog box. In the Diagnostics > Stateflow pane, you can select error, warning, or none. When you change the diagnostic level for a configuration parameter, the diagnostic level for the corresponding edit-time check also changes. For example, if you set the Unreachable execution path configuration parameter to none, then Stateflow does not highlight transition shadowing in the editor. Not all edit-time checks have corresponding configuration parameters.

Object Contains a Syntax Error

In a state or transition, the notation for an action or condition does not follow the syntax rules. Violations are highlighted as errors. See Transition Label Notation and State Labels.

Note

Subcharts with syntax errors appear red in the parent chart with a badge indicating a syntax issue. In the subchart editor, the object is highlighted in red, however there is no badge indicating the issue.

Dangling Transition

A dangling transition is not connected to a destination object. Transitions must have a valid source state or junction and a valid destination state or junction. See Transitions.

Control the level of diagnostic action by setting the Unreachable execution path diagnostic configuration parameter.

Unreachable State

A state is unreachable when there is no valid execution path leading to the state. To make the state a reachable destination, connecting it with a transition from a reachable state or junction.

Control the level of diagnostic action by setting the Unreachable execution path diagnostic configuration parameter.

Transition Shadowing

Transition shadowing occurs when a chart contains an unconditional transition originating from a source that prevents other transitions from the same source from executing. To avoid transition shadowing:

  • Create no more than one unconditional transition for each group of outgoing transitions from a state or junction.

  • Explicitly specify an unconditional transition as a lower evaluation order than any transitions with conditions. See Transition Evaluation Order.

Control the level of diagnostic action by setting the Unreachable execution path diagnostic configuration parameter.

Invalid Default Transition Path

A default transition path is invalid when the execution path for the default transition exits the parent state. Violations are highlighted as errors. To resolve the error, create default transition paths that stay within the parent state.

Unconditional Path out of State with During Actions or Child States

Unconditional transitions leading out of a state inhibit:

  • The execution of the during actions in the state.

  • The default transitions to child states.

Control the level of diagnostic action by setting the Transition outside natural parent diagnostic configuration parameter.

Graphical Function Contains a State

When called, graphical functions must execute completely so they cannot contain any states. Violations are highlighted as errors. To resolve the error, delete the state from the graphical function.

Default Transition Is Missing

Charts or states with exclusive (OR) decomposition require a default transition to indicate the child state or junction where execution begins. See Default Transitions. Violations are highlighted as errors. To resolve the error, add a default transition to a child state or junction.

Default Transition Path Does Not Terminate in a State

In charts or states with exclusive (OR) decomposition and at least one substate:

  • Every path along the default transition must lead to a substate.

  • There must be one default transition path that is not guarded by a condition or triggered by an event.

If one path along the default transition remains unconditional, you can include multiple junctions and transitions.

Control the level of diagnostic action by setting the No unconditional default transitions diagnostic configuration parameter.

Unexpected Backtracking

Unintended backtracking of control flow can occur at a junction when these conditions are true:

  • The junction does not have an unconditional transition path to a state or terminating junction.

  • Multiple transition paths that share a source lead to the junction.

See Backtrack in Flow Charts.

Control the level of diagnostic action by setting the Unexpected backtracking diagnostic configuration parameter.

Transition Loops Outside Natural Parent

If a transition loops outside of the parent state between the source and destination, the exit and entry actions of the parent state execute before the destination state becomes active. For example, when the highlighted transition in this chart becomes active, the state actions are executed in this order:

  • exit actions in state B

  • exit actions in state A

  • entry actions in state A

  • entry actions in state C

To prevent the chart from exiting and reentering state A, move the transition so that it is contained within state A.

Control the level of diagnostic action by setting the Transition outside natural parent diagnostic configuration parameter.

Transition Action Precedes a Condition Action Along This Path

When there is a transition action on a path with a condition action on a following transition, the actions are not executed in the order of the transitions. Stateflow charts execute condition actions when the associated condition is evaluated as true. In contrast, charts execute transition actions only when the transition path is fully executed.

For example, in this chart, if ConditionA and ConditionB are true, then ConditionAction2 occurs before TransitionAction1. The transition path from state A to state B follows this order:

  • State A is active.

  • Chart evaluates ConditionA.

  • Chart evaluates ConditionB.

  • Chart executes ConditionAction2.

  • State A becomes inactive.

  • Chart executes TransitionAction1.

  • State B becomes active.

To improve the clarity of the chart, place the transition action after the last condition action on the path.

Control the level of diagnostic action by setting the Transition action specified before condition action diagnostic configuration parameter.

Transition Begins or Ends in a Parallel State

Transitions leading to or from a parallel state cause all sibling parallel states to become active or inactive. Violations are highlighted as warnings. To resolve the warning and avoid unintentional behavior, delete transitions into or out of parallel states.

Monitoring Leaf or Child State Activity of Parallel States

Leaf or child state activity is not supported for parallel states. Violations are highlighted as warnings. To resolve the warning, in the Property Inspector or the Model Explorer, clear the Create output for monitoring check box or select Self activity from the drop down list. For more information, see Monitor State Activity Through Active State Data.

Invalid Transitions Crossing into Graphical Function

Transitions cannot have a graphical function as the destination. Call graphical functions from state actions or transitions. Violations are highlighted as errors. To resolve the error, remove the transition crossing into the graphical function.

Invalid Transitions Crossing out of Graphical Function

Transitions cannot have a graphical function as the destination. Call graphical functions from state actions or transitions. Violations are highlighted as errors. To resolve the error, remove the transition crossing out of the graphical function.

Related Topics