    

 ## On this page

  

 

 # fmu\_logic

 Last update: 16.07.2025 

<a id="l00001" name="l00001"></a> 1 

<a id="l00003" name="l00003"></a> 3 

<a id="l00004" name="l00004"></a> 4\#pragma once

<a id="l00005" name="l00005"></a> 5 

<a id="l00006" name="l00006"></a> 6\#include "core/lifecycle/fmu\_activity/fmu\_state.h"

<a id="l00007" name="l00007"></a> 7\#include "core/lifecycle/fmu\_activity/i\_fmu\_logic.h"

<a id="l00008" name="l00008"></a> 8\#include &lt;memory&gt;

<a id="l00009" name="l00009"></a> 9\#include &lt;set&gt;

<a id="l00010" name="l00010"></a> 10 

<a id="l00011" name="l00011"></a>[ 11](namespacefmi4cpp.xhtml)namespace [fmi4cpp](namespacefmi4cpp.xhtml)

<a id="l00012" name="l00012"></a> 12{

<a id="l00013" name="l00013"></a> 13namespace fmi2

<a id="l00014" name="l00014"></a> 14{

<a id="l00015" name="l00015"></a> 15class fmu;

<a id="l00016" name="l00016"></a> 16class cs_fmu;

<a id="l00017" name="l00017"></a> 17class cs_slave;

<a id="l00018" name="l00018"></a> 18} // namespace fmi2

<a id="l00019" name="l00019"></a> 19enum class status;

<a id="l00020" name="l00020"></a> 20} // namespace fmi4cpp



<a id="l00021" name="l00021"></a> 21 

<a id="l00026" name="l00026"></a> 26namespace [simulation\_framework](namespacesimulation__framework.xhtml)

<a id="l00027" name="l00027"></a> 27{

<a id="l00028" name="l00028"></a> 28namespace [core](namespacecore.xhtml)

<a id="l00029" name="l00029"></a> 29{

<a id="l00030" name="l00030"></a> 30 

<a id="l00031" name="l00031"></a> 31namespace lifecycle

<a id="l00032" name="l00032"></a> 32{

<a id="l00033" name="l00033"></a> 33 

<a id="l00034" name="l00034"></a> 34class FmuLogicImpl;

<a id="l00035" name="l00035"></a> 35 

<a id="l00036" name="l00036"></a> 36namespace fmi = fmi4cpp::fmi2;

<a id="l00037" name="l00037"></a> 37 

<a id="l00040" name="l00040"></a>[ 40](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)class [FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml) : public [IFmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1IFmuLogic.xhtml)

<a id="l00041" name="l00041"></a> 41{

<a id="l00042" name="l00042"></a> 42 public:

<a id="l00045" name="l00045"></a>[ 45](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abdb6a692a31b7ee3ddc87f87d353af22) [FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abdb6a692a31b7ee3ddc87f87d353af22)(const std::string&amp; [fmu\_path](classsimulation__framework_1_1core_1_1Topic.xhtml));

<a id="l00046" name="l00046"></a> 46 

<a id="l00048" name="l00048"></a> 48 virtual [~FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)() override;

<a id="l00049" name="l00049"></a> 49 [FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)([FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)&amp;&amp;) [noexcept](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00050" name="l00050"></a> 50 [FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)&amp; [operator](classsimulation__framework_1_1core_1_1Topic.xhtml)=([FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)&amp;&amp;) [noexcept](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00052" name="l00052"></a> 52 

<a id="l00054" name="l00054"></a>[ 54](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a52bbed4e360462046b9b6f019f760034) void [SetupExperiment](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a52bbed4e360462046b9b6f019f760034)(double [start](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0, double [stop](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0, double [tolerance](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00055" name="l00055"></a> 55 

<a id="l00057" name="l00057"></a>[ 57](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a0203fe646f1a5621e83f862fc2c4861f) void [EnterInitialization](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a0203fe646f1a5621e83f862fc2c4861f)() [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00058" name="l00058"></a> 58 

<a id="l00060" name="l00060"></a>[ 60](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abd981adc51682e6e7562332888f00932) void [ExitInitialization](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abd981adc51682e6e7562332888f00932)() [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00061" name="l00061"></a> 61 

<a id="l00063" name="l00063"></a>[ 63](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ac9e6b73f6d11c16f28e5647e62d3d48c) void [Setup](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ac9e6b73f6d11c16f28e5647e62d3d48c)(double [start](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0, double [stop](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0, double [tolerance](classsimulation__framework_1_1core_1_1Topic.xhtml) = 0) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00064" name="l00064"></a> 64 

<a id="l00066" name="l00066"></a>[ 66](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8899be3914f9378637f15fd3aa6fbdef) FmuInOutMap [InitInOutMap](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8899be3914f9378637f15fd3aa6fbdef)([std](classsimulation__framework_1_1core_1_1Topic.xhtml)::[set](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt;[std](classsimulation__framework_1_1core_1_1Topic.xhtml)::string&gt; [variable\_names](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00067" name="l00067"></a> 67 

<a id="l00069" name="l00069"></a>[ 69](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#add2ea6f3b48f6010178076e8916db410) bool [Step](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#add2ea6f3b48f6010178076e8916db410)(double [step\_size](classsimulation__framework_1_1core_1_1Topic.xhtml), [const](classsimulation__framework_1_1core_1_1Topic.xhtml) FmuInOutMap&amp; [input](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00070" name="l00070"></a> 70 

<a id="l00072" name="l00072"></a>[ 72](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a00b5e8f8ecd66354c524a2cc1d4fe2e3) bool [Step](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#add2ea6f3b48f6010178076e8916db410)(double [step\_size](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00073" name="l00073"></a> 73 

<a id="l00075" name="l00075"></a>[ 75](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1b0f3a1cba93d938fc55bd8917e836b5) void [SetInputs](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1b0f3a1cba93d938fc55bd8917e836b5)([const](classsimulation__framework_1_1core_1_1Topic.xhtml) FmuInOutMap&amp; [inputs](classsimulation__framework_1_1core_1_1Topic.xhtml)) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00076" name="l00076"></a> 76 

<a id="l00081" name="l00081"></a> 81 [template](classsimulation__framework_1_1core_1_1Topic.xhtml) &lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [T](classsimulation__framework_1_1core_1_1Topic.xhtml)&gt;

<a id="l00082" name="l00082"></a>[ 82](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a35747b8e4e37700c8ff8706b3a93a833) void [SetValue](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a35747b8e4e37700c8ff8706b3a93a833)([const](classsimulation__framework_1_1core_1_1Topic.xhtml) [std](classsimulation__framework_1_1core_1_1Topic.xhtml)::string&amp; [variable\_name](classsimulation__framework_1_1core_1_1Topic.xhtml), [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [T](classsimulation__framework_1_1core_1_1Topic.xhtml)&amp; value);

<a id="l00083" name="l00083"></a> 83 

<a id="l00088" name="l00088"></a> 88 [template](classsimulation__framework_1_1core_1_1Topic.xhtml) &lt;[typename](classsimulation__framework_1_1core_1_1Topic.xhtml) [T](classsimulation__framework_1_1core_1_1Topic.xhtml)&gt;

<a id="l00089" name="l00089"></a>[ 89](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a4ed808f5ab02cc3bcc60f76c1bcff10f) [T](classsimulation__framework_1_1core_1_1Topic.xhtml) [GetOutput](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a4ed808f5ab02cc3bcc60f76c1bcff10f)([const](classsimulation__framework_1_1core_1_1Topic.xhtml) [std](classsimulation__framework_1_1core_1_1Topic.xhtml)::string&amp; [variable\_name](classsimulation__framework_1_1core_1_1Topic.xhtml)) [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00090" name="l00090"></a> 90 

<a id="l00092" name="l00092"></a>[ 92](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae31cf08f14147691cf9f354f1cadd7cf) FmuInOutMap [GetOutputs](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae31cf08f14147691cf9f354f1cadd7cf)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00093" name="l00093"></a> 93 

<a id="l00097" name="l00097"></a>[ 97](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a611e8286778b474c013150f46e37caf0) void [GetOutputs](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae31cf08f14147691cf9f354f1cadd7cf)(FmuInOutMap&amp; [requested\_outputs](classsimulation__framework_1_1core_1_1Topic.xhtml)) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [override](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00098" name="l00098"></a> 98 

<a id="l00101" name="l00101"></a>[ 101](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abf602595ae1d4b9c0eb21315aaa11b1f) double [GetSimulationTime](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abf602595ae1d4b9c0eb21315aaa11b1f)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00102" name="l00102"></a> 102 

<a id="l00105" name="l00105"></a>[ 105](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a739ac5f7595d5faec57787a4572b1c56) [fmi4cpp](namespacefmi4cpp.xhtml)::[status](classsimulation__framework_1_1core_1_1Topic.xhtml) [GetLastStatus](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a739ac5f7595d5faec57787a4572b1c56)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00106" name="l00106"></a> 106 

<a id="l00109" name="l00109"></a>[ 109](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8df07fcf204cdee5434a6df81f558022) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [fmi](classsimulation__framework_1_1core_1_1Topic.xhtml)::[fmu](classsimulation__framework_1_1core_1_1Topic.xhtml)* [GetFmuPtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8df07fcf204cdee5434a6df81f558022)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00110" name="l00110"></a> 110 

<a id="l00113" name="l00113"></a>[ 113](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ab9b56c6037217a85c73fc7595bc622fd) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [fmi](classsimulation__framework_1_1core_1_1Topic.xhtml)::[cs\_fmu](classsimulation__framework_1_1core_1_1Topic.xhtml)* [GetCsFmuPtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ab9b56c6037217a85c73fc7595bc622fd)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00114" name="l00114"></a> 114 

<a id="l00117" name="l00117"></a>[ 117](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae1052072c17b9b4bb54f106f654f610a) [const](classsimulation__framework_1_1core_1_1Topic.xhtml) [fmi](classsimulation__framework_1_1core_1_1Topic.xhtml)::[cs\_slave](classsimulation__framework_1_1core_1_1Topic.xhtml)* [GetFmuInstancePtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae1052072c17b9b4bb54f106f654f610a)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00118" name="l00118"></a> 118 

<a id="l00121" name="l00121"></a>[ 121](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1e11576f34334fcdfb90bafc88c9daac) [FmuState](classsimulation__framework_1_1core_1_1Topic.xhtml) [GetFmuState](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1e11576f34334fcdfb90bafc88c9daac)() [const](classsimulation__framework_1_1core_1_1Topic.xhtml);

<a id="l00122" name="l00122"></a> 122 

<a id="l00123" name="l00123"></a> 123 [private](classsimulation__framework_1_1core_1_1Topic.xhtml):

<a id="l00125" name="l00125"></a> 125 [std](classsimulation__framework_1_1core_1_1Topic.xhtml)::[unique\_ptr](classsimulation__framework_1_1core_1_1Topic.xhtml)&lt;[FmuLogicImpl](classsimulation__framework_1_1core_1_1Topic.xhtml)&gt; impl_;

<a id="l00126" name="l00126"></a> 126};



<a id="l00127" name="l00127"></a> 127 

<a id="l00128" name="l00128"></a> 128} // namespace lifecycle

<a id="l00129" name="l00129"></a> 129} // namespace core

<a id="l00130" name="l00130"></a> 130} // namespace simulation\_framework

[simulation\_framework::core::Topic](classsimulation__framework_1_1core_1_1Topic.xhtml)

This is the concrete Topic class that can be used for creation of a communication channel with given ...

**Definition** [topic.h:38](topic_8h_source.xhtml#l00037)



[simulation\_framework::core::lifecycle::FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml)

An implementation of the IFmuLogic interface using the FMI4cpp library.

**Definition** [fmu\_logic.h:41](fmu__logic_8h_source.xhtml#l00040)



[simulation\_framework::core::lifecycle::FmuLogic::EnterInitialization](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a0203fe646f1a5621e83f862fc2c4861f)

void EnterInitialization() override

Call fmi2EnterInitializationMode



[simulation\_framework::core::lifecycle::FmuLogic::SetInputs](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1b0f3a1cba93d938fc55bd8917e836b5)

void SetInputs(const FmuInOutMap &amp;inputs) override

Set the fmu inputs.



[simulation\_framework::core::lifecycle::FmuLogic::GetFmuState](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a1e11576f34334fcdfb90bafc88c9daac)

FmuState GetFmuState() const

Get the Fmu state.



[simulation\_framework::core::lifecycle::FmuLogic::SetValue](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a35747b8e4e37700c8ff8706b3a93a833)

void SetValue(const std::string &amp;variable_name, const T &amp;value)

Modify or set a parameter for a single variable in the FMU.



[simulation\_framework::core::lifecycle::FmuLogic::GetOutput](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a4ed808f5ab02cc3bcc60f76c1bcff10f)

T GetOutput(const std::string &amp;variable_name) const

Get the value of a single variable from the FMU.



[simulation\_framework::core::lifecycle::FmuLogic::SetupExperiment](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a52bbed4e360462046b9b6f019f760034)

void SetupExperiment(double start=0, double stop=0, double tolerance=0) override

Call fmi2SetupExperiment



[simulation\_framework::core::lifecycle::FmuLogic::GetLastStatus](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a739ac5f7595d5faec57787a4572b1c56)

fmi4cpp::status GetLastStatus() const

Get the status from the last fmi2 function call.



[simulation\_framework::core::lifecycle::FmuLogic::InitInOutMap](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8899be3914f9378637f15fd3aa6fbdef)

FmuInOutMap InitInOutMap(std::set&lt; std::string &gt; variable_names) override

Use the internal implementation to initialize the inputs or outputs with the correct underlying type.



[simulation\_framework::core::lifecycle::FmuLogic::GetFmuPtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#a8df07fcf204cdee5434a6df81f558022)

const fmi::fmu * GetFmuPtr() const

Get the pointer to the FMU object.



[simulation\_framework::core::lifecycle::FmuLogic::GetCsFmuPtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ab9b56c6037217a85c73fc7595bc622fd)

const fmi::cs_fmu * GetCsFmuPtr() const

Get the pointer to the Co-simulation FMU object.



[simulation\_framework::core::lifecycle::FmuLogic::ExitInitialization](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abd981adc51682e6e7562332888f00932)

void ExitInitialization() override

Call fmi2ExitInitializationMode



[simulation\_framework::core::lifecycle::FmuLogic::FmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abdb6a692a31b7ee3ddc87f87d353af22)

FmuLogic(const std::string &amp;fmu_path)

Constructor for FmuLogic.



[simulation\_framework::core::lifecycle::FmuLogic::GetSimulationTime](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#abf602595ae1d4b9c0eb21315aaa11b1f)

double GetSimulationTime() const

Get the simulation time.



[simulation\_framework::core::lifecycle::FmuLogic::Setup](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ac9e6b73f6d11c16f28e5647e62d3d48c)

void Setup(double start=0, double stop=0, double tolerance=0) override

Call SetupExperiment, EnterInitialization, and ExitInitialization.



[simulation\_framework::core::lifecycle::FmuLogic::Step](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#add2ea6f3b48f6010178076e8916db410)

bool Step(double step_size, const FmuInOutMap &amp;input) override

Set the fmu inputs and step the FMU model for given step size by calling fmi2DoStep



[simulation\_framework::core::lifecycle::FmuLogic::GetFmuInstancePtr](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae1052072c17b9b4bb54f106f654f610a)

const fmi::cs_slave * GetFmuInstancePtr() const

Get the pointer to the Co-simulation FMU instance object.



[simulation\_framework::core::lifecycle::FmuLogic::GetOutputs](classsimulation__framework_1_1core_1_1lifecycle_1_1FmuLogic.xhtml#ae31cf08f14147691cf9f354f1cadd7cf)

FmuInOutMap GetOutputs() const override

Get all fmu outputs.



[simulation\_framework::core::lifecycle::IFmuLogic](classsimulation__framework_1_1core_1_1lifecycle_1_1IFmuLogic.xhtml)

The interface for FMU Logic to be used by an FMU activity.

**Definition** [i\_fmu\_logic.h:26](i__fmu__logic_8h_source.xhtml#l00025)



[core](namespacecore.xhtml)

The namespace for all core functionalities under namespace simulation_framework.



[fmi4cpp](namespacefmi4cpp.xhtml)

**Definition** [fmu\_logic.h:12](fmu__logic_8h_source.xhtml#l00011)



[simulation\_framework](namespacesimulation__framework.xhtml)

The top namespace for simulation framework.