15#include <cppfmu_cs.hpp>
17#include "DataMapper.hpp"
18#include "DynamicPubSub.hpp"
19#include "LoggerAdapters.hpp"
34 FmuInstance(
const std::string& name,
const std::filesystem::path& resource_path, cppfmu::Logger logger)
35 : m_name(name), m_resource_path(resource_path), m_logger(logger) {
40 const cppfmu::FMIValueReference vr[], std::size_t nvr,
const cppfmu::FMIReal value[])
override {
41 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
set_double(vr[i], value[i]); }
45 const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIReal value[])
const override {
46 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
get_double(vr[i], value[i]); }
50 const cppfmu::FMIValueReference vr[], std::size_t nvr,
51 const cppfmu::FMIInteger value[])
override {
52 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
set_int(vr[i], value[i]); }
55 void GetInteger(
const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIInteger value[])
57 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
get_int(vr[i], value[i]); }
61 const cppfmu::FMIValueReference vr[], std::size_t nvr,
62 const cppfmu::FMIBoolean value[])
override {
63 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
set_bool(vr[i],
static_cast<bool>(value[i])); }
66 void GetBoolean(
const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIBoolean value[])
68 for (std::size_t i = 0; i < nvr; ++i) {
76 const cppfmu::FMIValueReference vr[], std::size_t nvr,
77 const cppfmu::FMIString value[])
override {
78 for (std::size_t i = 0; i < nvr; ++i) { m_mapper.
set_string(vr[i], value[i]); }
81 void GetString(
const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIString value[])
83 for (std::size_t i = 0; i < nvr; ++i) {
86 value[i] = val.c_str();
97 cppfmu::FMIBoolean , cppfmu::FMIReal , cppfmu::FMIReal tStart,
98 cppfmu::FMIBoolean , cppfmu::FMIReal )
override {
103 cppfmu::FMIReal currentCommunicationPoint, cppfmu::FMIReal communicationStepSize,
104 cppfmu::FMIBoolean , cppfmu::FMIReal& )
override {
105 m_time = currentCommunicationPoint + communicationStepSize;
114 m_mapper.
reset(m_resource_path);
115 m_pubsub.
reset(m_resource_path, &m_mapper, m_name, &m_logger);
120 cppfmu::FMIReal m_time;
122 std::filesystem::path m_resource_path;
125 cppfmu::Logger m_logger;
Manages mapping between FMU signals and xtypes data storage.
Definition: DataMapper.hpp:36
void get_bool(const std::int32_t value_ref, bool &value) const
Definition: DataMapper.hpp:85
void set_int(const std::int32_t value_ref, const std::int32_t &value)
Definition: DataMapper.hpp:76
void set_bool(const std::int32_t value_ref, const bool &value)
Definition: DataMapper.hpp:82
void get_double(const std::int32_t value_ref, double &value) const
Definition: DataMapper.hpp:73
void get_int(const std::int32_t value_ref, std::int32_t &value) const
Definition: DataMapper.hpp:79
void get_string(const std::int32_t value_ref, std::string &value) const
Definition: DataMapper.hpp:91
void reset(const std::filesystem::path &fmu_resources)
Clears and repopulates internal data structures.
Definition: DataMapper.cpp:36
void set_double(const std::int32_t value_ref, const double &value)
Definition: DataMapper.hpp:70
void set_string(const std::int32_t value_ref, const std::string &value)
Definition: DataMapper.hpp:88
Dynamic Publisher and Subscriber.
Definition: DynamicPubSub.hpp:98
void take()
Takes DDS data into data in DataMapper.
Definition: DynamicPubSub.cpp:173
void init_key_filters()
Initialize content filters for keyed topics.
Definition: DynamicPubSub.cpp:92
void write()
Writes DDS data by using data from DataMapper.
Definition: DynamicPubSub.cpp:83
void reset(const std::filesystem::path &fmu_resources, DataMapper *const mapper, const std::string &name="dds-fmu", cppfmu::Logger *const logger=nullptr)
Resets all members of DynamicPubSub.
Definition: DynamicPubSub.cpp:240
Co-simulation slave instance for dds-fmu.
Definition: FmuInstance.hpp:32
void GetString(const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIString value[]) const override
Definition: FmuInstance.hpp:81
void GetInteger(const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIInteger value[]) const override
Definition: FmuInstance.hpp:55
void SetupExperiment(cppfmu::FMIBoolean, cppfmu::FMIReal, cppfmu::FMIReal tStart, cppfmu::FMIBoolean, cppfmu::FMIReal) override
Definition: FmuInstance.hpp:96
bool DoStep(cppfmu::FMIReal currentCommunicationPoint, cppfmu::FMIReal communicationStepSize, cppfmu::FMIBoolean, cppfmu::FMIReal &) override
Definition: FmuInstance.hpp:102
void SetString(const cppfmu::FMIValueReference vr[], std::size_t nvr, const cppfmu::FMIString value[]) override
Definition: FmuInstance.hpp:75
void SetReal(const cppfmu::FMIValueReference vr[], std::size_t nvr, const cppfmu::FMIReal value[]) override
Definition: FmuInstance.hpp:39
void GetReal(const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIReal value[]) const override
Definition: FmuInstance.hpp:44
void GetBoolean(const cppfmu::FMIValueReference vr[], std::size_t nvr, cppfmu::FMIBoolean value[]) const override
Definition: FmuInstance.hpp:66
FmuInstance(const std::string &name, const std::filesystem::path &resource_path, cppfmu::Logger logger)
Definition: FmuInstance.hpp:34
void SetBoolean(const cppfmu::FMIValueReference vr[], std::size_t nvr, const cppfmu::FMIBoolean value[]) override
Definition: FmuInstance.hpp:60
void SetInteger(const cppfmu::FMIValueReference vr[], std::size_t nvr, const cppfmu::FMIInteger value[]) override
Definition: FmuInstance.hpp:49
virtual void ExitInitializationMode() override
Definition: FmuInstance.hpp:90
void Reset() override
Definition: FmuInstance.hpp:112
Definition: auxiliaries.cpp:26