Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+409
@@ -0,0 +1,409 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-25
|
||||
*/
|
||||
#include "client_message.h"
|
||||
|
||||
#include "WebSocketInterface/Messages/reply_message.h"
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
#include "WebSocketInterface/data_manager.h"
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QSet>
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
|
||||
template <typename T>
|
||||
static QJsonArray fillArray(const T &messages)
|
||||
{
|
||||
QJsonArray arr;
|
||||
for (const auto ¤tMsg : messages)
|
||||
arr += currentMsg.json().value(LtsWebSocket::JsonKeys::DATA());
|
||||
return arr;
|
||||
}
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == OcBaseDownload::WebSocketInterface::JsonKeys::BASE_DL_REQUEST())
|
||||
result = new BaseDlRequest(m_dataManager, client, m_type, m_typeId, m_uuid);
|
||||
else if (m_type == GET_ASSETS())
|
||||
result = new GetAssetsMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == GET_ASSET_STATE())
|
||||
result = new GetAssetStateMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == GET_BUILDING_STATE())
|
||||
result = new GetBuildingStateMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == GET_ESSENTIALS())
|
||||
result = new GetEssentialsMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == GET_OBJECT_MOUNTING())
|
||||
result = new GetObjectMountingMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == GET_PLANNED_MOUNTINGS())
|
||||
result = new GetPlannedMountingsMessage(m_dataManager, client, m_type, m_typeId, m_uuid);
|
||||
else if (m_type == MOUNT())
|
||||
result = new MountMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == MOUNT_TAG())
|
||||
result = new MountTagMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == OBJECT_MOUNTING_READY())
|
||||
result = new ObjectMountingReadyMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == UNMOUNT_AREA())
|
||||
result = new UnmountAreaMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == UNMOUNT_ASSET())
|
||||
result = new UnmountAssetMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == UNMOUNT_MOUNTING_POINT())
|
||||
result = new UnmountMountingPointMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
else if (m_type == UNMOUNT_OBJECT())
|
||||
result = new UnmountObjectMessage(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
// ####### ClientMessageFactory end #######
|
||||
|
||||
// ####### ClientMessage begin #######
|
||||
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, typeId, uuid, data)
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### GetAssetStateMessage begin #######
|
||||
void GetAssetStateMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->getAssetState(m_data.toObject().value(ASSET_ID()).toInt(),
|
||||
m_data.toObject().value(ASSET_TAG()).toString(),
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool GetAssetStateMessage::hasValidData() const
|
||||
{
|
||||
// one (exclusive) value has to be set
|
||||
return ((!m_data.toObject().value(ASSET_ID()).isDouble() && m_data.toObject().value(ASSET_TAG()).isString()) ||
|
||||
(m_data.toObject().value(ASSET_ID()).isDouble() && !m_data.toObject().value(ASSET_TAG()).isString()));
|
||||
}
|
||||
|
||||
|
||||
GetAssetStateMessage::GetAssetStateMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### GetAssetStateMessage end #######
|
||||
|
||||
// ####### GetAssetStateMessage begin #######
|
||||
void GetAssetsMessage::process()
|
||||
{
|
||||
const QJsonValue val = m_data.toObject().value(ASSET_TYPE_ID());
|
||||
QSet<int> assetTypeIds;
|
||||
if (val.isArray())
|
||||
{
|
||||
const QJsonArray ary = val.toArray();
|
||||
assetTypeIds.reserve(ary.size());
|
||||
for (const auto &ele : ary)
|
||||
assetTypeIds += ele.toInt();
|
||||
}
|
||||
else
|
||||
assetTypeIds += val.toInt();
|
||||
m_client->addReply(m_dataManager->getAssets(assetTypeIds,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool GetAssetsMessage::hasValidData() const
|
||||
{
|
||||
const auto val = m_data.toObject().value(ASSET_TYPE_ID());
|
||||
return val.isDouble() || val.isArray();
|
||||
}
|
||||
|
||||
GetAssetsMessage::GetAssetsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### GetAssetStateMessage end #######
|
||||
|
||||
// ####### GetBuildingStateMessage begin #######
|
||||
void GetBuildingStateMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->getBuildingState(m_data.toObject().value(BUILDING_ID()).toInt(),
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool GetBuildingStateMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(BUILDING_ID()).isDouble();
|
||||
}
|
||||
|
||||
GetBuildingStateMessage::GetBuildingStateMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### GetBuildingStateMessage end #######
|
||||
|
||||
class GetEssentialsReply final : public ReplyMessage
|
||||
{
|
||||
public:
|
||||
GetEssentialsReply(const QJsonObject &obj, const QString &uuid)
|
||||
: ReplyMessage(QStringLiteral("essentials"), 2, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(LtsWebSocket::JsonKeys::DATA(), obj);
|
||||
}
|
||||
};
|
||||
|
||||
// ####### GetEssentialsMessage begin #######
|
||||
void GetEssentialsMessage::process()
|
||||
{
|
||||
const DataManager::EinruestEssentials data = m_dataManager->getEssentials(m_uuid);
|
||||
|
||||
QJsonObject obj;
|
||||
obj[TRAINING_AREAS()] = fillArray(data.trainingAreas);
|
||||
obj[AREAS()] = fillArray(data.areas);
|
||||
obj[OBJECTS()] = fillArray(data.objects);
|
||||
obj[LEVELS()] = fillArray(data.levels);
|
||||
obj[ROOMS()] = fillArray(data.rooms);
|
||||
obj[MOUNTING_POINTS()] = fillArray(data.mountingPoints);
|
||||
obj[ASSET_TYPES()] = fillArray(data.assetTypes);
|
||||
|
||||
m_client->addReply(new GetEssentialsReply(obj, m_uuid));
|
||||
}
|
||||
|
||||
bool GetEssentialsMessage::hasValidData() const
|
||||
{
|
||||
return true; // no data part to validate
|
||||
}
|
||||
|
||||
GetEssentialsMessage::GetEssentialsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### GetEssentialsMessage end #######
|
||||
|
||||
// ####### GetPlannedMountingMessage begin #######
|
||||
|
||||
class PlannedMountingsReply final : public ReplyMessage
|
||||
{
|
||||
public:
|
||||
PlannedMountingsReply(const QJsonArray &arr, const QString &uuid)
|
||||
: ReplyMessage(QStringLiteral("plannedMountings"), 13, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(LtsWebSocket::JsonKeys::DATA(), arr);
|
||||
}
|
||||
};
|
||||
|
||||
void GetPlannedMountingsMessage::process()
|
||||
{
|
||||
const QVector<PlannedMountingMessage> plannedMountings = m_dataManager->getPlannedMounting(m_uuid);
|
||||
m_client->addReply(new PlannedMountingsReply(fillArray(plannedMountings), m_uuid));
|
||||
}
|
||||
|
||||
bool GetPlannedMountingsMessage::hasValidData() const
|
||||
{
|
||||
return true; // no data part to validate
|
||||
}
|
||||
|
||||
GetPlannedMountingsMessage::GetPlannedMountingsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{
|
||||
}
|
||||
// ####### GetPlannedMountingMessage end #######
|
||||
|
||||
// ####### GetObjectMountingMessage begin #######
|
||||
void GetObjectMountingMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->getObjectMounting(m_data.toObject().value(PLANNED_MOUNTING_ID()).toInt(),
|
||||
m_data.toObject().value(OBJECT_ID()).toInt(),
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool GetObjectMountingMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(PLANNED_MOUNTING_ID()).isDouble() &&
|
||||
m_data.toObject().value(OBJECT_ID()).isDouble();
|
||||
}
|
||||
|
||||
GetObjectMountingMessage::GetObjectMountingMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### GetObjectMountingMessage end #######
|
||||
|
||||
// ####### MountMessage begin #######
|
||||
void MountMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->mount(m_data.toObject().value(MOUNTING_POINT_ID()).toInt(),
|
||||
m_data.toObject().value(ASSET_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool MountMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(MOUNTING_POINT_ID()).isDouble() &&
|
||||
m_data.toObject().value(ASSET_ID()).isDouble();
|
||||
}
|
||||
|
||||
MountMessage::MountMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### MountMessage end #######
|
||||
|
||||
// ####### MountTagMessage begin #######
|
||||
void MountTagMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->mountTag(m_data.toObject().value(MOUNTING_POINT_TAG()).toString(),
|
||||
m_data.toObject().value(ASSET_TAG()).toString(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool MountTagMessage::hasValidData() const
|
||||
{
|
||||
// at least one
|
||||
return m_data.toObject().value(ASSET_TAG()).isString() || m_data.toObject().value(MOUNTING_POINT_TAG()).isString();
|
||||
}
|
||||
|
||||
MountTagMessage::MountTagMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### MountTagMessage end #######
|
||||
|
||||
// ####### ObjectMountingReadyMessage begin #######
|
||||
void ObjectMountingReadyMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->objectMountingReady(m_data.toObject().value(PLANNED_MOUNTING_ID()).toInt(),
|
||||
m_data.toObject().value(OBJECT_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool ObjectMountingReadyMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(PLANNED_MOUNTING_ID()).isDouble() &&
|
||||
m_data.toObject().value(OBJECT_ID()).isDouble();
|
||||
}
|
||||
|
||||
ObjectMountingReadyMessage::ObjectMountingReadyMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### ObjectMountingReadyMessage end #######
|
||||
|
||||
// ####### UnmountAreaMessage begin #######
|
||||
void UnmountAreaMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->unmountArea(m_data.toObject().value(AREA_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool UnmountAreaMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(AREA_ID()).isDouble();
|
||||
}
|
||||
|
||||
UnmountAreaMessage::UnmountAreaMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### UnmountAreaMessage end #######
|
||||
|
||||
// ####### UnmountAssetMessage begin #######
|
||||
void UnmountAssetMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->unmountAsset(m_data.toObject().value(ASSET_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool UnmountAssetMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(ASSET_ID()).isDouble();
|
||||
}
|
||||
|
||||
UnmountAssetMessage::UnmountAssetMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### UnmountAssetMessage end #######
|
||||
|
||||
// ####### UnmountMountingPointMessage begin #######
|
||||
void UnmountMountingPointMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->unmountMountingPoint(m_data.toObject().value(MOUNTING_POINT_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool UnmountMountingPointMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(MOUNTING_POINT_ID()).isDouble();
|
||||
}
|
||||
|
||||
UnmountMountingPointMessage::UnmountMountingPointMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### UnmountMountingPointMessage end #######
|
||||
|
||||
// ####### UnmountObjectMessage begin #######
|
||||
void UnmountObjectMessage::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->unmountObject(m_data.toObject().value(OBJECT_ID()).toInt(),
|
||||
m_type,
|
||||
m_uuid));
|
||||
}
|
||||
|
||||
bool UnmountObjectMessage::hasValidData() const
|
||||
{
|
||||
return m_data.toObject().value(OBJECT_ID()).isDouble();
|
||||
}
|
||||
|
||||
UnmountObjectMessage::UnmountObjectMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{
|
||||
}
|
||||
// ####### UnmountObjectMessage end #######
|
||||
|
||||
// ####### BaseDlRequest begin #######
|
||||
BaseDlRequest::BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid)
|
||||
{}
|
||||
|
||||
void BaseDlRequest::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->assetBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->mainStructureElementBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->structureElementBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->structureElementFootprintBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->mountingPointAssetBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->mountingPointScheduleBaseData(m_uuid));
|
||||
m_client->addReply(m_dataManager->mountingPointPlanBaseData(m_uuid));
|
||||
}
|
||||
|
||||
bool BaseDlRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### BaseDlRequest end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace Infrastrukture Management
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-25
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
class DataManager;
|
||||
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief The ClientMessageFactory class creates ClientMessages which will then be processed
|
||||
*/
|
||||
class ClientMessageFactory final : public LtsWebSocket::AbstractClientMessageFactory
|
||||
{
|
||||
public:
|
||||
explicit ClientMessageFactory(DataManager *dataManager);
|
||||
/**
|
||||
* @brief create Only way to create a ClientMessage object
|
||||
* @param message Text message which will be converted to a ClientMessage object
|
||||
* @return A ClientMessage object, which represents a concrete ClientMessage
|
||||
*/
|
||||
LtsWebSocket::AbstractClientMessage *createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message);
|
||||
|
||||
private:
|
||||
DataManager *m_dataManager;
|
||||
|
||||
}; // class ClientMessageFactory
|
||||
|
||||
/**
|
||||
* @brief The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
*/
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
protected: // method
|
||||
explicit ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data = QJsonValue());
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
// the following classes are concrete implementation classes of ClientMessage
|
||||
/**
|
||||
* @brief The GetAssetStateMessage class represents the appropriate telegram
|
||||
*/
|
||||
class GetAssetStateMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit GetAssetStateMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class AssetStateMessage
|
||||
|
||||
/**
|
||||
* @brief Retrieve all assets for the given asset type
|
||||
*/
|
||||
class GetAssetsMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
GetAssetsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class GetAssetsMessage
|
||||
|
||||
/**
|
||||
* @brief The GetBuildingStateMessage class represents the appropriate telegram
|
||||
*/
|
||||
class GetBuildingStateMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit GetBuildingStateMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class GetBuildingStateMessage
|
||||
|
||||
/**
|
||||
* @brief The GetEssentialsMessage class represents the appropriate telegram
|
||||
*/
|
||||
class GetEssentialsMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit GetEssentialsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class GetEssentialsMessage
|
||||
|
||||
/**
|
||||
* @brief The GetPlannedMountingMessage class represents the appropriate telegram
|
||||
*/
|
||||
class GetPlannedMountingsMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit GetPlannedMountingsMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class GetPlannedMountingMessage
|
||||
|
||||
/**
|
||||
* @brief The GetObjectMountingMessage class represents the appropriate telegram
|
||||
*/
|
||||
class GetObjectMountingMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit GetObjectMountingMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class GetObjectMountingMessage
|
||||
|
||||
/**
|
||||
* @brief The MountMessage class represents the appropriate telegram
|
||||
*/
|
||||
class MountMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit MountMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class MountMessage
|
||||
|
||||
/**
|
||||
* @brief The MountTagMessage class represents the appropriate telegram
|
||||
*/
|
||||
class MountTagMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit MountTagMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class MountTagMessage
|
||||
|
||||
/**
|
||||
* @brief The ObjectMountingReadyMessage class represents the appropriate telegram
|
||||
*/
|
||||
class ObjectMountingReadyMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
ObjectMountingReadyMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class ObjectMountingReadyMessage
|
||||
|
||||
/**
|
||||
* @brief The UnmountAreaMessage class represents the appropriate telegram
|
||||
*/
|
||||
class UnmountAreaMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit UnmountAreaMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class UnmountAreaMessage
|
||||
|
||||
/**
|
||||
* @brief The UnmountAssetMessage class represents the appropriate telegram
|
||||
*/
|
||||
class UnmountAssetMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit UnmountAssetMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class UnmountAssetMessage
|
||||
|
||||
class UnmountMountingPointMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit UnmountMountingPointMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class UnmountMountingPointMessage
|
||||
|
||||
class UnmountObjectMessage final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit UnmountObjectMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
void process() override;
|
||||
bool hasValidData() const override;
|
||||
}; // class UnmountObjectMessage
|
||||
|
||||
/**
|
||||
* @brief The BaseDlRequest class handles the base DL request and sends multiple replys depending on the data requested
|
||||
*/
|
||||
class BaseDlRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit BaseDlRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class BaseDlRequest
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace InfrastructureManagement
|
||||
+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
|
||||
+534
@@ -0,0 +1,534 @@
|
||||
/**
|
||||
* @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
|
||||
|
||||
Reference in new issue
Block a user