Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,71 @@
/**
* @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 ServiceManagement
{
namespace WebSocketInterface
{
namespace Messages
{
using namespace JsonKeys;
// ####### 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 == SERVICE_PORTS_INFORMATION_REQUEST())
result = new ServicePortsInformationRequest(m_dataManager, client, m_type, m_typeId, m_uuid);
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 #######
// ####### ServicesInformation begin #######
ServicePortsInformationRequest::ServicePortsInformationRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
: ClientMessage (dataManager,client, type, typeId, uuid)
{}
void ServicePortsInformationRequest::process()
{
m_client->addReply(m_dataManager->servicesInformation(m_uuid));
}
bool ServicePortsInformationRequest::hasValidData() const
{
return true;
}
// ####### ServicesInformation end #######
} // namespace Messages
} // namespace WebSocketInterface
} // namespace ServiceManagement
@@ -0,0 +1,73 @@
/**
* @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 <LtsWebSocket/client_message_factory.h>
#include <LtsWebSocket/client_message.h>
#include "logger.h"
namespace ServiceManagement
{
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
// ################## Message Implementations ##################
class ServicePortsInformationRequest : public ClientMessage
{
public:
explicit ServicePortsInformationRequest (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
void process();
bool hasValidData() const;
}; // class ServicesInformation
} // namespace Messages
} // namespace WebSocketInterface
} // namespace ServiceManagement
@@ -0,0 +1,69 @@
/**
* @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 ServiceManagement
{
namespace WebSocketInterface
{
namespace Messages
{
using namespace JsonKeys;
using namespace LtsWebSocket::JsonKeys;
// ####### ServicePortsInformationMessage begin #######
/********************************************************
* Warning: 6002 has been negotiated with ESG for ADLER *
********************************************************/
ServicePortsInformationMessage::ServicePortsInformationMessage(const QVector<ExerciseInformation> &data, const QString &uuid)
: ReplyMessage (SERVICE_PORTS_INFORMATION(), 6002, uuid) // Todo check whether TypeID is correct.
{
QJsonArray exercises;
for (const auto &exercise : data)
{
QJsonArray services;
for (const auto &service : exercise.services)
{
QJsonArray ports;
for (const auto &port : service.ports)
{
ports.append(QJsonObject({{NUMBER(),port.number},
{TYPE_ID(),port.type},
{PROPERTIES(), port.properties}
}));
}
services.append(QJsonObject({{NAME(), service.name},
{NAME_ABBR(), service.abbreviation},
{PORTS(), ports}
}));
}
QJsonObject obj({{EXERCISE_ID(), exercise.exerciseId},
{SERVICES(), services}
});
if (exercise.replayPartitionId.is_set())
obj.insert(REPLAY_PARTITION_ID(), exercise.replayPartitionId.get());
exercises.append(obj);
}
m_jsonRepresentation.insert(DATA(), exercises);
}
// ####### ServicePortsInformationMessage end #######
} // namespace Messages
} // namespace WebSocketInterface
} // namespace ServiceManagement
@@ -0,0 +1,71 @@
/**
* @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 ServiceManagement
{
namespace WebSocketInterface
{
namespace Messages
{
/**
* @brief The ServicePortsInformationMessage class represents the service informations collected by the svcServiceManagement
*/
class ServicePortsInformationMessage final : public LtsWebSocket::ReplyMessage
{
public:
/**
* @brief The PortInformation struct holds the information what kind of port we have here
*/
struct PortInformation
{
int32_t number;
int32_t type;
QString properties;
};
/**
* @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;
};
explicit ServicePortsInformationMessage (const QVector<ExerciseInformation> &data, const QString &uuid);
}; // class ServicePortsInformationMessage
} // namespace Messages
} // namespace WebSocketInterface
} // namespace ServiceManagement