Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,398 @@
|
||||
/**
|
||||
* Websocket interface for building control unit - telgram definition
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-01-30
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <BuildingControlUnit/buildingcontrolcommon_export.h>
|
||||
#include <bcu_types.h>
|
||||
|
||||
class QJsonObject;
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
namespace Json
|
||||
{
|
||||
namespace Telegrams
|
||||
{
|
||||
class BUILDINGCONTROLCOMMON_EXPORT BaseTelegram
|
||||
{
|
||||
protected:
|
||||
explicit BaseTelegram(const QString &telegramId)
|
||||
: m_telegramId(telegramId)
|
||||
{}
|
||||
public:
|
||||
virtual ~BaseTelegram() = default;
|
||||
|
||||
QString telegramId() const
|
||||
{
|
||||
return m_telegramId;
|
||||
}
|
||||
virtual QByteArray toJson() const = 0;
|
||||
|
||||
static BaseTelegram *telegramFromJson(const QByteArray &jsonMsg);
|
||||
protected:
|
||||
virtual QByteArray toJsonInternal(const QJsonObject &data) const;
|
||||
private:
|
||||
QString m_telegramId;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT BaseReport : public BaseTelegram
|
||||
{
|
||||
protected:
|
||||
explicit BaseReport(const QString &telegramId)
|
||||
: BaseTelegram(telegramId)
|
||||
{}
|
||||
|
||||
protected:
|
||||
QByteArray toJsonInternal(const QJsonObject &_data) const override;
|
||||
static void fromJsonInternal(const QJsonObject &data, BaseReport *tele, bool &bOk);
|
||||
public:
|
||||
qint64 timestamp = 0;
|
||||
};
|
||||
|
||||
// for debug/instrumentation purposes
|
||||
class BUILDINGCONTROLCOMMON_EXPORT BsmTriggerFlashlight : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("BsmTriggerFlashlight"); }
|
||||
BsmTriggerFlashlight()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static BsmTriggerFlashlight *fromJson(const QJsonObject &data);
|
||||
|
||||
int sensorId = 0;
|
||||
int numberOfFlashes = 1; // 1..254, 255 - infinite, 0 - stop
|
||||
int pauseBetweenFlashesSec = 1; // 1..10
|
||||
QString hostname; // either sensorId or hostname
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT SetDamageState : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("SetDamageState"); }
|
||||
explicit SetDamageState()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static SetDamageState *fromJson(const QJsonObject &data);
|
||||
|
||||
DamageState damageState = DamageState::NoDamage;
|
||||
QVector<int> roomIds; // optional
|
||||
int originatorId = 0;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT SetContaminationState : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("SetContaminationState"); }
|
||||
explicit SetContaminationState()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static SetContaminationState *fromJson(const QJsonObject &data);
|
||||
|
||||
std::vector<BuildingControlUnit::ContaminationState> contaminationStates;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT ResetContaminationState : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("ResetContaminationState"); }
|
||||
explicit ResetContaminationState()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static ResetContaminationState *fromJson(const QJsonObject &data);
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT SetEffectStates : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("SetEffectStates"); }
|
||||
explicit SetEffectStates()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static SetEffectStates *fromJson(const QJsonObject &data);
|
||||
|
||||
QString segment = QString();
|
||||
QVector<BcuEffectState> effectStates;
|
||||
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT SwitchRelay : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("SwitchRelay"); }
|
||||
explicit SwitchRelay()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static SwitchRelay *fromJson(const QJsonObject &data);
|
||||
|
||||
QString segment;
|
||||
SwitchRelayValues switchRelayValues;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT RelayState : public BaseReport
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("RelayState"); }
|
||||
explicit RelayState()
|
||||
: BaseReport(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static RelayState *fromJson(const QJsonObject &data);
|
||||
|
||||
struct RelayStateInfo
|
||||
{
|
||||
int id = 0;
|
||||
bool state = false;
|
||||
};
|
||||
QVector<RelayStateInfo> relayStates;
|
||||
QString segment = QString();
|
||||
qint64 stateTime = 0;
|
||||
qint64 offlineTime = 0;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT EffectOverride : public BaseReport
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("EffectOverrides"); }
|
||||
explicit EffectOverride()
|
||||
: BaseReport(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static EffectOverride *fromJson(const QJsonObject &data);
|
||||
|
||||
struct OverrideInfo
|
||||
{
|
||||
int id = 0;
|
||||
int effectOverride = 0;
|
||||
};
|
||||
QVector<OverrideInfo> overrides;
|
||||
QString segment = QString();
|
||||
qint64 stateTime = 0;
|
||||
qint64 offlineTime = 0;
|
||||
};
|
||||
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT SetFortifyFactor : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("SetFortifyFactor"); }
|
||||
explicit SetFortifyFactor()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static SetFortifyFactor *fromJson(const QJsonObject &data);
|
||||
|
||||
struct FortifyInfo
|
||||
{
|
||||
int roomId = 0;
|
||||
double fortifyFactor = 1.0;
|
||||
};
|
||||
QVector<FortifyInfo> fortifyFactors;
|
||||
|
||||
int originatorId = 0;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT CentralEffectSimulationHit : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("CentralEffectSimulationHit"); }
|
||||
explicit CentralEffectSimulationHit()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static CentralEffectSimulationHit *fromJson(const QJsonObject &data);
|
||||
|
||||
qint64 effectTimeMSec = 0;
|
||||
int chargeTypeId = 0; // TAS Code
|
||||
int destructiveFactor = -1; // optional -1 = not set
|
||||
int penetrationFactor = -1; // optional -1 = not set
|
||||
int aesId = 0;
|
||||
struct
|
||||
{
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
double z = 0;
|
||||
} relPosition;
|
||||
QString properties;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT CentralEffectSimulationHit3D : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("CentralEffectSimulationHit3D"); }
|
||||
explicit CentralEffectSimulationHit3D()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static CentralEffectSimulationHit3D *fromJson(const QJsonObject &data);
|
||||
|
||||
qint64 effectTimeMSec{0};
|
||||
int chargeTypeId{0}; // TAS Code
|
||||
int destructiveFactor{-1}; // optional -1 = not set
|
||||
int penetrationFactor{-1}; // optional -1 = not set
|
||||
int aesId{0};
|
||||
struct
|
||||
{
|
||||
double x{0};
|
||||
double y{0};
|
||||
double z{0};
|
||||
} impactPosition, detonationLocation;
|
||||
double detonationDistance{0};
|
||||
QString properties;
|
||||
};
|
||||
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT DebugSimulateBSMHit : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("DebugSimulateBSMHit"); }
|
||||
explicit DebugSimulateBSMHit()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static DebugSimulateBSMHit *fromJson(const QJsonObject &data);
|
||||
|
||||
qint64 effectTimeMSec = 0;
|
||||
int sensorId = 0;
|
||||
int originatorId = 0;
|
||||
int chargeTypeId = 0;
|
||||
int deposition1 = 0;
|
||||
int deposition2 = 0;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT HitResult : public BaseReport
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("HitResult"); }
|
||||
explicit HitResult()
|
||||
: BaseReport(telegramId())
|
||||
, hitResult(HitResultInfo())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static HitResult *fromJson(const QJsonObject &data);
|
||||
|
||||
struct HitRoomInfo
|
||||
{
|
||||
int roomId = 0;
|
||||
int damagePercent = 0;
|
||||
int remainingEffectPercent = 0;
|
||||
double fortifyFactor = 1.0;
|
||||
};
|
||||
|
||||
struct ContaminationStateInfo
|
||||
{
|
||||
int aesId = 0;
|
||||
std::vector<int> rooms;
|
||||
};
|
||||
|
||||
struct HitResultInfo
|
||||
{
|
||||
int sensorId = 0;
|
||||
int originatorId = 0;
|
||||
OriginatorType originatorType = OriginatorType::Unknown;
|
||||
int chargeTypeId = 0; // = TAS Code
|
||||
int damagePercentOld = 0;
|
||||
int damagePercentNew = 0;
|
||||
int effectSoundId = 0;
|
||||
int hitOnRoomId = 0; // the room which was initially hit
|
||||
DamageState damageState = DamageState::Unknown;
|
||||
QVector<HitRoomInfo> rooms;
|
||||
QVector<ContaminationStateInfo> contaminations;
|
||||
} hitResult;
|
||||
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT BsmState : public BaseReport
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("BsmState"); }
|
||||
explicit BsmState()
|
||||
: BaseReport(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static BsmState *fromJson(const QJsonObject &data);
|
||||
|
||||
struct BsmStateInfo
|
||||
{
|
||||
QString hostname;
|
||||
QString versionInfo;
|
||||
int id = 0;
|
||||
quint16 port;
|
||||
bool connected = false;
|
||||
};
|
||||
QVector<BsmStateInfo> bsmStates;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT GetBsmBitTimeout : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("GetBsmBitTimeout"); }
|
||||
explicit GetBsmBitTimeout()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static GetBsmBitTimeout *fromJson(const QJsonObject &data);
|
||||
|
||||
int sensorId = 0;
|
||||
};
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT GetBsmConfiguration : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("GetBsmConfiguration"); }
|
||||
explicit GetBsmConfiguration()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static GetBsmConfiguration *fromJson(const QJsonObject &data);
|
||||
|
||||
int sensorId = 0;
|
||||
};
|
||||
|
||||
|
||||
class BUILDINGCONTROLCOMMON_EXPORT GetBsmTechnicalStatus : public BaseTelegram
|
||||
{
|
||||
public:
|
||||
static QString telegramId() { return QStringLiteral("GetBsmTechnicalStatus"); }
|
||||
explicit GetBsmTechnicalStatus()
|
||||
: BaseTelegram(telegramId())
|
||||
{}
|
||||
|
||||
QByteArray toJson() const override;
|
||||
static GetBsmTechnicalStatus *fromJson(const QJsonObject &data);
|
||||
|
||||
int sensorId = 0;
|
||||
};
|
||||
|
||||
} // namespace Telegrams
|
||||
} // namespace Json
|
||||
} // namespace BuildingControlUnit
|
||||
Reference in new issue
Block a user