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

Signal distributor helper for creating model description. More...

#include <SignalDistributor.hpp>

Public Types

enum class  Cardinality { INPUT , OUTPUT , PARAMETER }
 

Public Member Functions

 SignalDistributor ()
 Constructor that sets integer members to 0;. More...
 
void load_idls (const std::filesystem::path &resource_path)
 Loads the IDLs into a member variable. More...
 
bool has_structure (const std::string &topic_type)
 Returns true if IDL has the scoped structure topic_type. More...
 
void add (const std::string &topic_name, const std::string &topic_type, Cardinality cardinal)
 Adds signal mappings in form of SignalInfo entries. More...
 
void queue_for_key_parameter (const std::string &topic_name, const std::string &topic_type)
 Queues signal mappings in form of SignalInfo entries for key parameters, if any. More...
 
void process_key_queue ()
 Processes queued output data by adding them to the signal mapping. More...
 
const std::vector< SignalInfo > & get_mapping () const
 Returns reference to the vector of SignalInfo. More...
 
std::uint32_t outputs () const
 Returns number of scalar FMU outputs. More...
 

Static Public Member Functions

static config::ScalarVariableType resolve_type (const eprosima::xtypes::DynamicData::ReadableNode &node)
 Resolves the FMI primitive type given an xtypes::DynamicData node. More...
 

Detailed Description

It loads both the IDL files and ddsfmu mapping configuration to establish correct entries in the modelDescription.xml. This entails defining entries in <ModelVariables> as <ScalarVariable> with structured name, value references and causality. Moreover, it provides the number of outputs, so that <ModelStructure> <Outputs> can be generated.

Member Enumeration Documentation

◆ Cardinality

Enumerator
INPUT 
OUTPUT 
PARAMETER 

Constructor & Destructor Documentation

◆ SignalDistributor()

ddsfmu::SignalDistributor::SignalDistributor ( )

Member Function Documentation

◆ add()

void ddsfmu::SignalDistributor::add ( const std::string &  topic_name,
const std::string &  topic_type,
Cardinality  cardinal 
)

This function resolves the FMU types for each member of a specified topic type. The structured name used in the ScalarVariable is [pubsub].[topic].[structured_name], where structured_name is defined according to FMU structured name convention, andpubsub is pub or sub, depending on whether it is a published or subscribed signal.

Parameters
[in]topic_nameTopic name
[in]topic_typeType name
[in]cardinalWhether the signal is input, output, or parameter

◆ get_mapping()

const std::vector< SignalInfo > & ddsfmu::SignalDistributor::get_mapping ( ) const
inline

◆ has_structure()

bool ddsfmu::SignalDistributor::has_structure ( const std::string &  topic_type)

This function simply passes the query further on to xtypes::idl::Context::module().

Parameters
[in]topic_typeScoped name of the queried type (e.g. My::Impl)
Returns
The result of the check

◆ load_idls()

void ddsfmu::SignalDistributor::load_idls ( const std::filesystem::path &  resource_path)
Parameters
[in]resource_pathPath to the FMU resources folder

◆ outputs()

std::uint32_t ddsfmu::SignalDistributor::outputs ( ) const
inline

◆ process_key_queue()

void ddsfmu::SignalDistributor::process_key_queue ( )

This function creates SignalInfo and appends them to the vector, which can be retrieved by get_mapping(). Parameters are added after outputs and inputs.

◆ queue_for_key_parameter()

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

This function resolves the FMU types for each member of a specified topic type. The structured name used in the ScalarVariable is key.sub.[topic].[structured_name], where structured_name is defined according to FMU structured name convention, and 'key' indicate that it is a key parameter to be selected.

The user must run process_key_queue() after this function has been run for all outputs.

Parameters
[in]topic_nameTopic name
[in]topic_typeType name

◆ resolve_type()

ddsfmu::config::ScalarVariableType ddsfmu::SignalDistributor::resolve_type ( const eprosima::xtypes::DynamicData::ReadableNode &  node)
static

Internally, a switch case of xtypes::TypeKind types that maps to a ScalarVariableType In case the type is unsupported: returns ddsfmu::config::Unknown;

Parameters
[in]nodeA node, which is a primitive type or resolvable type (std::string and maybe other)
Returns
The scalar variable type (Real, Integer, Boolean, String)