Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/SoundManagement/handler_sounds.h
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

137 lines
4.9 KiB
C++
Executable File

/**
* 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
};
} // namespace SoundManagement