Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/InfrastructureManagement/main_handler.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- 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>
2026-08-19 06:06:24 +02:00

181 lines
6.1 KiB
C++
Executable File

/**
* @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() << "--- Start InfrastructureManagement MainHandler.";
// initialize DDS
// for InfrastructureManagement => exerciseId = partitionId
m_ddsHandler = std::make_shared<DdsHandler>(domainId);
if (!m_ddsHandler->init())
{
ERROR_LOG() << "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() << "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() << "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() << "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() << "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() << "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() << "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() << "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() << "Initialisation WebSocketInterface failed.";
pm->setNewState(Core::RunningState::StartingError);
return false;
}
INFO_LOG() << "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;