Skip to main content

AVxcelerate Simulation Framework 2025 R2 SP02

fmu_base_activity

Last update: 19.09.2025
1
3
4#pragma once
5
6#include "core/lifecycle/activity/base_activity.h"
7#include "core/lifecycle/fmu_activity/fmu_config.h"
8#include "core/lifecycle/fmu_activity/i_fmu_logic.h"
9#include "core/message/rtidds/fmu/fmu_message.hpp"
10#include "core/scheduler/i_scheduler_client/i_scheduler_client.h"
11#include <optional>
12
18{
19namespace core
20{
21
22class CommunicationManager;
23
24namespace lifecycle
25{
26
31{
32 public:
41 FmuBaseActivity(const std::string& name,
42 std::shared_ptr<CommunicationManager> communication_manager,
43 std::unique_ptr<scheduling::ISchedulerClient> scheduler_client,
45 std::unique_ptr<IFmuLogic> fmu_logic,
46 const std::optional<double> step_size = std::nullopt);
47
49 virtual void ExecuteStep() override;
50
52 virtual void Init() override;
53
55 virtual void AddPublisherAndSubscriber() override;
56
57 protected:
61 FmuInOutMap DecodeMessage(const rtidds::FmuMessage& message);
62
66 rtidds::FmuMessage EncodeMessage(const FmuInOutMap& outputs);
67
71 FmuInOutMap DecodeBytesMessage(const rtidds::GenericBytesMessage& message);
72
76 rtidds::GenericBytesMessage EncodeBytesMessage(const FmuInOutMap& outputs);
77
80
82 std::unique_ptr<IFmuLogic> fmu_logic_;
83
85 std::optional<double> step_size_;
86
88 FmuTopicToVarMap input_topics_to_var_map_{};
89
91 FmuTopicToVarMap output_topics_to_var_map_{};
92};
93
94} // namespace lifecycle
95} // namespace core
96} // namespace simulation_framework
This is the concrete Topic class that can be used for creation of a communication channel with given ...
Definition topic.h:38
This is the basic implementation of IActivity interface. Inheriting classes, i.e. a concrete simulati...
An activity that subscribes to messages to input to an FMU and publishes the FMU output.
virtual void ExecuteStep() override
Sets FMU inputs from subscribed topics, steps the FMU, and gets FMU outputs ready for published topic...
FmuConfig fmu_config_
A struct containing information about topics and corresponding FMU variables.
std::optional< double > step_size_
The step size to increment the FMU's independent variable.
virtual void Init() override
Initialize FMU parameters.
std::unique_ptr< IFmuLogic > fmu_logic_
A pointer to the logic that manages simulating the FMU.
rtidds::FmuMessage EncodeMessage(const FmuInOutMap &outputs)
Put the outputs from the IFmuLogic implementation into an FmuMessage to be published.
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.
virtual void AddPublisherAndSubscriber() override
Adds publishers and subscribers of rtidds::FmuMessage based on information from FmuConfig.
FmuInOutMap DecodeBytesMessage(const rtidds::GenericBytesMessage &message)
Put the received GenericBytes values in a format understood by the IFmuLogic implementation.
FmuInOutMap DecodeMessage(const rtidds::FmuMessage &message)
Put the received FmuMessage 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.
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.
The namespace for all core functionalities under namespace simulation_framework.
The top namespace for simulation framework.
A helper struct to pass necessary information to create FmuBaseActivity.
Definition fmu_config.h:33

Connect with Ansys