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

181 lines
6.2 KiB
C++

/**
* @RDE_HEADER@
* MainHandler for InfrastructureManagement
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2016-11-26
*/
#include "main_handler.h"
#include "handler_main_structure_element.h"
#include "handler_instrumentation_asset.h"
#include "handler_mounting_point_asset.h"
#include "handler_effect_area.h"
#include "handler_main_schedule.h"
#include "handler_special_area.h"
#include "parse_building_xml.h"
#include "WebSocketInterface/websocket_interface_handler.h"
#include "settings.h"
#include <DDS/DDSConnector/dds_connector.h>
#include <DDS/Core/pacemaker.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <ngldb/db_service_handler.h>
namespace InfrastructureManagement
{
//-------------------------------------------------------------------------------------------------------------
MainHandler::MainHandler()
: m_logger(getLogger("MainHandler"))
{
} // end of ctor()
//-------------------------------------------------------------------------------------------------------------
MainHandler::~MainHandler()
{
m_handlerWebSocketInterface = nullptr;
m_handlerMainSchedule = nullptr;
m_handlerMountingPointAsset = nullptr;
m_handlerInstrumentationAsset = nullptr;
m_handlerMainStructureElement = nullptr;
m_dbHandler = nullptr;
m_ddsHandler = nullptr;
m_exmDtc = nullptr;
} // end of dtor()
//-------------------------------------------------------------------------------------------------------------
bool MainHandler::init(int domainId)
{
INFO_LOG(m_logger) << "--- Start InfrastructureManagement MainHandler.";
// initialize DDS
// for InfrastructureManagement => exerciseId = partitionId
m_ddsHandler = std::make_shared<DdsHandler>(domainId);
if (!m_ddsHandler->init())
{
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
if (m_ddsHandler->pacemaker())
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
return false;
}
auto pm = m_ddsHandler->pacemaker();
// initialize database
m_dbHandler = std::make_shared<DbHandler>();
if (!m_dbHandler->init(0, Settings::settings()))
{
ERROR_LOG(m_logger) << "Initialisation DbHandler failed.";
pm->setNewState(Core::RunningState::StoppedError);
return false;
}
pm->setNewState(Core::RunningState::Starting);
QScopedPointer<DDSConnector::CoherentSet> cs(Settings::useCoherentSet() ? new DDSConnector::CoherentSet(dds()->ddsConnector()) : nullptr);
// read project specific data from database
// publish project specific data
// initialize handler MainStructureElement
m_handlerMainStructureElement = std::make_shared<HandlerMainStructureElement>(this);
if (!m_handlerMainStructureElement->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerMainStructureElement failed.";
pm->setNewState(Core::RunningState::StoppedError);
return false;
}
// pm->setNewState(Core::RunningState::Starting);
// initialize handler Asset
m_handlerInstrumentationAsset = std::make_shared<HandlerInstrumentationAsset>(this);
if (!m_handlerInstrumentationAsset->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerInstrumentationAsset failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
// initialize handler MountingPointAsset
m_handlerMountingPointAsset = std::make_shared<HandlerMountingPointAsset>(this);
if (!m_handlerMountingPointAsset->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerMountingPointAsset failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
// pm->setNewState(Core::RunningState::Starting);
// initialize handler SoundArea
m_handlerEffectArea = std::make_shared<HandlerEffectArea>(this);
if (!m_handlerEffectArea->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerEffectArea failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
// initialize handler SpecailArea
m_handlerSpecialArea = std::make_shared<HandlerSpecialArea>(this);
if (!m_handlerSpecialArea->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerSpecialArea failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
// init MainSchedule handler
m_handlerMainSchedule = std::make_shared<HandlerMainSchedule>(this);
if (!m_handlerMainSchedule->init())
{
ERROR_LOG(m_logger) << "Initialisation HandlerMainSchedule failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
// pm->setNewState(Core::RunningState::Starting);
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector());
m_exmDtc->enableExercise();
QObject::connect(m_exmDtc.get(), &ExerciseManagement::Interface::Dtc::exerciseChanged, m_handlerMainStructureElement.get(), &HandlerMainStructureElement::onExerciseStateChanged);
// init WebSocketInterface
using namespace WebSocketInterface;
m_handlerWebSocketInterface = std::make_shared<WebSocketInterfaceHandler>(this);
if (!m_handlerWebSocketInterface->init())
{
ERROR_LOG(m_logger) << "Initialisation WebSocketInterface failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
INFO_LOG(m_logger) << "ISM MainHandler initialized.";
pm->setNewState(Core::RunningState::Running);
pm->addPort(m_handlerWebSocketInterface->webSocketPort(), Core::PortType::WebSocketServer);
return true;
} // end of init()
//-------------------------------------------------------------------------------------------------------------
std::shared_ptr<DatabaseInterface> MainHandler::db() const
{
return m_dbHandler->db();
}
//-------------------------------------------------------------------------------------------------------------
int MainHandler::exerciseId() const
{
if (dds())
return dds()->ddsConnector()->getPartitionId();
return -1;
}
//-------------------------------------------------------------------------------------------------------------
QPointF rotatePoint(const double xIn, const double yIn, double angleDegree)
{
const double angleRad = angleDegree * LtsCoordTrans::deg2rad();
const double sinAngle = sin(angleRad);
const double cosAngle = cos(angleRad);
return QPointF(xIn * cosAngle - yIn * sinAngle, xIn * sinAngle + yIn * cosAngle);
}
} // namespace InfrastructureManagement;