Continues migration with DDS, Common
This commit is contained in:
1 parent
9b15cee841
commit
fa48db111e
668 files changed
+111841
-2
No files matched your search
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
IF(BUILD_TESTING AND TARGET ddsgen AND TARGET ddsdtc AND TARGET ddsfts AND TARGET ddsQoS)
|
||||
|
||||
SET(xml_FILE ddsut.xml)
|
||||
|
||||
SET(SRCS_common
|
||||
ddsut_export.h
|
||||
)
|
||||
# Generates ddsut.idl / ddsut_enums.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate *.cpp/*.hpp from ddsut_enums.idl / ddsut.idl
|
||||
RTIDDSGEN(SRCS_common ddsut_enums.idl)
|
||||
RTIDDSGEN(SRCS_common ddsut.idl)
|
||||
# Generate ddsut_dt[s,c]_types.h, ddsut_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# generate ddsut_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(ALL ddsut_common SHARED ${SRCS_common})
|
||||
NGL_TARGET_LINK_LIBRARIES(ddsut_common
|
||||
PRIVATE
|
||||
NGLLogger
|
||||
PUBLIC
|
||||
LtsUtilsCoreHeaderOnly
|
||||
Qt5::Core
|
||||
RTI::nddsc
|
||||
RTI::nddscore
|
||||
RTI::nddscpp2
|
||||
ddscore
|
||||
)
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(ddsut_common
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------------
|
||||
# Testing DataWriter/DataReader without DTS/DTC
|
||||
# -----------------------------------------------------------------------------------
|
||||
SET(SRCS_TEST1
|
||||
generic_data_tests.cpp
|
||||
generic_data_tests.h
|
||||
initialisation.cpp
|
||||
initialisation.h
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------------
|
||||
# Testing DataTopic Functionality (DTS/DTC)
|
||||
# -----------------------------------------------------------------------------------
|
||||
SET(SRCS_TEST2
|
||||
data_topic_tests_main.cpp
|
||||
data_topic_tests_main.h
|
||||
data_topic_tests.cpp
|
||||
data_topic_tests.h
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------------
|
||||
# Testing FunctionTopic Functionality (FTS/FTC)
|
||||
# -----------------------------------------------------------------------------------
|
||||
SET(SRCS_TEST3
|
||||
function_topic_tests.cpp
|
||||
function_topic_tests.h
|
||||
)
|
||||
|
||||
|
||||
# Testing DataWriter/DataReader without DTS/DTC
|
||||
ADD_EXECUTABLE(ddsGenericDataTests ${SRCS_TEST1})
|
||||
TARGET_LINK_LIBRARIES(ddsGenericDataTests
|
||||
ddsgen
|
||||
ddsdtc
|
||||
ddsQoS
|
||||
nglcoreapplication
|
||||
NGLLogger
|
||||
ProjectConfig
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
ddsut_common
|
||||
)
|
||||
ADD_TEST(NAME ddsGenericDataTests COMMAND $<TARGET_FILE:ddsGenericDataTests>)
|
||||
|
||||
# Testing DataTopic Functionality (DTS/DTC)
|
||||
ADD_EXECUTABLE(ddsDataTopicTests ${SRCS_TEST2})
|
||||
TARGET_LINK_LIBRARIES(ddsDataTopicTests
|
||||
nglcoreapplication
|
||||
NGLLogger
|
||||
RTI::nddscpp2
|
||||
ddsgen
|
||||
ddsdts
|
||||
ddsdtc
|
||||
ddsQoS
|
||||
ProjectConfig
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
ddsut_common
|
||||
)
|
||||
ADD_TEST(NAME ddsDataTopicTests COMMAND $<TARGET_FILE:ddsDataTopicTests>)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTS/FTC)
|
||||
ADD_EXECUTABLE(ddsFunctionTopicTests ${SRCS_TEST3})
|
||||
TARGET_LINK_LIBRARIES(ddsFunctionTopicTests
|
||||
ddsgen
|
||||
ddsfts
|
||||
ddsftc
|
||||
ddsQoS
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
NGLLogger
|
||||
ngltools
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
ddsut_common
|
||||
)
|
||||
ADD_TEST(NAME ddsFunctionTopicTests COMMAND $<TARGET_FILE:ddsFunctionTopicTests>)
|
||||
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS ddsut_common DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV TARGETS ddsGenericDataTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV TARGETS ddsDataTopicTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV TARGETS ddsFunctionTopicTests DESTINATION bin/test)
|
||||
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_ddsUnitTests.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
Executable
+155
@@ -0,0 +1,155 @@
|
||||
|
||||
|
||||
|
||||
#include "data_topic_tests.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
#include <DDS/DTC/generic_dtc_impl.h>
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
#include <QVariant>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
DataTopicTests::DataTopicTests()
|
||||
: m_domainParticipantPub(nullptr)
|
||||
, m_domainParticipantSub(nullptr)
|
||||
, m_domainId(0)
|
||||
, m_partitionId(1)
|
||||
, m_ddsPublisher(nullptr)
|
||||
, m_testPart(nullptr)
|
||||
, m_ddsSubscriber(nullptr)
|
||||
, m_subscriberListener(nullptr)
|
||||
, m_dtcTestPart(nullptr)
|
||||
, m_mainThreadId(QThread::currentThreadId())
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.DataTopicTests"))
|
||||
{
|
||||
if (!DDS::QosProfile::setDefault())
|
||||
ERROR_LOG(m_logger) << "Error setting default QoS from xml-file ";
|
||||
|
||||
DEBUG_LOG(m_logger) << "Main thread ID is " << m_mainThreadId;
|
||||
}
|
||||
|
||||
DataTopicTests::~DataTopicTests()
|
||||
{
|
||||
|
||||
delete m_testPart;
|
||||
|
||||
|
||||
delete m_dtcTestPart;
|
||||
|
||||
|
||||
|
||||
delete m_subscriberListener;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool DataTopicTests::initPublisher()
|
||||
{
|
||||
m_domainParticipantPub =
|
||||
dds::domain::DomainParticipant(m_domainId,
|
||||
DDS::QosProfile::domainParticipantShm());
|
||||
|
||||
dds::pub::qos::PublisherQos publisherQos = m_domainParticipantPub.default_publisher_qos();
|
||||
|
||||
|
||||
QString partition = QString::fromStdString(IDL::exercisePartition(m_partitionId));
|
||||
|
||||
dds::core::policy::Partition partitionQos;
|
||||
partitionQos.name( { partition.toStdString() } );
|
||||
publisherQos << partitionQos;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Publish on partition " << partition;
|
||||
|
||||
m_ddsPublisher = dds::pub::Publisher(m_domainParticipantPub, publisherQos);
|
||||
m_testPart = new DTS::TestParticipantImpl(m_domainParticipantPub, m_ddsPublisher);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DataTopicTests::write(const DdsUnitTests::TestParticipant &data)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Publish topic TestParticipant ";
|
||||
DEBUG_LOG(m_logger) << "ParticipantId: " << data.location().participantId()
|
||||
<< ", equipNo = " << data.location().equipNo();
|
||||
|
||||
return m_testPart->write(data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool DataTopicTests::initSubscriber()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Initialisation DDS (Subscriber/Reader)";
|
||||
|
||||
m_domainParticipantSub =
|
||||
dds::domain::DomainParticipant(m_domainId,
|
||||
DDS::QosProfile::domainParticipantShm());
|
||||
|
||||
dds::sub::qos::SubscriberQos subscriberQos = m_domainParticipantSub.default_subscriber_qos();
|
||||
|
||||
|
||||
dds::core::StringSeq partitions;
|
||||
partitions.reserve(1);
|
||||
for(int partitionId : { 1 } )
|
||||
{
|
||||
partitions.push_back(IDL::exercisePartition(partitionId));
|
||||
}
|
||||
|
||||
dds::core::policy::Partition partitionQos;
|
||||
partitionQos.name( partitions );
|
||||
subscriberQos << partitionQos;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Initialise DTC::SubscriberListener";
|
||||
m_subscriberListener = new DDSGeneric::SubscriberListener();
|
||||
m_ddsSubscriber = dds::sub::Subscriber(m_domainParticipantSub,
|
||||
subscriberQos,
|
||||
m_subscriberListener,
|
||||
DDSGeneric::SubscriberListener::mask());
|
||||
|
||||
|
||||
m_dtcTestPart = new DTC::SampleInfo::TestParticipantImpl(m_domainParticipantSub,
|
||||
m_ddsSubscriber,
|
||||
m_subscriberListener);
|
||||
|
||||
m_dtcTestPart->setSubscriberCallback([this](const DdsUnitTests::TestParticipant &data, const dds::sub::SampleInfo &si) { processData(data, si); } );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DataTopicTests::deleteDTC()
|
||||
{
|
||||
delete m_dtcTestPart;
|
||||
m_dtcTestPart = nullptr;
|
||||
}
|
||||
|
||||
void DataTopicTests::deleteSubscriber()
|
||||
{
|
||||
m_ddsSubscriber = nullptr;
|
||||
delete m_subscriberListener;
|
||||
m_subscriberListener = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DataTopicTests::processData(const DdsUnitTests::TestParticipant &instance, const dds::sub::SampleInfo &si)
|
||||
{
|
||||
INFO_LOG(m_logger) << "process data in topic TestParticipant, Sampleinfo: " << si.source_timestamp().sec();
|
||||
|
||||
DEBUG_LOG(m_logger) << "participantId: " << instance.location().participantId();
|
||||
DEBUG_LOG(m_logger) << "equipNo: " << instance.location().equipNo();
|
||||
|
||||
m_receivedParticipantData = instance;
|
||||
|
||||
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
||||
|
||||
emit testParticipantDataArrived();
|
||||
}
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <DDS/Generic/subscriber_listener.h>
|
||||
|
||||
#include <DdsUnitTests/ddsut_dtc_types.h>
|
||||
#include <DdsUnitTests/ddsut_dts_types.h>
|
||||
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class DataTopicTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataTopicTests();
|
||||
virtual ~DataTopicTests();
|
||||
|
||||
|
||||
bool initPublisher();
|
||||
bool initSubscriber();
|
||||
|
||||
|
||||
bool write(const DdsUnitTests::TestParticipant &data);
|
||||
|
||||
|
||||
DdsUnitTests::TestParticipant getReceivedParticipantData() const { return m_receivedParticipantData; }
|
||||
void deleteDTC();
|
||||
void deleteSubscriber();
|
||||
|
||||
protected:
|
||||
|
||||
void processData(const DdsUnitTests::TestParticipant &instance, const dds::sub::SampleInfo &si);
|
||||
|
||||
Q_SIGNALS:
|
||||
void testParticipantDataArrived();
|
||||
|
||||
private:
|
||||
dds::domain::DomainParticipant m_domainParticipantPub;
|
||||
dds::domain::DomainParticipant m_domainParticipantSub;
|
||||
int m_domainId;
|
||||
int m_partitionId;
|
||||
|
||||
|
||||
dds::pub::Publisher m_ddsPublisher;
|
||||
DTS::TestParticipant *m_testPart;
|
||||
|
||||
|
||||
dds::sub::Subscriber m_ddsSubscriber;
|
||||
DDSGeneric::SubscriberListener *m_subscriberListener;
|
||||
|
||||
DTC::SampleInfo::TestParticipant *m_dtcTestPart;
|
||||
|
||||
Qt::HANDLE m_mainThreadId;
|
||||
|
||||
DdsUnitTests::TestParticipant m_receivedParticipantData;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
|
||||
|
||||
|
||||
#include "data_topic_tests_main.h"
|
||||
#include "data_topic_tests.h"
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTests", "log4cxx_ddsUnitTests.props");
|
||||
|
||||
DataTopicTestsMain *tc = new DataTopicTestsMain;
|
||||
|
||||
int retCode = QTest::qExec(tc, argc, argv);
|
||||
|
||||
delete tc;
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
DataTopicTestsMain::DataTopicTestsMain()
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.DataTopicTestsMain"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DataTopicTestsMain::initTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: initTestCase";
|
||||
|
||||
m_dtTest = new DataTopicTests();
|
||||
QVERIFY2(m_dtTest, "Initialisation of DataTopicTest failed");
|
||||
QVERIFY2(m_dtTest->initPublisher(), "Initialisation Publisher failed");
|
||||
QVERIFY2(m_dtTest->initSubscriber(), "Initialisation Subscriber failed");
|
||||
|
||||
m_participantDataArrivedSpy = new QSignalSpy(m_dtTest, &DataTopicTests::testParticipantDataArrived);
|
||||
}
|
||||
|
||||
|
||||
void DataTopicTestsMain::publishTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: publish TestParticipant";
|
||||
|
||||
m_sentParticipantData.location().participantId(100);
|
||||
m_sentParticipantData.location().equipNo(1010);
|
||||
m_sentParticipantData.testId(100);
|
||||
QVERIFY2(m_dtTest->write(m_sentParticipantData), "Publishing Topic TestParticipant failed");
|
||||
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: publish ready";
|
||||
}
|
||||
|
||||
|
||||
void DataTopicTestsMain::subscribeTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "IN subscribeTestCase";
|
||||
|
||||
QTRY_COMPARE(m_participantDataArrivedSpy->count(), 1);
|
||||
|
||||
DdsUnitTests::TestParticipant recvPartiticpant = m_dtTest->getReceivedParticipantData();
|
||||
|
||||
QCOMPARE(recvPartiticpant.location().participantId(), m_sentParticipantData.location().participantId());
|
||||
QCOMPARE(recvPartiticpant.location().equipNo(), m_sentParticipantData.location().equipNo());
|
||||
}
|
||||
|
||||
|
||||
void DataTopicTestsMain::deleteDataReaderTestCase()
|
||||
{
|
||||
DdsUnitTests::TestParticipant data;
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
m_sentParticipantData.id(i);
|
||||
m_dtTest->write(m_sentParticipantData);
|
||||
}
|
||||
m_dtTest->deleteDTC();
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
m_sentParticipantData.id(i);
|
||||
m_dtTest->write(m_sentParticipantData);
|
||||
}
|
||||
m_dtTest->deleteSubscriber();
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
m_sentParticipantData.id(i);
|
||||
m_dtTest->write(m_sentParticipantData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DataTopicTestsMain::cleanupTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"DataTopicTestsMain: cleanupTestCase";
|
||||
delete m_dtTest; m_dtTest = nullptr;
|
||||
delete m_participantDataArrivedSpy; m_participantDataArrivedSpy = nullptr;
|
||||
}
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QSignalSpy>
|
||||
#include <DdsUnitTests/ddsut_dtc_types.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class DataTopicTests;
|
||||
|
||||
|
||||
class DataTopicTestsMain : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DataTopicTestsMain();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void publishTestCase();
|
||||
void subscribeTestCase();
|
||||
void deleteDataReaderTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
DdsUnitTests::TestParticipant m_sentParticipantData;
|
||||
QSignalSpy *m_participantDataArrivedSpy = nullptr;
|
||||
DataTopicTests *m_dtTest = nullptr;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
Executable
+123
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="DdsUnitTests" abbreviation="DDSUT" procNames="">
|
||||
<rcs>
|
||||
<Id Id="$Id: core.xml 38132 2018-01-10 07:52:50Z ehrlicher $"/>
|
||||
<HeadURL HeadURL="$HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/DDS/Core/core.xml $"/>
|
||||
<Author Author="$Author: ehrlicher $"/>
|
||||
</rcs>
|
||||
<tables/>
|
||||
<views/>
|
||||
<topicTypes>
|
||||
<topicType name="BaseEntity">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="name" idlType="string"/>
|
||||
<column name="isDeleted" idlType="boolean"/>
|
||||
<column name="isUsed" idlType="boolean" comment="Defines if it is used by others (i.e. foreign key constraint)"/>
|
||||
<column name="isBlockedForEdit" idlType="boolean"/>
|
||||
</topicType>
|
||||
<topicType name="BaseEntityTranslatable">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="name" idlType="string" isTranslatable="1"/>
|
||||
<column name="isDeleted" idlType="boolean"/>
|
||||
<column name="isUsed" idlType="boolean" comment="Defines if it is used by others (i.e. foreign key constraint)"/>
|
||||
<column name="isBlockedForEdit" idlType="boolean"/>
|
||||
</topicType>
|
||||
<topicType name="BaseEntityWithSampleTime" extensibility="EXTENSIBLE" baseValueType="BaseEntity">
|
||||
<column name="sampleTime" idlType="long long" comment="Timestamp"/>
|
||||
</topicType>
|
||||
<topicType name="CurrentRunningState" isDataObject="1" routeToClient="0" routeInReplay="0">
|
||||
<column name="pid" idlType="long long" isKey="1"/>
|
||||
<column name="runningState" idlType="Core::RunningState"/>
|
||||
<column name="ports" idlType="sequence<PortInformation>" isOptional="1"/>
|
||||
<column name="errorString" idlType="string" isOptional="1"/>
|
||||
</topicType>
|
||||
<topicType name="Entity" extensibility="EXTENSIBLE" baseValueType="BaseEntityWithSampleTime">
|
||||
<column name="location" idlType="SpatialData"/>
|
||||
<column name="symbolId" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="FunctionReply">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="errorString" idlType="string"/>
|
||||
<column name="errorParams" idlType="sequence<string>"/>
|
||||
</topicType>
|
||||
<topicType name="FunctionReplyWithState" baseValueType="FunctionReply">
|
||||
<column name="replyState" idlType="Core::FtReplyState"/>
|
||||
</topicType>
|
||||
<topicType name="FunctionRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="value" idlType="double"/>
|
||||
<column name="info" idlType="string" isOptional="1"/>
|
||||
</topicType>
|
||||
<topicType name="FunctionRequestWithState" baseValueType="FunctionRequest">
|
||||
<column name="status" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="GeoPosition" extensibility="FINAL">
|
||||
<column name="lon" idlType="double"/>
|
||||
<column name="lat" idlType="double"/>
|
||||
<column name="z" idlType="double" comment="height above ground"/>
|
||||
</topicType>
|
||||
<topicType name="GeoPosition2D" extensibility="FINAL">
|
||||
<column name="lon" idlType="double" comment="[m]"/>
|
||||
<column name="lat" idlType="double" comment="[m]"/>
|
||||
</topicType>
|
||||
<topicType name="Orientation" extensibility="FINAL">
|
||||
<column name="heave" idlType="double"/>
|
||||
<column name="pitch" idlType="double"/>
|
||||
<column name="roll" idlType="double"/>
|
||||
</topicType>
|
||||
<topicType name="PartitionTime" isDataObject="1" routeToClient="1" routeInReplay="0">
|
||||
<column name="timeStamp" idlType="long long"/>
|
||||
</topicType>
|
||||
<topicType name="PortInformation">
|
||||
<column name="number" idlType="long"/>
|
||||
<column name="type" idlType="PortType"/>
|
||||
</topicType>
|
||||
<topicType name="RelativePosition">
|
||||
<column name="offsetX" idlType="double" comment="in meter"/>
|
||||
<column name="offsetY" idlType="double" comment="in meter"/>
|
||||
<column name="offsetZ" idlType="double" comment="in meter"/>
|
||||
</topicType>
|
||||
<topicType name="RemoveElementRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="ReplayPartition" isDataObject="1" routeToClient="1" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="name" idlType="string"/>
|
||||
<column name="exerciseId" idlType="long"/>
|
||||
<column name="workstationId" idlType="long"/>
|
||||
<column name="operatorId" idlType="long"/>
|
||||
<column name="replayType" idlType="Core::ReplayType"/>
|
||||
<column name="domainId" idlType="long"/>
|
||||
<column name="tcpConnectionUrl" idlType="string"/>
|
||||
</topicType>
|
||||
<topicType name="SpatialData" isDataObject="1" routeToClient="0" routeInReplay="0">
|
||||
<column name="changedAt" idlType="long"/>
|
||||
<column name="equipNo" idlType="long"/>
|
||||
<column name="gpsPosition" idlType="GeoPosition"/>
|
||||
<column name="orientation" idlType="Orientation"/>
|
||||
<column name="participantId" idlType="long"/>
|
||||
<column name="velocity" idlType="Velocity"/>
|
||||
</topicType>
|
||||
<topicType name="TestParticipant" isDataObject="1" routeToClient="0" routeInReplay="0" recordTopic="1" baseValueType="Entity">
|
||||
<column name="designator" idlType="string<20>"/>
|
||||
<column name="testId" idlType="long"/>
|
||||
<column name="gpsQuality" idlType="short"/>
|
||||
<column name="equipmentNumber" idlType="long"/>
|
||||
</topicType>
|
||||
<topicType name="Velocity">
|
||||
<column name="x" idlType="double"/>
|
||||
<column name="y" idlType="double"/>
|
||||
<column name="z" idlType="double"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="FunctionTopicTest" requestTopicType="FunctionRequest" replyTopicType="FunctionReply" requestTopicName="FunctionTopicTestRequest" replyTopicName="FunctionTopicTestReply" routeInReplay="0"/>
|
||||
<functionTopic name="FunctionTopicTestWithState" requestTopicType="FunctionRequestWithState" replyTopicType="FunctionReplyWithState" requestTopicName="FunctionTopicTestWithStateRequest" replyTopicName="FunctionTopicTestWithStateReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<enumerations>
|
||||
<enumeration name="PortType">
|
||||
<attribute key="Unknown" value="0"/>
|
||||
<attribute key="WebSocketServer" value="1"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
</service>
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef DDSUT_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define DDSUT_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_DDSUT_COMMON_LIB)
|
||||
# define DDSUT_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define DDSUT_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
|
||||
|
||||
|
||||
#include "function_topic_tests.h"
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <DDS/DDSConnector/subscriber.h>
|
||||
#include <DDS/DDSConnector/publisher.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTests", "log4cxx_ddsUnitTests.props");
|
||||
|
||||
FunctionTopicTests *tc = new FunctionTopicTests;
|
||||
|
||||
int retCode = QTest::qExec(tc, argc, argv);
|
||||
|
||||
delete tc;
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
|
||||
FunctionTopicTests::FunctionTopicTests()
|
||||
: m_mainThreadId(QThread::currentThreadId())
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.FunctionTopicTests"))
|
||||
{
|
||||
qRegisterMetaType<DdsUnitTests::FunctionReply>("DdsUnitTests::FunctionReply");
|
||||
qRegisterMetaType<DdsUnitTests::FunctionReplyWithState>("DdsUnitTests::FunctionReplyWithState");
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::initTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"FunctionTopicTests: initTestCase";
|
||||
|
||||
const int domainId = 0;
|
||||
|
||||
m_ddsConnectorClient = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global);
|
||||
QVERIFY2(m_ddsConnectorClient->init(), "Initialisation of ddsconnector (Client) failed");
|
||||
m_ddsConnectorClient->initSubscriber();
|
||||
QVERIFY2(m_ddsConnectorClient->getSubscriber(), "Initialisation of Subscriber (DdsConnectorClient) failed");
|
||||
m_ddsConnectorClient->initPublisher();
|
||||
QVERIFY2(m_ddsConnectorClient->getPublisher(), "Initialisation of Publisher (DdsConnectorClient) failed");
|
||||
|
||||
m_ddsConnectorServer = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global);
|
||||
QVERIFY2(m_ddsConnectorServer->init(), "Initialisation of ddsconnector (Server) failed");
|
||||
m_ddsConnectorServer->initSubscriber();
|
||||
QVERIFY2(m_ddsConnectorServer->getSubscriber(), "Initialisation of Subscriber (DdsConnectorServer) failed");
|
||||
m_ddsConnectorServer->initPublisher();
|
||||
QVERIFY2(m_ddsConnectorServer->getPublisher(), "Initialisation of Publisher (DdsConnectorServer) failed");
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::initFTSTestCase()
|
||||
{
|
||||
m_fts.reset(m_ddsConnectorServer->createFTS<FTS::FunctionTopicTest>());
|
||||
QVERIFY2(m_fts.get(), "Initialisation of FTS Replier failed");
|
||||
m_fts->setSubscriberCallback([this](const rti::core::SampleIdentity &identity, const DdsUnitTests::FunctionRequest &request) { this->onFunctionTopicRequest(identity, request);});
|
||||
|
||||
m_ftsWS.reset(m_ddsConnectorServer->createFTS<FTS::FunctionTopicTestWithState>());
|
||||
QVERIFY2(m_ftsWS.get(), "Initialisation of FTS Replier failed");
|
||||
m_ftsWS->setSubscriberCallback([this](const rti::core::SampleIdentity &identity, const DdsUnitTests::FunctionRequestWithState &request) { this->onFunctionTopicRequest(identity, request);});
|
||||
|
||||
}
|
||||
|
||||
void FunctionTopicTests::initFTCTestCase()
|
||||
{
|
||||
m_ftc.reset(m_ddsConnectorClient->createFTC<FTC::FunctionTopicTest>(this));
|
||||
QVERIFY2(m_ftc.get(), "Initialisation of FTC Requester failed");
|
||||
m_ftcWS.reset(m_ddsConnectorClient->createFTC<FTC::FunctionTopicTestWithState>(this));
|
||||
QVERIFY2(m_ftc.get(), "Initialisation of FTC Requester failed");
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::requestTestCase1()
|
||||
{
|
||||
|
||||
requestWithState();
|
||||
|
||||
QCOMPARE(m_ddsConnectorServer->getWaitSetHandler()->attachedConditionCount(), 3);
|
||||
requestWithState();
|
||||
|
||||
QCOMPARE(m_ddsConnectorServer->getWaitSetHandler()->attachedConditionCount(), 3);
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::requestWithState()
|
||||
{
|
||||
|
||||
QSignalSpy spyRequest(this, &FunctionTopicTests::functionTopicRequestFinished);
|
||||
QSignalSpy spyReply(this, &FunctionTopicTests::functionTopicReply);
|
||||
|
||||
DEBUG_LOG(m_logger) <<"FunctionTopicTests: request";
|
||||
|
||||
|
||||
DdsUnitTests::FunctionRequestWithState data;
|
||||
|
||||
data.id(1);
|
||||
data.info(std::string("Test request"));
|
||||
data.value(1000.0);
|
||||
|
||||
int uniqueId = 0;
|
||||
bool bRet = m_ftcWS->requestDataClassic(data,
|
||||
SLOT(slotRequestedData(DdsUnitTests::FunctionTopicTestWithStateReply,int,bool)),
|
||||
SLOT(slotRequestedDataError(int,int,int)),
|
||||
uniqueId);
|
||||
|
||||
QVERIFY2(bRet, "Could not request data!");
|
||||
|
||||
QTRY_COMPARE(spyRequest.count(), 1);
|
||||
QTRY_COMPARE(spyReply.count(), 2);
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::requestTestCase2()
|
||||
{
|
||||
|
||||
QSignalSpy spyRequest(this, &FunctionTopicTests::functionTopicRequestFinished);
|
||||
QSignalSpy spyReply(this, &FunctionTopicTests::functionTopicReply);
|
||||
|
||||
DEBUG_LOG(m_logger) <<"FunctionTopicTests: request";
|
||||
|
||||
|
||||
DdsUnitTests::FunctionRequest data;
|
||||
|
||||
data.id(1);
|
||||
data.info(std::string("Test request"));
|
||||
data.value(1000.0);
|
||||
|
||||
int uniqueId = 0;
|
||||
bool bRet = m_ftc->requestDataClassic(data,
|
||||
SLOT(slotRequestedData(DdsUnitTests::FunctionTopicTestReply,int,bool)),
|
||||
SLOT(slotRequestedDataError(int,int,int)),
|
||||
uniqueId);
|
||||
|
||||
QVERIFY2(bRet, "Could not request data!");
|
||||
|
||||
QTRY_COMPARE(spyRequest.count(), 1);
|
||||
QTRY_COMPARE(spyReply.count(), 1);
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::cleanupTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"FunctionTopicTests: cleanupTestCase";
|
||||
|
||||
m_fts = nullptr;
|
||||
m_ftc = nullptr;
|
||||
m_ftsWS = nullptr;
|
||||
m_ftcWS = nullptr;
|
||||
m_ddsConnectorServer = nullptr;
|
||||
m_ddsConnectorClient = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void FunctionTopicTests::onFunctionTopicRequest(const rti::core::SampleIdentity &sampleId,
|
||||
const DdsUnitTests::FunctionRequestWithState &request)
|
||||
{
|
||||
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
||||
|
||||
INFO_LOG(m_logger) << "Got function topic request (with status member)";
|
||||
m_requestTopicWithState = request;
|
||||
QCOMPARE(m_requestTopicWithState.id(), 1);
|
||||
QCOMPARE(m_requestTopicWithState.info().get(), std::string("Test request"));
|
||||
QCOMPARE(m_requestTopicWithState.value(), 1000.0);
|
||||
|
||||
DdsUnitTests::FunctionReplyWithState reply;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Send sample with status REPLY_COMPLETED";
|
||||
reply.id(1);
|
||||
reply.errorString("Hello");
|
||||
reply.replyState(Core::FtReplyState::Completed);
|
||||
|
||||
bool bRet = m_ftsWS->sendReply(sampleId, reply);
|
||||
QVERIFY2(bRet, "Sending Reply failed");
|
||||
|
||||
emit functionTopicRequestFinished();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionTopicTests::onFunctionTopicRequest(const rti::core::SampleIdentity &sampleId,
|
||||
const DdsUnitTests::FunctionRequest &request)
|
||||
{
|
||||
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
||||
|
||||
INFO_LOG(m_logger) << "Got function topic request (without status member)";
|
||||
|
||||
m_requestTopic = request;
|
||||
|
||||
DdsUnitTests::FunctionReply reply;
|
||||
|
||||
reply.id(2);
|
||||
reply.errorString("What?");
|
||||
|
||||
bool bRet = m_fts->sendReply(sampleId, reply);
|
||||
QVERIFY2(bRet, "Sending Reply failed");
|
||||
|
||||
emit functionTopicRequestFinished();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionTopicTests::slotRequestedData(const DdsUnitTests::FunctionTopicTestWithStateReply &reply,
|
||||
int seqNo, bool bFinished)
|
||||
{
|
||||
Q_UNUSED(seqNo);
|
||||
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
||||
|
||||
INFO_LOG(m_logger) << "Got reply from FTS: " << reply.replyState();
|
||||
|
||||
m_replyTopicWithState = reply;
|
||||
|
||||
if (m_replyTopicWithState.replyState() == Core::FtReplyState::InProgress)
|
||||
{
|
||||
QVERIFY(!bFinished);
|
||||
QCOMPARE(m_replyTopicWithState.id(), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
QVERIFY(bFinished);
|
||||
QCOMPARE(m_replyTopicWithState.id(), 1);
|
||||
QCOMPARE(m_replyTopicWithState.errorString(), std::string("Hello"));
|
||||
QCOMPARE(m_replyTopicWithState.replyState().underlying(), Core::FtReplyState::Completed);
|
||||
}
|
||||
emit functionTopicReply();
|
||||
}
|
||||
|
||||
void FunctionTopicTests::slotRequestedData(const DdsUnitTests::FunctionTopicTestReply &reply,
|
||||
int seqNo, bool bFinished)
|
||||
{
|
||||
Q_UNUSED(seqNo);
|
||||
QVERIFY(bFinished);
|
||||
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
||||
|
||||
m_replyTopic = reply;
|
||||
QCOMPARE(m_replyTopic.id(), 2);
|
||||
QCOMPARE(m_replyTopic.errorString(), std::string("What?"));
|
||||
|
||||
emit functionTopicReply();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FunctionTopicTests::slotRequestedDataError(int reason, int seqNo, int requestId)
|
||||
{
|
||||
Q_UNUSED(seqNo);
|
||||
Q_UNUSED(requestId);
|
||||
QFAIL(qPrintable(QStringLiteral("Error when trying to request data: %1").arg(reason)));
|
||||
}
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QSignalSpy>
|
||||
#include <QThread>
|
||||
|
||||
#include <DdsUnitTests/ddsut.hpp>
|
||||
#include <DdsUnitTests/ddsut_ftc_types.h>
|
||||
#include <DdsUnitTests/ddsut_fts_types.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/FTC/generic_ftc_impl.h>
|
||||
#include <DDS/FTS/generic_fts_impl.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class FunctionTopicTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FunctionTopicTests();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void initFTSTestCase();
|
||||
void initFTCTestCase();
|
||||
void requestTestCase1();
|
||||
void requestTestCase2();
|
||||
void cleanupTestCase();
|
||||
|
||||
Q_SIGNALS:
|
||||
void functionTopicRequestFinished();
|
||||
void functionTopicReply();
|
||||
protected Q_SLOTS:
|
||||
|
||||
void slotRequestedData(const DdsUnitTests::FunctionTopicTestReply &reply, int seqNo, bool bFinished);
|
||||
void slotRequestedData(const DdsUnitTests::FunctionTopicTestWithStateReply &reply, int seqNo, bool bFinished);
|
||||
void slotRequestedDataError(int reason, int seqNo, int requestId);
|
||||
|
||||
void onFunctionTopicRequest(const rti::core::SampleIdentity &sampleId,
|
||||
const DdsUnitTests::FunctionRequest &request);
|
||||
void onFunctionTopicRequest(const rti::core::SampleIdentity &sampleId,
|
||||
const DdsUnitTests::FunctionRequestWithState &request);
|
||||
|
||||
private:
|
||||
void requestWithState();
|
||||
private:
|
||||
|
||||
std::unique_ptr<FTS::FunctionTopicTest> m_fts;
|
||||
std::unique_ptr<FTS::FunctionTopicTestWithState> m_ftsWS;
|
||||
|
||||
std::unique_ptr<FTC::FunctionTopicTest> m_ftc;
|
||||
std::unique_ptr<FTC::FunctionTopicTestWithState> m_ftcWS;
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorClient;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnectorServer;
|
||||
|
||||
|
||||
DdsUnitTests::FunctionRequest m_requestTopic;
|
||||
DdsUnitTests::FunctionReply m_replyTopic;
|
||||
|
||||
DdsUnitTests::FunctionRequestWithState m_requestTopicWithState;
|
||||
DdsUnitTests::FunctionReplyWithState m_replyTopicWithState;
|
||||
|
||||
Qt::HANDLE m_mainThreadId;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
Executable
+226
@@ -0,0 +1,226 @@
|
||||
|
||||
|
||||
|
||||
#include "generic_data_tests.h"
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <DDS/Generic/generic_data_reader.h>
|
||||
#include <DDS/Generic/generic_data_writer.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTests", "log4cxx_ddsUnitTests.props");
|
||||
|
||||
GenericDataTests *tc = new GenericDataTests;
|
||||
|
||||
int retCode = QTest::qExec(tc, argc, argv);
|
||||
|
||||
delete tc;
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
GenericDataTests::GenericDataTests()
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.GenericDataTests"))
|
||||
{
|
||||
m_spatialData.equipNo(0);
|
||||
m_testPart.location().equipNo(0);
|
||||
m_testPart.location().participantId(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GenericDataTests::initTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"GenericDataTests: initTestCase";
|
||||
|
||||
m_init = new Initialisation();
|
||||
|
||||
int domainId = 0;
|
||||
int exerciseId = 2;
|
||||
|
||||
QVERIFY2(m_init, "Initialisation failed");
|
||||
QVERIFY2(m_init->initDDS(domainId, exerciseId, Initialisation::USE_PUBLISHER), "Initialisation (Publisher) failed");
|
||||
QVERIFY2(m_init->initDDS(domainId, exerciseId, Initialisation::USE_SUBSCRIBER), "Initialisation (Subscriber) failed");
|
||||
|
||||
|
||||
QVERIFY2(m_init->getSubscriberListener(), "Initialisation SubscriberListener failed");
|
||||
}
|
||||
|
||||
void GenericDataTests::initDRTestCase()
|
||||
{
|
||||
m_dataReader = new DTC::DroTestParticipant;
|
||||
QVERIFY2(m_dataReader, "Initialisation of GenericDataReader(TestParticipant) failed");
|
||||
QVERIFY2(m_dataReader->create(m_init->getDomainParticipantSub(), m_init->getDDSSubscriber()), "Creating DataReader (TestParticipant) failed");
|
||||
m_init->getSubscriberListener()->addCallback(m_dataReader->getDataReader(), this);
|
||||
|
||||
m_dataReaderSd = new DTC::DroSpatialData;
|
||||
QVERIFY2(m_dataReaderSd, "Initialisation of GenericDataReader(SpatialData) failed");
|
||||
QVERIFY2(m_dataReaderSd->create(m_init->getDomainParticipantSub(), m_init->getDDSSubscriber()), "Creating DataReader (SpatialData) failed");
|
||||
m_init->getSubscriberListener()->addCallback(m_dataReaderSd->getDataReader(), this);
|
||||
}
|
||||
|
||||
void GenericDataTests::initDWTestCase()
|
||||
{
|
||||
m_dataWriter = new DTS::DwoTestParticipant();
|
||||
QVERIFY2(m_dataWriter, "Initialisation of GenericDataWriter(TestParticipant) failed");
|
||||
QVERIFY2(m_dataWriter->create(m_init->getDomainParticipant(), m_init->getDDSPublisher()), "Creating DataWriter (TestParticipant) failed");
|
||||
|
||||
m_dataWriterSd = new DTS::DwoSpatialData();
|
||||
QVERIFY2(m_dataWriterSd, "Initialisation of GenericDataWriter(SpatialData) failed");
|
||||
QVERIFY2(m_dataWriterSd->create(m_init->getDomainParticipant(), m_init->getDDSPublisher()), "Creating DataWriter (SpatialData) failed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GenericDataTests::dataWriterTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"GenericDataTests: dataWriter";
|
||||
|
||||
|
||||
DdsUnitTests::SpatialData data;
|
||||
|
||||
data.participantId(100);
|
||||
data.equipNo(999);
|
||||
data.gpsPosition().lon(70000);
|
||||
data.gpsPosition().lat(90000);
|
||||
data.gpsPosition().z(10);
|
||||
|
||||
data.orientation().heave(10);
|
||||
data.orientation().pitch(10);
|
||||
data.orientation().roll(10);
|
||||
|
||||
data.velocity().x(10);
|
||||
data.velocity().y(2);
|
||||
data.velocity().z(1);
|
||||
|
||||
data.changedAt(11111);
|
||||
|
||||
QVERIFY2(m_dataWriterSd->write(data), "Publishing Topic (SpatialData) failed");
|
||||
|
||||
DdsUnitTests::TestParticipant allData;
|
||||
|
||||
allData.name("************************ Name of TestParticpant ***********************");
|
||||
allData.location() = data;
|
||||
allData.id(10000);
|
||||
QVERIFY2(m_dataWriter->write(allData), "Publishing Topic (TestParticipant) failed");
|
||||
allData.id(11000);
|
||||
QVERIFY2(m_dataWriter->write(allData), "Publishing Topic (TestParticipant) failed");
|
||||
allData.id(11100);
|
||||
QVERIFY2(m_dataWriter->write(allData), "Publishing Topic (TestParticipant) failed");
|
||||
allData.id(11110);
|
||||
QVERIFY2(m_dataWriter->write(allData), "Publishing Topic (TestParticipant) failed");
|
||||
|
||||
allData.id(11111);
|
||||
|
||||
QVERIFY2(m_dataWriter->write(allData), "Publishing Topic (TestParticipant) failed");
|
||||
}
|
||||
|
||||
|
||||
void GenericDataTests::dataReaderTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "GenericDataTests: dataReader";
|
||||
|
||||
|
||||
QTRY_COMPARE(m_spatialData.equipNo(), 999);
|
||||
QCOMPARE(m_spatialData.changedAt(), 11111);
|
||||
|
||||
QTRY_COMPARE(m_testPart.location().equipNo(), 999);
|
||||
QCOMPARE(m_testPart.location().participantId(), 100);
|
||||
|
||||
bool bSeenUnreadSamples = false;
|
||||
dds::sub::LoanedSamples<DdsUnitTests::TestParticipant> vecTp = m_dataReader->readAlive(bSeenUnreadSamples);
|
||||
INFO_LOG(m_logger) <<"vecTp size: " << vecTp.length();
|
||||
QCOMPARE(vecTp.length(), static_cast<decltype(vecTp.length())>(5));
|
||||
QCOMPARE(vecTp[0].data().id(), 10000);
|
||||
QCOMPARE(vecTp[1].data().id(), 11000);
|
||||
QCOMPARE(vecTp[2].data().id(), 11100);
|
||||
QCOMPARE(vecTp[3].data().id(), 11110);
|
||||
QCOMPARE(vecTp[4].data().id(), 11111);
|
||||
|
||||
dds::sub::LoanedSamples<DdsUnitTests::TestParticipant> vecTpLoaned = m_dataReader->takeAlive(bSeenUnreadSamples);
|
||||
INFO_LOG(m_logger) <<"vecTpLoaned size: " << vecTp.length();
|
||||
QCOMPARE(vecTpLoaned.length(), static_cast<decltype(vecTpLoaned.length())>(5));
|
||||
QCOMPARE(vecTpLoaned[0].data().id(), 10000);
|
||||
QCOMPARE(vecTpLoaned[1].data().id(), 11000);
|
||||
QCOMPARE(vecTpLoaned[2].data().id(), 11100);
|
||||
QCOMPARE(vecTpLoaned[3].data().id(), 11110);
|
||||
QCOMPARE(vecTpLoaned[4].data().id(), 11111);
|
||||
}
|
||||
|
||||
|
||||
void GenericDataTests::deleteDataReaderTestCase()
|
||||
{
|
||||
DdsUnitTests::TestParticipant data;
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
data.id(i);
|
||||
m_dataWriter->write(data);
|
||||
}
|
||||
m_init->getSubscriberListener()->removeCallback(m_dataReader->getDataReader(), this);
|
||||
delete m_dataReader;
|
||||
m_dataReader = nullptr;
|
||||
for(int i = 0; i < 1000; ++i)
|
||||
{
|
||||
data.id(i);
|
||||
m_dataWriter->write(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GenericDataTests::cleanupTestCase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) <<"GenericDataTests: cleanupTestCase";
|
||||
if (m_dataReader)
|
||||
{
|
||||
m_init->getSubscriberListener()->removeCallback(m_dataReader->getDataReader(), this);
|
||||
delete m_dataReader;
|
||||
}
|
||||
if (m_dataReaderSd)
|
||||
{
|
||||
m_init->getSubscriberListener()->removeCallback(m_dataReaderSd->getDataReader(), this);
|
||||
delete m_dataReaderSd;
|
||||
}
|
||||
m_init->cleanupSubscriberListener();
|
||||
delete m_dataWriter;
|
||||
delete m_dataWriterSd;
|
||||
delete m_init;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void GenericDataTests::processData(const DdsUnitTests::SpatialData &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "SpatialData: equipNo = " << data.equipNo() << " modType: " << modType;
|
||||
m_spatialData = data;
|
||||
}
|
||||
|
||||
void GenericDataTests::processData(const DdsUnitTests::TestParticipant &data, const dds::sub::SampleInfo &si)
|
||||
{
|
||||
Q_UNUSED(si);
|
||||
DEBUG_LOG(m_logger) << "TestParticipant: equipNo = " << data.location().equipNo();
|
||||
m_testPart = data;
|
||||
}
|
||||
|
||||
void GenericDataTests::droDataAvailable(const std::string &topicType, const std::string &topicName)
|
||||
{
|
||||
Q_UNUSED(topicName)
|
||||
DEBUG_LOG(m_logger) << "IN droDataAvailable: type = " << topicType;
|
||||
if (topicType == "DdsUnitTests::TestParticipant")
|
||||
{
|
||||
m_init->getSubscriberListener()->enableCallback(m_dataReader->getDataReader(), this);
|
||||
m_dataReader->read([this](const DdsUnitTests::TestParticipant &data, const dds::sub::SampleInfo &si) { processData(data, si); });
|
||||
}
|
||||
else if(topicType == "DdsUnitTests::SpatialData")
|
||||
{
|
||||
m_init->getSubscriberListener()->enableCallback(m_dataReaderSd->getDataReader(), this);
|
||||
m_dataReaderSd->read([this](const DdsUnitTests::SpatialData &data, DataModification modType) { processData(data, modType); } );
|
||||
}
|
||||
}
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <DdsUnitTests/ddsut_dtc_types.h>
|
||||
#include <DdsUnitTests/ddsut_dts_types.h>
|
||||
|
||||
#include <DDS/Generic/subscriber_listener.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class GenericDataTests : public DDSGeneric::SubscriberListenerCallback
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GenericDataTests();
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void initDRTestCase();
|
||||
void initDWTestCase();
|
||||
void dataWriterTestCase();
|
||||
void dataReaderTestCase();
|
||||
void deleteDataReaderTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
protected:
|
||||
void droDataAvailable(const std::string &topicType, const std::string &topicName) override;
|
||||
void noWriterAnymore(const std::string &topicType, const std::string &topicName) override
|
||||
{
|
||||
Q_UNUSED(topicType);
|
||||
Q_UNUSED(topicName);
|
||||
}
|
||||
|
||||
void writerAvailable(const std::string &topicType, const std::string &topicName) override
|
||||
{
|
||||
Q_UNUSED(topicType);
|
||||
Q_UNUSED(topicName);
|
||||
}
|
||||
|
||||
void processData(const DdsUnitTests::TestParticipant &data, const dds::sub::SampleInfo &si);
|
||||
void processData(const DdsUnitTests::SpatialData &data, DataModification modType);
|
||||
|
||||
private:
|
||||
Initialisation *m_init = nullptr;
|
||||
|
||||
DTS::DwoTestParticipant *m_dataWriter = nullptr;
|
||||
DTC::DroTestParticipant *m_dataReader = nullptr;
|
||||
|
||||
DTS::DwoSpatialData *m_dataWriterSd = nullptr;
|
||||
DTC::DroSpatialData *m_dataReaderSd = nullptr;
|
||||
|
||||
DdsUnitTests::SpatialData m_spatialData;
|
||||
DdsUnitTests::TestParticipant m_testPart;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
|
||||
|
||||
Initialisation::Initialisation()
|
||||
: m_domainParticipant(nullptr)
|
||||
, m_domainParticipantSub(nullptr)
|
||||
, m_domainId(0)
|
||||
, m_exerciseId(-1)
|
||||
, m_ddsPublisher(nullptr)
|
||||
, m_ddsSubscriber(nullptr)
|
||||
, m_subListener(new DDSGeneric::SubscriberListener)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.Initialisation"))
|
||||
{
|
||||
if (!DDS::QosProfile::setDefault())
|
||||
ERROR_LOG(m_logger) << "Error setting default QoS from xml-file ";
|
||||
|
||||
}
|
||||
|
||||
Initialisation::~Initialisation()
|
||||
{
|
||||
cleanupSubscriberListener();
|
||||
m_ddsSubscriber = nullptr;
|
||||
m_ddsPublisher = nullptr;
|
||||
}
|
||||
|
||||
void Initialisation::cleanupSubscriberListener()
|
||||
{
|
||||
if (m_ddsSubscriber != nullptr && m_subListener != nullptr)
|
||||
{
|
||||
m_ddsSubscriber.listener(nullptr, dds::core::status::StatusMask::none());
|
||||
delete m_subListener;
|
||||
m_subListener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Initialisation::initDDS(int domainId, int exerciseId, PubSub pubsub)
|
||||
{
|
||||
if (m_domainParticipant == nullptr)
|
||||
m_domainParticipant = dds::domain::DomainParticipant(domainId, DDS::QosProfile::domainParticipantShm());
|
||||
|
||||
|
||||
|
||||
if (pubsub == USE_PUBLISHER || pubsub == USE_PUB_SUB)
|
||||
{
|
||||
dds::pub::qos::PublisherQos publisherQos = m_domainParticipant.default_publisher_qos();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Publish on partition " << IDL::exercisePartition(exerciseId);
|
||||
|
||||
|
||||
dds::core::policy::Partition partitionQos;
|
||||
partitionQos.name( { IDL::exercisePartition(exerciseId) } );
|
||||
publisherQos << partitionQos;
|
||||
|
||||
m_ddsPublisher = dds::pub::Publisher(m_domainParticipant,
|
||||
publisherQos);
|
||||
}
|
||||
|
||||
if (pubsub == USE_SUBSCRIBER || pubsub == USE_PUB_SUB)
|
||||
{
|
||||
dds::domain::DomainParticipant domainPart = m_domainParticipant;
|
||||
if ( domainPart == nullptr || m_domainParticipantSub == nullptr)
|
||||
{
|
||||
m_domainParticipantSub = dds::domain::DomainParticipant(domainId, DDS::QosProfile::domainParticipantShm());
|
||||
domainPart = m_domainParticipantSub;
|
||||
}
|
||||
|
||||
dds::sub::qos::SubscriberQos subscriberQos = domainPart.default_subscriber_qos();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Subsribing on partition " << IDL::exercisePartition(exerciseId);
|
||||
|
||||
|
||||
dds::core::policy::Partition partitionQos;
|
||||
partitionQos.name( { IDL::exercisePartition(exerciseId) } );
|
||||
subscriberQos << partitionQos;
|
||||
|
||||
m_ddsSubscriber = dds::sub::Subscriber(domainPart,
|
||||
subscriberQos,
|
||||
m_subListener,
|
||||
m_subListener->mask());
|
||||
}
|
||||
|
||||
if (m_domainId == 0)
|
||||
m_domainId = domainId;
|
||||
|
||||
if (m_exerciseId < 0)
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
return true;
|
||||
}
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
#include <DDS/Generic/subscriber_listener.h>
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class Initialisation
|
||||
{
|
||||
public:
|
||||
Initialisation();
|
||||
virtual ~Initialisation();
|
||||
|
||||
enum PubSub
|
||||
{
|
||||
USE_PUBLISHER = 1,
|
||||
USE_SUBSCRIBER = 2,
|
||||
USE_PUB_SUB = 4
|
||||
};
|
||||
|
||||
|
||||
bool initDDS(int domainId, int exerciseId, PubSub pubsub = USE_PUBLISHER);
|
||||
void cleanupSubscriberListener();
|
||||
|
||||
dds::domain::DomainParticipant getDomainParticipant() { return m_domainParticipant; }
|
||||
dds::domain::DomainParticipant getDomainParticipantSub() { return m_domainParticipantSub != nullptr ? m_domainParticipantSub : m_domainParticipant; }
|
||||
dds::pub::Publisher getDDSPublisher() { return m_ddsPublisher; }
|
||||
dds::sub::Subscriber getDDSSubscriber() { return m_ddsSubscriber; }
|
||||
DDSGeneric::SubscriberListener *getSubscriberListener() { return m_subListener; }
|
||||
|
||||
private:
|
||||
dds::domain::DomainParticipant m_domainParticipant;
|
||||
dds::domain::DomainParticipant m_domainParticipantSub;
|
||||
int m_domainId;
|
||||
int m_exerciseId;
|
||||
dds::pub::Publisher m_ddsPublisher;
|
||||
dds::sub::Subscriber m_ddsSubscriber;
|
||||
DDSGeneric::SubscriberListener *m_subListener;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.UnitTests.main=WARN
|
||||
|
||||
# GenericDataTests
|
||||
log4j.logger.UnitTests.Initialisation=WARN
|
||||
log4j.logger.UnitTests.GenericDataTests=WARN
|
||||
|
||||
# DataTopicTests
|
||||
log4j.logger.UnitTests.DataTopicTestsMain=WARN
|
||||
log4j.logger.UnitTests.DataTopicTests=WARN
|
||||
|
||||
# FunctionTopicTests
|
||||
log4j.logger.UnitTests.FunctionTopicTests=WARN
|
||||
|
||||
# GenericTopicSqlTests
|
||||
log4j.logger.UnitTests.GenericTopicSqlTests=WARN
|
||||
|
||||
# Qos Infos
|
||||
log4j.logger.DDS.DefaultQos=WARN
|
||||
|
||||
# Generic
|
||||
#log4j.logger.GenericBase=DEBUG
|
||||
#log4j.logger.Generic.DataWriter=DEBUG
|
||||
#log4j.logger.Generic.DataReader=DEBUG
|
||||
#log4j.logger.Generic.DroTypeInfo=DEBUG
|
||||
|
||||
log4j.logger.GenericBase=WARN
|
||||
log4j.logger.Generic.Subscriber=WARN
|
||||
log4j.logger.Generic.Publisher=WARN
|
||||
log4j.logger.Generic.DataWriter=WARN
|
||||
log4j.logger.Generic.DataReader=WARN
|
||||
log4j.logger.Generic.DroTypeInfo=WARN
|
||||
|
||||
# DTCs
|
||||
log4j.logger.Generic.DTC=WARN
|
||||
log4j.logger.DTC.SubscriberListener=WARN
|
||||
log4j.logger.DTC.Topic=WARN
|
||||
log4j.logger.DTC.Exercise=WARN
|
||||
log4j.logger.DTC.StatusDRWatcher=WARN
|
||||
|
||||
# FTSs / FTCs
|
||||
log4j.logger.FTS.Replier=WARN
|
||||
log4j.logger.FTC.Requester=WARN
|
||||
log4j.logger.Generic.FTS=WARN
|
||||
log4j.logger.Generic.FTC=WARN
|
||||
|
||||
|
||||
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}_dds_unittests.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:
|
||||
Reference in new issue
Block a user