dds-fmu 0.5.1
DDS-FMU communication integration
|
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... | |
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.
|
strong |
ddsfmu::SignalDistributor::SignalDistributor | ( | ) |
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.
[in] | topic_name | Topic name |
[in] | topic_type | Type name |
[in] | cardinal | Whether the signal is input, output, or parameter |
|
inline |
bool ddsfmu::SignalDistributor::has_structure | ( | const std::string & | topic_type | ) |
This function simply passes the query further on to xtypes::idl::Context::module().
[in] | topic_type | Scoped name of the queried type (e.g. My::Impl) |
void ddsfmu::SignalDistributor::load_idls | ( | const std::filesystem::path & | resource_path | ) |
[in] | resource_path | Path to the FMU resources folder |
|
inline |
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.
|
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.
[in] | topic_name | Topic name |
[in] | topic_type | Type name |
|
static |
Internally, a switch case of xtypes::TypeKind types that maps to a ScalarVariableType In case the type is unsupported: returns ddsfmu::config::Unknown;
[in] | node | A node, which is a primitive type or resolvable type (std::string and maybe other) |