Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+329
@@ -0,0 +1,329 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
#include "reply_message.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
// ####### ReplyMessage begin #######
|
||||
QJsonObject ReplyMessage::LonLatPoint::toJSon() const
|
||||
{
|
||||
return {{LONGITUDE(), lon}, {LATITUDE(), lat}};
|
||||
}
|
||||
|
||||
QJsonObject ReplyMessage::Point3d::toJSon() const
|
||||
{
|
||||
return {{X(), x}, {Y(), y}, {Z(), z}};
|
||||
}
|
||||
|
||||
QJsonObject ReplyMessage::XYPoint::toJSon() const
|
||||
{
|
||||
return {{X(), x}, {Y(), y}};
|
||||
}
|
||||
|
||||
|
||||
ReplyMessage::ReplyMessage(const QString &type, const int typeId, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage(type, typeId, uuid)
|
||||
{}
|
||||
// ####### ReplyMessage end #######
|
||||
|
||||
// ####### OkMessage begin #######
|
||||
OkMessage::OkMessage(const OkMessage::OkData &data)
|
||||
: ReplyMessage(OK(), 1, QString()) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(),
|
||||
QJsonObject({{UUID_(), data.uuid},
|
||||
{MESSAGE_TYPE(), data.messageType},
|
||||
{INFO(), data.info}
|
||||
}));
|
||||
}
|
||||
// ####### OkMessage end #######
|
||||
|
||||
// ####### RoomMessage begin #######
|
||||
RoomMessage::RoomMessage(const RoomMessage::RoomData &data, const QString &uuid)
|
||||
: ReplyMessage(ROOM(), 3, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(),
|
||||
QJsonObject({{PATH(), vecToPath(data.path)},
|
||||
{ID(), data.id},
|
||||
{DESIGNATION(), data.designation},
|
||||
{LEVEL_ID(), data.levelId}
|
||||
}));
|
||||
}
|
||||
// ####### RoomMessage end #######
|
||||
|
||||
// ####### AssetData begin #######
|
||||
QJsonObject AssetData::toJsonObject() const
|
||||
{
|
||||
return QJsonObject(
|
||||
{
|
||||
{ID(), id},
|
||||
{ERROR_DESCRIPTION(), errorDescription},
|
||||
{TIME(), time},
|
||||
{STATE(), state},
|
||||
{IP_ADDRESS(), hostname}, // TODO: Fix ICD
|
||||
{MOUNTING_POINT_ID(), mountingPointId},
|
||||
{ASSET_TYPE_ID(), assetTypeId},
|
||||
{ASSET_TAG(), assetTag},
|
||||
{DESIGNATION(), designation}
|
||||
});
|
||||
}
|
||||
// ####### AssetData end #######
|
||||
|
||||
// ####### AreaMessage begin #######
|
||||
AreaMessage::AreaMessage(const AreaMessage::AreaData &data, const QString &uuid)
|
||||
: ReplyMessage(AREA(), 4, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(),
|
||||
QJsonObject({{PATH(), vecToPath(data.path)},
|
||||
{ID(), data.id},
|
||||
{DESIGNATION(), data.designation},
|
||||
{TRAINING_AREA_ID(), data.trainingAreaId}
|
||||
}));
|
||||
}
|
||||
// ####### AreaMessage end #######
|
||||
|
||||
// ####### AssetStateMessage begin #######
|
||||
AssetStateMessage::AssetStateMessage(const AssetData &data, const QString &uuid)
|
||||
: ReplyMessage(ASSET_STATE(), 5, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), {data.toJsonObject()});
|
||||
}
|
||||
// ####### AssetStateMessage end #######
|
||||
|
||||
// ####### AssetStateMessage begin #######
|
||||
AssetsMessage::AssetsMessage(const QVector<AssetData> &data,
|
||||
const QString &uuid)
|
||||
: ReplyMessage(ASSETS(), 6, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
QJsonArray arr;
|
||||
for (const AssetData &ad : data)
|
||||
arr += ad.toJsonObject();
|
||||
m_jsonRepresentation.insert(DATA(), arr);
|
||||
}
|
||||
|
||||
// ####### AssetStateMessage end #######
|
||||
|
||||
// ####### AssetStateObjectMessage begin #######
|
||||
AssetStateObjectMessage::AssetStateObjectMessage(const AssetStateObjectMessage::AssetStateObjectData &data, const QString &uuid)
|
||||
: ReplyMessage(ASSET_STATE_OBJECT(), 7, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
QJsonArray assetStates;
|
||||
|
||||
for (const AssetStatesEntry ¤tEntry : data.assetStates)
|
||||
assetStates.append(QJsonObject({{MOUNTING_POINT_ID(), currentEntry.mountingPointId},
|
||||
{ASSET_ID(), currentEntry.assetId},
|
||||
{ASSET_TYPE_ID(), currentEntry.assetTypeId},
|
||||
{IP_ADDRESS(), currentEntry.hostname}, // TODO: Fix ICD
|
||||
{STATE(), currentEntry.state}
|
||||
}));
|
||||
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{ASSET_STATES(), assetStates},
|
||||
{OBJECT_ID(), data.objectId},
|
||||
{TIME(), data.time}
|
||||
}));
|
||||
}
|
||||
// ####### AssetStateObjectMessage end #######
|
||||
|
||||
// ####### AssetTypeMessage begin #######
|
||||
AssetTypeMessage::AssetTypeMessage(const AssetTypeMessage::AssetTypeData &data, const QString &uuid)
|
||||
: ReplyMessage(ASSET_TYPE(), 8, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{ID(), data.id},
|
||||
{DESIGNATION(), data.designation},
|
||||
{DEVICE_CLASS(), data.deviceClass}
|
||||
}));
|
||||
}
|
||||
// ####### AssetTypeMessage end #######
|
||||
|
||||
// ####### LevelMessage end #######
|
||||
LevelMessage::LevelMessage(const LevelMessage::LevelData &data, const QString &uuid)
|
||||
: ReplyMessage(LEVEL(), 9, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{Z_POSITION(), data.zPos},
|
||||
{NUMBER(), data.number},
|
||||
{OBJECT_ID(), data.objectid},
|
||||
{DESIGNATION(), data.designation},
|
||||
{ID(), data.id},
|
||||
{PATH(), vecToPath(data.path)}
|
||||
}));
|
||||
}
|
||||
// ####### LevelMessage end #######
|
||||
|
||||
// ####### MountingPointMessage begin #######
|
||||
MountingPointMessage::MountingPointMessage(const MountingPointMessage::MountingPointData &data, const QString &uuid)
|
||||
: ReplyMessage(MOUNTING_POINT(), 10, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
QJsonArray supportedAssetTypeIds;
|
||||
|
||||
for (int currentId : data.supportedAssetTypIds)
|
||||
supportedAssetTypeIds.append(currentId);
|
||||
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{SUPPORTED_ASSET_TYPE_IDS(), supportedAssetTypeIds},
|
||||
{POSITION_3D(), data.position3d.toJSon()},
|
||||
{ID(), data.id},
|
||||
{DESIGNATION(), data.designation},
|
||||
{TAG(), data.tag},
|
||||
{OBJECT_ID(), data.objectId},
|
||||
{LEVEL_ID(), data.levelId},
|
||||
{ROOM_ID(), data.roomId},
|
||||
{ASSET_ID(), data.assetId}
|
||||
}));
|
||||
}
|
||||
// ####### MountingPointMessage end #######
|
||||
|
||||
// ####### ObjectMessage begin #######
|
||||
ObjectMessage::ObjectMessage(const ObjectMessage::ObjectMessageData &data, const QString &uuid)
|
||||
: ReplyMessage(OBJECT(), 11, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{NUMBER(), data.number},
|
||||
{STREET(), data.street},
|
||||
{AREA_ID(), data.areaId},
|
||||
{DESIGNATION(), data.designation},
|
||||
{ID(), data.id},
|
||||
{MSE_ID(), data.mseId},
|
||||
{REF_POINT(), data.refPoint.toJSon()},
|
||||
{Z(), data.z},
|
||||
{ROTATION_DEGREE(), data.rotationDegree},
|
||||
{PATH(), vecToPath(data.path)},
|
||||
{PATH_RELATIVE(), vecToPath(data.pathRelative)}
|
||||
}));
|
||||
}
|
||||
// ####### ObjectMessage end #######
|
||||
|
||||
// ####### ObjectMountingMessage begin #######
|
||||
ObjectMountingMessage::ObjectMountingMessage(const ObjectMountingMessage::ObjectMountingData &data, const QString &uuid)
|
||||
: ReplyMessage(OBJECT_MOUNTING(), 12, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
QJsonArray planned;
|
||||
|
||||
for (const PlannedEntry ¤tEntry : data.planned)
|
||||
planned.append(QJsonObject({{ID(), currentEntry.id},
|
||||
{ASSET_ID(), currentEntry.assetId},
|
||||
{PLANNING_STATE(), currentEntry.planningState}
|
||||
}));
|
||||
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{PLANNED(), planned},
|
||||
{PLANNED_MOUNTING_ID(), data.plannedMountingId},
|
||||
{OBJECT_ID(), data.objectId}
|
||||
}));
|
||||
}
|
||||
// ####### ObjectMountingMessage end #######
|
||||
|
||||
// ####### PlannedMountingMessage begin #######
|
||||
PlannedMountingMessage::PlannedMountingMessage(const PlannedMountingMessage::PlannedMountingData &data, const QString &uuid)
|
||||
: ReplyMessage(PLANNED_MOUNTING(), 13, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
QJsonArray mounting;
|
||||
|
||||
for (const MountingEntry ¤tEntry : data.mounting)
|
||||
mounting.append(QJsonObject({{ID(), currentEntry.id},
|
||||
{STATE(), currentEntry.state}
|
||||
}));
|
||||
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{MOUNTING(), mounting},
|
||||
{PLANNED_MOUNTING_ID(), data.plannedMountingId},
|
||||
{DESIGNATION(), data.designation},
|
||||
{AREA_ID(), data.areaId}
|
||||
}));
|
||||
}
|
||||
// ####### PlannedMountingMessage end #######
|
||||
|
||||
// ####### TrainingAreaMessage begin #######
|
||||
TrainingAreaMessage::TrainingAreaMessage(const TrainingAreaMessage::TrainingAreaData &data, const QString &uuid)
|
||||
: ReplyMessage(TRAINING_AREA(), 14, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), QJsonObject({{PATH(), vecToPath(data.path)},
|
||||
{ID(), data.id},
|
||||
{DESIGNATION(), data.designation}
|
||||
}));
|
||||
}
|
||||
// ####### TrainingAreaMessage end #######
|
||||
|
||||
// ######################### base DL messages #########################
|
||||
|
||||
// ####### AssetBaseData begin #######
|
||||
AssetBaseData::AssetBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (ISM_ASSET_BASE_DATA(), 15, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### AssetBaseData end #######
|
||||
|
||||
// ####### MainStructureElementBaseData begin #######
|
||||
MainStructureElementBaseData::MainStructureElementBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (MAIN_STRUCTURE_ELEMENT_BASE_DATA(), 16, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### MainStructureElementBaseData end #######
|
||||
|
||||
// ####### VulnerabilityModelDataBaseData begin #######
|
||||
VulnerabilityModelDataBaseData::VulnerabilityModelDataBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (VULNERABILITY_MODEL_DATA_BASE_DATA(), 17, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### VulnerabilityModelDataBaseData end #######
|
||||
|
||||
// ####### StructureElementBaseData begin #######
|
||||
StructureElementBaseData::StructureElementBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (STRUCTURE_ELEMENT_BASE_DATA(), 18, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### StructureElementBaseData end #######
|
||||
|
||||
// ####### StructureElementFootprintBaseData begin #######
|
||||
StructureElementFootprintBaseData::StructureElementFootprintBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (STRUCTURE_ELEMENT_FOOTPRINT_BASE_DATA(), 19, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### StructureElementFootprintBaseData end #######
|
||||
|
||||
// ####### MountingPointAssetBaseData begin #######
|
||||
MountingPointAssetBaseData::MountingPointAssetBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (MOUNTING_POINT_ASSET_BASE_DATA(), 20, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### MountingPointAssetBaseData end #######
|
||||
|
||||
// ####### MountingPointPlanBaseData begin #######
|
||||
MountingPointPlanBaseData::MountingPointPlanBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (MOUNTING_POINT_PLAN_BASE_DATA(), 21, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### MountingPointPlanBaseData end #######
|
||||
|
||||
// ####### MountingPointScheduleBaseData begin #######
|
||||
MountingPointScheduleBaseData::MountingPointScheduleBaseData(const QJsonArray &data, const QString &uuid)
|
||||
: LtsWebSocket::ReplyMessage (MOUNTING_POINT_SCHEDULE_BASE_DATA(), 22, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### MountingPointScheduleBaseData end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace Infrastrukture Management
|
||||
Reference in new issue
Block a user