This information is part of the Modelica Standard Library maintained by the Modelica Association.
There is a much improved library available called "Modelica_StateGraph2".
If this library is not yet distributed with your Modelica tool, you can download
it from https://github.com/modelica/Modelica_StateGraph2.
Find below a comparison with respect to Modelica.StateGraph.
It is not yet clear whether Modelica_StateGraph2 will be included in a
future version of the Modelica package. Another option is to provide
built-in support for state machines in a future Modelica language version
which would allow an even more powerful treatment of state machines in Modelica.
The Modelica_StateGraph2 library (called StateGraph2 below)
is based on the experience with the current
Modelica.StateGraph library (called StateGraph1 below) and is
a significantly further development of StateGraph1. Furthermore, it is heavily
based on the article (Malmheden et. al. 2008), see Literature below,
but uses a different implementation
technique as described in this article. The StateGraph2
library has the following improvements with respect to the StateGraph1
- 3 Basic Components (Step, Transition, Parallel)
All multiple versions of a component are
combined in only one version (e.g., one step and not 4 step components).
This is easier to understand and more convenient to use.
The "Parallel" component is both used as "composite step" (so only one branch),
as well as "parallel step" (so several execution branches).
- Conveniently connecting components
Connecting components of a state machine in Modelica means to provide
new vector dimensions and to provide a vector index to connect to.
In StateGraph2, the new "connectorSizing" annotation is used and
therefore all this is now performed automatically (from a users point
of view, these actions are hidden; this is not the case in
StateGraph1 and makes the usage of the StateGraph1 library clumsy).
- Safer state machines
It is no longer possible to construct a wrong state machine in the sense that properties
of the graph are violated (e.g., two initial steps, or branching wrongly out of a parallel
component). Contrary to StateGraph2, in StateGraph1 such wrong graphs do not lead to an
error but to unexpected simulation results. Still, other desirable properties
of a state machine, such as "no deadlock" or "lifeliness" or "every step reachable",
are not (yet) guaranteed with the current StateGraph2.
- Composite, autonomous, synchronized, preempted subgraphs
Composite steps and parallel steps are described in a much better and more powerful
way as in StateGraph1: Either by component "Parallel" or
by inheriting from "PartialParallel". The first alternative has the advantage that it
is simple to use (not necessary to construct a new class and instantiating this class, and
easy variable access since no new hierarchy is constructed), the second alternative
has the advantage that it introduces a Modelica hierarchy (useful for large subgraphs).
In both cases, various options are possible, such as
This is achieved by enabling/disabling the different ports.
- autonomous subgraphs (branches are executed in parallel autonomously),
- synchronized subgraphs (branches are executed in parallel and are synchronized
before leaving the subgraph via the outPort),
- subgraphs with preemption and exception (a parallel step can be interrupted via
the suspend ports and can continue execution via the resume ports).
- No infinite looping:
As in StateGraph1, there are two types of transitions: immediate transitions (during event
iteration all immediate transitions fire until no transition condition is true anymore) and
delayed transitions (a transition fires only after a delay). Contrary to StateGraph1,
in StateGraph2 every loop must have at least one delayed transition. If this is not the case
a translation error occurs which states that the model contains an algebraic loop
between Booleans with the name "checkOneDelayedTransitionPerLoop".
This property guarantees that an event
iteration over a StateGraph2 converges after a
finite number of iterations, provided the modeller does not introduce an unsafe construct
in the actions associated with a StateGraph2 (e.g., "i = pre(i) + 1" in the equation section
outside of a when-clause will give an event iteration that never stops).
It is possible to switch off this feature, by setting parameter
"loopCheck = false" in one transition of a loop, instead of using a "delayed transition"
at this place (in cases where immediate transitions are
important and the transition conditions are in a form that they cannot fire at the
same time instant).
The Modelica_StateGraph2 library is described in detail in
(Otter et. al. 2009, see below) and is additionally
based on the following references:
- André, C. (2003):
Semantics of S.S.M (Safe State Machine)..
I3S Laboratory, UMR 6070 University of Nice-Sophia Antipolis / CNRS.
- Årzén K.-E. (2004):
- JGrafchart User Manual. Version 1.5.
Department of Automatic Control, Lund Institute of Technology,
Lund, Sweden, Feb. 13, 2004.
- Dressler I. (2004):
Code Generation From JGrafchart to Modelica..
Master thesis, supervisor: Karl-Erik Årzén,
Department of Automatic Control, Lund Institute of Technology,
Lund, Sweden, March 30, 2004.
- Elmqvist H., Mattsson S.E., Otter M. (2001):
- Object-Oriented and Hybrid Modeling in Modelica.
Journal Europeen des systemes automatises (JESA),
Volume 35 - n. 1, 2001.
- Harel, D. (1987):
A Visual Formalism for Complex Systems.
Science of Computer Programming 8, 231-274. Department of Applied Mathematics,
The Weizmann Institute of Science, Rehovot, Israel.
- Malmheden M. (2007):
ModeGraph - A Mode-Automata-Based Modelica Library for Embedded Control.
Master thesis, Department of Automatic Control, Lund University, Sweden.
- Malmheden M., Elmqvist H., Mattsson S.E., Henrisson D., Otter M. (2008):
ModeGraph - A Modelica Library for Embedded Control based on Mode-Automata.
Modelica'2008 Conference, March 3-4, 2008.
- Maraninchi F., Rémond, Y. (2002):
A New Domain-Specific Construct for the Development of Safe Critical Systems.
- Mosterman P., Otter M., Elmqvist H. (1998):
Modeling Petri Nets as Local Constraint Equations for
Hybrid Systems using Modelica.
SCSC'98, Reno, Nevada, USA,
Society for Computer Simulation International, pp. 314-319, 1998.
- Otter M., Malmheden M., Elmqvist H., Mattsson S.E., Johnsson C. (2009):
A New Formalism for Modeling of Reactive and Hybrid Systems.
Modelica'2009 Conference, Como, Italy, Sept. 20-22, 2009.