While using events is quite clear, sometimes you may need to define some more sophisticated behavior that cannot be defined using events and dynamic events. This can be done using statecharts. Statechart is the most advanced construct to describe event- and time-driven behavior. For some objects, this event- and time-ordering of operations is so pervasive that you can best characterize the behavior of such objects in terms of a state transition diagram – a statechart. 

Statechart has states and transitions. Transitions may be triggered by user-defined conditions (timeouts or rates, messages received by the statechart, and Boolean conditions). Transition execution may lead to a state change where a new set of transitions becomes active. States in the statechart may be hierarchical, i.e. contain other states and transitions.

Statechart is used to show the state space of a given algorithm, the events that cause a transition from one state to another, and the actions that result from state change.

By using statecharts you can visually capture a wide variety of discrete behaviors, much more rich than just idle/busy, open/closed, or up/down status offered by most block-based tools.

Statechart elements

The behavior of a statechart is defined in a graphical editor using the following statechart constructs:

  Statechart entry point



  Initial state pointer

  Final state


  History state

Statechart elements are added on the diagram from the Statechart stencil of the Palette view.

Related topics

 Execution order. Example

 Statechart functions

 API Reference: Statechart Class