dds-fmu 0.5.1
DDS-FMU communication integration
ddsfmu::DataMapper Class Reference

Manages mapping between FMU signals and xtypes data storage. More...

#include <DataMapper.hpp>

Public Types

enum class  Direction { Read , Write , Parameter }
 
typedef std::tuple< std::int32_t, std::int32_t, std::int32_t, std::int32_t > IndexOffsets
 

Public Member Functions

 DataMapper ()=default
 
 DataMapper (const DataMapper &)=delete
 Copy constructor. More...
 
DataMapperoperator= (const DataMapper &)=delete
 Copy assignment. More...
 
void reset (const std::filesystem::path &fmu_resources)
 Clears and repopulates internal data structures. More...
 
void set_double (const std::int32_t value_ref, const double &value)
 
void get_double (const std::int32_t value_ref, double &value) const
 
void set_int (const std::int32_t value_ref, const std::int32_t &value)
 
void get_int (const std::int32_t value_ref, std::int32_t &value) const
 
void set_bool (const std::int32_t value_ref, const bool &value)
 
void get_bool (const std::int32_t value_ref, bool &value) const
 
void set_string (const std::int32_t value_ref, const std::string &value)
 
void get_string (const std::int32_t value_ref, std::string &value) const
 
eprosima::xtypes::DynamicData & data_ref (const std::string &topic, Direction read_write_param)
 
const eprosima::xtypes::DynamicData & data_ref (const std::string &topic, Direction read_write_param) const
 
eprosima::xtypes::idl::Context & idl_context ()
 
IndexOffsets index_offsets (const std::string &topic, Direction read_write_param) const
 
void queue_for_key_parameter (const std::string &topic_name, const std::string &topic_type)
 
void process_key_queue ()
 

Detailed Description

Types defined in IDL is mapped onto four FMU types, namely: Real, Integer, Boolean and String. Integer types with more than 32 bits are mapped to Real. The primitive types: uint32_t, int64_t, and uint64_t are all mapped to Real. Enumerations are mapped to Integer. All data are stored in xtypes::DynamicData. Each data member of DynamicData is directly written to or read from using visitor functions, which use references. The visitor functions are called from specialized setters and getters:

set_double(), get_double(), set_int(), get_int(), set_bool(), get_bool(), set_string(), get_string()

Member Typedef Documentation

◆ IndexOffsets

typedef std::tuple<std::int32_t, std::int32_t, std::int32_t, std::int32_t> ddsfmu::DataMapper::IndexOffsets

Start index offsets for readers/writers functions for a given topic and direction. This is useful if you know all the data types for a type and want to access readers/writers directly. Order of indexes in tuple: double, integer, bool, string See index_offsets().

Member Enumeration Documentation

◆ Direction

enum class ddsfmu::DataMapper::Direction
strong

Internal indication whether the mapped signal it is intended for reading (FMU output) or writing (FMU input). Parameter is a special case for @key filtering used by readers.

Enumerator
Read 

Read from DDS, FMU output.

Write 

Write to DDS, FMU input.

Parameter 

Used for Read content filter of @key.

Constructor & Destructor Documentation

◆ DataMapper() [1/2]

ddsfmu::DataMapper::DataMapper ( )
default

◆ DataMapper() [2/2]

ddsfmu::DataMapper::DataMapper ( const DataMapper )
delete

Member Function Documentation

◆ data_ref() [1/2]

eprosima::xtypes::DynamicData & ddsfmu::DataMapper::data_ref ( const std::string &  topic,
Direction  read_write_param 
)
inline

◆ data_ref() [2/2]

const eprosima::xtypes::DynamicData & ddsfmu::DataMapper::data_ref ( const std::string &  topic,
Direction  read_write_param 
) const
inline

◆ get_bool()

void ddsfmu::DataMapper::get_bool ( const std::int32_t  value_ref,
bool &  value 
) const
inline

◆ get_double()

void ddsfmu::DataMapper::get_double ( const std::int32_t  value_ref,
double &  value 
) const
inline

◆ get_int()

void ddsfmu::DataMapper::get_int ( const std::int32_t  value_ref,
std::int32_t &  value 
) const
inline

◆ get_string()

void ddsfmu::DataMapper::get_string ( const std::int32_t  value_ref,
std::string &  value 
) const
inline

◆ idl_context()

eprosima::xtypes::idl::Context & ddsfmu::DataMapper::idl_context ( )
inline

◆ index_offsets()

IndexOffsets ddsfmu::DataMapper::index_offsets ( const std::string &  topic,
Direction  read_write_param 
) const
inline

◆ operator=()

DataMapper & ddsfmu::DataMapper::operator= ( const DataMapper )
delete

◆ process_key_queue()

void ddsfmu::DataMapper::process_key_queue ( )

◆ queue_for_key_parameter()

void ddsfmu::DataMapper::queue_for_key_parameter ( const std::string &  topic_name,
const std::string &  topic_type 
)
inline

◆ reset()

void ddsfmu::DataMapper::reset ( const std::filesystem::path &  fmu_resources)

Clears member variables and containers by first calling clear(). Loads IDL files into xtypes and uses dds to fmu mapping configuration file to set up mapping between DDS topics to FMU scalar signals.

Parameters
[in]fmu_resourcesPath to resources folder of FMU

◆ set_bool()

void ddsfmu::DataMapper::set_bool ( const std::int32_t  value_ref,
const bool &  value 
)
inline

◆ set_double()

void ddsfmu::DataMapper::set_double ( const std::int32_t  value_ref,
const double &  value 
)
inline

◆ set_int()

void ddsfmu::DataMapper::set_int ( const std::int32_t  value_ref,
const std::int32_t &  value 
)
inline

◆ set_string()

void ddsfmu::DataMapper::set_string ( const std::int32_t  value_ref,
const std::string &  value 
)
inline