Coupling AutoFOCUS3 with other Tools using Co-Simulation

The following sections provide introduction and discuss cosimulation functionality in detail.

Introduction

AF3 alone cannot satisfy all the needs of system development. Other tools are often needed, e.g., for modeling continuous behavior (for the environment or for analog parts of a system), for interoperability with legacy tools, or simply for using non-AF3 features in combination with AF3 (e.g., visualization).

In such cases, AF3 has cosimulation capabilities which allows to use AF3 simulation with other tools in a synchronous manner. AF3 offers cosimulation functionality in the following two ways:

Cosimulation using FMI (Functional Mockup Interface)

This feature supports for now only FMU export satisfying the following constraints:

Exporting component architecture as an FMU

FMI export can be done at the level of both component architecture and component. To export anyone of them to the FMU, right-click on it in the model navigator and select "Export to FMU2.0":

AF3 works with logical time, however cosimulation is generally achieved with tools modeling reality and therefore working with real time. Therefore, the FMI standard requires that AF3 notion of time is translated to real time. For that, a function with the name 'samplingTime()' can be defined in the data dictionary and used inside the AF3 component's behavior. If the samplingTime() is not defined, the user will be asked to provide the required frequency (equivalent to sampling time) for the component:

You will then be asked where to store the generated FMU. Once this is done, a message confirming that generation was successful appears and you can find the generated FMU in the directory that you selected. You can then make use of the numerous cosimulation tools along with AF3 itself, supporting FMI to cosimulate the generated AF3 model's FMU.

Importing FMUs and their cosimulation

The FMU's from other tools can be imported in AF3 for the cosimulation together with the AF3's own behavior components.

Creating an FMU Specification

To use the cosimulation feature, you have to create the FMU Specification inside the component. Only the entire component architecture can be simulated having FMUs or other AF3 behaviors inside its subcomponents.

To create an FMU specification for a component, open the context menu of the component and select "FMU Specification".

The FMU Specification can also be dragged and dropped from the Model Elements window.

The FMU Specification consists of only one section available by double clicking the FMU Specification icon or its component. It has a field with:

Different AF3 component and the FMUs are connected with each other through the input and output ports. The outputs that has to be displayed as a result of the cosimulation are assigned to the Component Architecture's root component.

Running a Cosimulation

To start the cosimulation, right-click on the Component Architecture element in the Model Navigator and select "Run Cosimulator". Remember that this option will only be available, if there is at least two atomic component and one of them has an FMU Specification behavior.

If there would be no error in the model, then Cosimulation Configuration window will open containing two sections:

Then press OK to proceed or cancel to stop the cosimulator.

OK will execute the cosimulation of the components and at last the window with graph having the results will pop up.