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

158 lines
4.7 KiB
C++

/**
* @RDE_HEADER@
* Initialization for FileManagement
* $Id$
* $HeadURL$
* $Author$
* Created by Iuliana Ojog, SLSE, 2017-04-03
*/
#include "initialization.h"
#include "dds_handler.h"
#include <ComponentMonitor/cmo.hpp>
#include <ComponentMonitor/cmo_dts.h>
#include <ComponentMonitor/settings.h>
#include <QTimer>
namespace ComponentMonitor
{
Initialization::Initialization()
: m_logger(getLogger("Initialization"))
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
Initialization::~Initialization()
{
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
m_checkmkHandler = nullptr;
m_componentStatusHandler = nullptr;
m_ddsHandler = nullptr;
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
}
bool Initialization::initialize(const std::shared_ptr<DdsHandler> &ddsHandler)
{
INFO_LOG(m_logger) << LOGFUNCTION << " START";
// initialize database
// empty / not required at CMO
// initialize DDS
m_ddsHandler = ddsHandler;
DEBUG_LOG(m_logger) << LOGFUNCTION << "ddsHandler referenced";
//
// setup ComponentStatusHandler
//
m_componentStatusHandler = std::make_shared<ComponentStatusHandler>();
// FIRST enable DTCs
// DTCs could get samples...
m_ddsHandler->enableDtcs();
// SECOND DELAYED real start
// all dtd::XY_changed (from enabling dtcs) should not be emitted anymore
QTimer::singleShot(5000, nullptr, [this]()
{
this->delayedInit();
});
// DO NOT initialize
//
// initialize CheckMk (Nagios)
//
m_checkmkHandler = std::make_shared<CheckmkHandler>();
const QString host = Settings::checkMkHost();
const int port = Settings::checkMkPort();
const int intervalSec = Settings::checkMkIntervalSec();
//
// Nov 2021, Thore Poggenburg:
// CheckMk prueft alle 5 min.
//
if (!m_checkmkHandler->initialize(host, port, intervalSec))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " CheckmkHandler::initialize failed";
return false;
}
INFO_LOG(m_logger) << LOGFUNCTION << " CheckmkHandler:initialize succesful";
QObject::connect(m_checkmkHandler.get(), &CheckmkHandler::newState,
m_componentStatusHandler.get(), &ComponentStatusHandler::onNewState, Qt::UniqueConnection);
//
// TriggerUpdate via COMMAND 'SCHEDULE_FORCED_HOST_CHECK'
//
m_checkmkHandlerScheduleCheck = std::make_shared<CheckmkHandlerScheduleCheck>(m_ddsHandler);
if (!m_checkmkHandlerScheduleCheck->initialize(host, port))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " CheckmkHandlerScheduleCheck::initialize failed";
return false;
}
INFO_LOG(m_logger) << LOGFUNCTION << " CheckmkHandlerScheduleCheck:initialize succesful";
#ifdef LTS_DEBUG
//
// debug purpose:
//
QTimer::singleShot(20000, m_checkmkHandlerScheduleCheck.get(), [this](){
qCritical() << " trigger Update";
// REF_GUEZ_ECVMAVS01, REF_GUEZ_ECVMADB01, REF_GUEZ_ECMAPWS11
m_checkmkHandlerScheduleCheck->addScheduleCheckHostnames({QStringLiteral("REF_GUEZ_ECVMAVS01")});
m_checkmkHandlerScheduleCheck->addScheduleCheckHostnames({QStringLiteral("REF_GUEZ_ECVMADB01")});
m_checkmkHandlerScheduleCheck->addScheduleCheckHostnames({QStringLiteral("REF_GUEZ_ECMAPWS11")});
m_checkmkHandlerScheduleCheck->run(1000); // msec
});
#endif // LTS_DEBUG
INFO_LOG(m_logger) << LOGFUNCTION << " END";
return true;
}
bool Initialization::delayedInit()
{
INFO_LOG(m_logger) << LOGFUNCTION << " START";
bool success = true;
if (!m_componentStatusHandler->initialize(m_ddsHandler))
{
ERROR_LOG(m_logger) << LOGFUNCTION << " initialize failed for ComponentStatusHandler";
success = false;
}
INFO_LOG(m_logger) << LOGFUNCTION << " ComponentStatusHandler, statusMapSize=" << m_componentStatusHandler->getHostnames().size();
m_checkmkHandler->run();
// after schedules check(s), get new status list:
QObject::connect(m_checkmkHandlerScheduleCheck.get(), &CheckmkHandlerScheduleCheck::newCheckScheduled,
m_checkmkHandler.get(), &CheckmkHandler::onImmediateGetStateRequested, Qt::UniqueConnection);
// UpdateLastCheckTimeDirect :
const bool updateLastCheckTimeDirect = Settings::updateLastCheckTimeDirect();
NOTICE_LOG(m_logger) << LOGFUNCTION << " updateLastCheckTimeDirect [bool] = " << updateLastCheckTimeDirect;
if (updateLastCheckTimeDirect)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " updateLastCheckTimeDirect is enabled";
QObject::connect(m_checkmkHandlerScheduleCheck.get(), &CheckmkHandlerScheduleCheck::updateLastCheckTimeDirect,
m_componentStatusHandler.get(), &ComponentStatusHandler::onUpdateLastCheckTimeDirect, Qt::DirectConnection);
}
// UpdateLastCheckTimeDirect :
INFO_LOG(m_logger) << LOGFUNCTION << " END";
return success;
}
} // namespace ComponentMonitor