State Machine Diagrams


State Machine diagrams were formerly known as State diagrams.

A State Machine diagram illustrates how an element (often a Class) can move between states, classifying its behavior according to transition triggers and constraining guards.  Other aspects of State Machine diagrams further depict and explain movement and behavior.

For information on code generation from State Machine diagrams, see the SW Code Generation - State Machine Diagrams and State Machine Modeling for HDLs topics.

State Machine representations in UML are based on the Harel State Chart Notation (see the OMG UML Superstructure Specification 2.1.1, section 15.1), and therefore are sometimes referred to as State Charts.

You can display a State Machine as a diagram (as below) or as a table in one of three relationship formats. In all formats, you use the same Toolbox elements and connectors.

To select the display format, follow the steps below:

  1. Right-click on the diagram background to display the context menu.
  2. Select the Statechart Editor option.
  3. Select the appropriate display option:
  • Diagram
  • Table (State-Next State)
  • Table (State-Trigger)
  • Table (Trigger-State).

Example Diagram

The following diagram illustrates some features of State Machine diagrams. The Saved State is a Composite State, and enclosed States are sub-states. Initial and final pseudo-states indicate the entry to and exit from the State Machine. Composite States and sub-states are both State elements, a Composite State being an expanded State element that encloses other State elements, which are then referred to as sub-states. Composite States and State Machines can also contain Regions.


State elements can display either with or without a line across them. The line - as shown below - displays when the element has features such as attributes (which could be hidden) or when the Show State Compartment checkbox is selected in the Objects page of the Options dialog.

Example of a State Machine or State Chart

You have two options for exposing the contents of a composite State, such as Saved. Firstly, you can double-click on the element to display its child diagram separately, as shown below:


Alternatively, you can right-click on the composite element and select the Advanced | Show Composite Diagram context menu option, which displays the child diagram in the context of the parent diagram.


Toolbox Elements and Connectors

Select State Machine diagram elements and connectors from the State pages of the Toolbox.


Click on the following elements and connectors for more information.

State Machine Diagram Elements

State Machine Diagram Connectors





























OMG UML Specification

The OMG UML specification (UML Superstructure Specification, v2.1.1, Section 15.3.12, p. 560 ) states:

A state machine owns one or more regions, which in turn own vertices and transitions.

The behaviored classifier context owning a state machine defines which signal and call triggers are defined for the state machine, and which attributes and operations are available in activities of the state machine. Signal triggers and call triggers for the state machine are defined according to the receptions and operations of this classifier.

As a kind of behavior, a state machine may have an associated behavioral feature (specification) and be the method of this behavioral feature. In this case the state machine specifies the behavior of this behavioral feature. The parameters of the state machine in this case match the parameters of the behavioral feature and provide the means for accessing (within the state machine) the behavioral feature parameters.

A state machine without a context classifier may use triggers that are independent of receptions or operations of a classifier, i.e. either just signal triggers or call triggers based upon operation template parameters of the (parameterized) state machine.