Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+187
@@ -0,0 +1,187 @@
|
||||
/**
|
||||
* MainHandler for TetraRadio
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-04-14
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "dds_handler.h"
|
||||
#include "exercises_handler.h"
|
||||
#include "interface_wms2ecc_impl.h"
|
||||
#include <WMS_Interface/json_keys.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include <QWebSocket>
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
#include <LtsWebSocket/client_connection.h>
|
||||
#include <LtsWebSocket/client_message_factory.h>
|
||||
|
||||
class EquipmentTypes;
|
||||
class Registration;
|
||||
namespace WarehouseManagement
|
||||
{
|
||||
class DataManager;
|
||||
/**
|
||||
* @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
|
||||
|
||||
class ClientMessage : public LtsWebSocket::AbstractClientMessage
|
||||
{
|
||||
protected: // method
|
||||
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)
|
||||
{}
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
class EquipmentTypesReply final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit EquipmentTypesReply (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process() override;
|
||||
bool hasValidData() const override { return true; }
|
||||
}; // class EquipmentTypesReply
|
||||
|
||||
class ExercisesRequest final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ExercisesRequest (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process() override;
|
||||
bool hasValidData() const override { return true; }
|
||||
}; // class ExercisesRequest
|
||||
|
||||
class ParticipantRequest final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantRequest (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process() override;
|
||||
bool hasValidData() const override { return true; }
|
||||
}; // class ParticipantRequest
|
||||
|
||||
|
||||
|
||||
class EquipmentTypeRequest : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
EquipmentTypeRequest()
|
||||
: LtsWebSocket::ReplyMessage(WebSocketInterface::JsonKeys::EQUIPMENT_TYPES_REQUEST(), 1, QStringLiteral("eins"))
|
||||
{}
|
||||
};
|
||||
|
||||
class ExerciseReply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ExerciseReply(const std::shared_ptr<IWMS2ECC_Impl> &wms2ecc);
|
||||
};
|
||||
|
||||
class ExerciseUpdate : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ExerciseUpdate(const IWMS2ECC::Exercise &data, DataModification modType);
|
||||
};
|
||||
|
||||
class ParticipantReply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantReply(const std::shared_ptr<IWMS2ECC_Impl> &wms2ecc, int exerciseId);
|
||||
|
||||
};
|
||||
|
||||
class ParticipantUpdate : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantUpdate(const IWMS2ECC::PlayerInfo &pl, DataModification modType);
|
||||
};
|
||||
|
||||
class ParticipantRegisterInExconRequest final : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantRegisterInExconRequest (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process() override;
|
||||
bool hasValidData() const override { return true; }
|
||||
}; // class ParticipantRegisterInExconRequest
|
||||
|
||||
|
||||
class ParticipantRegisterInExconReply : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantRegisterInExconReply(int exerciseId, qint32 participantId, ParticipantManagement::RegisterReturnValue retValue);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DataManager : public QObject
|
||||
, ParticipantManagement::Interface::Ftc::ModifyEquipmentTypeDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DataManager(const std::shared_ptr<IWMS2ECC_Impl> &wms2ecc, const std::shared_ptr<DdsHandler> &ddsHandler, const std::shared_ptr<ExercisesHandler> &exHandler);
|
||||
~DataManager();
|
||||
|
||||
bool init();
|
||||
|
||||
std::shared_ptr<IWMS2ECC_Impl> getWms2Ecc() { return m_wms2ecc; }
|
||||
void handleEquipmentTypes(const ::EquipmentTypes &eTypes);
|
||||
void registerParticipant(const Registration ®);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType, int exerciseId);
|
||||
void onExerciseChanged(const ExerciseManagement::Exercise &data, DataModification modType);
|
||||
void onRegistrationReturnValue(int exerciseId, qint32 participantId, ParticipantManagement::RegisterReturnValue retValue);
|
||||
|
||||
private Q_SLOTS:
|
||||
void openWebSocket();
|
||||
void closeWebSocket();
|
||||
void onWebSocketError(QAbstractSocket::SocketError error);
|
||||
void onWebSocketConnected();
|
||||
void onWebSocketDisconnected();
|
||||
|
||||
bool addEquipmentTypeRequest();
|
||||
bool sendAllExercises();
|
||||
bool sendAllParticipants();
|
||||
void newTextMessageFromClient(LtsWebSocket::ClientConnection *client, const QString &message);
|
||||
void onModifyEquipmentTypeDataReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private:
|
||||
|
||||
ClientMessageFactory *m_messageFactory;
|
||||
LtsWebSocket::ClientConnection *m_clientConnection;
|
||||
QTimer *m_wsReconnectTimer;
|
||||
std::shared_ptr<IWMS2ECC_Impl> m_wms2ecc;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<ExercisesHandler> m_exercisesHandler;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // namespace WarehouseManagement
|
||||
Reference in new issue
Block a user