Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/SoundManagement/handler_sounds.h
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

138 lines
4.9 KiB
C++

/**
* Handler for table-io message data request
* $Id$
* $HeadURL$
* $Author$
* Created by hjl, SLSE, 2016-10-12
*/
#pragma once
#include <QObject>
#include "dds_handler.h"
#include "logger.h"
#include <som_db.h>
#include <ngldb/db_service_handler.h>
#include "main_handler.h"
#include <SoundManagement/som_fts.h>
#include <SoundManagement/som_dts.h>
#include <InfrastructureManagement/ism_dtc.h>
#include <LtsCoordTrans/lts_coord_trans.h>
// HTTP Request
#include <QNetworkAccessManager>
#include <QTimer>
#include <QEventLoop>
namespace SoundManagement
{
template <typename Func1>
void await(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal)
{
QEventLoop x;
QObject::connect(sender, signal, &x, &QEventLoop::quit);
x.exec();
}
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
inline QPointF geographic2Utm(const Core::GeoPosition2D &geoPos, int *zone = nullptr)
{
const int zoneToUse = zone ? *zone : -1;
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat(), zoneToUse);
if (zone)
*zone = utm.zone;
return {utm.x, utm.y};
}
class HandlerSounds final
: public QObject
, protected Interface::Fts::GetActiveSoundsRequestHandler
, protected Interface::Fts::StopAllSoundsRequestHandler
, protected Interface::Fts::GetSoundsRequestHandler
, protected Interface::Fts::ControlSoundRequestHandler
{
Q_OBJECT
public:
explicit HandlerSounds(const std::shared_ptr<DdsHandler> &ddsHandler,
const std::shared_ptr<DbHandler> &dbHandler,
QObject *parent = nullptr);
~HandlerSounds() = default;
bool init();
private Q_SLOTS:
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType);
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType);
void onSoundStateChanged(const SoundManagement::SoundState &data, DataModification modType);
void httpFinished();
void onStopSingleSound(const int egcuId, const SoundManagement::SoundCategory soundCategory, const int soundId);
private: // methods
QString httpFinishedBlocking(QNetworkReply *reply);
void onGetActiveSoundsRequest(const rti::core::SampleIdentity &cookie,
const GetActiveSoundsRequest &request) override;
void onStopAllSoundsRequest(const rti::core::SampleIdentity &cookie,
const StopAllSoundsRequest &request) override;
void onGetSoundsRequest(const rti::core::SampleIdentity &cookie,
const GetSoundsRequest &request) override;
void onControlSoundRequest(const rti::core::SampleIdentity &cookie,
const ControlSoundRequest &request) override;
void onTimerTimeout();
QString stopAllSounds(const int egcuId); // BLOCKING!
void getActiveSounds();
void getActiveSound(const int egcuId);
QString playBackgroundSound(const QString &user,
const QString &passwd,
const QString &host,
const QString &category,
const int sound,
const int volume,
const int control);
void startRequest(const QUrl &requestedUrl);
QString startRequestBlocking(const QUrl &requestedUrl);
QString enumToString(const SoundManagement::SoundCategory &category);
SoundManagement::SoundCategory stringToEnum(const QString &category);
void handleSoundReport(const QString &json, const QString &host);
int getAssetId(const QString &hostName);
int getDuration(const SoundCategory &category, const int soundId);
int getSoundIndex(const SoundCategory &category, const QString &name);
private: // attributes
struct SoundStr
{
int index = 0;
int soundId = 0;
SoundManagement::SoundCategory category = SoundManagement::SoundCategory::Unknown;
QString name = QString();
QString displayName = QString();
int duration = 0;
bool isRepeatable = false;
};
std::shared_ptr<DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
std::shared_ptr<DbHandler> m_dbHandler; ///< Pointer to DB handler
QHash<int, QString> m_hostnames; // key = assetId, value = hostname
QHash<QString, QString> m_activeSounds; // key = hostname
QNetworkAccessManager m_qnam;
QTimer *m_updateActiveSoundsTimer{new QTimer(this)};
bool m_httpRequestAborted{false};
QVector<SoundStr> m_soundNames{QVector<SoundStr>()};
int m_indexActiveSound{0};
QVector<SoundState> m_soundStates{QVector<SoundManagement::SoundState>()};
int m_topicId{0};
QHash <int, int> m_mountingPointAsset; // Key= structureElementId, value= assetId
NGL::INGLLogger &m_logger;
};
} // namespace SoundManagement