Stateflow | ![]() ![]() |
States
A state describes a mode of an event-driven system. The activity or inactivity of the states dynamically changes based on events and conditions.
Every state has a parent. In a Stateflow diagram consisting of a single state, that state's parent is the Stateflow diagram itself (also called the Stateflow diagram root). You can place states within other higher-level states. In the preceding figure, StateA1
is a child of StateA
.
A state can have its activity history recorded in a history junction. History provides an efficient means of basing future activity on past activity. See History Junction.
States have labels that can specify actions executed in a sequence based upon action type. The action types are entry
, during
, exit
, and on
. See Actions.
The decomposition of a state defines the kind of state that a state can contain and the next level of containment. Stateflow provides two types of states: exclusive (OR) and parallel (AND) states. Exclusive (OR) states are used to describe modes that are mutually exclusive. A chart or state that contains exclusive (OR) states is said to have exclusive decomposition. The following transmission example has exclusive (OR) states.
An automatic transmission can be set to either neutral or engaged. In this example either the neutral
state or the engaged
state is active at any one time. Both cannot be active at the same time.
A chart or state with parallel states has two or more states that can be active at the same time. A chart or state that contains parallel (AND) states is said to have parallel decomposition.
Parallel (AND) states are displayed as dashed rectangles. The activity of each parallel state is essentially independent of other states. In the diagram on page 2-10, StateA2
has parallel (AND) state decomposition. Its states, StateA2a
and StateA2b,
are parallel (AND) states.
The following Stateflow diagram has parallel superstate decomposition.
In this example, the transmission, heating, and light systems are parallel subsystems in a car. They are active at the same time and are physically independent of each other. There are many other parallel components in a car, such as the braking and windshield wiper subsystems.
![]() | Graphical Objects Example Diagram | Transitions | ![]() |