Drawing state machine diagrams

State machine diagram shows flow of control from state to state within single object. It usually contains simple states, composite states, composite states, transitions, events and actions.

Creating state machine diagram

Right click State Machine Diagram on Diagram Navigator and select New State Machine Diagram from the pop-up menu to create a state machine diagram.

Create state machine diagram
Create state machine diagram

 

Creating states and transitions

After creating a state machine diagram, an initial pseudo state appears by default. Move the mouse over it and click its resource icon Transition -> State.

Create state from initial pseudo state
Create state from initial pseudo state

Drag it to your preferred place and then release the mouse to confirm the place. As a result, a state is created and is connected to the initial pseudo state with a transition.

State and transition created
State and transition created

Similarly, you can use the Transition -> Final State resource to create a final state.

Create final state
Create final state

Final state does not show caption by default. To show it, right-click on the diagram and select Presentation Options > Show Shape Caption > Final State.

Show caption of final state
Show caption of final state

Adding region to state

To model substates of a composite state, you need to add one or more regions to it. To add a region, right-click the state and select Add Horizontal Region from the popup menu.

Add region to state
Add region to state

Next, you can draw the substates inside the region.

Substates in a composite state
Substates in a composite state

Modeling properties of transition

To model properties of transition such as effect and guard, right-click the transition and select Open Specification... from the pop-up menu.

Open specification of transition
Open specification of transition

When the Transition Specification dialog box pops out, you can edit its name, effect and guard. Next, click Edit... button of the Effect property.

Transition Specification dialog box
Transition Specification dialog box

In Activity Specification (Effect) dialog box, change its name, and then click OK button to apply the change.

Edit effect property of transition
Edit effect property of transition

Click OK in the Transition Specification dialog box to close it. The name and effect are shown on the transition caption.

Name and effect shown in caption of transition
Name and effect shown in caption of transition