- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
245 lines
7.4 KiB
C++
Executable File
245 lines
7.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Unit test for ServiceManagement (SCM)
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hannes Baeuerle, SLSE, 2015-03-14
|
|
*/
|
|
|
|
#include "data_topic_tests.h"
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
|
#include <Common/ProjectConfig/project_defines.h>
|
|
#include <DDS/DTS/generic_dts_impl.h>
|
|
#include <DDS/DTC/generic_dtc_impl.h>
|
|
|
|
#include <QtTest/QTest>
|
|
#include <QVariant>
|
|
#include <QThread>
|
|
|
|
|
|
|
|
DataTopicTests::DataTopicTests()
|
|
: m_domainParticipantPub(nullptr)
|
|
, m_domainParticipantSub(nullptr)
|
|
, m_domainId(0)
|
|
, m_ddsPublisher(nullptr)
|
|
, m_dtsServiceInformation(nullptr)
|
|
, m_dtsGroupInformation(nullptr)
|
|
, m_ddsSubscriber(nullptr)
|
|
, m_subscriberListener(nullptr)
|
|
, m_subscriberListenerBinder(nullptr)
|
|
, m_dtcServiceInformation(nullptr)
|
|
, m_dtcGroupInformation(nullptr)
|
|
, m_mainThreadId(QThread::currentThreadId())
|
|
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTests.DataTopicTests"))
|
|
{
|
|
if (!DDS::QosProfile::setDefault())
|
|
ERROR_LOG() << "Error setting default QoS from xml-file ";
|
|
|
|
DEBUG_LOG() << "Main thread ID is " << m_mainThreadId;
|
|
}
|
|
|
|
DataTopicTests::~DataTopicTests()
|
|
{
|
|
// Publisher
|
|
delete m_dtsServiceInformation;
|
|
delete m_dtsGroupInformation;
|
|
|
|
// Subscriber
|
|
delete m_dtcServiceInformation;
|
|
delete m_dtcGroupInformation;
|
|
|
|
m_subscriberListener->prepareShutdown();
|
|
m_subscriberListenerBinder = nullptr;
|
|
|
|
m_ddsSubscriber = nullptr;
|
|
m_ddsPublisher = nullptr;
|
|
|
|
m_domainParticipantSub = nullptr;
|
|
m_domainParticipantPub = nullptr;
|
|
}
|
|
|
|
/**
|
|
* Publisher
|
|
**/
|
|
|
|
bool DataTopicTests::initPublisher()
|
|
{
|
|
m_domainParticipantPub =
|
|
dds::domain::DomainParticipant(m_domainId,
|
|
DDS::QosProfile::domainParticipantShm());
|
|
|
|
dds::pub::qos::PublisherQos publisherQos = m_domainParticipantPub.default_publisher_qos();
|
|
|
|
// ExerciseData will be published to Partition 0
|
|
// use only selected partition
|
|
const std::string partition = IDL::exercisePartition(0);
|
|
|
|
dds::core::policy::Partition partitionQos;
|
|
partitionQos.name( { partition } );
|
|
publisherQos << partitionQos;
|
|
|
|
DEBUG_LOG() << "Publish on partition " << partition;
|
|
|
|
m_ddsPublisher = dds::pub::Publisher(m_domainParticipantPub, publisherQos);
|
|
|
|
// Create DTSs
|
|
m_dtsServiceInformation = new DTS::ServiceInformationImpl(m_domainParticipantPub, m_ddsPublisher);
|
|
m_dtsGroupInformation = new DTS::GroupInformationImpl(m_domainParticipantPub, m_ddsPublisher);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool DataTopicTests::write(const ServiceManagement::ServiceInformation &data)
|
|
{
|
|
INFO_LOG() << "Publish topic ServiceInformation ";
|
|
|
|
DEBUG_LOG() << "Id: " << data.id()
|
|
<< ", Name: " << data.name()
|
|
<< ", State: " << data.state()
|
|
<< ", Timestamp: " << data.timestamp()
|
|
<< ", ErrorString: " << data.errorString()
|
|
;
|
|
|
|
return m_dtsServiceInformation->write(data);
|
|
}
|
|
|
|
bool DataTopicTests::write(const ServiceManagement::GroupInformation &data)
|
|
{
|
|
INFO_LOG() << "Publish topic GroupInformation ";
|
|
|
|
if(m_logger.isDebugEnabled())
|
|
{
|
|
QString services;
|
|
|
|
for(int serviceId : data.services())
|
|
{
|
|
services.append(QString::number(serviceId));
|
|
services.append(QLatin1Char(','));
|
|
}
|
|
|
|
if(services.endsWith(QLatin1Char(',')))
|
|
services.chop(1);
|
|
|
|
DEBUG_LOG() << "Type: " << data.type()
|
|
<< ", Domain: " << data.domainId()
|
|
<< ", Partition: " << data.exercisePartitionId()
|
|
<< ", Partition: " << data.replayPartitionId()
|
|
<< ", Services: " << services
|
|
<< ", Timestamp: " << data.timestamp();
|
|
}
|
|
|
|
return m_dtsGroupInformation->write(data);
|
|
}
|
|
|
|
ServiceManagement::ServiceInformation DataTopicTests::getReceivedServiceInformationData() const
|
|
{
|
|
return m_receivedServiceInformationData;
|
|
}
|
|
|
|
ServiceManagement::GroupInformation DataTopicTests::getReceivedGroupInformationData() const
|
|
{
|
|
return m_receivedGroupInformationData;
|
|
}
|
|
|
|
void DataTopicTests::processData(const ServiceManagement::ServiceInformation &instance, DataModification modType)
|
|
{
|
|
Q_UNUSED(modType);
|
|
INFO_LOG() << "process Lts_ServiceInformation";
|
|
|
|
DEBUG_LOG() << "Id: " << instance.id();
|
|
DEBUG_LOG() << "Name: " << instance.name();
|
|
DEBUG_LOG() << "State: " << instance.state();
|
|
DEBUG_LOG() << "Timestamp: " << instance.timestamp();
|
|
DEBUG_LOG() << "ErrorString: " << instance.errorString();
|
|
|
|
m_receivedServiceInformationData = instance;
|
|
|
|
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
|
|
|
emit serviceInformationDataArrived();
|
|
}
|
|
|
|
void DataTopicTests::processData(const ServiceManagement::GroupInformation &instance, DataModification modType)
|
|
{
|
|
Q_UNUSED(modType);
|
|
INFO_LOG() << "process Lts_ServiceInformation";
|
|
|
|
if(m_logger.isDebugEnabled())
|
|
{
|
|
QString services;
|
|
|
|
for(int serviceId : instance.services())
|
|
{
|
|
services.append(QString::number(serviceId));
|
|
services.append(QLatin1Char(','));
|
|
}
|
|
|
|
if(services.endsWith(QLatin1Char(',')))
|
|
services.chop(1);
|
|
|
|
DEBUG_LOG() << "Type: " << instance.type();
|
|
DEBUG_LOG() << "Domain: " << instance.domainId();
|
|
DEBUG_LOG() << "Partition: " << instance.exercisePartitionId();
|
|
DEBUG_LOG() << "Replay Partition: " << instance.replayPartitionId();
|
|
DEBUG_LOG() << "Services: " << services;
|
|
DEBUG_LOG() << "Timestamp: " << instance.timestamp();
|
|
}
|
|
|
|
m_receivedGroupInformationData = instance;
|
|
|
|
QCOMPARE(m_mainThreadId, QThread::currentThreadId());
|
|
|
|
emit groupInformationDataArrived();
|
|
}
|
|
|
|
/**
|
|
* Subscriber
|
|
**/
|
|
|
|
bool DataTopicTests::initSubscriber()
|
|
{
|
|
DEBUG_LOG() << "Initialisation DDS (Subscriber/Reader)";
|
|
|
|
m_domainParticipantSub =
|
|
dds::domain::DomainParticipant(m_domainId,
|
|
DDS::QosProfile::domainParticipantShm());
|
|
|
|
dds::sub::qos::SubscriberQos subscriberQos = m_domainParticipantSub.default_subscriber_qos();
|
|
|
|
// Initial Partition for listening on topic Exercise => partition 0
|
|
// + Listening for Topics in partition 1
|
|
dds::core::StringSeq partitions;
|
|
partitions.reserve(2);
|
|
for(int partitionId : { 0, 1 } )
|
|
{
|
|
partitions.push_back(IDL::exercisePartition(partitionId));
|
|
}
|
|
|
|
dds::core::policy::Partition partitionQos;
|
|
partitionQos.name( partitions );
|
|
subscriberQos << partitionQos;
|
|
|
|
DEBUG_LOG() << "Initialise DTC::SubscriberListener";
|
|
m_subscriberListener = new DDSGeneric::SubscriberListener;
|
|
|
|
m_ddsSubscriber = dds::sub::Subscriber(m_domainParticipantSub,
|
|
subscriberQos);
|
|
m_subscriberListenerBinder = rti::core::bind_and_manage_listener(m_ddsSubscriber,
|
|
m_subscriberListener,
|
|
DDSGeneric::SubscriberListener::mask());
|
|
|
|
// Initialise DTCs
|
|
m_dtcServiceInformation = new DTC::ServiceInformationImpl(m_domainParticipantSub, m_ddsSubscriber, m_subscriberListener);
|
|
m_dtcGroupInformation = new DTC::GroupInformationImpl(m_domainParticipantSub, m_ddsSubscriber, m_subscriberListener);
|
|
|
|
m_dtcServiceInformation->setSubscriberCallback([this] (const ServiceManagement::ServiceInformation &data, DataModification modType) { processData(data, modType); } );
|
|
m_dtcGroupInformation->setSubscriberCallback([this] (const ServiceManagement::GroupInformation &data, DataModification modType) { processData(data, modType); } );
|
|
|
|
return true;
|
|
}
|