MATLAB Examples

Diagnostics in State Transition Tables

This example shows how to use the static error diagnostics in State Transition Tables (STT) in Stateflow® (new in R2012b).

The STT editor has a Chart > Run diagnostics menu item. This allows you to quickly parse the table statically to determine errors while constructing the STT. These diagnostics checks ensure that the table is correct by construction. These checks also run when the model is simulated.

Following is the screen shot of the state transition table and the corresponding auto-generated chart.

Select the Chart > Run diagnostics menu item while viewing the table editor, or run the simulation to view static diagnostics for the State Transition Table. For easy navigation, the diagnostic messages contain hyperlinks to individual cells on the table that caused the diagnostic message.

Following are the 6 diagnostics provided:

1) Find states with no incoming transitions

Notice that state2 has no incoming transition and is consequently, unreachable from the default transitions. This diagnostic flags this state.

2) Find transition cells with condition or action specified but no destination

The transition cell on the right of state1 has an action and a condition specified, but the destination cell is empty. This is likely an oversight by the user. This diagnostic flags such transition cells. To explicitly account for conditions, on which no transitions need to be taken, choose % IGNORE % in the destination cell.

3) Find transition cells which contain action text in the condition cell

Notice that the transition cell that marks the transition between state1 and state4 has an action specified in the condition cell. This is detected by this diagnostic.

4) Find unreachable states

In this table, notice that although state3 has an incoming transition, there is no way to reach this state from any of the default transitions. This diagnostic flags such unreachable states.

5) Find instances where the default transition row is present, but all destination states are guarded by conditions

In this state transition table, a default transition row is used to specify multiple default transitions. However all these transitions are guarded by conditions. This may lead to state inconsistency error during simulation. This diagnostic detects such instances. The resolution to this error is to have at least one unconditional default transition.

6) Find instances where there is a mismatch in the execution order of transitions for an inner transition row.

The table has an inner transition row. The execution order of the transitions as specified on the table is state4_2 followed by state4_1. However these states occur in the reverse order from top to bottom in the state hierarchy. This is marked as an error in the state transition table. The inner transition row for a state must specify destination states from left to right in the same order as the corresponding states appear in the table, from top to bottom.