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