Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/RoutingServiceNG/main_handler.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

105 lines
3.2 KiB
C++

/**
* @RDE_HEADER@
* Routing Test - main object
* $Id$
* $HeadURL$
* $Author$
*/
#include "main_handler.h"
#include <LtsPluginManager/lts_plugin_loader.h>
#include <DDS/Generic/topic_type_plugin.h>
#include <DDS/QosProfile/DDS_DefaultQos.h>
#include <ExerciseManagement/exm_dtc.h>
#include <rti/config/Logger.hpp>
#include <nglapplication/nglloggerhandler.h>
#include <Core/core_dts_types.h>
#include <DDS/Core/pacemaker.h>
#include <DDS/DTS/generic_dts_impl.h>
namespace RoutingService
{
MainHandler::MainHandler()
: m_logger(getLogger("MainHandler"))
{
}
MainHandler::~MainHandler()
{
m_pacemaker = nullptr;
shutdown();
}
bool MainHandler::init(int domainIdIn, int domainIdOut, unsigned short tcpPortOut)
{
shutdown();
if (!DDS::QosProfile::setDefault())
{
ERROR_LOG(m_logger) << "Error setting default QoS from xml-file ";
return false;
}
NGL::LoggerHandler *lh = NGL::LoggerHandler::getLoggerHandler();
if (lh)
{
const QByteArray postfix = lh->loggerNamePostfix().toLocal8Bit() + "_dds_";
const QByteArray prefix = lh->loggerNamePrefix().toLocal8Bit();
rti::config::Logger &ddsLogger = rti::config::Logger::instance();
//ddsLogger.output_file(fdopen(STDOUT_FILENO, "w"));
ddsLogger.output_file_set(postfix.data(), prefix.data(), 10 * 1024 * 1024, 10);
ddsLogger.verbosity(rti::config::Verbosity_def::WARNING);
//ddsLogger.verbosity_by_category(rti::config::LogCategory_def::COMMUNICATION, rti::config::Verbosity_def::STATUS_ALL);
}
std::shared_ptr<DDSConnector::DdsConnector> ddsConnectorIn(
new DDSConnector::DdsConnector(domainIdIn, IDL::PartitionType::Global));
ddsConnectorIn->initDomainParticipant();
ddsConnectorIn->initPublisherSubscriber(); // for ExerciseManagement::Exercise, Core::SituationReplay, Heartbeat
QUrl tcpDiscoveryUrl;
tcpDiscoveryUrl.setPort(tcpPortOut);
std::shared_ptr<DDSConnector::DdsConnector> ddsConnectorOut(
new DDSConnector::DdsConnector(domainIdOut, IDL::PartitionType::Global, 0, tcpDiscoveryUrl));
ddsConnectorOut->initDomainParticipant();
m_sessionHandler.reset(new SessionHandler(IDL::PartitionType::Exercise, ddsConnectorIn, ddsConnectorOut));
m_pacemaker = std::make_shared<Core::Pacemaker>(ddsConnectorIn);
m_pacemaker->setNewState(Core::RunningState::Starting);
m_partitionHandler.reset(new PartitionHandler(ddsConnectorIn));
connect(m_partitionHandler.get(), &PartitionHandler::createSession,
m_sessionHandler.get(), &SessionHandler::onCreateSession);
connect(m_partitionHandler.get(), &PartitionHandler::destroySession,
m_sessionHandler.get(), &SessionHandler::onDestroySession);
if (!m_partitionHandler->init() ||
!m_sessionHandler->init())
{
m_pacemaker->setNewState(Core::RunningState::StartingError);
return false;
}
const QString ex_0(QString::fromStdString(DDSConnector::DdsConnector::getPartitionString(IDL::PartitionType::Global)));
m_sessionHandler->onCreateSession(ex_0, ex_0);
m_pacemaker->setNewState(Core::RunningState::Running);
return true;
}
void MainHandler::shutdown()
{
if (m_sessionHandler)
m_sessionHandler->shutdown();
m_sessionHandler = nullptr;
m_partitionHandler = nullptr;
}
} // namespace RoutingService