Introducing Damos 0.3

Damos 0.3 is just around the corner with many new features and improvements. In this post I will introduce the most interesting new features. If you want to try the new version, you can install the required plug-ins directly from our Eclipse update site.

We will also have a stand at the Embedded World at the end of this month, so stop by if you want to meet us in person.

Block Type Language

Block types can now be defined using a textual DSL. This DSL incorporates Mscript, so that you can not only define the structure of the block type, but also its behavior. You can create new block types directly in your project, and simply drag-and-drop the block type from your project explorer into the block diagram.

System Interface Language

Another textual DSL has been created to define system interfaces (needed to create subsystems). If you select an existing block diagram and open the New System Interface Wizard, the system interface of the first fragment of the selected block diagram is automatically extracted (given that it contains In/Outports).

Configuration Language Dconfig

Simulation and code generation was previously configured using various configuration models. This has been greatly simplified by introducing a generic configuration language called Dconfig. Dconfig configurations contain global properties and properties for individual Damos model elements (using an annotation mechanism). Furthermore, configurations can extend and/or override other configurations, so that, for instance, properties that are common to simulation and code generation can be extracted to a base configuration (previously known as execution model). Dconfig also incorporates the computation model metamodel to allow for configuring computation-related aspects (e.g. fixed-point artithmetic operations).

Other plug-ins can contribute new property definitions. In this way, customized code generators and simulators can define their own set of properties.

Quick Fixes

Quick fixes are now available for many common problems. They can be directly accessed from the error marker tooltip, or within the Problems view by right-clicking on the corresponding problem and selecting Quick Fix.

Real-Time Simulation

Real-time simulation will now be performed if you do not specify the simulation time. You can also put virtual instrument blocks into the block diagram to visualize or interact with the running simulation.

Solvers

When simulating continuous systems, the simulation engine needs to compute the continuous states of continuous blocks by means of numerical integration. Therefore, the accuracy of the simulation result largely depends on the used integration method. The simplest integration method is the Euler method. The major disadvantage of this method is that it requires small step sizes in order to achieve acceptable accuracy, which, on the other hand, increases the computation time. Other methods such as the Runge-Kutta methods usually provide better performance.

In the past, the Euler method was the only integration method supported in Damos. In the upcoming version, the process of computing the block states is encapsulated in so-called solvers. Each solver utilizes a numerical integration method for computing the continuous block states. Solvers can be customized or new solvers can be added using the Eclipse plug-in mechanism. Currently, the following solvers are available in Damos:

  • Fixed step size solvers:
    • Euler
    • Classical Runge-Kutta
  • Adaptive step size solvers:
    • Dormand-Prince 5(4)
    • Dormand-Prince 8(5,3)

To illustrate the accuracy issue, the following model was first simulated utilizing the Euler solver and then utilizing the classical Runge-Kutta solver using the same step size (0.05s). The last figure shows the exact simulation result utilizing an adaptive step size solver.

PI controller model:
PI Controller

Simulation result utilizing the Euler solver (notice the incorrect overshoot):
Simulation Result Euler

Simulation result utilizing the classical Runge-Kutta solver:
Simulation Result Classical Runge-Kutta

Exact simulation result utilizing the Dormand-Prince 5(4) solver:
Simulation Result Dormand-Prince

Conditional & Iteration Constructs

The main characteristic of data flow-oriented systems is that the execution of the system components is triggered by the continuous flow of data that passes through the system. Since each component is directly or indirectly connected to a source component (inports, step function blocks, etc.), you assume that each component is executed exactly once during each execution cycle. That is, all system components (with inputs) will obtain valid input data during each execution cycle.

Action Compounds

Sometimes it is desired to execute a component or a group of components only if certain conditions are met. With data-flow oriented systems, however, you cannot simply ‘disable’ a group of components, since other components whose inputs are driven by the disabled components will not receive valid data anymore. Therefore, if your system contains components that are executed conditionally, you must provide an alternative input to the components that are driven by the conditionally executed components.

To specify conditionally executing components in Damos, you must place them in a so-called action compound. Each action compound must be linked to a Choice component, which declares the conditions at which the action compounds are executed. Since it is not allowed to connect more than one connection to an input port, a Join component must be used to merge alternative connections (the ones leaving the action compounds) back into one connection.

Simple Actions

In the example above, two action compounds (rounded gray rectangles) are shown. The upper one is executed if the input of the Choice (octagonal figure) evaluates to true, and the lower one is executed if the Choice input evaluates to false. The dashed arrows between the Choice and the action compounds are called action links. If the action link conditions (which can be any expression) are not true and false, a default action link must be provided to ensure that in any case one action compound is executed. The Join component on the right side of the action compounds passes on the result of the Sum block (upper action) or the value 20 (lower action), depending on which action compound has been executed.

While Loops

Another type of compounds that can be used in Damos are while loops. The components inside a while loop are executed as long as the while loop condition input (small rectangle on the while loop border) evaluates to true. To pass values from one iteration to the next, a Memory component can be used. The Memory component simply outputs its input value of the previous iteration; or in the case of the first iteration, the initial condition input value (top input port). While loops are executed atomically within a single time step; that is, all intermediate results are local to the while loop.

Do While Loop

The while loop in the example above counts from 10 to 20 with an increment of 1. The final value (20) is then passed on to the input of the scope block. Hence, the resulting graph is a horizontal line with the equation y(t)=20. You may have noticed that the initial value block is located outside the while loop. This is necessary because the initial value must be available before the while loop starts.

The while loop that has been discussed so far is, in fact, a do while loop. This is because the components inside the while loop are executed at least once before evaluating the while loop condition input. Since the while loop is a specialized action compound, they can be used in place of ordinary action compounds—and in this way, real while loops can be constructed. This is illustrated in the example below.

While Loop

New Features in Damos 0.2

In the last couple of months, I was quite busy with the development of the next version of Damos. This new version will bring many new features. In this post I will introduce the most interesting ones, which are:

  • System Interfaces and Subsystems
  • System Fragments
  • Units of Measurement
  • Specifying Block Behavior with Mscript

System Interfaces and Subsystems

The classic way to structure large models is by dividing the system into subsystems. In contrast to other tools, subsystems are described in Damos solely through their provided system interface. On the one hand, this allows for using different subsystem implementations for a single subsystem. On the other hand, it enables the decoupling of the model that uses the subsystem and the model that realizes the subsystem (i.e. there is no model reference from the using model to the realizing model).

A system interface specifies the system inputs and outputs—so called inlets and outlets—and their data types. When adding a new subsystem to a model, the user must specify the system interface that is provided by the new subsystem. Newly added subsystems do not specify its realizing model—that is, the realizing model must be specified explicitly later on. Subsystems without a realization specification are visualized in the block diagram with a dashed border.

Subsystem

In order to simulate the model or to generate code, the realizing models for all subsystems must be specified. This is done by defining a subsystem realization for each subsystem, which binds the subsystem to a realizing model. When using system fragments (see next section), it is even possible to override previously defined subsystem realizations with a subsystem realization on a child fragment. Realized subsystems are visualized in the block diagram with a solid border and a triangle to the left of the subsystem name. In the case of an overridden subsystem realization, an opaque green triangle is used instead.

Realized Subsystem

The model of the realizing system must contain a corresponding inport and outport for each inlet and outlet of the system interface, respectively. These inports and outports represent the interface of a system from the implementation point of view.

Subsystem Implementation

System Fragments

When modeling data flow-oriented systems, it is often desired to incorporate blocks that are used for simulation purposes only (e.g. step function blocks and scopes). These blocks are not related to the functional concern (i.e. core concern) of the model, but represent an unrelated concern that cross-cuts the model’s functional concern. In aspect-oriented programming (AOP) terminology, such cross-cutting concerns are called aspects.

Mixing cross-cutting concerns and functional concerns on the same model leads to undesired effects. For instance, imagine you need to design a process model which will later be included as a subsystem in a control loop model to simulate the behavior of a digital controller design. However, during the design of the process model you often need to add simulation-specific blocks to verify the correctness of the process model itself. Now, if you include the process model—keeping the simulation-specific blocks—as a subsystem in your digital controller design, the simulation-specific blocks on the process subsystem will likely interfere with the simulation of the overall system.

The problem is even more significant if you add simulation-specific blocks to a model which is later used to generate code from. In this case, the code generator will either generate invalid code or fail altogether because it does not know how to handle simulation-only model elements.

It becomes clear that we need a means to separate the various aspects of a system model. In Damos this can be accomplished with the concept of system fragments. System fragments are basically a grouping mechanism for blocks. For instance, if your model contains simulation-specific blocks in addition to the functional blocks, you would extract those blocks to a separate fragment.

System Fragments

System fragments are hierarchically structured, which is orthogonal to the subsystem hierarchy. A system model consists of exactly one root fragment and any number of child fragments (including none at all). In the example above, the functional fragment would be the root fragment and the simulation fragment its child. Since system fragments can have any number of children, different aspects of a system model can be defined in this way.

The set of system fragments which form a concrete system model is defined by the context fragment. The context fragment—which can be any fragment in the fragment hierarchy—and all its parent fragments up to the root fragment determine the set of blocks of a concrete system model. Therefore, if you need to specify a system model for simulation or code generation purposes, or when specifying the realizing system model of a subsystem, you must specify the context fragment.

System Fragment Hierarchy

As mentioned earlier, subsystem realizations, which bind subsystems to concrete implementations, are also located on system fragments. Due to the fact that they do not need to be located on the same fragment as the realized subsystem, but can be located on any child fragment, multiple realizations for a single subsystem can be defined. In this way, it is even possible to override existing subsystem realizations on parent fragments.

Units of Measurement

During model editing, Damos constantly validates the compatibility of the input and output data types of connected blocks. If the data types do not match, error markers are attached to the corresponding blocks. Because data flow-oriented modeling is often used to model physical systems, quantitative values can be specified. That is, any numeric value has a unit attached to it. If no unit is specified, a dimensionless value is assumed (i.e. unit is 1). Based on the block type, Damos can then validate the compatibility of the input data types and evaluate the resulting output data types with respect to its units. The output data types are then checked against the input data types of the next block.

Units of Measurement

Specifying Block Behavior with Mscript

In the new version of Damos, block behavior can be specified declaratively in the block type definition using the scripting language Mscript. That is, it is not necessary anymore to provide code templates and Java code for each block. This increases the accuracy of the simulation result versus the generated code, allows for defining new block types directly within a Damos project, and eliminates the necessity to recreate all code templates to support a new programming language.

Mscript is a declarative programming language where you define the relationship between the inputs and outputs of a function using a set of equations. In contrast to a functional language, Mscript functions can be stateful. Consequently, such functions must be instantiated (function objects). Stateful function equations can reference previous input and output values, which enable the specification of difference equations (not to be confused with differential equations). Difference equations are widely used to specify discrete transfer functions, for instance in the field of digital signal processing (e.g. FIR and IIR filters). The Mscript example below shows the difference equation of a discrete derivative.

Installing Damos 0.2

If you want to experiment with a preview version of Damos 0.2, you can checkout the source code from our project site, or install Damos from our Eclipse update site. I will also provide a step-by-step tutorial on block diagram editing, model simulation, and code generation in one of my next posts.

Previous and Upcoming Conferences

Last month Axel and I held a tutorial at the Eclipse Summit Europe where we talked about embedded systems modeling topics. We introduced the open source modeling tools that are shipped with the Yakindu workbench and showed a reference implementation of a textual component model. For demonstration purposes, we showcased a heat control application, which has been developed using our modeling tools.

We also submitted three talks (two Axel and one me) at the Embedded World Exhibition & Conference 2011, which is the world’s largest embedded systems exhibition. Gladly, all three talks were accepted. Axel will talk about modeling reactive systems using state machines and textual modeling techniques, and I will talk about data flow-oriented modeling with Eclipse. In this talk, I will introduce Mscript and the new features of Damos 0.2.

Customizing Damos

Recently we finished an interesting customer project where we built an Eclipse-based graphical tool for designing PLC (programmable logic controller) software using function block diagrams. The diagram editor of this tool was based on Damos. Thanks to the modular design of Damos, we were able to easily replace the original block types with customer-specific block types. We also defined a distinct appearance for function blocks. Some additional graphical features (e.g. varying line thickness of connections to visualize different signal types) were also added. All changes were done through extensions, which means that none of the Damos sources had to be patched.

Function Block Diagram

A PLC software project is divided into modules, which is divided into tasks, which again is divided into pages. Each page is represented by a function block diagram. To define the structure of a module (i.e. containing tasks and pages), we created a forms editor, where the PLC software developer can also define global symbols like variables, constants, and references. Finally, a compiler was built to transform the model of a module into binary code that can be executed on a PLC.

Good Bye DSM, Hello Damos!

In the last couple of month, I was quite busy with customer projects, and of course, Damos. Wait, Damos? Yes, the Dynamical Systems Modeler has been renamed to Damos. The old name was simply too long, and the acronym doesn’t sound great either. So, DSM is now Damos.

Furthermore, I decided to move the project to the Yakindu workbench project, which is hosted on eclipselabs.org. The goal of the Yakindu project is basically to provide an Eclipse distribution containing modeling tools for embedded systems. If you don’t want to bother with downloading and installing Eclipse plug-ins, you can download the complete Yakindu distribution from yakindu.com. However, this distribution only contains version 0.1 of Damos (still named DSM in 0.1). The upcoming version 0.2 will contain significant changes, which I will post later about.

Dynamical Systems Modeler

After one year of development, the Dynamical Systems Modeler (DSM) reached a point of being ready to experiment with. DSM is an open source Eclipse-based modeling tool for modeling dynamical systems. The main focus is on applications in the field of control systems and digital signal processing. DSM consists of three components: a block diagram editor, a simulator, and a C code generator. The official DSM distribution comes with a block library containing most commonly used blocks. If necessary, the users can easily extend or customize the block library, or even provide their own block libraries.

Dynamical Systems Modeler

The Dynamical Systems Modeler is under heavy development right now. The API is not stable yet, which means that if you write your own extensions, you may have to adjust them for the next DSM releases. One of the next upcoming features will be the support of subsystems. Currently, you have to model your system in a single block diagram, which is not acceptable for large systems. Another hot topic is model validation (in contrast to simulation). For instance, if your block diagram contains blocks with duplicate names, it should give you an error.

If you want to experiment with DSM, you need to install Eclipse (>=3.5) first. You can find the latest version here. If you are planning to generate C code, you probably want to install the Eclipse IDE for C/C++ Developers package. After you have installed Eclipse, you need to install DSM using the Eclipse update site http://esmp.sourceforge.net/update/ (Help->Install New Software… and then Add…, or simply enter the URL in the Work with field).

Eclipse Install Dialog

After the installation is completed, you can create a new project (e.g. C/C++ project) with a model and a src folder (or any name you like), and then create a new block diagram in the model folder (File->New->Other…->Dynamical Systems Modeler->Block Diagram). The src folder can later be used as the target folder for the C code generator.