Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/CentralEffectSimulation/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

217 lines
7.5 KiB
C++

/**
* MainHandler for MessageDataManagement
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-09-21
*/
#include "main_handler.h"
#include "settings.h"
#include <DDS/Core/pacemaker.h>
#include <LtsPluginManager/lts_plugin_loader.h>
#include <LtsElevation/lts_elevation_manager.h>
#include <LtsCoordinate/lts_coordinate.h>
namespace CentralEffectSimulation
{
MainHandler::MainHandler(QObject *parent)
: QObject(parent)
, m_logger(CentralEffectSimulation::getLogger("MainHandler"))
{
INFO_LOG(m_logger) << "MainHandler::MainHandler";
} // end of ctor()
//-----------------------------------------------------------------------------
MainHandler::~MainHandler()
{
m_ddsHandler.reset();
m_db.reset();
m_handlerParticipant.reset();
m_handlerBuildingData.reset();
INFO_LOG(m_logger) << "MainHandler::~MainHandler";
} // end of dtor()
//-----------------------------------------------------------------------------
bool MainHandler::loadPlugin(const LtsPluginManager::PluginInstance &pi)
{
DEBUG_LOG(m_logger) << "Trying to load ces plugin '" << pi.fullFileName << "'...";
Plugin::Plugin *cesPlugin = qobject_cast<Plugin::Plugin *>(pi.plugin);
if (!cesPlugin)
{
WARNING_LOG(m_logger) << "failed loading a ces plugin - not a CentralEffectSimulation object!";
return false;
}
DEBUG_LOG(m_logger) << "... success";
std::shared_ptr<Plugin::Interface> ifc = cesPlugin->createInterface(this,
// m_ddsHandler->dds(),
nullptr,
Settings::settings(),
this);
DEBUG_LOG(m_logger) << "Vorher: m_interfaces.size=" << m_interfaces.size();
if (!ifc || !ifc->init(m_domainId, m_exerciseId))
{
WARNING_LOG(m_logger) << "Could not initialize CentralEffectSimulation plugin";
return false;
}
static int counter = 0;
INFO_LOG(m_logger) << "Loading and init of ces_plugin successfull: "
<< ++counter
<< " pluginName = '" << pi.pluginName << "'"
<< ", filename '" << pi.fullFileName << "'";
m_interfaces.push_back(ifc);
DEBUG_LOG(m_logger) << "Nachher: m_interfaces.size=" << m_interfaces.size();
DEBUG_LOG(m_logger) << "ECHO!" << ifc->echo(QStringLiteral("TEST"));
return true;
}
bool MainHandler::init(int domainId, int exerciseId)
{
m_domainId = domainId;
m_exerciseId = exerciseId;
INFO_LOG(m_logger) << "Start MessageDataManagement MainHandler. domainId =" << domainId
<< " exerciseId=" << exerciseId;
// initialize database
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(exerciseId, Settings::settings()))
{
ERROR_LOG(m_logger) << "Initialisation DbHandler failed.";
return false;
}
m_db = m_dbHandler->db();
INFO_LOG(m_logger) << "MainHandler::init DbHandler initialized. ";
// initialize DDS
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
if (!m_ddsHandler->init())
{
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
if (m_ddsHandler->pacemaker())
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
return false;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " LtsElevationManager... ";
LtsElevation::LTS_ELEVATION_MANAGER_TYPE ltsElevationManager = LtsElevation::LtsElevationManager::createInstance(exerciseId,
dds()->exmDtc(),
dds()->asmDtc());
if (ltsElevationManager)
{
// waitForInitialization,
// ElevationFile is read in a workerThread and waitForInitialization is used via QFutureWatcher
// So the logMsg 'Finished reading elevation map of file' will be shown with a delay.
// This is no error.
ltsElevationManager->waitForInitialization();
DEBUG_LOG(m_logger) << LOGFUNCTION << " LtsElevationManager... waitForInitialization DONE";
// using elevationCbFunc = std::function<double(double, double, double, bool*)>;
using namespace std::placeholders;
LtsCoordTrans::LtsCoordinate::elevationCbFunc elevationCB = std::bind(&LtsElevation::LtsElevationManager::elevation,
ltsElevationManager.data(), _1, _2, _3, _4);
LtsCoordTrans::LtsCoordinate::setElevationCallback(elevationCB);
NOTICE_LOG(m_logger) << LOGFUNCTION << " LtsElevationManager... LtsCoordinate::setElevationCallback DONE";
}
DEBUG_LOG(m_logger) << LOGFUNCTION << " LtsElevationManager... DONE ";
// initialize handlerBuildingData do this before init AesDataHandler
m_handlerBuildingData = std::make_shared<HandlerBuildingData>(m_ddsHandler, this);
if (!m_handlerBuildingData->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerBuildingData failed.";
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
return false;
}
// initialize handlerParticipant
//m_handlerParticipant = std::make_shared<HandlerParticipant>(m_ddsHandler,
// this);
int cheatingDistanceVehicle = Settings::cesCheatingDistanceVehicle();
int cheatingDistanceSoldier = Settings::cesCheatingDistanceSoldier();
m_handlerParticipant = std::make_shared<HandlerParticipant>(m_ddsHandler,
m_handlerBuildingData,
cheatingDistanceVehicle,
cheatingDistanceSoldier,
this);
if (!m_handlerParticipant->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerParticipant failed.";
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
return false;
}
///////////////
/// Plugins ///
///////////////
// ProxyBuilding:
// some plugins need access to other plugins (siblings)
// If a plugin would like to offer a function, the ProxyXY could be used;
m_proxyBuilding = std::make_shared<ProxyBuilding>();
auto cb = [&](const LtsPluginManager::PluginInstance &pi) { return loadPlugin(pi); };
LtsPluginManager::LtsPluginLoader::getInstance()->loadPlugins(LtsPluginManager::PluginType::SPECIAL,
cb,
QStringList(),
QStringLiteral("ces"));
if (m_interfaces.empty())
{
WARNING_LOG(m_logger) << "Could not load any Central Effect Simulation plugin";
return false;
}
INFO_LOG(m_logger) << "m_interfaces size=" << m_interfaces.size();
// for (/*std::shared_ptr<*/Plugin::EchoInterface/*> &*/ *ifc : m_interfaces)
// INFO_LOG(m_logger) << "ECHO! " << ifc->echo(QStringLiteral("TEST"));
//m_txHandler->addTxHandler(ifc->sendToTab());
///////////////////
/// End Plugins ///
///////////////////
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
return true;
} // end of init()
//-----------------------------------------------------------------------------
} // namespace