<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>October</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>EmbeddedMontiArc: Textual modeling alternative to Simulink</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>(Tool Demonstration)</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Evgeny Kusmenko, Jean-Marc Ronck, Bernhard Rumpe, and Michael von Wenckstern Software Engineering, RWTH Aachen University</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2018</year>
      </pub-date>
      <volume>14</volume>
      <issue>2018</issue>
      <abstract>
        <p>The development of complex cyber-physical systems relies heavily on elaborate domain specific languages, agile processes, and tools. A quasi-standard in multiple engineering domains is Simulink, a component &amp; connector modeling tool by MathWorks. In this paper we present a versatile integrated development environment for EmbeddedMontiArc, a textual alternative for component &amp; connector modeling. In order to deliver an agile and test-driven modeling experience, we integrate the complete tool-chain including code generators, compilers, as well as a variety of target runtime environments such as simulators behind a single user interface facilitating the creation, execution, and validation of cyber-physical system models.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;C&amp;C Modeling</kwd>
        <kwd>Cyber-Physical Systems</kwd>
        <kwd>Vehicle Simulator</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>INTRODUCTION</title>
      <p>
        EmbeddedMontiArc is a Component &amp; Connector (C&amp;C) modeling
language family developed with an emphasis on the needs of the
embedded and cyber-physical systems domain [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. It is inspired
by the big players such as LabView and Simulink, but reveals a
novel textual approach to component and connector modeling. The
language family is composed of a multitude of modular textual
languages using the MontiCore language workbench [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]. The main
language elements include an architecture description language for
subdividing a system into its components and sub-components, a
matrix-based and strongly typed behavior specification language,
a stream language for model-based testing, etc. One of the main
strengths of EmbeddedMontiArc is its mathematical type system
abstracting away from the technical realization. It integrates
SIunits and unit-related compatibility checks as well as conversions
directly into the language.
      </p>
      <p>
        EmbeddedMontiArc provides an elaborate tool-chain
transforming the original user-defined model to an executable binary. Its
main steps include a parser, code generators for a series of target
languages such as C++ and WebAssembly as well as compilation
and linking [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. As models are rarely developed for stand-alone
usage as apps, but are rather meant to be used in heterogeneous
target environments such as robot controllers, vehicles, simulators,
and others, the resulting binaries often need to be deployed in a
runtime environment for testing. In our tool demonstration we present
EmbeddedMontiArcStudio (EMAS) - an integrated development
environment (IDE) providing the aforementioned development tools
out-of-the-box.
      </p>
    </sec>
    <sec id="sec-2">
      <title>FEATURES</title>
      <p>EMAS bundles all the features of EmbeddedMontiArc to a portable
Windows 10 64-bit application or a Ubuntu 16.04 64-bit virtual
machine enabling us to use EmbeddedMontiArc and its tool collection
out-of-the-box. EMAS is publicly available under:
http://www.se-rwth.de/materials/embeddedmontiarc/</p>
      <p>Similar to Simulink the main purpose of EmbeddedMontiArc is
C&amp;C modeling for embedded and/or cyber-physical systems. In
contrast to Simulink, which is a graphical modeling language and
stores multiple components (subsystems) in the same file,
EmbeddedMontiArc is a textual modeling language family that, similar
to Java classes, stores each component in its own file. Compared
to graphical modeling, the textual modeling concept of
EmbeddedMontiArc exhibits multiple advantages:</p>
      <p>(1) All model information is directly available in files, and can be
found and replaced by standard text programs. In graphical
modeling tools such as Simulink, Enterprise Architect, or PTC Integrity
Modeler this information is hidden behind a multitude of tabs or
dialog boxes and often stored in proprietary binary formats. Integrated
search speed for large models is slow.</p>
      <p>(2) Text-based versioning tools like SVN and git featuring model
diferencing as well as merging and branching can be used
out-ofthe-box. Graphical tools allow one to export their graph structure
as XML files, but reading an XML diference is hard since links
between graphical elements are represented as links between unique
identifiers.</p>
      <p>(3) In large projects where multiple teams work together on
the same model but on diferent files or even folders according to
their responsibilities, EmbeddedMontiArc follows the separation of
artifacts principle to enable modeling in the large. Having diferent
ifles for diferent components enables a better integration into
version control software since single components can be merged
or reverted independently.</p>
      <p>(4) Test driven development increases the code quality
dramatically. EmbeddedMontiArc has an easy to use first level integration
of unit tests for components whereas Simulink uses a graphical
testing framework based on the signal builder. In Simulink executing
multiple unit tests for one component is achieved by copying the
signal builder and the component under test several times.</p>
      <p>(5) In agile development, software is often updated to better
ift customer needs. But updating large graphical models (e.g.
inserting and reconnecting components) is very time consuming as
the existing graphical layout needs to be rearranged manually. In
EmbeddedMontiArc the graphical layout is generated automatically
based on the textual files, serving a better understanding of the
C&amp;C architecture. This way, the modeler can focus on the main
task by only adding, changing, or removing textual lines.</p>
      <p>Figure 1 shows screenshots of the six main features of
EmbeddedMontiArc: ○ A An interactive IDE with syntax highlighting, outline
and parse error messages. The IDE support for all the languages of
the EmbeddedMontiArc language family is automatically generated
using the MontiCore framework.</p>
      <p>○ B A quality report for all EmbeddedMontiArc models. The tool
shows all parse, resolve, and testing errors with its console
output; it is a continuous integration/deployment CI/CD front-end
for our modeling family. The tool can also be used stand-alone
(without EMAS) on a CI/CD server (e.g., travis-ci or gitlab runners)
to perform model-based regression tests.</p>
      <p>○ C The simplest simulator of EmbeddedMontiArc is the image
clusterer; it allows one to select pictures and converts them into
a third order tensor object (the first two tensor degrees represent
the height and the width of the image, respectively, while the third
degree contains the color channels red, green, and blue) which
is passed to the C&amp;C model; finally, the simulator converts the
resulting 2d matrix of the C&amp;C model back to a gray-scale image.</p>
      <p>○ D The visualization generator produces a graphical
representation of the textual EmbeddedMontiArc models as HTML and SVG
ifles. A special feature of this generator is to produce graphical
models with diferent abstraction levels, e.g. only showing the
connected components but no ports up to drawing the complete model
including all ports with their respective names and types. Since the
layouts are computed automatically unlike in Simulink where only
names or lines are hidden, the abstract graphical visualization is
much smaller than the complete one and thus well suited to obtain
an overview of large C&amp;C models.</p>
      <p>
        ○ E The car simulator [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ] with its 3d visualization and physics
engine executes car controllers to test EmbeddedMontiArc models
and their environment interactions. This feature is used for
acceptance testing allowing users to judge the driving behavior of cars
easily. Also the car simulator is a good motivation push for students
to create EmbeddedMontiArc models as they can experience their
models in the 3d visualization of the simulator.
      </p>
      <p>○ F The image classifier simulator works similarly to the image
clusterer. It allows to drag (or to select your own) pictures into
the analyze zone (white box) and then analyzes the content in the
images and returns a predicted class (such as dog, cat, truck, and so
on). The image classifier is a trained CNN (Convolutional Neural
Network) component where the test images of the simulator are of
course diferent from the training data.</p>
      <p>All three simulators ○ C , ○ E , and ○ F have in common that a C++
compiler toolchain translates the textual EMA models to native
code (dynamically linked libraries or standalone executables)
before the respective simulator can execute the model. A feature of
the toolchain is that it includes the highly optimized Armadillo
mathematics framework guaranteeing an eficient model execution
of computationally intensive software. This enables the simulation
of diferent cars at the same time and on the same laptop, the
execution of expensive algebraic algorithms in our image clustering
example, as well as the classification of images at nearly real-time
on standard customer hardware. Fast simulation results are a key
to keep students motivated to test their models and thus improve
them continually. For instance, our vehicle visualization works at
30 fps, image classification is executed without a noticeable delay.
3</p>
      <p>EMBEDDEDMONTIARC MODEL EXAMPLES
Figure 2 presents code snippets used in three of our executable
model examples: the Autopilot ○ E model snippet ○ 1 belongs to
the Autopilot model. This component checks whether the car is
still in the track. This component has two input ports (ll. 2-3) for
the car position relatively to the track accepting values between
-200 meters and +200 meters, and one Boolean output port (l. 4)
returning true when the car is outside the track boundaries. The
implementation part of the atomic component (ll. 5-8) contains code
defining how sensor inputs are mapped onto a Boolean output.</p>
      <p>
        Testing: ○ 2 is a blackbox unit test based on the stream
semantics. The concept is very similar to JUnit. A stream test operates
EmbeddedMontiArc (Tool Demonstration)
9 stream StatusControllerTest for StatusController {
10 x: 0m tick 200m tick -200m tick 250m;
11 y: 0m tick 120m tick -50m tick 50m;
12 status: false tick false tick false tick true; }
1 component CheckTrackBoundaries { ① 31 component SpectralClusterer {
2 ports in Q(-200m:200m) x, 32 ports in Q(-oo:oo)^{50,50} img[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ],
3 in Q(-200m:200m) y, 33 out Q(-oo:oo)^{2500, 1} cluster;
4 out B outsideTrack; 34
5 implementation Math{ 35
6 B boundariesX = (x &gt; 200m) || (x &lt; -200m); 36
7 B boundariesY = (y &gt; 120m) || (y &lt; -50m); 37
8 outsideTrack = boundariesX || boundariesY; }} 38
39
40
② 41
42
43
44
45
connect img[:] -&gt; similarity.img[:];
connect similarity.degree -&gt; normalizedLaplacian.degree;
connect similarity.similarity -&gt; normalizedLaplacian.similarity;
connect normalizedLaplacian.nLaplacian -&gt; eigenSolver.matrix;
connect eigenSolver.eigenvectors -&gt; kMeansClustering.vectors;
connect kMeansClustering.cluster -&gt; cluster; }
instance Similarity &lt;50&gt; similarity;
instance NormalizedLaplacian &lt;2500&gt; normalizedLaplacian;
instance EigenSolver &lt;2500, 50&gt; eigenSolver;
instance KMeansClustering &lt;2500, 50, 1&gt; kMeansClustering;
⑤
13 component Network {
14 ports in Z(0:255)^{3, 32, 32} data,
15 out Q(0:1)^{10} softmax;
16 implementation CNN {
17 data -&gt; conv -&gt; conv -&gt;
18 FullyConnected -&gt; Relu -&gt; Dropout -&gt;
19 FullyConnected -&gt; Softmax -&gt; softmax
20 }}
      </p>
      <p>
        ③
21 component NormalizedLaplacian {
22 ports in diag Q^{2500,2500} degree,
23 in Q^{2500,2500} W,
24 out Q^{2500,2500} nLaplacian;
25 implementation Math{
26 nLaplacian = degree^-0.5*W*
27 degree^-0.5; }}
④
value matrix
range dimensions
Q(0:255)^{50,50}[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]
img
      </p>
      <p>U</p>
      <p>array size
EigenSolver</p>
      <p>matrix
eigenvectors
img
...</p>
      <p>Similarity
similarity
degree</p>
      <p>KmeansClustering
vectors cluster</p>
      <p>SpectralClusterer</p>
      <p>W
D</p>
      <p>Q^{2500,2500}
NormalizedLaplacian
nLaplacian degree</p>
      <p>similarity
cluster id of each pixel cluster</p>
      <p>C&amp;C
⑥
D
W
on exactly one component specified after the for key word (l. 9).</p>
      <p>Of course, multiple stream tests can exist for each component. The
ifrst lines (ll. 10-11) provide the values for the input ports of the
components while the last line (l. 12) specifies the expected values
of the output port. The stream language also supports
underspecification, e.g. by defining ranges for output values. If the component
is executed and the calculated output values satisfy the expected
values of the stream, then the test will be considered as pass.</p>
      <p>Deep Learning Classifier ○ F : In ○ 3 a component using an
alternative implemention language, namely CNNArch is presented. It
supports a compact description of layered artificial neural networks
which become more and more ubiquitous in intelligent software
systems. The CNN model describes the layers of the network as well
as their interconnections. A generator then generates the target
network architecture, trains the network on a given labeled data
set and encapsulates the software in a standard EmbeddedMontiArc
component. Using a simulator similar to the clusterer users can
check the quality of the classification on their own images.</p>
      <p>SpectralCluster ○ C : the model snippets ○ 4 and ○ 5 belong to
the spectral clusterer model, which can be used to detect objects
in a picture. Since EmbeddedMontiArc is a textual modeling
language the developer writes down the model shown in ○ 5 , which
is semantically equivalent to the C&amp;C model displayed in ○ 6 . The
SpectralCluster component is decomposed into four
subcomponents (ll. 35-38). The information between these four
subcomponents is exchanged via unidirectional connectors (ll. 40-45). Model
○ 4 shows the implementation of the subcomponent
normalizedLaplacian (l. 36) having the type NormalizedLaplacian. Lines
26 and 27 show that the implementation part of
EmbeddedMontiArc models support normal matrix-vector expressions similar to
MATLAB code.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Christian</given-names>
            <surname>Frohn</surname>
          </string-name>
          , Petyo Ilov, Stefan Kriebel, Evgeny Kusmenko, Bernhard Rumpe, and
          <string-name>
            <given-names>Alexander</given-names>
            <surname>Ryndin</surname>
          </string-name>
          .
          <year>2018</year>
          .
          <article-title>Distributed Simulation of Cooperatively Interacting Vehicles</article-title>
          .
          <source>In 21st IEEE International Conference on Intelligent Transportation Systems (ITSC'18).</source>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Filippo</given-names>
            <surname>Grazioli</surname>
          </string-name>
          , Evgeny Kusmenko, Alexander Roth,
          <source>Bernhard Rumpe, and Michael von Wenckstern</source>
          .
          <year>2018</year>
          .
          <article-title>Simulation Framework for Executing Component and Connector Models of Self-Driving Vehicles</article-title>
          .
          <source>In Proceedings of MODELS 2017. Workshop EXE.</source>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>Katrin</given-names>
            <surname>Hölldobler</surname>
          </string-name>
          and
          <string-name>
            <given-names>Bernhard</given-names>
            <surname>Rumpe</surname>
          </string-name>
          .
          <year>2017</year>
          .
          <article-title>MontiCore 5 Language Workbench Edition 2017</article-title>
          . Shaker Verlag.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Evgeny</given-names>
            <surname>Kusmenko</surname>
          </string-name>
          , Alexander Roth,
          <source>Bernhard Rumpe, and Michael von Wenckstern</source>
          .
          <year>2017</year>
          .
          <article-title>Modeling Architectures of Cyber-Physical Systems</article-title>
          . In ECMFA.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Evgeny</given-names>
            <surname>Kusmenko</surname>
          </string-name>
          , Bernhard Rumpe,
          <source>Sascha Schneiders, and Michael von Wenckstern</source>
          .
          <year>2018</year>
          .
          <article-title>Highly-Optimizing and Multi-Target Compiler for Embedded System Models: C++ Compiler Toolchain for the Component and Connector Language EmbeddedMontiArc</article-title>
          . In MODELS.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>