Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+282
@@ -0,0 +1,282 @@
|
||||
/**
|
||||
* Telegrams between NASAT and GUEZ
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, NLE, 2019-09-18
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
|
||||
class JsonException final : public std::exception
|
||||
{
|
||||
public:
|
||||
JsonException(const QJsonObject &obj, const QString &key);
|
||||
const char *what() const noexcept override { return m_what.data(); }
|
||||
private:
|
||||
QJsonObject m_obj;
|
||||
QString m_key;
|
||||
QByteArray m_what;
|
||||
};
|
||||
template <typename T>
|
||||
struct Constraints;
|
||||
|
||||
|
||||
//
|
||||
// Enumerations
|
||||
//
|
||||
enum class FinalAttackHeadingMode
|
||||
{
|
||||
None = 0,
|
||||
HeadingOnly = 1,
|
||||
HeadingWithSector = 2,
|
||||
};
|
||||
|
||||
enum class FuseType
|
||||
{
|
||||
Undefined = 0,
|
||||
Instant = 1,
|
||||
Delay = 2,
|
||||
AirBurst = 3,
|
||||
};
|
||||
|
||||
enum class Heading2InitialPointMode
|
||||
{
|
||||
Undefined = 0,
|
||||
UseHdgIP2Target_1 = 1,
|
||||
UseHdgIP2Target_2 = 2,
|
||||
KeyholeA = 11,
|
||||
KeyholeB = 12,
|
||||
KeyholeC = 13,
|
||||
KeyholeD = 14,
|
||||
};
|
||||
|
||||
enum class Munition
|
||||
{
|
||||
Undefined = 0,
|
||||
Gun = 1,
|
||||
Missile_AGM114 = 2,
|
||||
Missile_AGM65 = 3,
|
||||
Missile_MK151 = 4,
|
||||
Missile_MK24 = 5,
|
||||
Bomb_MK82LD = 6,
|
||||
Bomb_MK83LD = 7,
|
||||
Bomb_MK84LD = 8,
|
||||
Bomb_MK82HD = 9,
|
||||
Bomb_MK83HD = 10,
|
||||
Bomb_MK84HD = 11,
|
||||
PGM_500lb = 12,
|
||||
PGM_1000lb = 13,
|
||||
PGM_2000lb = 14,
|
||||
Bomb_MK82_Unguided = 15,
|
||||
Bomb_MK83_Unguided = 16,
|
||||
Bomb_MK84_Unguided = 17,
|
||||
|
||||
PGM_GBU12 = 18,
|
||||
PGM_GBU24 = 19,
|
||||
PGM_GBU31 = 20,
|
||||
PGM_GBU32 = 21,
|
||||
PGM_GBU35 = 22,
|
||||
PGM_GBU38 = 23,
|
||||
PGM_GBU49 = 24,
|
||||
PGM_GBU54 = 25,
|
||||
PGM_BLU109 = 26,
|
||||
|
||||
MSL_AGM_114K = 27,
|
||||
MSL_AGM_114M = 28,
|
||||
MSL_AGM_114N = 29,
|
||||
MSL_AGM_114FA = 30,
|
||||
MSL_AGM_65 = 31,
|
||||
|
||||
GUN_FW20 = 32,
|
||||
GUN_FW25 = 33,
|
||||
GUN_20mm = 34,
|
||||
|
||||
Missile_MK_151 = 35, // impact radius 125
|
||||
Missile_MK229 = 36,
|
||||
Missile_MK261 = 37,
|
||||
Missile_MK151LowALT = 38,
|
||||
Missile_MK229LowALT = 39,
|
||||
Missile_MK261LowALT = 40,
|
||||
Missile_MK_24 = 41 // impact radius 125
|
||||
|
||||
};
|
||||
|
||||
enum class ReleaseMode
|
||||
{
|
||||
Undefined = 0,
|
||||
Manual = 1,
|
||||
Automatic = 2,
|
||||
};
|
||||
|
||||
enum class TimeForTargetMode
|
||||
{
|
||||
None = 0,
|
||||
TimeToTarget = 1,
|
||||
TimeOverTarget = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Structs
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
struct GeoPosition2D
|
||||
{
|
||||
double lat = 0; // in degree, WGS-84
|
||||
double lon = 0; // in degree, WGS-84
|
||||
|
||||
static GeoPosition2D fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct GeoPosition3D final : public GeoPosition2D
|
||||
{
|
||||
double height = 0; // above MSL
|
||||
|
||||
static GeoPosition3D fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatBase
|
||||
{
|
||||
int aircraftId = 0;
|
||||
double timestamp = 0; // in sec since 01.01.1970
|
||||
|
||||
virtual ~NasatBase() = default;
|
||||
virtual QJsonObject toJson() const = 0;
|
||||
virtual QString type() const = 0;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
template <typename T>
|
||||
struct NasatBaseTmpl : NasatBase
|
||||
{
|
||||
QString type() const override final { return Constraints<T>::type(); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatSimulationRequest final : public NasatBaseTmpl<NasatSimulationRequest>
|
||||
{
|
||||
GeoPosition2D position;
|
||||
bool enableSimulation = false;
|
||||
|
||||
// conversion functions
|
||||
static NasatSimulationRequest fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
template <> struct Constraints<NasatSimulationRequest>
|
||||
{
|
||||
static QString type() { return QStringLiteral("NasatSimulationRequest"); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatSimulationStatus final : public NasatBaseTmpl<NasatSimulationStatus>
|
||||
{
|
||||
bool simulationEnabled = false;
|
||||
|
||||
// conversion functions
|
||||
static NasatSimulationStatus fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
template <> struct Constraints<NasatSimulationStatus>
|
||||
{
|
||||
static QString type() { return QStringLiteral("NasatSimulationStatus"); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatPosition final : public NasatBaseTmpl<NasatPosition>
|
||||
{
|
||||
GeoPosition3D position;
|
||||
|
||||
// conversion functions
|
||||
static NasatPosition fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
template <> struct Constraints<NasatPosition>
|
||||
{
|
||||
static QString type() { return QStringLiteral("NasatPosition"); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatWeaponRelease final : public NasatBaseTmpl<NasatWeaponRelease>
|
||||
{
|
||||
GeoPosition2D impactPosition;
|
||||
double flightTime = 0;
|
||||
Munition munition = Munition::Undefined;
|
||||
FuseType fuseType = FuseType::Undefined;
|
||||
ReleaseMode releaseMode = ReleaseMode::Undefined;
|
||||
|
||||
// conversion functions
|
||||
static NasatWeaponRelease fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
template <> struct Constraints<NasatWeaponRelease>
|
||||
{
|
||||
static QString type() { return QStringLiteral("NasatWeaponRelease"); }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
struct NasatNineLiner final : public NasatBaseTmpl<NasatNineLiner>
|
||||
{
|
||||
struct Friendlies
|
||||
{
|
||||
int bearing = 0; // [degree], 0 <= bearing <= 360
|
||||
double distance = 0; // [m]
|
||||
|
||||
// conversion functions
|
||||
static Friendlies fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const;
|
||||
};
|
||||
struct FinalAttackHeading
|
||||
{
|
||||
int heading = 0; // [degree], 0 <= bearing <= 360
|
||||
int headingLow = 0; // sector right, delta to heading
|
||||
int headingHigh = 0; // sector left, delta to heading
|
||||
|
||||
// conversion functions
|
||||
static FinalAttackHeading fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const;
|
||||
};
|
||||
|
||||
|
||||
GeoPosition2D initialPoint;
|
||||
int initialPointMode = 0; // 0 if not defined in 9Liner
|
||||
|
||||
int headingInitialPoint2Target = 0; // [degree], 0 <= headingInitialPoint2Target <= 360
|
||||
Heading2InitialPointMode heading2InitialPointMode = Heading2InitialPointMode::Undefined;
|
||||
double distanceInitialPoint2Target = 0; // [m]
|
||||
int distance2InitialPointMode = 0; // 0 if not defined in 9Liner
|
||||
|
||||
GeoPosition2D targetPosition;
|
||||
int targetPositionMode = 0; // 0 if not defined in 9Liner
|
||||
double altitudeTarget = 0; // [m], above MSL
|
||||
int altitudeTargetMode = 0; // 0 if not defined in 9Liner
|
||||
|
||||
Friendlies friendlies;
|
||||
int modeFriendlies = 0; // 0 if not defined in 9Liner
|
||||
FinalAttackHeading finalAttackHeading;
|
||||
FinalAttackHeadingMode finalAttackHeadingMode = FinalAttackHeadingMode::None;
|
||||
|
||||
int timeForTarget = 0; // relative [s] (TimeToTarget) / absolute since midnight (TimeOverTarget)
|
||||
TimeForTargetMode timeForTargetMode = TimeForTargetMode::None;
|
||||
|
||||
// conversion functions
|
||||
static NasatNineLiner fromJson(const QJsonObject &obj);
|
||||
QJsonObject toJson() const override;
|
||||
};
|
||||
template <> struct Constraints<NasatNineLiner>
|
||||
{
|
||||
static QString type() { return QStringLiteral("NasatNineLiner"); }
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user