Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+126
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#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>
|
||||
|
||||
namespace OcSituationClient
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("ClientMessageFactory"))
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
|
||||
ClientMessageFactory::~ClientMessageFactory()
|
||||
{}
|
||||
|
||||
LtsWebSocket::AbstractClientMessage *ClientMessageFactory::createMessage(LtsWebSocket::ReplyHandler *client,
|
||||
const QString &message)
|
||||
{
|
||||
LtsWebSocket::AbstractClientMessage *result = checkAttributes(client, message);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_type == ServiceManagement::WebSocketInterface::JsonKeys::SERVICE_PORTS_INFORMATION())
|
||||
result = new ServicePortsInformation(m_dataManager, client, m_type, m_uuid, m_data);
|
||||
|
||||
return checkResult(client, message, result);
|
||||
}
|
||||
// ####### ClientMessageFactory end #######
|
||||
|
||||
// ####### ClientMessage begin #######
|
||||
ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data)
|
||||
: LtsWebSocket::AbstractClientMessage(client, type, uuid, data)
|
||||
, m_dataManager(dataManager)
|
||||
{}
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### ServicesInformation begin #######
|
||||
ServicePortsInformation::ServicePortsInformation(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, uuid, data)
|
||||
{}
|
||||
|
||||
void ServicePortsInformation::process()
|
||||
{
|
||||
QJsonArray exerciseInformationArray = m_data.toArray();
|
||||
QVector<ExerciseInformation> exercises;
|
||||
QVector<ServiceInformation> services;
|
||||
QVector<PortInformation> ports;
|
||||
exercises.reserve(exerciseInformationArray.size());
|
||||
|
||||
for (const auto &exerciseJsonValue : exerciseInformationArray)
|
||||
{
|
||||
QJsonObject exerciseJsonObject = exerciseJsonValue.toObject();
|
||||
ExerciseInformation exercise;
|
||||
|
||||
exercise.exerciseId = exerciseJsonObject.value(ServiceManagement::WebSocketInterface::JsonKeys::EXERCISE_ID()).toInt();
|
||||
if (exerciseJsonObject.find(ServiceManagement::WebSocketInterface::JsonKeys::REPLAY_PARTITION_ID()) != exerciseJsonObject.end())
|
||||
exercise.replayPartitionId = dds::core::optional<int32_t>(exerciseJsonObject.value(ServiceManagement::WebSocketInterface::JsonKeys::REPLAY_PARTITION_ID()).toInt());
|
||||
|
||||
QJsonArray servicesJsonArray = exerciseJsonObject.value(ServiceManagement::WebSocketInterface::JsonKeys::SERVICES()).toArray();
|
||||
|
||||
// prepare vector
|
||||
services.clear();
|
||||
services.reserve(servicesJsonArray.size());
|
||||
|
||||
for (const auto &serviceValue : servicesJsonArray)
|
||||
{
|
||||
ServiceInformation service;
|
||||
QJsonObject serviceObject = serviceValue.toObject();
|
||||
|
||||
service.name = serviceObject.value(ServiceManagement::WebSocketInterface::JsonKeys::NAME()).toString();
|
||||
service.abbreviation = serviceObject.value(ServiceManagement::WebSocketInterface::JsonKeys::NAME_ABBR()).toString();
|
||||
|
||||
QJsonArray portsJsonArray = serviceObject.value(ServiceManagement::WebSocketInterface::JsonKeys::PORTS()).toArray();
|
||||
|
||||
// prepare vector
|
||||
ports.clear();
|
||||
ports.reserve(portsJsonArray.size());
|
||||
|
||||
for (const auto &portValue : portsJsonArray)
|
||||
{
|
||||
QJsonObject portObject = portValue.toObject();
|
||||
PortInformation port;
|
||||
|
||||
port.number = portObject.value(ServiceManagement::WebSocketInterface::JsonKeys::NUMBER()).toInt();
|
||||
port.type = portObject.value(ServiceManagement::WebSocketInterface::JsonKeys::TYPE_ID()).toInt();
|
||||
|
||||
ports.append(port);
|
||||
}
|
||||
service.ports = ports;
|
||||
services.append(service);
|
||||
}
|
||||
exercise.services = services;
|
||||
exercises.append(exercise);
|
||||
}
|
||||
|
||||
m_dataManager->servicePortsInformation(exercises);
|
||||
}
|
||||
|
||||
bool ServicePortsInformation::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ServicesInformation end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace OcSituationClient
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ClientMessage class is an abstract base class for concrete ClientMessage objects
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QVector>
|
||||
|
||||
#include <DDS/Core/core.hpp>
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
#include <LtsWebSocket/client_message.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace OcSituationClient
|
||||
{
|
||||
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);
|
||||
virtual ~ClientMessageFactory();
|
||||
/**
|
||||
* @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 QString &uuid, const QJsonValue &data = QJsonValue());
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
// ################## Message Implementations ##################
|
||||
class ServicePortsInformation : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ServicePortsInformation (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief The PortInformation struct holds the information what kind of port we have here
|
||||
*/
|
||||
struct PortInformation
|
||||
{
|
||||
int32_t number;
|
||||
int32_t type;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The ServiceInformation struct information about a service
|
||||
*/
|
||||
struct ServiceInformation
|
||||
{
|
||||
QString name;
|
||||
QString abbreviation;
|
||||
QVector<PortInformation> ports;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The ExerciseInformation struct with information about an exercise (could also be a replay)
|
||||
*/
|
||||
struct ExerciseInformation
|
||||
{
|
||||
int32_t exerciseId;
|
||||
dds::core::optional<int32_t> replayPartitionId;
|
||||
QVector<ServiceInformation> services;
|
||||
};
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
}; // class ServicesInformation
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace OcSituationClient
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @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 Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#include "reply_message.h"
|
||||
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
#include "WebSocketInterface/json_keys.h"
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
||||
namespace OcSituationClient
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace JsonKeys;
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
ServicePortsInformationRequest::ServicePortsInformationRequest(const QString &uuid)
|
||||
: ReplyMessage(ServiceManagement::WebSocketInterface::JsonKeys::SERVICE_PORTS_INFORMATION_REQUEST(), uuid)
|
||||
{}
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace OcSituationClient
|
||||
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @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 Philipp Dassow, SLST, 2017-12-05
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
|
||||
#include <DDS/Core/core.hpp>
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
namespace OcSituationClient
|
||||
{
|
||||
namespace WebSocketInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
class ServicePortsInformationRequest : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ServicePortsInformationRequest(const QString &uuid);
|
||||
};
|
||||
} // namespace Messages
|
||||
} // namespace WebSocketInterface
|
||||
} // namespace OcSituationClient
|
||||
|
||||
Reference in new issue
Block a user