The blocks¶
| Block | SysML element |
|---|---|
StateCharts.Initial |
initial pseudo-state (black dot) |
StateCharts.State |
state, with entry / do / exit |
StateCharts.Transition |
transition trigger [guard] / effect |
StateCharts.Choice |
choice pseudo-state (diamond) |
StateCharts.FinalState |
final state (bull's eye) |
StateCharts.Chart |
stm frame: state machine used as a block |
StateCharts.Actions.SetBoolean, SetInteger, SetReal |
output value according to the active state |

Ports of the states¶
State, Initial, Choice and FinalState have an array of ports on each of their four sides: top[nTop], right[nRight], bottom[nBottom], left[nLeft]. The same port serves for leaving and entering transitions. OMEdit increases the size of the array at each connection (tab Ports of the parameter dialog).
Several transitions may leave the same state, from any sides: this is how the machine branches.
State¶
| Boolean output | Position | Role |
|---|---|---|
entry |
right, top | true for pulseDuration after each entry into the state |
do |
right, middle | true while the state is active |
exit |
right, bottom | true for pulseDuration after each exit from the state |
| Parameter | Default | Role |
|---|---|---|
pulseDuration |
0.1 s | duration of the entry and exit pulses; 0 = instantaneous pulse |
| Variable | Role |
|---|---|
entryCount |
number of entries since the start of the simulation |
activeDuration |
time spent in the state since its last entry (0 while inactive) |
An instantaneous pulse (pulseDuration = 0) is true only at the event instant: enough to trigger a when, but invisible on a plot. A transition from a state to itself causes an exit followed by an entry (exit and entry pulses, activeDuration reset to 0).
While browsing the results in OMEdit, the active state is colored green, and the words entry / do / exit turn green when the corresponding output is true.
Initial¶
The black dot. It is active at the start and left at once by its outgoing transition, which has no trigger (Completion), usually no guard, and may have an effect. One per state machine.
All the states are inactive during initialization; the initial pseudo-state becomes active right after it, at the first instant of the simulation. The entry pulse of the first state therefore occurs at t = 0.
Transition¶
A transition is placed on the arrow between two states: source (left) to the state it leaves, target (right) to the state it enters. Flip or rotate it to follow the arrow. Its label follows the SysML notation: trigger [guard] / effect, where the effect bears the name of the transition.
Trigger (trigger)¶

| Value | Label | The transition fires… |
|---|---|---|
Completion |
(nothing) | as soon as the source state is active and the guard is true |
Signal |
signal ↑ |
on the rising edge of the signal input (bottom left) |
After |
after(delay) |
when the source state has been active for delay |
When |
when(change) |
when the expression change becomes true, for instance change = sensor.T > 294.15 |
A Signal or When event that occurs while the source state is inactive, or while the guard is false, is lost. No event occurs at the start: only a change after the initial instant counts. With Completion and After, the transition fires as soon as the guard becomes true (once the delay has elapsed).
Guard (guard)¶
| Parameter | Default | Role |
|---|---|---|
useGuard |
false |
the transition has a guard |
guard |
true |
the guard, a Boolean expression: weight > 5, count >= 4 and not stop… |
useGuardPort |
false |
read the guard on the guardPort input (bottom) instead of guard |
priority |
1 | priority among the transitions leaving the same state (1 = highest) |
The guard (like the change expression) may use any variable visible from the model that contains the transition: outputs of other blocks (sensor.T), inputs of a Chart, parameters, variables of the states (pump.activeDuration > 10).
Priorities: when several transitions leaving the same state can fire at the same instant, the one with the lowest priority number wins; for equal numbers, the first one in the order of the ports (top, right, bottom, left, then index). The number is shown in front of the label (2:) as soon as it is greater than 1.
Effect (effect)¶
The Boolean output effect (bottom right) is true for pulseDuration (0.1 s by default) each time the transition fires; pulseDuration = 0 gives an instantaneous pulse. The variable fireCount counts the firings. While browsing the results, the arrow turns green during the effect.
Choice¶
The diamond. The state machine goes through it without stopping: as soon as it is reached, it is left by the outgoing transition of highest priority whose guard is true. Its outgoing transitions have no trigger; give the "else" branch the largest priority number and no guard. If no guard is true, the machine stays in the choice until one becomes true.
FinalState¶
The bull's eye. Once it is reached, the state machine is completed: completed = true. With stopSimulation = true, reaching it stops the simulation.
Chart¶
To use a state machine as a block in a larger model — a SysML stm frame — create a model that extends StateCharts.Chart, add inputs and outputs (Modelica.Blocks.Interfaces.RealInput, BooleanOutput…), then the states and transitions:
model ThermostatChart
extends StateCharts.Chart;
Modelica.Blocks.Interfaces.RealInput T;
Modelica.Blocks.Interfaces.BooleanOutput heating;
StateCharts.Initial start;
StateCharts.State off;
StateCharts.Transition startHeating(useGuard = true, guard = T < 292.15);
...
equation
connect(on.do, heating);
...
end ThermostatChart;
Full example: Examples.ThermostatChart, used by Examples.Thermostat.
Actions¶
These blocks turn the do outputs of the states into a signal:
| Block | Output y |
|---|---|
SetBoolean |
true if at least one of the connected states is active |
SetInteger |
values[i] for the first active state connected to u[i], otherwise y_default |
SetReal |
same, as a Real |
Connect the do output of each state to the u input of the block; nIn grows at each connection, and values must have the same size.