196 lines
6.0 KiB
C++
Executable File
196 lines
6.0 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* GeoPairing
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "../logger.h"
|
|
#include <CentralEffectSimulation/handler_participant.h>
|
|
#include <QtCore/QString>
|
|
#include <QtCore/QMap>
|
|
#include <FW_Ballistic/BallisticService.hpp>
|
|
#include <FW_Ballistic/AmmunitionTypes.hpp>
|
|
#include <GeoPairingImpl/GeoPairingImplAirTarget.hpp>
|
|
#include <iostream>
|
|
#include <memory>
|
|
|
|
namespace ZSSIWI
|
|
{
|
|
class AirTargetsInt;
|
|
class AutomaticCannonInt;
|
|
class GeoPairingDataInt;
|
|
class MortarHowitzerInt;
|
|
class SurfaceToAirInt;
|
|
}
|
|
|
|
class GeoPairing
|
|
{
|
|
public:
|
|
enum class ElevationError
|
|
{
|
|
NoError = 0,
|
|
ToHigh = 1,
|
|
ToLow = 2,
|
|
BelowZero = 3
|
|
};
|
|
|
|
struct FireToAircraft
|
|
{
|
|
qint64 impactTime = 0;
|
|
int participantIdTarget = 0;
|
|
int ammunitionTypeId = 0;
|
|
int equipmentNumberGunner = 0;
|
|
bool hit = false;
|
|
};
|
|
|
|
struct ReportTarget
|
|
{
|
|
QByteArray sendData;
|
|
int playerId = 0;
|
|
bool send = false;
|
|
};
|
|
|
|
struct SingleFireToCtas
|
|
{
|
|
qint64 impactTime = 0; int playerId = 0;
|
|
int duration = 0;
|
|
double impactPositionLat = 0.0;
|
|
double impactPositionLong = 0.0;
|
|
N_Ballistic::ammunitionTypeIndirectFire ammunitionType = N_Ballistic::UNKNOWN;
|
|
bool hit = false;
|
|
};
|
|
|
|
struct AreaFireToCtas
|
|
{
|
|
int playerId = 0;
|
|
qint64 impactTime = 0;
|
|
double duration = 0.0;
|
|
double impactPositionLat = 0.0;
|
|
double impactPositionLong = 0.0;
|
|
double fieldWidth = 0.0;
|
|
double fieldLength = 0.0;
|
|
double heading = 0.0;
|
|
int nbrRounds = 0;
|
|
N_Ballistic::ammunitionTypeIndirectFire ammunitionType = N_Ballistic::UNKNOWN;
|
|
N_Ballistic::ammunitionTypeOSAG ammunitionTypeOSAG = N_Ballistic::UNKNOWN_OSAG;
|
|
bool hit = false;
|
|
};
|
|
|
|
private:
|
|
struct GeoPCharge
|
|
{
|
|
int chargeId = 0;
|
|
double minEleval = -1.0;
|
|
double maxEleval = -1.0;
|
|
// QHash<weaponTypeId, allowed yes/no>
|
|
QMap<int, bool> isAllowed;
|
|
|
|
ElevationError checkElevation(double elevation) const
|
|
{
|
|
if (elevation < 0)
|
|
return ElevationError::BelowZero;
|
|
if (elevation < minEleval)
|
|
return ElevationError::ToLow;
|
|
if (elevation > maxEleval)
|
|
return ElevationError::ToHigh;
|
|
return ElevationError::NoError;
|
|
}
|
|
|
|
// 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 == ElevationError::NoError);
|
|
|
|
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() = default;
|
|
};
|
|
using GeoPMunitonMap = QMap<int, QMap<int, GeoPCharge> >;
|
|
|
|
|
|
public:
|
|
Q_DISABLE_COPY(GeoPairing)
|
|
explicit GeoPairing(const std::shared_ptr<N_Ballistic::BallisticService> &ballisticService);
|
|
|
|
bool geoPairingData(const std::shared_ptr<N_Ballistic::BallisticService> &ballisticService,
|
|
int equipmentNumber,
|
|
qint64 time,
|
|
double positionLat,
|
|
double positionLon,
|
|
const QByteArray &transparentDataAr,
|
|
const QHash<int, CentralEffectSimulation::HandlerParticipant::CesParticipantData> &aircrafts);
|
|
|
|
FireToAircraft fireToAircraft() const { return m_fireToAircraft; }
|
|
SingleFireToCtas singleFireToCtas() const { return m_singleFireToCtas; }
|
|
AreaFireToCtas areaFireToCtas() const { return m_areaFireToCtas; }
|
|
ReportTarget reportTarget() const { return m_reportTarget; }
|
|
|
|
// sets the global meteo conditions
|
|
// winddirection in degrees -+180
|
|
// windspeed in m/s
|
|
// temperature in degrees
|
|
// pressure default 1013
|
|
static void setMeteo(double winddirection, double windspeed, double temperature, double pressure);
|
|
|
|
//qint64 getImpactTime() { return m_ImpactTime;}
|
|
//double getImpactPositionLat() { return m_ImpactPositionLat;}
|
|
//double getImpactPositionLon() { return m_ImpactPositionLon;}
|
|
//int getAmmunitionType() { return m_AmmunitionType;}
|
|
//N_Ballistic::ammunitionTypeOSAG getAmmunitionTypeOSAG() { return m_AmmunitionTypeOSAG;}
|
|
//int getDeviceID() { return m_DeviceID;}
|
|
|
|
private:
|
|
//ZSSIWI::AirTargetsInt *m_airTargets;
|
|
//ZSSIWI::AutomaticCannonInt* m_automaticCannon;
|
|
//ZSSIWI::GeoPairingDataInt* m_geoPairingData;
|
|
//ZSSIWI::MortarHowitzerInt *m_mortarHowitzer;
|
|
//ZSSIWI::SurfaceToAirInt* m_surfaceToAir;
|
|
|
|
QString m_konfigPath; // Pfad fuer Konfigurationsverzeichnis
|
|
|
|
int m_equipmentNumber = -1;
|
|
qint64 m_Time = 0;
|
|
double m_PositionLat = 0;
|
|
double m_PositionLon = 0;
|
|
double m_PositionHeight = 0;
|
|
GeoPMunitonMap m_geoPMunMap;
|
|
std::shared_ptr<N_Ballistic::BallisticService> m_ballisticService; ///< Pointer Ballistic Service
|
|
|
|
//N_Ballistic::ammunitionTypeOSAG m_AmmunitionTypeOSAG;
|
|
int m_DeviceID = 0;
|
|
FireToAircraft m_fireToAircraft;
|
|
SingleFireToCtas m_singleFireToCtas;
|
|
AreaFireToCtas m_areaFireToCtas;
|
|
ReportTarget m_reportTarget;
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
void calculateAirFire(const QByteArray &transparentData,
|
|
const QHash<int, CentralEffectSimulation::HandlerParticipant::CesParticipantData> &aircrafts);
|
|
void calculateAreaFire(const QByteArray &transparentData,
|
|
const std::shared_ptr<N_Ballistic::BallisticService> &ballisticService);
|
|
void calculateSingleFire(const QByteArray &transparentData,
|
|
const std::shared_ptr<N_Ballistic::BallisticService> &ballisticService);
|
|
bool searchAirTarget(double a_elevation, double azimuth, int &playerId, uint64_t &impactTime);
|
|
void readAmmunitionIni();
|
|
};
|