/** * @RDE_HEADER@ * HlaDispatcher for AdlerJson Plugin * $Id: hla_dispatcher.h 62304 2024-03-21 08:17:45Z ewert_j $ * $HeadURL: svn://slssvn/TDS/branches/product/features/ufom/Lts/Proxies/TrainingAreaBase/Plugins/AdlerJson/hla_dispatcher.h $ * $Author: ewert_j $ * Created by Julius Ewert, ESIM, 2024-03-20 */ #pragma once #include #include #include #include #include // tr_lts #include // #include "logger.h" #include "aes_handler.h" #include "asm_handler.h" #include "flm_handler.h" #include "pdm_handler.h" #include "ppm_handler.h" #include "saa_interface.h" #include "telegrams.h" #include "ws_interface.h" // #include #include // #include // #include class QTimer; namespace AdlerJson { using namespace TrainingAreaBase; class JsonHandlerRx; class JsonHandlerTx; class DdsHandler; // class EXStatus; struct TrajectoryIdentifier { int aesItemId; int explosionId; }; class JsonDispatcher final : public TrainingAreaBase::Plugin::Interface , protected TrainingAreaBase::Interface::Fts::AdlerCalculateTrajectoryRequestHandler , protected NotificationManagement::Interface::Ftc::CreateNotificationReplyHandler { Q_OBJECT public: JsonDispatcher(TrainingAreaBase::Plugin::DataProvider *pdp, const std::shared_ptr &recvFromTabCb, const std::shared_ptr &sendToTabCb, NGL::Settings *settings, std::shared_ptr &ddsHandler, std::shared_ptr &flmHandler, MainDispatcher *mainDispatcher); public Q_SLOTS: bool init() override; public: std::shared_ptr sendToTab() override; bool isDebugInterface() const override { return false; } bool canSendData() const override; void exerciseChanged() override { return; } const char *name() const override { return tr_lts("dds", "APHLA"); } std::shared_ptr getSAAByParty(const int partyId); std::shared_ptr getSAAByWs(const int wsId); QString getSender() { return QStringLiteral("EXCON@GUEZ.DE"); } // SendToTele bool sendExFeuerbereit(const ExFeuerbereit &exFBDataIn, const int partyId); bool sendExAbgefeuert(const ExAbgefeuert &exAFDataIn, int partyId); bool sendExMqManuelleQuittung(const ExMqManuelleQuittung &exMQDataIn, int partyId); bool sendExTqTechnischeQuittung(const ExTqTechnischeQuittung &exTQDataIn, int partyId); bool sendExVollzugsmeldung(const ExVollzugsmeldung &exVZDataIn, int partyId); void onAdlerCalculateTrajectoryRequest(const rti::core::SampleIdentity &cookie, const TrainingAreaBase::AdlerCalculateTrajectoryRequest &request) override; int getAssetId(const QString &saaName) const; // misc void cleanupSaaInterfaces(const QString &saaName, int wsId, int partyId); void getCreateNotificationRequestData(const int wsId, const QString &title, NotificationManagement::CreateNotification &data, const QString &content = {}, const QStringList &contentArgs = {}); void createNotificationRequest(const int wsId, const QString &title, const NotificationManagement::MessageType messageType, const NotificationManagement::NotificationType notificationType, const QString &content = {}, const QStringList &contentArgs = {}); public Q_SLOTS: void onSAARegistration(const int wsId, const int partyId, const QString &saaName, const QString &szenarName, bool isVerbund, const QString &uuid); void onSAADeregistration(const int wsId, const int partyId); void onSAAConnectionTest(const int wsId, const QString &uuid); void onSAAStatus(const int wsId, const EXStatus &status); void onSAAExceptionStatus(const int wsId, const TechnischeDaten &exceptionStatus); void onSAASQWS(const int wsId, const Waffensystemdaten &exSQWS); void onSAASQFS(const int wsId, const Feuerstellungsdaten &exSQFS); void onSAASQLP(const int wsId, const Ladeplatzdaten &exSQLP); void sendParticipantInfoNotification(const int wsId, const int partyId, const bool isVerbund, const Einheit &einheit); void onSAAHXGuidingLines(const int wsId, const Koordinierungsdaten &koordinierungsdaten); void onSAAHXGuidingLinesAndBoundaries(const int wsId, const Fuehrungsdaten &fuehrungsdaten); void onSSAEXFIREHALT(const int wsId, const FeuerHaltDaten &feuerhaltdaten); void onSAATrajectoryData(const int wsId, const Flugbahndaten &exFlugbahndaten, const QString referenceUuid); void onWebSocketConnected(); void onNewWebsocketConnected(const int wsId, const QString &address, qint16 port); void onWSDisconnected(const int wsId); void onWebsocketExternalConnectionStateChanged(bool bConnected); void onWebSocketError(); void onRecivedTelegram(int wsId, const QJsonObject &telegramData); void onTextMessageReceived(const QByteArray &message); void connectWebsocket(); void reallyConnectWebsocket() { connectWebsocket(); } void onKeepAliveTimerTimeout(); void onCreateNotificationReply(const Core::FunctionReplyObject &replyObject); Q_SIGNALS: void broadcastTelegramsRequest(const int equipmentNumber, const int broadcastIndex, const int resetCounter); void jsonTelegramReceived(const TrainingAreaBase::TetraIcd::TrainingAreaTelegram *tele); void websocketConnected(quint16 port); private: QUrl webSocketUrl() const; bool isConnectionTest(QJsonDocument &doc); QString getParticipantInfoLink(const QString &verein, const int partyId, const bool isVerbund); std::shared_ptr getSAAByName(const QString &saaName); private: std::shared_ptr m_recvFromTabCb; std::shared_ptr m_recvFromWebsocket; std::shared_ptr m_sendToWebsocket; // DDS MainDispatcher *m_mainDispatcher; std::shared_ptr m_flmHandler; std::shared_ptr m_ppmHandler; std::shared_ptr m_ftsTab; std::shared_ptr m_dtsTab; std::shared_ptr m_ftcNom; QVector> m_saaInterfaces; QMap m_connectionKeepaliveTimer; QHash m_trajectoryIdentifier; // key = exFlugbahnberechnung.uuid QHash m_positionsLaunch; // key = exFlugbahnberechnung.uuid NGL::Settings *m_settings; QWebSocket *m_webSocket; std::shared_ptr m_webSocketInterface; QTimer *m_webSocketReconnectTimer; bool m_bWarnedOnce; rti::core::SampleIdentity m_cookieCalculateTrajectoryAdler; int m_explosionIndex; NGL::INGLLogger &m_logger; }; } // namespace AdlerJson