Files
qt5-legatus-legacy/Lts/Services/CentralEffectSimulation/Plugins/GeoPairing/handler_geopairing.h
T
2026-08-13 18:33:10 +02:00

153 lines
5.0 KiB
C++
Executable File

/**
* Handler for player data
* $Id$
* $HeadURL$
* $Author$
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include "CentralEffectSimulation/dds_handler.h"
#include "GeoPairing/GeoPairing.hpp"
#include "logger.h"
#include <TrainingAreaBase/tab_dtc.h>
#include <MeteoDataManagement/mdm_dtc.h>
#include <CentralEffectSimulation/handler_participant.h>
#include <FW_Ballistic/BallisticService.hpp>
#include <QTimer>
#include <QtCore/QObject>
// AES-Handling for participants within buildings
namespace CesGeoPairing
{
class HandlerGeoPairing : public QObject
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
, protected TrainingAreaBase::Interface::Ftc::SendGeopairingDataReplyHandler
, protected AreaEffectSimulation::Interface::Ftc::ExplosionSingleModifyReplyHandler
, protected AreaEffectSimulation::Interface::Ftc::ExplosionAreaModifyReplyHandler
{
Q_OBJECT
public:
enum ElevationError
{
eNoElevationError = 0,
eElevationToHigh = 1,
eElevationToLow = 2,
eElevationBelowZero = 3
};
private:
struct GeoPCharge
{
int chargeId;
double minEleval;
double maxEleval;
// QMap<weaponTypeId, allowed yes/no>
QMap<int, bool> isAllowed;
ElevationError checkElevation(double elevation) const
{
if (elevation < 0)
return eElevationBelowZero;
if (elevation < minEleval)
return eElevationToLow;
if (elevation > maxEleval)
return eElevationToHigh;
return eNoElevationError;
}
// Check if Elevation and Charge is correct, return _false_ if errors accure and
// change the Error integers
bool checkArty(int weaponTypeId, double elevation, ElevationError &eleError, int &chargeError) const
{
eleError = checkElevation(elevation);
bool ret = (eleError == eNoElevationError);
if (!isAllowed.value(weaponTypeId)) //Falls wert nicht vorhanden immer Falsche Kombi
{
chargeError = 1;
ret = false;
}
else
chargeError = 0;
return ret;
}
GeoPCharge(int _chargeId, double _minEleval, double _maxEleval, const QMap<int, bool> &_isAllowed)
: chargeId(_chargeId), minEleval(_minEleval), maxEleval(_maxEleval), isAllowed(_isAllowed)
{}
GeoPCharge()
: chargeId(-1), minEleval(-1), maxEleval(-1)
{}
};
typedef QMap<int, QMap<int, GeoPCharge> > GeoPMunitonMap;
public:
explicit HandlerGeoPairing(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandlerAes,
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
const std::shared_ptr<N_Ballistic::BallisticService> &ballisticService,
QObject *parent = nullptr);
~HandlerGeoPairing();
/**
* Initialize the handler to manage information from player management
*/
bool init();
int getDamagePercentFromBuilding(const int buildingId) const;
int getDamagePercentFromRoom(const int roomId) const;
protected:
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
void onSendCesHitInformationReply(const Core::FunctionReplyObject &replyObject) override final;
void onExplosionSingleModifyReply(const Core::FunctionReplyObject &replyObject) override final;
void onExplosionAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final;
void onSendGeopairingDataReply(const Core::FunctionReplyObject &replyObject) override final;
private Q_SLOTS:
/**
* Handle MeteoData 'MDM'
*/
void onMeteoDataChanged(const MeteoDataManagement::MeteoData &data, DataModification modType);
/**
* Handle GeopairingData greom 'TAB'
*/
void onGeoPairingDataChanged(const TrainingAreaBase::GeopairingData &data, DataModification modType);
/**
* Handle MainStructureElement from 'ISM'
*/
void sendFtcCesHitRequestTimeout();
private: // attributes
double calculateDistance(const float v0, const float elevation);
double calculateFlightTime(const float rw, const float v0, const float elevation);
QPointF calculateExplosionPosUtm(const float rw, const float azimut, const QPointF &posUtm);
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandlerAes; ///< Pointer to DDS handler
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
std::shared_ptr<N_Ballistic::BallisticService> m_ballisticService; ///< Pointer Ballistic Service
QHash<int, TrainingAreaBase::SendCesHitRequest> m_requestMap; // Key = equipmentNumber
QTimer *m_timer;
MeteoDataManagement::MeteoData m_meteoData;
GeoPMunitonMap m_geoPMunMap;
GeoPairing *m_geoPairingPtr;
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
};
} // namespace CesGeoPairing