Files
qt-migration-legatus/qt5-before/dlbo/Lts/Proxies/GuezNasat/initialization.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

189 lines
6.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Initialization for GuezNasat
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-11-14
*/
#include "initialization.h"
#include "settings.h"
#include "dds_handler.h"
#include "handler_nasat_aircraft.h"
#include "handler_nasat_aircraft_participant.h"
#include "handler_nasat_impact.h"
#include "handler_nasat_nine_liner.h"
#include "handler_participant.h"
#include "tcp_socket_handler.h"
#include "web_socket_handler.h"
#include <GuezNasat/gna_db.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/Core/pacemaker.h>
#include <QTimer>
namespace GuezNasat
{
Initialization::Initialization()
: m_logger(getLogger("Initialization"))
{
} // end of ctor()
//-----------------------------------------------------------------------------
Initialization::~Initialization()
{
m_jsonSocketHandler = nullptr;
m_handlerNasatAircraft = nullptr;
m_handlerNasatAircraftParticipant = nullptr;
m_handlerNasatImpact = nullptr;
m_handlerNasatNineLiner = nullptr;
m_handlerParticipant = nullptr;
m_ddsHandler = nullptr;
m_dbHandler = nullptr;
} // end of dtor()
//-----------------------------------------------------------------------------
bool Initialization::initialize(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector,
const QSqlDatabase &)
{
INFO_LOG(m_logger) << "Start GuezNasat Initialization.";
// initialize DDS
m_ddsHandler = std::make_shared<DdsHandler>(ddsConnector);
if (!m_ddsHandler->init())
{
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
return false;
}
// initialize database, we need an own DB connection
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(ddsConnector->getPartitionId(), Settings::settings()))
// if (!m_dbHandler->init(ddsConnector->getPartitionId(), sqlDb))
{
ERROR_LOG(m_logger) << "Initialisation DbHandler failed.";
return false;
}
// create HandlerNasatAircraft
m_handlerNasatAircraft.reset(new HandlerNasatAircraft(this));
// create HandlerNasatAircraftParticipant
m_handlerNasatAircraftParticipant.reset(new HandlerNasatAircraftParticipant(this));
// create HandlerNasatNineLiner
m_handlerNasatNineLiner.reset(new HandlerNasatNineLiner(this));
// create HandlerNasatAircraftParticipant
m_handlerNasatImpact.reset(new HandlerNasatImpact(this));
// create ParticipantPositionPublisher
m_handlerParticipant.reset(new HandlerParticipant(this));
// Connection to NASAT
if (Settings::useWebSocket())
{
INFO_LOG(m_logger) << "Using WebSocket";
m_jsonSocketHandler.reset(new WebSocketHandler);
}
else
{
INFO_LOG(m_logger) << "Using TcpSocket";
m_jsonSocketHandler.reset(new TcpSocketHandler);
}
INFO_LOG(m_logger) << "GuezNasat Initialization initialized";
return true;
} // end of init()
//-----------------------------------------------------------------------------
bool Initialization::loadFromDatabase()
{
TRACE_LOG(m_logger) << LOGFUNCTION << "START";
if (!m_ddsHandler ||
!m_dbHandler ||
!m_handlerNasatAircraft ||
!m_handlerNasatAircraftParticipant ||
!m_handlerNasatImpact ||
!m_handlerNasatNineLiner ||
!m_handlerParticipant ||
!m_jsonSocketHandler)
return false;
if (!m_handlerNasatAircraft->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerNasatAircraft failed.";
return false;
}
if (!m_handlerNasatAircraftParticipant->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerNasatAircraftParticipant failed.";
return false;
}
if (!m_handlerNasatImpact->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerNasatImpact failed.";
return false;
}
if (!m_handlerNasatNineLiner->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerNasatNineLiner failed.";
return false;
}
if (!m_handlerParticipant->init())
{
ERROR_LOG(m_logger) << "Initialisation ParticipantPositionPublisher failed.";
return false;
}
// related to NLDEVCTRL-844: NASAT: Weiterleitung der Luftunterstützung sporadisch ausser Funktion
// Waiting for all (relevant) exercises (AES) to be started, sounds better
// But it´s complicated (some ServiceManagement topics would have to be considered)
// 'AES process is started' is not enough, but when is the FTS available???
// So accept a bailing out (in case of (re-)starting GNA while NASAT is sending data)
// and keep it simple:
#define START_DELAYED
#ifdef START_DELAYED
QTimer::singleShot(31000, m_jsonSocketHandler.get(), [this]() {
NOTICE_LOG(m_logger) << "Initialisation SocketHandler ....";
if (!m_jsonSocketHandler->init(Settings::socketListenPort()))
{
ERROR_LOG(m_logger) << "Initialisation WebSocketHandler failed.";
}
});
#else
if (!m_jsonSocketHandler->init(Settings::socketListenPort()))
{
ERROR_LOG(m_logger) << "Initialisation WebSocketHandler failed.";
return false;
}
#endif // START_DELAYED
QObject::connect(m_jsonSocketHandler.get(), &AbstractSocketHandler::simulationStatusReceived,
m_handlerNasatAircraft.get(), &HandlerNasatAircraft::simulationStatusChanged);
QObject::connect(m_handlerNasatAircraft.get(), &HandlerNasatAircraft::activateNasatAircraftSimulation,
m_jsonSocketHandler.get(), &AbstractSocketHandler::setSimulationStatus);
QObject::connect(m_handlerNasatAircraft.get(), &HandlerNasatAircraft::nasatIdChanged,
m_handlerParticipant.get(), &HandlerParticipant::onNasatIdChanged);
QObject::connect(m_jsonSocketHandler.get(), &AbstractSocketHandler::positionReceived,
m_handlerParticipant.get(), &HandlerParticipant::onNasatPosition);
QObject::connect(m_jsonSocketHandler.get(), &AbstractSocketHandler::weaponReleaseReceived,
m_handlerNasatImpact.get(), &HandlerNasatImpact::nasatWeaponRelease);
QObject::connect(m_jsonSocketHandler.get(), &AbstractSocketHandler::nineLinerReceived,
m_handlerNasatNineLiner.get(), &HandlerNasatNineLiner::nineLinerReceived);
TRACE_LOG(m_logger) << LOGFUNCTION << "END";
return true;
}
std::shared_ptr<DatabaseInterface> Initialization::db() const
{
return m_dbHandler->db();
}
} // namespace GuezNasat