simulation_framework::core::lifecycle::FmuBaseActivity Class Reference
Last update: 19.09.2025An activity that subscribes to messages to input to an FMU and publishes the FMU output. More...
#include <fmu_base_activity.h>


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) | |
| Construct an BaseActivity to join simulation. | |
| 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) | |
| Construct an BaseActivity to join simulation. | |
| BaseActivity (const std::string &activity_name, const Topics &topics) | |
| Construct an BaseActivity using RTIDDS communication to join simulation. | |
| BaseActivity (const std::string &activity_name, const Topics &topics, std::chrono::milliseconds timeout) | |
| Construct an BaseActivity using RTIDDS communication to join simulation. | |
| virtual | ~BaseActivity () |
| Destructor of an BaseActivity class. | |
| std::string | GetName () const override |
| void | SetUpCommunication () final |
| Register this activity's bounding communications, managed by higher level. Modifying by inheriting classes is NOT allowed. | |
| void | Step () final |
| Calls the ExecuteStep() for internal logic and send/receive message from corresponding pub/sub, managed by higher level. Modifying by inheriting classes is NOT allowed. | |
| void | Shutdown () final |
| time::Timestamp | GetCurrentTimestamp () const final |
| Get current simulation timestamp. | |
| std::chrono::milliseconds | GetCycleTime () const final |
| Return cycle time of this activity as duration in milliseconds. | |
| std::string | GetSimulationOutputDirectory () const final |
| Return output directory of simulation as string. | |
| const SimulationParameters::CustomizedParameters & | GetCustomizedParameters () const final |
| Retrieves the customized parameters for the activity. | |
| void | SetSimulationSettings (const scheduling::SimulationSettings &sim_settings) final |
| Set the simulation settings for this activity. | |
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 method which allows user to add one publisher pushing message to the given Topic. | |
| template<typename Topic > | |
| void | AddSubscriber (const core::TopicId &topic_id, typename Topic::SubscriberMessageCallback callback) |
| Template method which allows user to add one subscriber receiving message to the given Topic. | |
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
-
name A unique name for the activity, which is used as identifier for connections communication_manager Communication Manager to enable the activity join in the communication channel scheduler_client The client which receives events from the scheduler server fmu_config A struct containing information about topics and corresponding FMU variables fmu_logic An IFmuLogic implementation responsible for setting up and simulating the FMU step_size A 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()
|
overridevirtual |
Adds publishers and subscribers of rtidds::FmuMessage based on information from FmuConfig.
Implements simulation_framework::core::lifecycle::BaseActivity.
◆ DecodeBytesMessage()
|
protected |
Put the received GenericBytes values in a format understood by the IFmuLogic implementation.
- Parameters
-
message The published message which was received
- Returns
- A map of variable names to variable values to be sent to the FMU
◆ DecodeMessage()
|
protected |
Put the received FmuMessage values in a format understood by the IFmuLogic implementation.
- Parameters
-
message The published message which was received
- Returns
- A map of variable names to variable values to be sent to the FMU
◆ EncodeBytesMessage()
|
protected |
Put the outputs from the IFmuLogic implementation into an GenericBytes to be published.
- Parameters
-
outputs A map of variable names to variable values from the FMU
- Returns
- The message to be published
◆ EncodeMessage()
|
protected |
Put the outputs from the IFmuLogic implementation into an FmuMessage to be published.
- Parameters
-
outputs A map of variable names to variable values from the FMU
- Returns
- The message to be published
◆ 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()
Initialize FMU parameters.
Reimplemented from simulation_framework::core::lifecycle::BaseActivity.
Member Data Documentation
◆ fmu_config_
|
protected |
A struct containing information about topics and corresponding FMU variables.
Definition at line 79 of file fmu_base_activity.h.
◆ 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_
|
protected |
A mapping of input topics to FMU variables.
Definition at line 88 of file fmu_base_activity.h.
◆ output_topics_to_var_map_
|
protected |
A mapping of output topics to FMU variables.
Definition at line 91 of file fmu_base_activity.h.
◆ 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:
Public Member Functions inherited from