Files
qt5-legatus-legacy/Lts/Services/InfrastructureManagement/WebSocketInterface/Messages/reply_message.h
T
2026-08-13 18:33:10 +02:00

535 lines
13 KiB
C++
Executable File

/**
* @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 Baeuerle, SLSE, 2016-08-25
*/
#pragma once
#include <LtsWebSocket/client_message_factory.h>
#include <QtCore/QVector>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonArray>
namespace InfrastructureManagement
{
namespace WebSocketInterface
{
namespace Messages
{
/**
* @brief The ReplyMessage class is an abstract base class for all possible messages
* which are sent to the client
*/
class ReplyMessage : public LtsWebSocket::ReplyMessage
{
public:
/**
* @brief The LonLatPoint struct represents a point in any data part which has lon lat
*/
struct LonLatPoint
{
double lon = 0.;
double lat = 0.;
QJsonObject toJSon() const;
};
/**
* @brief The Point3d struct represents a 3D point in any data part which needs it
*/
struct Point3d
{
double x = 0.;
double y = 0.;
double z = 0.;
QJsonObject toJSon() const;
};
/**
* @brief The XYPoint struct represents a 2D point in any data part which needs it
*/
struct XYPoint
{
double x = 0.;
double y = 0.;
QJsonObject toJSon() const;
};
ReplyMessage() = default;
/**
* @brief ~ReplyMessage Destructor
*/
virtual ~ReplyMessage() = default;
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 int typeId, const QString &uuid);
}; // class Reply Message
/**
* @brief The AreaMessage class represents an area
*/
class AreaMessage final
: public ReplyMessage
{
public:
/**
* @brief The AreaData struct represents the data part of an AreaMessage object
*/
struct AreaData
{
int id = 0;
int trainingAreaId = 0;
QString designation;
QVector<LonLatPoint> path;
};
/**
* @brief AreaMessage Constructor
* @param data Data part of an AreaMessage object
*/
AreaMessage(const AreaData &data, const QString &uuid);
AreaMessage() = default;
}; // class AreaMessage
/**
* @brief The AssetStateData struct represents the data part of an AssetStateMessage(/AssetsMessage object
*/
struct AssetData
{
int id = 0;
int assetTypeId = 0;
int mountingPointId = 0;
QString assetTag;
QString designation;
QString hostname; // Hostname
QString state;
QString time; // "DD.MM.JJ hh:mm"
QString errorDescription;
QJsonObject toJsonObject() const;
};
/**
* @brief The AssetStateMessage class represents an asset state
*/
class AssetStateMessage final
: public ReplyMessage
{
public:
/**
* @brief AssetStateMessage Constructor
* @param data Data part of an AssetStateMessage object
*/
explicit AssetStateMessage(const AssetData &data, const QString &uuid);
}; // class AssetStateMessage
/**
* @brief The AssetStateMessage class represents an asset state
*/
class AssetsMessage final
: public ReplyMessage
{
public:
/**
* @brief AssetStateMessage Constructor
* @param data Data part of an AssetStateMessage object
*/
explicit AssetsMessage(const QVector<AssetData> &data, const QString &uuid);
}; // class AssetStateMessage
/**
* @brief The AssetStateObjectMessage class includes data which represents the states of all
* assets in a specific object
*/
class AssetStateObjectMessage final
: public ReplyMessage
{
public:
/**
* @brief The AssetStatesEntry struct represents an entry in AssetStateObjectData.assetStates
*/
struct AssetStatesEntry
{
int assetId = 0;
int assetTypeId = 0;
int mountingPointId = 0;
QString hostname;
QString state;
};
/**
* @brief The AssetStateObjectData struct represents the data part of an AssetStateObjectMessage object
*/
struct AssetStateObjectData
{
int objectId = 0;
QString time; // "DD.MM.JJ hh:mm"
QVector<AssetStatesEntry> assetStates;
};
/**
* @brief AssetStateObjectMessage Constructor
* @param data Data part of an AssetStateObjectMessage object
*/
explicit AssetStateObjectMessage(const AssetStateObjectData &data, const QString &uuid);
}; // class AssetStateObjectMessage
/**
* @brief The AssetTypeMessage class represents an asset type
*/
class AssetTypeMessage final
: public ReplyMessage
{
public:
/**
* @brief The AssetTypeData struct represents the data part of an AssetStateObjectMessage object
*/
struct AssetTypeData
{
int id = 0;
int deviceClass = 0;
QString designation;
};
/**
* @brief AssetTypeMessage Construcor
* @param data Data part of an AssetTypeMessage object
*/
AssetTypeMessage(const AssetTypeData &data, const QString &uuid);
AssetTypeMessage() = default;
}; // class AssetTypeMessage
/**
* @brief The LevelMessage class represents a level
*/
class LevelMessage final
: public ReplyMessage
{
public:
/**
* @brief The LevelData struct represents the data part of an LevelMessage object
*/
struct LevelData
{
int id = 0;
int objectid = 0;
int number = 0;
double zPos = 0;
QString designation;
QVector<XYPoint> path;
};
/**
* @brief LevelMessage Constructor
* @param data Data part of an LevelMessage object
*/
LevelMessage(const LevelData &data, const QString &uuid);
LevelMessage() = default;
}; // class LevelMessage
/**
* @brief The MountingPointMessage class represents a mounting point
*/
class MountingPointMessage final
: public ReplyMessage
{
public:
/**
* @brief The MountingPointData struct represents the data part of an MountingPointMessage object
*/
struct MountingPointData
{
int id = 0;
int objectId = 0;
int levelId = 0;
int roomId = 0;
int assetId = 0;
QString tag;
QString designation;
Point3d position3d;
QVector<int> supportedAssetTypIds;
};
/**
* @brief MountingPointMessage Constructor
* @param data Data part of an MountingPointMessage object
*/
MountingPointMessage(const MountingPointData &data, const QString &uuid);
MountingPointMessage() = default;
}; // class MountingPointMessage
/**
* @brief The ObjectMessage class represents an object
*/
class ObjectMessage final
: public ReplyMessage
{
public:
/**
* @brief The ObjectMessageData struct represents the data part of an ObjectMessage object
*/
struct ObjectMessageData
{
int id = 0;
int areaId = 0;
int mseId = 0; //!< not part of ICD but needed for our tools
QString number;
QString designation;
LonLatPoint refPoint;
double z; // aboveMsl
double rotationDegree;
QString street;
QVector<LonLatPoint> path;
QVector<XYPoint> pathRelative;
};
/**
* @brief ObjectMessage Constructor
* @param data Data part of an ObjectMessage object
*/
ObjectMessage(const ObjectMessageData &data, const QString &uuid);
ObjectMessage() = default;
}; // class ObjectMessage
/**
* @brief The ObjectMountingMessage class represents an object mounting plan
*/
class ObjectMountingMessage final
: public ReplyMessage
{
public:
/**
* @brief The PlannedEntry struct represents an entry in ObjectMountingData.planned
*/
struct PlannedEntry
{
int id = 0;
int assetId = 0;
int planningState = 0;
};
/**
* @brief The ObjectMountingData struct represents the data part of an ObjectMountingMessage object
*/
struct ObjectMountingData
{
int objectId = 0;
int plannedMountingId = 0;
QVector<PlannedEntry> planned;
};
/**
* @brief ObjectMountingMessage Constructor
* @param data Data part of an ObjectMountingMessage object
*/
explicit ObjectMountingMessage(const ObjectMountingData &data, const QString &uuid);
}; // class ObjectMountingMessage
/**
* @brief The OkMessage is sent when a message from a client does not need
* any concrete response and eveything is fine
*/
class OkMessage final
: public ReplyMessage
{
public:
/**
* @brief The OkData struct represents the data part of an OkMessage object
*/
struct OkData
{
QString uuid;
QString messageType;
QString info;
};
/**
* @brief OkMessage Constructor
* @param data Data part of an OkMessage object
*/
explicit OkMessage(const OkData &data);
}; // class OkMessage
/**
* @brief The PlannedMountingMessage class represents a mounting plan
*/
class PlannedMountingMessage final
: public ReplyMessage
{
public:
/**
* @brief The MountingEntry struct represents an entry in PlannedMountingData.mounting
*/
struct MountingEntry
{
int id = 0;
int state = 0;
};
/**
* @brief The PlannedMountingData struct represents the data part of an PlannedMountingMessage object
*/
struct PlannedMountingData
{
int areaId = 0;
int plannedMountingId = 0;
QString designation;
QVector<MountingEntry> mounting;
};
/**
* @brief PlannedMountingMessage Constructor
* @param data Data part of an PlannedMountingMessage object
*/
PlannedMountingMessage(const PlannedMountingData &data, const QString &uuid);
PlannedMountingMessage() = default;
}; // class PlannedMountingMessage
/**
* @brief The RoomMessage class represents a room
*/
class RoomMessage final
: public ReplyMessage
{
public:
/**
* @brief The RoomData struct represents the data part of an RoomMessage object
*/
struct RoomData
{
int id = 0;
int levelId = 0;
QString designation;
QVector<XYPoint> path;
};
/**
* @brief RoomMessage Constructor
* @param data Data part of an RoomMessage object
*/
RoomMessage(const RoomData &data, const QString &uuid);
RoomMessage() = default;
}; // RoomMessage
/**
* @brief The TrainingAreaMessage class represents a training area
*/
class TrainingAreaMessage final
: public ReplyMessage
{
public:
/**
* @brief The TrainingAreaData struct represents the data part of an TrainingAreaMessage object
*/
struct TrainingAreaData
{
int id = 0;
QString designation;
QVector<LonLatPoint> path;
};
/**
* @brief TrainingAreaMessage Constructor
* @param data Data part of an TrainingAreaMessage object
*/
explicit TrainingAreaMessage(const TrainingAreaData &data, const QString &uuid);
TrainingAreaMessage() = default;
}; // class TrainingAreaMessage
// ######################### base DL messages #########################
/**
* @brief The AssetBaseData class asset data for base DL
*/
class AssetBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit AssetBaseData(const QJsonArray &data, const QString &uuid);
}; // class AssetBaseData
/**
* @brief The MainStructureElementBaseData class main structure element data for base DL
*/
class MainStructureElementBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit MainStructureElementBaseData(const QJsonArray &data, const QString &uuid);
}; // class MainStructureElementBaseData
/**
* @brief The VulnerabilityModelDataBaseData class vulnerability model data for base DL
*/
class VulnerabilityModelDataBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit VulnerabilityModelDataBaseData(const QJsonArray &data, const QString &uuid);
}; // class VulnerabilityModelDataBaseData
/**
* @brief The StructureElementBaseData class structure element data for base DL
*/
class StructureElementBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit StructureElementBaseData(const QJsonArray &data, const QString &uuid);
}; // class StructureElementBaseData
/**
* @brief The StructureElementFootprintBaseData class structure element footprint data for base DL
*/
class StructureElementFootprintBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit StructureElementFootprintBaseData(const QJsonArray &data, const QString &uuid);
}; // class StructureElementFootprintBaseData
/**
* @brief The MountingPointAssetBaseData class mounting point asset data for base DL
*/
class MountingPointAssetBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit MountingPointAssetBaseData(const QJsonArray &data, const QString &uuid);
}; // class MountingPointAssetBaseData
/**
* @brief The MountingPointScheduleBaseData class mounting point schedule data for base DL
*/
class MountingPointScheduleBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit MountingPointScheduleBaseData(const QJsonArray &data, const QString &uuid);
}; // class MountingPointScheduleBaseData
/**
* @brief The MountingPointPlanBaseData class mounting point plan data for base DL
*/
class MountingPointPlanBaseData : public LtsWebSocket::ReplyMessage
{
public:
explicit MountingPointPlanBaseData(const QJsonArray &data, const QString &uuid);
}; // class MountingPointPlanBaseData
} // namespace Messages
} // namespace WebSocketInterfac
} // namespace InfrastructureManagement