Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ReplyMessage class is an abstract base class for all possible messages which are sent to the client
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, SLSE, 2017-09-07
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
#include <QtCore/QString>
|
||||
|
||||
namespace CombatNetRadio
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
class ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct LonLatPoint
|
||||
{
|
||||
double lon = 0.;
|
||||
double lat = 0.;
|
||||
|
||||
LonLatPoint() = default;
|
||||
LonLatPoint(double _lon, double _lat)
|
||||
: lon(_lon)
|
||||
, lat(_lat)
|
||||
{}
|
||||
|
||||
QJsonObject toJSon() const;
|
||||
};
|
||||
|
||||
struct XYPoint
|
||||
{
|
||||
double x = 0.;
|
||||
double y = 0.;
|
||||
|
||||
QJsonObject toJSon() const;
|
||||
};
|
||||
|
||||
ReplyMessage() = default; //!< QVector requires this; don't use directly
|
||||
|
||||
virtual ~ReplyMessage() = default;
|
||||
|
||||
virtual QString toJsonString() const;
|
||||
QString uuid() const;
|
||||
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
static QJsonArray vecToPath(const QVector<T> &points)
|
||||
{
|
||||
QJsonArray result;
|
||||
for (const T &p : points)
|
||||
result.append(p.toJSon());
|
||||
return result;
|
||||
}
|
||||
|
||||
protected: // methods
|
||||
explicit ReplyMessage(const QString &type, const QString &uuid);
|
||||
|
||||
protected: // attributes
|
||||
QJsonObject m_jsonRepresentation;
|
||||
|
||||
}; // class Reply Message
|
||||
|
||||
class ErrorMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct ErrorData
|
||||
{
|
||||
int errorClass = 0;
|
||||
QString uuid;
|
||||
QString errorMessage;
|
||||
|
||||
ErrorData() = default;
|
||||
explicit ErrorData(int errorClass_, const QString &uuid_, const QString &errorMessage_)
|
||||
: errorClass(errorClass_)
|
||||
, uuid(uuid_)
|
||||
, errorMessage(errorMessage_)
|
||||
{}
|
||||
};
|
||||
|
||||
explicit ErrorMessage(const ErrorData &data);
|
||||
explicit ErrorMessage(int errorClass, const QString &uuid, const QString &errorMessage)
|
||||
: ErrorMessage(ErrorData(errorClass, uuid, errorMessage))
|
||||
{}
|
||||
}; // class ErrorMessage
|
||||
|
||||
|
||||
class OkMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct OkData
|
||||
{
|
||||
QString uuid;
|
||||
QString messageType;
|
||||
QString info;
|
||||
};
|
||||
|
||||
explicit OkMessage(const OkData &data);
|
||||
}; // class OkMessage
|
||||
|
||||
class TrainingAreaMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct TrainingAreaData
|
||||
{
|
||||
int32_t id;
|
||||
QString designation;
|
||||
LonLatPoint refPoint;
|
||||
QVector<LonLatPoint> path;
|
||||
};
|
||||
|
||||
explicit TrainingAreaMessage(const TrainingAreaData &data, const QString &uuid);
|
||||
}; // class TrainingAreaMessage
|
||||
|
||||
class RadioStationMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
|
||||
struct RadioStationData
|
||||
{
|
||||
int32_t id;
|
||||
QString designation;
|
||||
LonLatPoint geoPoint;
|
||||
int32_t trainingAreaId;
|
||||
};
|
||||
|
||||
explicit RadioStationMessage(const RadioStationData &data, const QString &uuid);
|
||||
}; // RadioStationMessage
|
||||
|
||||
class ConfigCnrMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct SubRadioCircuit
|
||||
{
|
||||
QString rcSubId;
|
||||
QString rcSubName;
|
||||
int32_t frequencyBand = 0;
|
||||
int32_t rcMode = 0;
|
||||
int32_t station = 0;
|
||||
int32_t ptSig = 0;
|
||||
int32_t rcType;
|
||||
int32_t crossbeam;
|
||||
int32_t orientation;
|
||||
int32_t frequency = 0;
|
||||
int32_t akw = 0;
|
||||
int32_t fsb = 0;
|
||||
int32_t rcAkw = 0;
|
||||
int32_t comsec = 0;
|
||||
int32_t modulationType;
|
||||
int32_t channelSpacing;
|
||||
int32_t squelch = 0;
|
||||
bool clipper;
|
||||
bool agc;
|
||||
|
||||
QJsonObject toJSon() const;
|
||||
};
|
||||
|
||||
struct RadioCircuit
|
||||
{
|
||||
QString rcId;
|
||||
int32_t ssrc = 0;
|
||||
QString rcName;
|
||||
bool isRoaming;
|
||||
|
||||
QVector<SubRadioCircuit> subCircuits;
|
||||
QJsonObject toJSon() const;
|
||||
};
|
||||
|
||||
struct ConfigCnrData
|
||||
{
|
||||
int32_t setId = 0;
|
||||
QString time;
|
||||
QVector<RadioCircuit> radioCircuit;
|
||||
};
|
||||
|
||||
explicit ConfigCnrMessage(const ConfigCnrData &data, const QString &uuid);
|
||||
}; // ConfigCnrMessage
|
||||
|
||||
class PositionsCnrMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
struct RadioCircuit
|
||||
{
|
||||
QString rcId;
|
||||
QVector<LonLatPoint> positions;
|
||||
|
||||
QJsonObject toJSon() const;
|
||||
};
|
||||
|
||||
struct PositionsCnrMessageData
|
||||
{
|
||||
QString time;
|
||||
QVector<RadioCircuit> radioCircuit;
|
||||
};
|
||||
|
||||
explicit PositionsCnrMessage(const PositionsCnrMessageData &data, const QString &uuid);
|
||||
}; // PositionsCnrMessage
|
||||
|
||||
class UpdateMessage final
|
||||
: public ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit UpdateMessage(const QString &info = QString());
|
||||
}; // UpdateMessage
|
||||
|
||||
class PongMessage final : public ReplyMessage
|
||||
{
|
||||
public:
|
||||
static QString strPong() { return QStringLiteral("pong"); }
|
||||
explicit PongMessage(const QString &payload)
|
||||
: ReplyMessage(strPong(), QString())
|
||||
, m_payload(payload)
|
||||
{}
|
||||
|
||||
QString toJsonString() const override
|
||||
{
|
||||
return m_payload.isEmpty() ? strPong() : QStringLiteral("%1 %2").arg(strPong(), m_payload);
|
||||
}
|
||||
private:
|
||||
QString m_payload;
|
||||
};
|
||||
|
||||
class AliveResponse final : public ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit AliveResponse(const QString &uuid);
|
||||
};
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace CombatNetRadio
|
||||
|
||||
Reference in new issue
Block a user