Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
initialisation.cpp
|
||||
topic_data.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(HDRS
|
||||
initialisation.h
|
||||
topic_data.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV NO_TRANSLATION tDataSampleReceiver ${SRCS} ${HDRS})
|
||||
NGL_TARGET_LINK_LIBRARIES(tDataSampleReceiver
|
||||
Qt5::Core
|
||||
ddsdtc
|
||||
ddsgen
|
||||
ddsconnector
|
||||
svcExmCommon
|
||||
svcPpmCommon
|
||||
ProjectConfig
|
||||
LtsPluginLoader
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
topic_type_plugin
|
||||
)
|
||||
NGL_INSTALL_TARGET(tDataSampleReceiver)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_tdsr.props DESTINATION bin)
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Initialisation for Subscribing for data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
Initialisation::Initialisation(int domainId, int exerciseId, const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
: DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId)
|
||||
, m_vDdro(vDdro)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DSR.Initialisation"))
|
||||
|
||||
{
|
||||
INFO_LOG(m_logger) << "Initialisation for partition: " << getDefaultPartition();
|
||||
}
|
||||
|
||||
bool Initialisation::init(const QStringList &qosFileList)
|
||||
{
|
||||
if(!DDSConnector::DdsConnector::init(qosFileList))
|
||||
return false;
|
||||
// Subscribing for data
|
||||
initDomainParticipant();
|
||||
setSubscriber(new DataSampleReceiver::TopicData(getDomainParticipant(), getDefaultPartition(), m_vDdro));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // Namespace DataSampleReceiver
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Initialisation for Subscriber
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <dds/dds.hpp>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include "topic_data.h"
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
class Initialisation : public DDSConnector::DdsConnector
|
||||
{
|
||||
public:
|
||||
Initialisation(int domainId, int exerciseId, const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
~Initialisation() = default;
|
||||
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList()) override final;
|
||||
|
||||
private:
|
||||
|
||||
// DroTypes that will be subscribed to
|
||||
QVector<DDSGeneric::TopicDescription> m_vDdro;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.DSR.main=DEBUG
|
||||
log4j.logger.DSR.Initialisation=DEBUG
|
||||
log4j.logger.DSR.Settings=DEBUG
|
||||
log4j.logger.DSR.Subscriber=DEBUG
|
||||
log4j.logger.DSR.TopicData=DEBUG
|
||||
log4j.logger.DSR.SubscriberListener=WARN
|
||||
#log4j.logger.DSR.SubscriberListener=INFO
|
||||
|
||||
|
||||
log4j.logger.GenericBase=DEBUG
|
||||
log4j.logger.Generic.DataWriter=DEBUG
|
||||
log4j.logger.Generic.DataReader=DEBUG
|
||||
log4j.logger.Generic.TopicSql=DEBUG
|
||||
#log4j.logger.DTC=DEBUG
|
||||
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_spm.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main (TopicDataGenerator)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <DDS/Generic/topic_type_plugin.h>
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QSet>
|
||||
|
||||
// static
|
||||
static QVector<DDSGeneric::TopicDescription> getAvailableTopicTypes() // get topicTypes per plugin mechanism
|
||||
{
|
||||
QVector<DDSGeneric::TopicDescription> topicTypeDescs;
|
||||
|
||||
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::TOPIC_TYPE, [&](const LtsPluginManager::PluginInstance &pi)
|
||||
{
|
||||
DDSGeneric::TopicTypePlugin *typePlugin = qobject_cast<DDSGeneric::TopicTypePlugin*>(pi.plugin);
|
||||
if (!typePlugin)
|
||||
return false;
|
||||
|
||||
QMap<std::string,DDSGeneric::TopicDescription> topics = typePlugin->getDataTopics();
|
||||
topics.unite(typePlugin->getFunctionTopics());
|
||||
|
||||
QMap<std::string, DDSGeneric::TopicDescription>::iterator it = topics.begin();
|
||||
for( ; it != topics.end(); ++it)
|
||||
{
|
||||
topicTypeDescs.append(it.value());
|
||||
}
|
||||
|
||||
return false; // we don't need the plugins anymore -> unload
|
||||
});
|
||||
|
||||
return topicTypeDescs;
|
||||
}
|
||||
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("maxSamples"),
|
||||
QLatin1String("Default: 0 (infinite loop)"),
|
||||
QLatin1String("Max Samples"),
|
||||
QLatin1String("0") } );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("doType"),
|
||||
QLatin1String("Default: all, can be a list of doTypes, i.e. 1,2,5 (more Infos on doType, use -h)"),
|
||||
QLatin1String("doType"),
|
||||
QLatin1String("0") } );
|
||||
}
|
||||
|
||||
int maxSamples() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> getDoTypes(NGL::INGLLogger &logger) const
|
||||
{
|
||||
const QVector<DDSGeneric::TopicDescription> availDataTopics = getAvailableDoTypes();
|
||||
if (!isSet(QLatin1String("t")))
|
||||
return availDataTopics;
|
||||
|
||||
// Convert list of DoTypes, separated by comma (given by user)
|
||||
const QString doTypeStr = value(QLatin1String("t"));
|
||||
const QVector<QStringRef> strList = doTypeStr.splitRef(QLatin1Char(','), QString::SkipEmptyParts);
|
||||
|
||||
if (strList.isEmpty())
|
||||
return availDataTopics;
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> vDt;
|
||||
vDt.reserve(strList.size());
|
||||
for (const QStringRef &doTypeStr : strList)
|
||||
{
|
||||
bool ok = false;
|
||||
int doTypeInt = doTypeStr.toInt(&ok);
|
||||
INFO_LOG(logger) << "doType: " << doTypeInt;
|
||||
if (ok && doTypeInt >= 0 && doTypeInt < availDataTopics.size())
|
||||
vDt.append(availDataTopics.at(doTypeInt));
|
||||
else
|
||||
WARNING_LOG(logger) << doTypeStr.toString() << " is not a valid DoType, skipping.. ";
|
||||
}
|
||||
return vDt;
|
||||
}
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> getAvailableDoTypes() const
|
||||
{
|
||||
return getAvailableTopicTypes();
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
LtsCommandLineParser::init(false);
|
||||
if (isSet(QLatin1String("h")))
|
||||
{
|
||||
QVector<DDSGeneric::TopicDescription> doTypes = getAvailableDoTypes();
|
||||
auto it = doTypes.begin();
|
||||
for(int i=0 ; it != doTypes.end(); ++it, ++i)
|
||||
fprintf(stdout, "\ndoType(%d): %s ", i, (*it).name.c_str());
|
||||
fprintf(stdout, "\n\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int main ( int argc, char**argv )
|
||||
{
|
||||
NGLCoreApplication app ( argc, argv );
|
||||
app.createLogger("DataSampleGenerator.main", "log4cxx_tdsr.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
QVector<DDSGeneric::TopicDescription> doTypes = options.getDoTypes(app.baseLogger());
|
||||
INFO_LOG(app.baseLogger()) << "size vDoTypes: " << doTypes.size();
|
||||
DataSampleReceiver::Initialisation* initDtcr = new DataSampleReceiver::Initialisation(options.domainId(), options.exerciseId(), doTypes);
|
||||
if (!initDtcr->init())
|
||||
return -2;
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
delete initDtcr;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Executable
+234
@@ -0,0 +1,234 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* TopicData
|
||||
* Uses DTC to subscribe to data
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "topic_data.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
TopicData::TopicData(const dds::domain::DomainParticipant &dp, const std::string &partition, const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
: DDSConnector::Subscriber(dp, partition)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DSR.TopicData"))
|
||||
{
|
||||
initDDTCs(vDdro);
|
||||
}
|
||||
|
||||
TopicData::~TopicData()
|
||||
{
|
||||
qDeleteAll(m_ddtcMap);
|
||||
m_ddtcMap.clear();
|
||||
}
|
||||
|
||||
bool TopicData::initDDTCs(const QVector<DDSGeneric::TopicDescription> &vDdro)
|
||||
{
|
||||
if (m_domainParticipant == nullptr ||
|
||||
m_ddsSubscriber == nullptr ||
|
||||
m_subscriberListener == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Inititialisation failed: "
|
||||
" m_domainParticipant/m_ddsSubscriber/m_subscriberListener not initialised";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_vDdro = vDdro;
|
||||
|
||||
INFO_LOG(m_logger) << "TopicDescriptions size: #" << vDdro.size();
|
||||
|
||||
// Initialise DDTCs
|
||||
for (const DDSGeneric::TopicDescription &topicDesc : vDdro)
|
||||
{
|
||||
INFO_LOG(m_logger) << "topicDesc.topicName: " << topicDesc.name;
|
||||
INFO_LOG(m_logger) << "topicDesc.topicType: " << topicDesc.typeName;
|
||||
|
||||
DTC::Ddtc<DDSGeneric::DynamicDataReader>* ddtc = this->create(
|
||||
[this](const dds::core::xtypes::DynamicData& data, const std::string &topicName, DataModification modType)
|
||||
{ Q_UNUSED(modType); processData(data, QString::fromStdString(topicName)); },
|
||||
topicDesc.type,
|
||||
nullptr /* Use SubscriberListener from DdsConnector */,
|
||||
topicDesc.name );
|
||||
|
||||
if (ddtc == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Can't create ddtc for Topic (" << topicDesc.name
|
||||
<< "), TypeName (" << topicDesc.typeName << ")";
|
||||
continue;
|
||||
}
|
||||
|
||||
m_ddtcMap.insert(topicDesc.name, ddtc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicData::processData(const ExerciseManagement::Exercise &data)
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "=> IN processData Exercise";
|
||||
|
||||
INFO_LOG(m_logger) << "|#| id: # " << data.id();
|
||||
INFO_LOG(m_logger) << "|#| name: # " << data.name();
|
||||
INFO_LOG(m_logger) << "|#| state: # " << data.state();
|
||||
INFO_LOG(m_logger) << "|#| partition: # " << data.partitionName();
|
||||
INFO_LOG(m_logger) << "|#| isUsed: # " << data.isUsed();
|
||||
INFO_LOG(m_logger) << "|#| markedAsDeleted: # " << data.isDeleted();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TopicData::processData(const ParticipantManagement::Participant &data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "-> IN processData Participant";
|
||||
|
||||
INFO_LOG(m_logger) << "|#| participantId: #" << data.id();
|
||||
INFO_LOG(m_logger) << "|#| name: #" << data.name();
|
||||
INFO_LOG(m_logger) << "|#| hierarchyNo: #" << data.hierarchyNumber();
|
||||
INFO_LOG(m_logger) << "|#| equipNo: #" << data.equipmentNumber();
|
||||
|
||||
//processData(data.location());
|
||||
}
|
||||
|
||||
bool TopicData::processData(const dds::core::xtypes::DynamicData &data, const QString &ns)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "-> IN processData dynamicData";
|
||||
if (tryProcessDataAsTyped(data, ns))
|
||||
return true;
|
||||
|
||||
// maybe also possible;
|
||||
// getStructType() from ddtc (m_ddtcMap)
|
||||
|
||||
// If no Namespace (thus, external call) or no valid data: Create new DynData
|
||||
//if ( data.type().kind() == dds::core::xtypes::TypeKind::NO_TYPE )
|
||||
// data = dds::core::xtypes::DynamicData(*m_type);
|
||||
|
||||
// data[n] runs from 1..count()!
|
||||
for (uint32_t member_index = 1; member_index <= data.member_count(); ++member_index)
|
||||
{
|
||||
const rti::core::xtypes::DynamicDataMemberInfo info = data.member_info(member_index);
|
||||
|
||||
INFO_LOG(m_logger) << "Parameter: " << info.member_name();
|
||||
TRACE_LOG(m_logger) << "MemberName: " << ns << " - " << info.member_name();
|
||||
TRACE_LOG(m_logger) << "member_id = " << info.member_index()
|
||||
<< ", member_kind = " << info.member_kind()
|
||||
<< ", index: " << data.member_index(info.member_name());
|
||||
|
||||
// if (!data.member_exists(member_index))
|
||||
// continue;
|
||||
|
||||
QVariant var;
|
||||
switch(info.member_kind().underlying())
|
||||
{
|
||||
case dds::core::xtypes::TypeKind::CHAR_8_TYPE:
|
||||
var = data.value<char>(member_index);
|
||||
break;
|
||||
#if RTI_DDS_VERSION_MAJOR < 6
|
||||
case dds::core::xtypes::TypeKind::CHAR_32_TYPE:
|
||||
#else
|
||||
case dds::core::xtypes::TypeKind::CHAR_16_TYPE:
|
||||
#endif
|
||||
var = data.value<DDS_Wchar>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_8_TYPE:
|
||||
var = data.value<uint8_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_16_TYPE:
|
||||
var = data.value<int16_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_16_TYPE:
|
||||
var = data.value<uint16_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_32_TYPE:
|
||||
var = data.value<int32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_32_TYPE:
|
||||
var = data.value<uint32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::INT_64_TYPE:
|
||||
var = data.value<qlonglong>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::UINT_64_TYPE:
|
||||
var = data.value<qulonglong>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::FLOAT_32_TYPE:
|
||||
var = data.value<float>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::FLOAT_64_TYPE:
|
||||
var = data.value<double>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::ENUMERATION_TYPE:
|
||||
var = data.value<int32_t>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::BOOLEAN_TYPE:
|
||||
var = data.value<bool>(member_index);
|
||||
break;
|
||||
case dds::core::xtypes::TypeKind::STRING_TYPE:
|
||||
{
|
||||
const dds::core::string tmp = data.value<dds::core::string>(member_index);
|
||||
if (tmp.c_str()) // unset -> nullptr
|
||||
var = QString::fromUtf8(tmp.c_str ());
|
||||
break;
|
||||
}
|
||||
case dds::core::xtypes::TypeKind::STRUCTURE_TYPE:
|
||||
{
|
||||
// rti::core::xtypes::LoanedDynamicData innerLoaned = data.loan_value(member_index);
|
||||
processData(data.value<dds::core::xtypes::DynamicData>(member_index), ns + QString::fromStdString(info.member_name()) + QLatin1Char('.'));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "Content : '" << var.toString() << "'";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicData::tryProcessDataAsTyped(const dds::core::xtypes::DynamicData &data, const QString &ns)
|
||||
{
|
||||
// ExerciseManagement::Exercise
|
||||
if (processData<ExerciseManagement::Exercise>(data,ns))
|
||||
return true;
|
||||
|
||||
// Core::SpatialData
|
||||
if (processData<ParticipantManagement::Participant>(data,ns))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the typeCode of a topic if available in m_vddro
|
||||
* @param topicName
|
||||
* @return
|
||||
*/
|
||||
dds::core::xtypes::StructType TopicData::getTypeCode(const std::string &topicName) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_vDdro.size = " << m_vDdro.size();
|
||||
|
||||
for (int i = 0; i < m_vDdro.size(); ++i)
|
||||
{
|
||||
DDSGeneric::TopicDescription td = m_vDdro.at(i);
|
||||
if (td.name == topicName)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Found topicType for #" << topicName;
|
||||
return td.type;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: oder besser throw?
|
||||
return dds::core::xtypes::StructType("Unknown");
|
||||
}
|
||||
|
||||
|
||||
} // Namespace DataSampleReceiver
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
*
|
||||
* TopicData
|
||||
* Uses DDTCs to subscribe to data
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QVector>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <dds/dds.hpp>
|
||||
#include <dds/core/xtypes/DynamicData.hpp>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <DDS/DDSConnector/subscriber.h>
|
||||
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DataSampleReceiver
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
class TopicData : public DDSConnector::Subscriber
|
||||
{
|
||||
|
||||
public:
|
||||
explicit TopicData(const dds::domain::DomainParticipant &dp, const std::string &partition, const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
~TopicData();
|
||||
|
||||
bool initDDTCs(const QVector<DDSGeneric::TopicDescription> &vDdro);
|
||||
|
||||
// Process data for specific topics
|
||||
void processData(const ExerciseManagement::Exercise &data);
|
||||
void processData(const ParticipantManagement::Participant &data);
|
||||
|
||||
bool processData(const dds::core::xtypes::DynamicData &data, const QString &ns = QString());
|
||||
|
||||
|
||||
// Process data as "typed" data
|
||||
template<typename T>
|
||||
bool processData(const dds::core::xtypes::DynamicData &data, const QString &topicName)
|
||||
{
|
||||
// TODO: really not needed?
|
||||
Q_UNUSED(topicName)
|
||||
if (rti::core::xtypes::can_convert<T>(data))
|
||||
{
|
||||
const T typedData = rti::core::xtypes::convert<T>(data);
|
||||
processData(typedData);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected:
|
||||
dds::core::xtypes::StructType getTypeCode(const std::string &topicName) const;
|
||||
|
||||
bool tryProcessDataAsTyped(const dds::core::xtypes::DynamicData &data, const QString &ns);
|
||||
|
||||
private:
|
||||
QVector<DDSGeneric::TopicDescription> m_vDdro;
|
||||
QMap<std::string, DTC::Ddtc<DDSGeneric::DynamicDataReader>*> m_ddtcMap;
|
||||
NGL::INGLLogger& m_logger;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user