Skip to main content

AVxcelerate Simulation Framework 2025 R2

simulation_framework::core::lifecycle::FmuLogic Class Reference

Last update: 16.07.2025

An implementation of the IFmuLogic interface using the FMI4cpp library. More...

#include <fmu_logic.h>

Inheritance diagram for simulation_framework::core::lifecycle::FmuLogic:
Collaboration diagram for simulation_framework::core::lifecycle::FmuLogic:

Public Member Functions

 FmuLogic (const std::string &fmu_path)
 Constructor for FmuLogic.
 
void SetupExperiment (double start=0, double stop=0, double tolerance=0) override
 Call fmi2SetupExperiment
 
void EnterInitialization () override
 Call fmi2EnterInitializationMode
 
void ExitInitialization () override
 Call fmi2ExitInitializationMode
 
void Setup (double start=0, double stop=0, double tolerance=0) override
 Call SetupExperiment, EnterInitialization, and ExitInitialization.
 
FmuInOutMap InitInOutMap (std::set< std::string > variable_names) override
 Use the internal implementation to initialize the inputs or outputs with the correct underlying type.
 
bool Step (double step_size, const FmuInOutMap &input) override
 Set the fmu inputs and step the FMU model for given step size by calling fmi2DoStep
 
bool Step (double step_size) override
 Step the FMU model for given step size by calling fmi2DoStep
 
void SetInputs (const FmuInOutMap &inputs) override
 Set the fmu inputs.
 
template<typename T >
void SetValue (const std::string &variable_name, const T &value)
 Modify or set a parameter for a single variable in the FMU.
 
template<typename T >
T GetOutput (const std::string &variable_name) const
 Get the value of a single variable from the FMU.
 
FmuInOutMap GetOutputs () const override
 Get all fmu outputs.
 
void GetOutputs (FmuInOutMap &requested_outputs) const override
 Get a subset of the fmu outputs.
 
double GetSimulationTime () const
 Get the simulation time.
 
fmi4cpp::status GetLastStatus () const
 Get the status from the last fmi2 function call.
 
const fmi::fmu * GetFmuPtr () const
 Get the pointer to the FMU object.
 
const fmi::cs_fmu * GetCsFmuPtr () const
 Get the pointer to the Co-simulation FMU object.
 
const fmi::cs_slave * GetFmuInstancePtr () const
 Get the pointer to the Co-simulation FMU instance object.
 
FmuState GetFmuState () const
 Get the Fmu state.
 

Detailed Description

An implementation of the IFmuLogic interface using the FMI4cpp library.

Definition at line 40 of file fmu_logic.h.

Constructor & Destructor Documentation

◆ FmuLogic()

simulation_framework::core::lifecycle::FmuLogic::FmuLogic ( const std::string &  fmu_path)

Constructor for FmuLogic.

Parameters
fmu_pathThe path to the FMU file

Member Function Documentation

◆ EnterInitialization()

void simulation_framework::core::lifecycle::FmuLogic::EnterInitialization ( )
overridevirtual

Call fmi2EnterInitializationMode

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ ExitInitialization()

void simulation_framework::core::lifecycle::FmuLogic::ExitInitialization ( )
overridevirtual

Call fmi2ExitInitializationMode

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ GetCsFmuPtr()

const fmi::cs_fmu * simulation_framework::core::lifecycle::FmuLogic::GetCsFmuPtr ( ) const

Get the pointer to the Co-simulation FMU object.

Returns
The pointer to the Co-simulation FMU object

◆ GetFmuInstancePtr()

const fmi::cs_slave * simulation_framework::core::lifecycle::FmuLogic::GetFmuInstancePtr ( ) const

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

Returns
The pointer to the Co-simulation FMU instance object

◆ GetFmuPtr()

const fmi::fmu * simulation_framework::core::lifecycle::FmuLogic::GetFmuPtr ( ) const

Get the pointer to the FMU object.

Returns
The pointer to the FMU object

◆ GetFmuState()

FmuState simulation_framework::core::lifecycle::FmuLogic::GetFmuState ( ) const

Get the Fmu state.

Returns
The current FmuState enum value

◆ GetLastStatus()

fmi4cpp::status simulation_framework::core::lifecycle::FmuLogic::GetLastStatus ( ) const

Get the status from the last fmi2 function call.

Returns
The status as an fmi4cpp::status enumeration

◆ GetOutput()

template<typename T >
T simulation_framework::core::lifecycle::FmuLogic::GetOutput ( const std::string &  variable_name) const

Get the value of a single variable from the FMU.

Template Parameters
TType of the object. Supported types: bool, int, double, std::string, std::vector<uint8_t>
Parameters
variable_nameThe name of the variable in the FMU
Returns
The value of the variable

◆ GetOutputs() [1/2]

FmuInOutMap simulation_framework::core::lifecycle::FmuLogic::GetOutputs ( ) const
overridevirtual

Get all fmu outputs.

Returns
The map of outputs, where keys are variable name, and the value is the variable value

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ GetOutputs() [2/2]

void simulation_framework::core::lifecycle::FmuLogic::GetOutputs ( FmuInOutMap &  requested_outputs) const
overridevirtual

Get a subset of the fmu outputs.

Parameters
[in,out]requested_outputsThe map of requested outputs, whose keys are already set to the requested subset of variables. The values will contain the output variable values.

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ GetSimulationTime()

double simulation_framework::core::lifecycle::FmuLogic::GetSimulationTime ( ) const

Get the simulation time.

Returns
The value of the simulation time as a double

◆ InitInOutMap()

FmuInOutMap simulation_framework::core::lifecycle::FmuLogic::InitInOutMap ( std::set< std::string >  variable_names)
overridevirtual

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

Parameters
variable_namesA set of strings of variable names to initialize
Returns
The map of variables with the values being initialized to the correct std::variant type

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ SetInputs()

void simulation_framework::core::lifecycle::FmuLogic::SetInputs ( const FmuInOutMap &  inputs)
overridevirtual

Set the fmu inputs.

Parameters
inputsThe map of inputs to set where keys are variable name, and the value is the variable value

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ Setup()

void simulation_framework::core::lifecycle::FmuLogic::Setup ( double  start = 0,
double  stop = 0,
double  tolerance = 0 
)
overridevirtual

Call SetupExperiment, EnterInitialization, and ExitInitialization.

Parameters
startThe fixed initial value of the independent variable
stopThe final value of the independent variable
toleranceThe tolerance when using a numerical integration scheme. Can be ignored for co-simulation.

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ SetupExperiment()

void simulation_framework::core::lifecycle::FmuLogic::SetupExperiment ( double  start = 0,
double  stop = 0,
double  tolerance = 0 
)
overridevirtual

Call fmi2SetupExperiment

Parameters
startThe fixed initial value of the independent variable
stopThe final value of the independent variable
toleranceThe tolerance when using a numerical integration scheme. Can be ignored for co-simulation.

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ SetValue()

template<typename T >
void simulation_framework::core::lifecycle::FmuLogic::SetValue ( const std::string &  variable_name,
const T &  value 
)

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

Template Parameters
TType of the object. Supported types: bool, int, double, std::string, std::vector<uint8_t>
Parameters
variable_nameThe name of the variable in the FMU
valueThe value of the variable to set

◆ Step() [1/2]

bool simulation_framework::core::lifecycle::FmuLogic::Step ( double  step_size)
overridevirtual

Step the FMU model for given step size by calling fmi2DoStep

Parameters
step_sizeThe update interval of the independent variable
Returns
A boolean value indicating whether the step was successful

Implements simulation_framework::core::lifecycle::IFmuLogic.

◆ Step() [2/2]

bool simulation_framework::core::lifecycle::FmuLogic::Step ( double  step_size,
const FmuInOutMap &  input 
)
overridevirtual

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

Parameters
step_sizeThe update interval of the independent variable
inputThe map of inputs to set where keys are variable name, and the value is the variable value
Returns
A boolean value indicating whether the step was successful

Implements simulation_framework::core::lifecycle::IFmuLogic.


The documentation for this class was generated from the following file:

Connect with Ansys