Welcome to the PlantUML User Guide focused on creating hierarchical state machines. This guide is designed to help you utilize a specific subset of PlantUML syntax for state machines, enabling the generation of code from your diagrams. Note that only selected features of PlantUML for state machines are supported here.
The state machine Autocoder supports the following features:
- Hierarchical states
- Complex junctions
- Complex initial transitions
- Transition guards and actions
- Internal transitions
- Self transitions
The state machine Autocoder does NOT support the following features:
- Sub state machines
- Orthogonal regions
In addition, the parser does not support PlantUML graphical layout information. This may be supported on later releases.
To define a state, use the state
keyword followed by the state’s name and enclose any nested states or definitions within curly braces {}
.
state S2 {
}
States can be nested within other states to represent hierarchical relationships.
state S2 {
state S21 {
}
}
Specify actions that occur on entering or exiting states by appending :Entry:
or :Exit:
to the state name, followed by the action.
state S2 {
S2:Entry: foo()
S2:Exit: bar()
}
Multiple actions can be delineated using semicolons ;
.
state S2 {
S2:Entry: foo(); foo2()
S2:Exit: bar(); bar2()
}
Transitions between states are defined using the format: source_state -→ target_state : Event [guard()] / action()
.
Junctions, or choice points, allow for branching transitions and are defined as a state with the [choice]
stereotype.