/** * Handler for all oc situation data at the client * $Id$ * $HeadURL$ * $Author$ * Created by Philipp Dassow, NLST, 01-03-2018 */ #pragma once #include #include #include #include #include #include #include #include "dds_handler.h" #include "logger.h" namespace OcSituationClient { class HandlerOcSituationData : public QObject , protected ParticipantManagement::Interface::Ftc::ModifyParticipantDataReplyHandler { Q_OBJECT public: explicit HandlerOcSituationData(const std::shared_ptr &dds, const std::shared_ptr &ppmDtc, const std::shared_ptr &ppmFtc, const std::shared_ptr &tabDts, const std::shared_ptr &tabocDtc, const std::shared_ptr &tabocDts, QObject *parent); ~HandlerOcSituationData(); bool init(); void process(const QByteArray &data, bool bIsInitial); void removeAllPositions(); void setInvalidPositionForParticipant(int participantId); void onModifyParticipantDataReply(const Core::FunctionReplyObject &reply); bool withCompression() const { return m_bWithCompression; } void setWithCompression(bool bOn) { m_bWithCompression = bOn; } bool withVBGTime() const { return m_bWithVBGTime; } void setWithVBGTime(bool bOn) { m_bWithVBGTime = bOn; } private: bool decodeSituationData(const QByteArray &data); void sendParticipantData(int requestId); template void publishMap(QMap &map); void sendTrainingAreaBaseData(); bool getParticipantId(const QByteArray &buf, size_t &pos, int &participantId, OcSituation::ModificationBits &modifiedFlags) const; bool getPosition2D(const QByteArray &buf, size_t &pos, TrainingAreaBase::EquipmentPosition &position, bool bAvailable) const; bool getPosition3D(const QByteArray &buf, size_t &pos, TrainingAreaBase::EquipmentPosition &position, bool bAvailable) const; bool getVBG(const QByteArray &buf, size_t &pos, TrainingAreaBase::EquipmentState &equipmentState, TrainingAreaBase::ParticipantSanitation &sanitation, bool bAvailable) const; bool getState(const QByteArray &buf, size_t &pos, TrainingAreaBase::SpecialSensorData &specialSensorData, TrainingAreaBase::EquipmentOperationalState &equipmentOperationalState, bool bAvailable) const; bool getStructure(const QByteArray &buf, size_t &pos, ParticipantManagement::ParticipantData &participant, bool bAvailable) const; bool getDesignator(const QByteArray &buf, size_t &pos, ParticipantManagement::ParticipantData &participant, bool bAvailable) const; bool getSymbolSidc(const QByteArray &buf, size_t &pos, ParticipantManagement::ParticipantData &participant, bool bAvailable) const; void onPartyChanged(const ParticipantManagement::Party &party, DataModification mod); void onParticipantChanged(const ParticipantManagement::Participant &participant, DataModification mod); private: // for partition time std::shared_ptr m_dds; // data publishing std::shared_ptr m_ppmDtc; std::shared_ptr m_ppmFtc; std::shared_ptr m_tabDts; std::shared_ptr m_tabocDtc; std::shared_ptr m_tabocDts; // internal participant data // all paired to thier participantId QMap m_participantData; QMap m_equipmentPositions; QMap m_equipmentStates; QMap m_participantSanitations; QMap m_equipmentOperationalStates; QMap m_specialSensorData; // internal management data QHash m_participantId2EqId; QHash m_modifiyRequests; QSet m_knownParties; QHash m_participants; int m_requestId = 1; // options, must be in sync with oss bool m_bWithCompression = true; bool m_bWithVBGTime = true; LOGGER_T &m_logger; }; } // namespace OcSituationClient