Skip to main content

AVxcelerate Simulation Framework 2025 R2

simulation_framework::core::lifecycle::FmuBaseActivity Class Reference

Last update: 16.07.2025

An activity that subscribes to messages to input to an FMU and publishes the FMU output. More...

#include <fmu_base_activity.h>

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

Public Member Functions

 FmuBaseActivity (const std::string &name, std::shared_ptr< CommunicationManager > communication_manager, std::unique_ptr< scheduling::ISchedulerClient > scheduler_client, FmuConfig fmu_config, std::unique_ptr< IFmuLogic > fmu_logic, const std::optional< double > step_size=std::nullopt)
 Construct an FMU activity to join the simulation.
 
virtual void ExecuteStep () override
 Sets FMU inputs from subscribed topics, steps the FMU, and gets FMU outputs ready for published topics.
 
virtual void Init () override
 Initialize FMU parameters.
 
virtual void AddPublisherAndSubscriber () override
 Adds publishers and subscribers of rtidds::FmuMessage based on information from FmuConfig.
 
- Public Member Functions inherited from simulation_framework::core::lifecycle::BaseActivity
 BaseActivity (const std::string &activity_name, std::shared_ptr< core::CommunicationManager > communication_manager_ptr, std::unique_ptr< scheduling::ISchedulerClient > scheduler_client)
 
 BaseActivity (const std::string &activity_name, std::shared_ptr< core::CommunicationManager > communication_manager_ptr, std::unique_ptr< scheduling::ISchedulerClient > scheduler_client, std::chrono::milliseconds timeout)
 
 BaseActivity (const std::string &activity_name, const Topics &topics)
 
 BaseActivity (const std::string &activity_name, const Topics &topics, std::chrono::milliseconds timeout)
 
virtual ~BaseActivity ()
 
std::string GetName () const override
 
void SetUpCommunication () final
 
void Step () final
 
void Shutdown () final
 
time::Timestamp GetCurrentTimestamp () const final
 
std::chrono::milliseconds GetCycleTime () const final
 
std::string GetSimulationOutputDirectory () const final
 
std::vector< File > GetInputFiles () const final
 
- Public Member Functions inherited from simulation_framework::core::lifecycle::IActivity
virtual ~IActivity ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Protected Member Functions

FmuInOutMap DecodeMessage (const rtidds::FmuMessage &message)
 Put the received FmuMessage values in a format understood by the IFmuLogic implementation.
 
rtidds::FmuMessage EncodeMessage (const FmuInOutMap &outputs)
 Put the outputs from the IFmuLogic implementation into an FmuMessage to be published.
 
FmuInOutMap DecodeBytesMessage (const rtidds::GenericBytesMessage &message)
 Put the received GenericBytes values in a format understood by the IFmuLogic implementation.
 
rtidds::GenericBytesMessage EncodeBytesMessage (const FmuInOutMap &outputs)
 Put the outputs from the IFmuLogic implementation into an GenericBytes to be published.
 
- Protected Member Functions inherited from simulation_framework::core::lifecycle::BaseActivity
template<typename Topic >
void AddPublisher (const core::TopicId &topic_id, typename Topic::PublisherCallback callback)
 
template<typename Topic >
void AddSubscriber (const core::TopicId &topic_id, typename Topic::SubscriberMessageCallback callback)
 

Protected Attributes

FmuConfig fmu_config_ {}
 A struct containing information about topics and corresponding FMU variables.
 
std::unique_ptr< IFmuLogic > fmu_logic_
 A pointer to the logic that manages simulating the FMU.
 
std::optional< double > step_size_
 The step size to increment the FMU's independent variable.
 
FmuTopicToVarMap input_topics_to_var_map_ {}
 A mapping of input topics to FMU variables.
 
FmuTopicToVarMap output_topics_to_var_map_ {}
 A mapping of output topics to FMU variables.
 

Detailed Description

An activity that subscribes to messages to input to an FMU and publishes the FMU output.

The configuration of the topics and which FMU variables they contain is given by the FmuConfig.

See also
FmuConfig

Definition at line 30 of file fmu_base_activity.h.

Constructor & Destructor Documentation

◆ FmuBaseActivity()

simulation_framework::core::lifecycle::FmuBaseActivity::FmuBaseActivity ( const std::string &  name,
std::shared_ptr< CommunicationManager >  communication_manager,
std::unique_ptr< scheduling::ISchedulerClient >  scheduler_client,
FmuConfig  fmu_config,
std::unique_ptr< IFmuLogic >  fmu_logic,
const std::optional< double >  step_size = std::nullopt 
)

Construct an FMU activity to join the simulation.

Parameters
nameA unique name for the activity, which is used as identifier for connections
communication_managerCommunication Manager to enable the activity join in the communication channel
scheduler_clientThe client which receives events from the scheduler server
fmu_configA struct containing information about topics and corresponding FMU variables
fmu_logicAn IFmuLogic implementation responsible for setting up and simulating the FMU
step_sizeA fixed step size to increment the FMU's independent variable. if not given, the step size will be retrieved from json scheduling configuration

Member Function Documentation

◆ AddPublisherAndSubscriber()

virtual void simulation_framework::core::lifecycle::FmuBaseActivity::AddPublisherAndSubscriber ( )
overridevirtual

Adds publishers and subscribers of rtidds::FmuMessage based on information from FmuConfig.

Implements simulation_framework::core::lifecycle::BaseActivity.

◆ DecodeBytesMessage()

FmuInOutMap simulation_framework::core::lifecycle::FmuBaseActivity::DecodeBytesMessage ( const rtidds::GenericBytesMessage &  message)
protected

Put the received GenericBytes values in a format understood by the IFmuLogic implementation.

Parameters
messageThe published message which was received
Returns
A map of variable names to variable values to be sent to the FMU

◆ DecodeMessage()

FmuInOutMap simulation_framework::core::lifecycle::FmuBaseActivity::DecodeMessage ( const rtidds::FmuMessage &  message)
protected

Put the received FmuMessage values in a format understood by the IFmuLogic implementation.

Parameters
messageThe published message which was received
Returns
A map of variable names to variable values to be sent to the FMU

◆ EncodeBytesMessage()

rtidds::GenericBytesMessage simulation_framework::core::lifecycle::FmuBaseActivity::EncodeBytesMessage ( const FmuInOutMap &  outputs)
protected

Put the outputs from the IFmuLogic implementation into an GenericBytes to be published.

Parameters
outputsA map of variable names to variable values from the FMU
Returns
The message to be published

◆ EncodeMessage()

rtidds::FmuMessage simulation_framework::core::lifecycle::FmuBaseActivity::EncodeMessage ( const FmuInOutMap &  outputs)
protected

Put the outputs from the IFmuLogic implementation into an FmuMessage to be published.

Parameters
outputsA map of variable names to variable values from the FMU
Returns
The message to be published

◆ ExecuteStep()

virtual void simulation_framework::core::lifecycle::FmuBaseActivity::ExecuteStep ( )
overridevirtual

Sets FMU inputs from subscribed topics, steps the FMU, and gets FMU outputs ready for published topics.

Implements simulation_framework::core::lifecycle::BaseActivity.

◆ Init()

virtual void simulation_framework::core::lifecycle::FmuBaseActivity::Init ( )
overridevirtual

Initialize FMU parameters.

Reimplemented from simulation_framework::core::lifecycle::BaseActivity.

Member Data Documentation

◆ fmu_config_

FmuConfig simulation_framework::core::lifecycle::FmuBaseActivity::fmu_config_ {}
protected

A struct containing information about topics and corresponding FMU variables.

Definition at line 79 of file fmu_base_activity.h.

79{};

◆ fmu_logic_

std::unique_ptr<IFmuLogic> simulation_framework::core::lifecycle::FmuBaseActivity::fmu_logic_
protected

A pointer to the logic that manages simulating the FMU.

Definition at line 82 of file fmu_base_activity.h.

◆ input_topics_to_var_map_

FmuTopicToVarMap simulation_framework::core::lifecycle::FmuBaseActivity::input_topics_to_var_map_ {}
protected

A mapping of input topics to FMU variables.

Definition at line 88 of file fmu_base_activity.h.

88{};

◆ output_topics_to_var_map_

FmuTopicToVarMap simulation_framework::core::lifecycle::FmuBaseActivity::output_topics_to_var_map_ {}
protected

A mapping of output topics to FMU variables.

Definition at line 91 of file fmu_base_activity.h.

91{};

◆ step_size_

std::optional<double> simulation_framework::core::lifecycle::FmuBaseActivity::step_size_
protected

The step size to increment the FMU's independent variable.

Definition at line 85 of file fmu_base_activity.h.


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

Connect with Ansys