Coupling AF3 with other tools using cosimulation
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
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:
The AF3 model can be exported as an FMU, which can be used as one of the components for cosimulation in other tools.
- AF3 provides the environment for FMUs cosimulation by utilizing Cosimulation Orchestration Engine (COE)
provided by INTO-CPS as a service. Thus, the FMUs from different tools can be imported and cosimulated together along with the AF3 components.
Cosimulation using FMI (Functional Mockup Interface)
This feature supports for now only FMU export satisfying the following constraints:
Please contact us if you wish to get support for a different environment.
- Windows 32/64bit
- GCC compilation - One has to use TDM-GCC MinGW
- Input and output values cannot carry NoVal but instead contain default values (0 for integers and reals, false for booleans, first item for enumerations)
Note: This behaviour is different from AF3 simulation
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 two fields with:
- Browse button: To upload the FMU. The input/output ports will be automatically generated.
- Update button: If any changes in the FMU has been made, it can be updated (without again providing the path).
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.
- Simulation time: The step size, start and end time values has to be provided for which the simulation needs to be run.
The end time should be greater than the start time and the step size should be greater than zero and within the range of start and end time.
- Ports to be displayed: The check boxes with port names (that were assigned to the root component ports) to be displayed on the output graph.
Pressing OK will execute the cosimulation of the components and at last the window with graph having the results will pop up.