Beruflich Dokumente
Kultur Dokumente
Wladimir Schamai
EADS Innovation Works (Hamburg, Germany)
Linkoping University (Linkoping, Sweden)
Abstract: This document provides a short introduction to ModelicaML, points out existing
constraints and limitations, and describes how to set up a ModelicaML modeling environment.
1
Table of Contents
2
Table of Figures
3
1 ModelicaML: Short Introduction
Modelica Modeling Language (ModelicaML) is a graphical modeling language for hybrid (time-
continuous and time-discrete/event-based) systems description. ModelicaML is defined as a
concrete graphical syntax (diagrams) and enables different views (composition, inheritance,
behavior) on system definition. It is based on a subset of the OMG Unified Modeling Language
(UML) [2] and reuses concepts from the OMG Systems Modeling Language (SysML) [3].
ModelicaML is defined towards generation of executable Modelica code from UML-based
graphical models.
UML/SysML provide the modeler with powerful descriptive constructs at the expense of loosely
defined semantics that are marked as “semantic variation points” in the UML/SysML
specifications. The intention of the ModelicaML is to provide the modeler with powerful
executable constructs and precise execution semantics that are based on the Modelica language.
Therefore, ModelicaML uses a limited set of the UML, extends the UML meta-model (using the
UML profiling mechanism) with new constructs in order to introduce missing Modelica concepts
and reuses concepts from the SysML. However, as the UML and SysML, ModelicaML is only a
graphical notation. ModelicaML models are eventually translated into Modelica code. Hence, the
execution semantics are defined by the Modelica language and ultimately by a Modelica compiler,
that translates the generated Modelica code into an executable form.
Since the ModelicaML profile is an extension of the UML meta-model it can be used for both:
Modeling with the standard UML and with the SysML1. See [6] for more detailed description of
the ModelicaML profile and an application example.
The following sections point out constraints and limitations that exist in ModelicaML.
1
SysML itself is also a UML Profile. All stereotypes that extend UML meta-classes are applicable to the SysML as well.
4
- Composite Structure Diagram: for representing class components and their
interconnection. This diagram is similar to the Modelica Connection Diagram.
- Activity Diagram: for modeling of conditional equations or algorithm statements.
- State Machine Diagram: for modeling of state-based behavior.
Textual requirements are represented using classes with additional attributes such as id and text. It
is possible to link requirements to other classes in order to establish traceability. Furthermore, it is
possible to formalize requirements, bind them to design models in order to evaluate requirements
during system simulations. See ModelicaML documentation for more information.
The code generator may modify the names of model elements as following:
- It replaces all special characters and white spaces (if there are any)
- If a name starts with a number the code generator adds “_” in front of the number
In parallel to the code generation the ModelicaML model is checked for consistencies. Violations
or warnings are displayed in error view and advise the modeler to correct the model. Note,
however, it does not check if there is a name clashing between classes (e.g. two classes in a
package that have the same name).
5
Note, however, this features have not been tested yet.
6
1.5 Limitations With Regard To Modelica
Since ModelicaML is based on the UML meta-model some limitations exist with regard to the
Modelica code to be generated or imported. These limitations are particularly important to be
aware of when importing existing Modelica code (e.g. Modelica Standard Library) into UML-
based (e.g. ModelicaML) models. Modelica code that makes use of the features mentioned will
most likely have to be rearranged.
The UML meta-model does not allow Packages to be nested in Classes or DataTypes as
explained in the following table.
UML Package UML Class UML DataType
(represents Modelica package) (represents Modelica model or block) (represents Modelica connector or record, type)
can have nested
UML Packages x
UML Classes x x
UML DataTypes x x
The resulting implication on the Modelica code to be generated from a ModelicaML model or to
be imported into a ModelicaML model is as following.
Modelica package Modelica model / block Modelica connector / record / type
can have nested
Modelica package x
Modelica model / block x x
Modelica connector / record / type x x
In other words, in ModelicaML, it is not possible nest packages in classes or classes in records,
connectors etc.
1.5.4 Short-Class-Definition
Modelica short-class-definition is not possible in ModelicaML. The modeler should use
inheritance constructs instead.
7
1.5.5 Import Clause
When modeling with ModelicaML it is not necessary to import packages or classes explicitly. The
modeler can simply use any classes from other packages. The ModelicaML code generator will
generate Modelica code with qualified names so that no import clauses are required.
8
2 Installation
Presently, ModelicaML modeling and code generation environment is implemented using the
Eclipse technology and including the following plug-ins:
- Papyrus 1.12 [5] as UML-based modeling tool (ModelicaML modeling)
- Acceleo 2.6 [4] for model to text transformation (Modelica code generation)
Both2, Papyrus and Acceleo became Eclipse Projects and will deliver new versions in the next few
moth. We plan to migrate the current environment to the new versions.
Procedure:
- Download, extract and start Eclipse 3.5 Modeling Tools
- Update the network connection properties (if required) so you can install other plug-ins.
2
http://www.eclipse.org/modeling/mdt/?project=papyrus
http://www.eclipse.org/modeling/m2t/?project=acceleo
9
Figure 4: Eclipse Network Connections
Procedure:
- In Eclipse go to Help -> Install New Software
- Add the Update-Site (see screenshot below)
Procedure:
- In Eclipse go to Help -> Install New Software
- Add the Update-Site
- Install Acceleo (see screenshot)
10
Figure 6: Add the Acceleo update-site
Procedure:
- In Eclipse go to Help -> Install New Software
- Add the Update-Site
- Install MDT (see screenshot)
11
2.5 Install ModelicaML Profile and Code Generator
Download the ModelicaML Eclipse plug-ins
- ModelicaML Profile and
- ModelicaML Code Generator.
Procedure:
- Unzip this files
- Copy the .jar files into your Eclipse “plug-in” directory.
- Restart Eclipse
12
- Select the example project
- Select the option “copy projects into workspace”
13
Figure 11: Result of importing the example project
14
Figure 13: Simulation of the ModelicaML example model in MathModelica System Designer
15
Figure 15: Un-apply the Standard profile
16
Figure 16: Apply ModelicaML profile
- Select all except the “ProfileDecumentationStereotypes”. This sub-profile is used only for
internal ModelicaML Profile documentation only. It is not used for modeling.
- The result should be like in the screenshot below.
17
Figure 18: Create a Package
18
Figure 20: Apply a stereotype to the Class
19
Figure 21: Applied stereotype
20
Figure 22: Import ModelicaML primitive types
- In particular this import is required for the selection of types for function variables (see
screenshot below)
21
2.9.3 Setup the ModelicaML Code Generator
Procedure:
- In your project create a new Acceleo “Module Launcher”
22
Figure 26: Define the name for the ModelicaML Code Generator Module Launcher
- Select the ModelicaML model, the folder and location for the error.log file
Figure 27: Define the locations for the model, the target folder and the log file
- Open the Acceleo log view. The ModelicaML code generator will display any warning or
errors in this view
23
Figure 28: Open Acceleo Log View
- If there are any errors the code generator will inform you as illustrated below
24
Figure 30: Example of error or warning notification
- You can clear or delete the logs using these buttons (see screenshot below).
- By default the Modelica code is generated into the “code” directory of your project.
- You can open the Modelica file using the Modelica Development Tooling as shown
below.
25
Figure 33: Generated Modelica code
26
References
[1] Modelica Association. Modelica: A Unified Object-Oriented Language for Physical
Systems Modeling: Language Specification Version 3.0, Sept 2007. www.modelica.org
[2] OMG. OMG Unified Modeling Language TM (OMG UML). Superstructure Version 2.2,
February 2009.
[3] OMG. OMG Systems Modeling Language (OMG SysML™), Version 1.1, November 2008.
[4] Acceleo, Eclipse Plug-In. www.acceleo.org/pages/home/en
[5] Papyrus UML, www.papyrusuml.org
[6] W.Schamai. ModelicaML: a UML Profile for Modelica, Technical Report
http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-20553
27