130 lines
4.7 KiB
C++
Executable File
130 lines
4.7 KiB
C++
Executable File
/**
|
|
* Handler for player data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by gr, SLSE, 2017-02-20
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
//#include <CentralEffectSimulation/dds_handler.h>
|
|
#include "logger.h"
|
|
|
|
#include "targettimer.h"
|
|
#include "dds_handler.h"
|
|
#include <CentralEffectSimulation/point_helpers.h>
|
|
|
|
|
|
#include <LtsUtilsCore/outdated_position.h>
|
|
|
|
#include <QtCore/QObject>
|
|
#include <QtCore/QMap>
|
|
#include <QtCore/QHash>
|
|
#include <QtCore/QPointF>
|
|
#include <QtCore/QLineF>
|
|
#include <QtCore/QSet>
|
|
#include <QtGui/QPolygonF>
|
|
#include <TrainingAreaBase/tab_ftc.h>
|
|
|
|
// AES-Handling for participants outside buildings
|
|
namespace TargetAreas
|
|
{
|
|
|
|
class HandlerTargetAreas : public QObject
|
|
, protected TrainingAreaBase::Interface::Ftc::SendControlDataReplyHandler
|
|
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
|
|
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
|
|
struct ParticipantPosition : public ParticipantManagement::ParticipantPosition
|
|
{
|
|
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState_def::CombatReady;
|
|
Core::GeoPosition lastGeoPosition;
|
|
bool positionValid = false;
|
|
|
|
ParticipantPosition() = default;
|
|
explicit ParticipantPosition(const ParticipantManagement::ParticipantPosition &p)
|
|
: ParticipantManagement::ParticipantPosition(p)
|
|
, lastGeoPosition(p.pos())
|
|
, positionValid(true)
|
|
{}
|
|
};
|
|
|
|
struct ShootbackTarget
|
|
{
|
|
int participantId;
|
|
ParticipantManagement::TargetInformation targetInformation;
|
|
QVector<QPolygonF> shootbackAreasUtm;
|
|
|
|
};
|
|
protected:
|
|
void onSendControlDataReply(const Core::FunctionReplyObject &reply) override final;
|
|
void onSendCesHitInformationReply(const Core::FunctionReplyObject &reply) override final;
|
|
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
|
|
|
public:
|
|
explicit HandlerTargetAreas(const std::shared_ptr<DdsHandlerTargetAreas> &ddsHandler,
|
|
QObject *parent = nullptr);
|
|
|
|
~HandlerTargetAreas();
|
|
|
|
/**
|
|
* Initialize the handler to manage information from player management
|
|
*/
|
|
bool init();
|
|
|
|
QHash<int, ParticipantPosition> positions() const { return m_positionsMap; }
|
|
ParticipantPosition position(int participantId) const { return m_positionsMap.value(participantId); }
|
|
ParticipantManagement::Participant participant(int participantId) const { return m_participantData.value(participantId); }
|
|
ParticipantManagement::TypeClass typeClassFromTypeId(int typeId) const { return m_typeMap.value(typeId); }
|
|
bool isOutdated(const ParticipantPosition &pos) const
|
|
{
|
|
return LtsUtils::isPositionTimeOutdated(m_ddsHandler->currentPartitionTime(), pos.sampleTime());
|
|
}
|
|
|
|
int getParticipantId(int equipentNumber);
|
|
|
|
|
|
private slots:
|
|
/**
|
|
* Handle the signals from 'ParticipantManagement'
|
|
*/
|
|
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
|
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
|
void onTypeChanged(const ParticipantManagement::Type &data, DataModification modType);
|
|
void onTargetInformationChanged(const ParticipantManagement::TargetInformation &data, DataModification modType);
|
|
void on_preWarningIntervalFinished(int participantId, int targetParticipantId);
|
|
void on_TimeToEffectFinished(int participantId, int targetParticipantId);
|
|
|
|
private: // methoden
|
|
void checkShootbackAreaPosition(const ParticipantManagement::ParticipantPosition &data);
|
|
void printShootbackTarget(const ShootbackTarget &shootbackTarget);
|
|
void printShootbackAreas();
|
|
void printQPolygon(const QPolygonF polygon);
|
|
bool checkPosInShootbackTarget(const ShootbackTarget &shootbackTarget, const QPointF &participantPosUtm);
|
|
void sendRequestsToTab(int participantId, int targetParticipantId, int countBlink, int effectPercent);
|
|
|
|
private: // attributes
|
|
|
|
std::shared_ptr<DdsHandlerTargetAreas> m_ddsHandler; ///< Pointer to VOM DDS handler
|
|
|
|
QHash<int, ParticipantPosition> m_positionsMap; ///key = participantId < Reference map participant (player) to room id (participantId, roomId) inside Building
|
|
QHash<int, ParticipantManagement::TypeClass> m_typeMap;
|
|
QHash<int, ParticipantManagement::Participant> m_participantData; /// key = participantId
|
|
QHash<int, ShootbackTarget> m_shootbackTargets; ///key = participantId < >
|
|
QHash<int, TargetTimer *> m_targetTimers; ///key = participantId < >
|
|
|
|
|
|
int m_zone = -1;
|
|
|
|
QHash<int, TrainingAreaBase::SendControlDataRequest> m_requestMap; // Key = equipmentNumber
|
|
|
|
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
|
};
|
|
} // namespace TargetAreas
|
|
|