Skip to content
Snippets Groups Projects
cosimulation_with_af3.html 8.49 KiB
Newer Older
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<!--    User documentation for Cosimulation feature. -->

	<link rel="stylesheet" type="text/css" href="../layout/stylesheet.css">
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>Cosimulation</title>
</head>
<div class="header">
<div class="box">
<div class="navbar">
<!--a href="https://www.fortiss.org/" align="left">
<img src="fortiss-logo.png" width="90px" height="20px" align="left">
</a-->
 <div class="dropdown">
    <button class="btn" id="hamburger">
    <label for="hamburger" class="hamburger">
        <span class="hamburgerLine"></span>
        <span class="hamburgerLine"></span>
        <span class="hamburgerLine"></span>
    </label>
    </button>
    <div class="dropdown-content">  
      <a href="../getting_started.html"> Main Page</a>
      <a href="../ModandSim/model_element_attributes.html">Modeling and Simulation</a>
      <a href="../ta/technical_viewpoint.html">Deployment and Code Generation</a>
      <a href="../dse/dse_perspective.html">Design Space Exploration (DSE)</a>
      <a href="../assuranceCases/creation.html">Assurance Case Modeling</a>
      <a href=".././af3_further_resources.html">Further Resources</a>
    </div>
   </div> 
    <div class="dropdown">
    <button class="dropbtn">Modeling and Simulation <i class="triangle"></i></button>
    <div class="dropdown-content">
	   
	<a href="model_element_attributes.html">Introduction to Graphical Modeling Interface</a>
	<a href="component_architecture.html">Component Architecture Modeling</a>
    <a href="data_dictionary.html">Data Dictionary: Types and Functions</a>
    <a href="code_specification.html">Behavior Modeling -> Code Specifications</a>
	<a href="state_automaton.html">Behavior Modeling -> State Automata</a>
	<a href="hierarchical_state_automaton.html">Behavior Modeling -> Hierarchical State Automata</a>
	<a href="mode_automaton.html">Behavior Modeling -> Mode Automata</a>
	<a href="simulation_with_af3.html">Simulation -> Simulation</a>
	<a href="operatorpanels.html">Simulation -> Operator Panels</a>
	<a href="operatorpanels_advanced.html">Simulation -> Advanced Operator Panels</a>
	<a href="refactoring.html">Refactoring</a>
	<a href="model_markers_view.html">On-the-fly Checks</a>
    </div>
   </div>
<div class="topnav-right">
      <a href="mailto:af_user@lists.fortiss.org?subject=Reporting 'cosimulation_with_af3.html' Documentation Problem!&body= Dear Af3 team, I am reporting an issue related to 'modelling and simulation'. 
       {Please specify the problem precisely here.}.">Report a Problem?</a>
    </div>
  </div>
</head>
</div>
</div>
<div class="box">

<button onclick="topFunction()" id="upBtn" title="Go to top">Top</button>
<h2>Coupling AF3 with other tools using cosimulation</h2>
<p>The following sections provide introduction and discuss cosimulation functionality in detail.</p>
<h3>Introduction</h3>
<p> 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). </p>
<p>
In such cases, AF3 has <i>cosimulation</i> capabilities which allows to use AF3 <a href="simulation_with_af3.html">simulation</a>
with other tools in a synchronous manner. 

AF3 offers cosimulation functionality in the following two ways:
<ul> <li>
The AF3 model can be exported as an <a href="http://www.fmi-standard.org">FMU</a>, which can be used as one of the components for cosimulation in other tools.

Saad bin Abid's avatar
Saad bin Abid committed
 <li>AF3 provides the environment for FMUs cosimulation by utilizing Cosimulation Orchestration Engine (<a href="https://into-cps-association.github.io/simulation/coe.html">COE</a>) 
provided by INTO-CPS as a service. Thus, the FMUs from different tools can be imported and cosimulated together along with the AF3 components.

</ul> 
<h3>Cosimulation using FMI (Functional Mockup Interface)</h3>
<b>This feature supports for now only FMU export satisfying the following constraints:
<ul> <li>FMI2.0
<li> Windows 32/64bit
<li> GCC compilation - One has to use <a href="http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm64-gcc-5.1.0-2.exe/download"> TDM-GCC MinGW</a> 
<li> 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 <i>simulation</i>
</ul> 
Please contact us if you wish to get support for a different environment.</b>
<h3></font>Exporting component architecture as an FMU</h3>

<p>
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":</p>

<img src="./pictures/FMI_menu.png">
<p> 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:</p>

<img src="./pictures/FMI_tick_duration.png">
<p> 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 <a href="https://www.fmi-standard.org/tools">numerous cosimulation tools</a> along with AF3 itself, supporting FMI to cosimulate the generated AF3 model's FMU.</p>
<h3>Importing FMUs and their cosimulation</h3>
The FMU's from other tools can be imported in AF3 for the cosimulation together with the AF3's own behavior components.</p>
<h4>Creating an FMU Specification</h4>

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

<p>To create an <i>FMU specification</i> for a component, open the context menu of the component and select "FMU Specification".</p>

<img src="./pictures/FMUSpecification.png">

<p>The FMU Specification can also be dragged and dropped from the <i>Model Elements</i> window.</p>

<img src="./pictures/FMUModelElements.png">


<p> The <i>FMU Specification</i> consists of only one section available by double clicking the FMU Specification icon or its component.
<ul>
<li><i>Browse button:</i> To upload the FMU. The input/output ports will be automatically generated.
</ul>
<img src="./pictures/externalSpecificationEditor.png">

<p>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.</p>

<img src="./pictures/cosimulationComponentsConnection.png">

<h4>Running a Cosimulation</h4>
<p>To start the cosimulation, right-click on the <i>Component Architecture</i> element in the <i>Model Navigator</i> 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.</p>

<img src="./pictures/runCosimulator.png">

If there would be no error in the model, then Cosimulation Configuration window will open containing two sections:
<ul>
<li><i>Simulation time:</i> 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. 
<li><i>Ports to be displayed:</i> The check boxes with port names (that were assigned to the root component ports) to be displayed on the output graph. 
</ul>
</p>

<p>Then press OK to proceed or cancel to stop the cosimulator.</p>

<img src="./pictures/cosimulationConfigurations.png">


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


<img src="./pictures/cosimulationResults.png">

</div>

<script src="../layout/jsscript/topBtn.js">
</script>