/** * Handler for player data * $Id$ * $HeadURL$ * $Author$ * Created by gr, SLSE, 2017-02-20 */ #pragma once #include "supplytimer.h" #include #include #include #include #include #include #include #include #include #include // AES-Handling for participants namespace CES_FUNCTIONAL_AREA { enum class EffectType { Unknown = 0, EffectiveMineRangeEnter = 0xf0000 | 1, // AtMineAreaSingleMines = 15 = 0xf EffectiveMineRangeLeave = 0xf0000 | 2, // AtMineAreaSingleMines = 15 = 0xf NContaminationLeave = 0x10000 | 0, // AtNContamination = 1 NContaminationEnterArea1 = 0x10000 | 1, NContaminationEnterArea2 = 0x10000 | 2, NContaminationDetonation = 0x10000 | 255, FunctionalAreaLeave = 0xc0000 | 0, // AtReconArea = 12 = 0xc FunctionalAreaEnter = 0xc0000 | 1, ExplosionArea = 0x30000 | 2, // AtExplosionArea = 3 ExplosionSingle = 0x40000 | 3, // AtExplosionSingle = 4 BCContaminationLeave = 0x20000 | 0, // AtBCContamination = 2 BCContaminationEnterFloating = 0x20000 | 1, BCContaminationEnterResident = 0x20000 | 2, BCContaminationEnterFloatingArea = 0x20000 | 3, BeStillWarning = 11, }; QString toString(EffectType et); struct ParticipantDistance { double squareDistance = 0; CentralEffectSimulation::HandlerParticipant::CesParticipantData participantPosition; }; struct EnterLeaveType { ProjectDataManagement::EventType eventType = ProjectDataManagement::EventType_def::Unknown; bool isAlreadySupplied = false; }; class HandlerFunctionalAreas : public QObject , protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler , protected TrainingAreaBase::Interface::Ftc::DemandInitReplyHandler { Q_OBJECT public: explicit HandlerFunctionalAreas(const std::shared_ptr &ddsHandler, const std::shared_ptr &participantHandler, const std::shared_ptr &handlerBuildingData, QObject *parent = nullptr); ~HandlerFunctionalAreas(); /** * Initialize the handler to manage information from player management */ bool init(); protected: void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final; void onDemandInitReply(const Core::FunctionReplyObject &replyObject) override final; private Q_SLOTS: /** * Handle the signals from 'AES' */ void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType); private: // methoden void calculateFunctionalArea(const CentralEffectSimulation::AesItemViewUtm &itemView); void calculateDangerArea(const CentralEffectSimulation::AesItemViewUtm &itemView); void deleteDangerArea(const int aesItemId); void onNewParticipantPosition(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData); void onNewIndoorParticipantPosition(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData); void onRestoreRadioReadinessChanged(const int participantId); bool inCircle(const QPointF ¢erUtm, const double radius, const QPointF &pointUtm); bool inBoundingBoxCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData); bool inFormCheck(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData); void sendCesHitRequest(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData, ProjectDataManagement::EventType eventType); void sendParticipantEvent(const CentralEffectSimulation::AesItemViewUtm &itemView, const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData, const ProjectDataManagement::EventType eventType); ProjectDataManagement::EventType leaveEventTypeForAesType(AreaEffectSimulation::AesType aesTypeId); EffectType leaveEffectTypeForAesType(AreaEffectSimulation::AesType aesTypeId); EffectType effectTypeForNContaminationArea(const CentralEffectSimulation::AesItemViewUtm &itemView, const QPointF &participantPosUtmPoint, qint64 partPosSampleTime); EffectType effectTypeForBCContaminationArea(const CentralEffectSimulation::AesItemViewUtm &itemView, const QPointF &participantPosUtmPoint); void aesItemViewRemoved(int aesItemId); void removeParticipant(int participantId); void sendEnterLeave(const CentralEffectSimulation::AesItemViewUtm &itemView, int participantId, bool inForm); void startSupplyTimer(int participantId, int aesId, long time); void stopSupplyTimer(int participantId); void on_supplyFinished(int participantId, int aesId); void sendInitSupplyToTab(int participantId, int aesId); private: // attributes std::shared_ptr m_ddsHandler; ///< Pointer to VOM DDS handler std::shared_ptr m_handlerParticipant; std::shared_ptr m_handlerBuildingData; QHash m_aesItemId2partIdMap; // AES-Values QHash m_aesItemViews; // key = aesItemId QQueue m_sendCesHitRequestQueue; QQueue m_sendInitRequestQueue; QHash, EnterLeaveType> m_cesEnterLeaveFunctionalArea; // QPair < aesItemId, participantId> Last Event QHash m_supplyTimers; // participantId QHash> m_aesPolygonEncloseBuilding; // key = aesItemId value = BuildingIds inside form int m_requestId = 1; NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility }; } // namespace CES_FUNCTIONAL_AREA