SysML mapping¶
This page maps the concepts of SysML state machine diagrams to the blocks of StateCharts.
Mapping¶
| SysML | StateCharts |
|---|---|
| stm diagram (frame) | model that extends Chart, with its inputs / outputs |
| Initial pseudo-state ● | Initial connected to the first state by a Transition |
| State | State |
entry / behavior |
Boolean output entry (pulse) |
do / activity |
Boolean output do (true while the state is active) |
exit / behavior |
Boolean output exit (pulse) |
Transition trigger [guard] / effect |
Transition, Boolean output effect |
| Signal event | trigger = Signal, signal input (rising edge) |
Time event after(t) |
trigger = After, delay = t |
Change event when(c) |
trigger = When, change = c |
| Completion transition | trigger = Completion |
| Choice pseudo-state ◇ | Choice |
| Final state ◉ | FinalState |
| — | priority parameter of the transition (order between transitions that can fire at the same instant) |
Using the Boolean outputs¶
Behaviors and effects are not code run by the diagram: they are Boolean signals used by the rest of the model.
Drive an actuator: connect do (or effect) to the Boolean input of a block — BooleanToReal, a switch, a valve…
Count, remember: a when clause on a pulse, in the model that contains the diagram:
Integer cycles(start = 0, fixed = true);
algorithm
when red.entry then // entry / cycles++
cycles := cycles + 1;
end when;
when goGreen.effect then // / goGreen: effect of the transition
...
end when;
One value per state: an Actions.SetInteger or SetReal block connected to the do outputs.
Execution specifics¶
- Continuous time. The diagram is not run at a fixed step: a transition fires at the exact instant of its event, located by the solver (threshold crossing of a temperature, end of an
after, edge of a signal). - Chaining at the same instant. If the state reached has an outgoing transition that can already fire (completion with a true guard), it fires too, at the same instant: this is how a
Choiceis traversed. Example:Thermostatstarts at 15 °C, entersoffand moves on toonat once, at t = 0. - Guarded completion and
after. In strict SysML, the completion orafterevent is evaluated once; here, the transition fires as soon as the guard becomes true afterwards. For a strict event behavior, useWhen. - Pulses of finite duration.
entry,exitandeffectlastpulseDuration(0.1 s by default) so that they show on plots;pulseDuration = 0makes them instantaneous. - Not available yet: see Limits.