Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+192
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* @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 "WsBaseDataInterface/Messages/reply_message.h"
|
||||
#include "WsBaseDataInterface/data_manager.h"
|
||||
|
||||
#include <WMS_Interface/json_keys.h>
|
||||
#include <LtsWebSocket/json_keys.h>
|
||||
|
||||
#include <WMS_Interface/wms_ecc_exercises.h>
|
||||
#include <WMS_Interface/wms_ecc_playerInfo.h>
|
||||
#include <WMS_Interface/wms_ecc_registration.h>
|
||||
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
namespace WarehouseGuez
|
||||
{
|
||||
namespace WsBaseDataInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
// ####### ClientMessageFactory begin #######
|
||||
ClientMessageFactory::ClientMessageFactory(DataManager *dataManager)
|
||||
: LtsWebSocket::AbstractClientMessageFactory(getLogger("BiteClientMessageFactory"))
|
||||
, 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 == LtsWebSocket::JsonKeys::ERROR_())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error in message: " << message;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::EQUIPMENT_TYPES_REQUEST())
|
||||
result = new EquipmentTypesRequest(m_dataManager, client, m_type, m_typeId, m_uuid);
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::EXERCISE_UPDATE())
|
||||
result = new ExerciseUpdate(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::EXERCISES_REPLY())
|
||||
result = new ExercisesReply(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::PARTICIPANTS_UPDATE())
|
||||
result = new ParticipantsUpdate(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::PARTICIPANTS_REPLY())
|
||||
result = new ParticipantsReply(m_dataManager, client, m_type, m_typeId, m_uuid, m_data);
|
||||
if (m_type == ::WebSocketInterface::JsonKeys::PARTICIPANT_REGISTER_IN_EXCON_REPLY())
|
||||
result = new ParticipantRegisterInExconReply(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 #######
|
||||
|
||||
// ####### EquipmentTypesRequest begin #######
|
||||
EquipmentTypesRequest::EquipmentTypesRequest(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, QJsonValue())
|
||||
{}
|
||||
|
||||
void EquipmentTypesRequest::process()
|
||||
{
|
||||
m_client->addReply(m_dataManager->equipmentTypes(m_uuid));
|
||||
}
|
||||
|
||||
bool EquipmentTypesRequest::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### EquipmentTypesRequest end #######
|
||||
|
||||
// ####### ExercisesReply begin #######
|
||||
ExercisesReply::ExercisesReply(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, data)
|
||||
{}
|
||||
|
||||
void ExercisesReply::process()
|
||||
{
|
||||
EXCON::Exercises ex = EXCON::Exercises::fromJsonAll(m_data.toObject());
|
||||
m_dataManager->newExerciseInformationsFromEXCON(ex);
|
||||
}
|
||||
|
||||
bool ExercisesReply::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ExercisesReply end #######
|
||||
|
||||
|
||||
// ####### ExercisesReply begin #######
|
||||
ExerciseUpdate::ExerciseUpdate(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, data)
|
||||
{}
|
||||
|
||||
void ExerciseUpdate::process()
|
||||
{
|
||||
const QJsonObject obj = m_data.toObject();
|
||||
DataModification modType = (DataModification) obj[::WebSocketInterface::JsonKeys::DATA_MODIFICATION()].toInt();
|
||||
IWMS2ECC::Exercise exeData = EXCON::Exercises::fromJson(obj);
|
||||
m_dataManager->exerciseChanged(exeData, modType);
|
||||
}
|
||||
|
||||
bool ExerciseUpdate::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ExerciseUpdate end #######
|
||||
|
||||
|
||||
|
||||
// ####### ParticipantsReply begin #######
|
||||
ParticipantsReply::ParticipantsReply(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, data)
|
||||
{}
|
||||
|
||||
void ParticipantsReply::process()
|
||||
{
|
||||
PlayerInfo pl = PlayerInfo::fromJsonAll(m_data.toObject());
|
||||
m_dataManager->participantsFromEXCON(pl);
|
||||
}
|
||||
|
||||
bool ParticipantsReply::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ParticipantsReply end #######
|
||||
|
||||
// ####### ParticipantsUpdate begin #######
|
||||
ParticipantsUpdate::ParticipantsUpdate(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, data)
|
||||
{}
|
||||
|
||||
void ParticipantsUpdate::process()
|
||||
{
|
||||
const QJsonObject obj = m_data.toObject();
|
||||
int modType = obj[::WebSocketInterface::JsonKeys::DATA_MODIFICATION()].toInt();
|
||||
IWMS2ECC::PlayerInfo pl = PlayerInfo::fromJson(obj);
|
||||
m_dataManager->participantFromEXCON(pl, modType);
|
||||
}
|
||||
|
||||
bool ParticipantsUpdate::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ParticipantsUpdate end #######
|
||||
|
||||
// ####### ParticipantRegisterInExconReply begin #######
|
||||
ParticipantRegisterInExconReply::ParticipantRegisterInExconReply(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage (dataManager,client, type, typeId, uuid, data)
|
||||
{}
|
||||
|
||||
void ParticipantRegisterInExconReply::process()
|
||||
{
|
||||
const QJsonObject obj = m_data.toObject();
|
||||
int exerciseId = obj[::WebSocketInterface::JsonKeys::EXERCISE_ID()].toInt();
|
||||
qint32 participantId = obj[::WebSocketInterface::JsonKeys::PARTICIPANT_ID()].toInt();
|
||||
int returnValue = obj[::WebSocketInterface::JsonKeys::REGISTRATION_RETURN_VALUE()].toInt();
|
||||
//qWarning() << "exerciseId: " << exerciseId << ", participantId: " << participantId << ", retValue: " << returnValue;
|
||||
|
||||
m_dataManager->registerReply(exerciseId, participantId, returnValue);
|
||||
}
|
||||
|
||||
bool ParticipantRegisterInExconReply::hasValidData() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// ####### ParticipantRegisterInExconReply end #######
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WsBiteInterface
|
||||
} // namespace WarehouseGuez
|
||||
@@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @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"
|
||||
#include <WMS_Interface/json_keys.h>
|
||||
|
||||
// incoming messages
|
||||
|
||||
namespace WarehouseGuez
|
||||
{
|
||||
namespace WsBaseDataInterface
|
||||
{
|
||||
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);
|
||||
|
||||
protected: // attributes
|
||||
DataManager *m_dataManager;
|
||||
}; // class ClientMessage
|
||||
|
||||
// ################## Message Implementations ##################
|
||||
class EquipmentTypesRequest : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit EquipmentTypesRequest (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class EquipmentTypesRequest
|
||||
|
||||
// Client -> Server - answer to ExercisesRequest or information from Client that a specific exercise changed
|
||||
// -> then there is only one exercise in the message
|
||||
class ExercisesReply : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ExercisesReply (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ExercisesReply
|
||||
|
||||
class ExerciseUpdate : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ExerciseUpdate (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ExerciseUpdate
|
||||
|
||||
|
||||
class ParticipantsReply : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantsReply (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ParticipantsReply
|
||||
|
||||
class ParticipantsUpdate : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantsUpdate (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ParticipantsUpdate
|
||||
|
||||
class ParticipantRegisterInExconReply : public ClientMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantRegisterInExconReply (DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ParticipantRegisterInExconReply
|
||||
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WsBiteInterface
|
||||
} // namespace WarehouseGuez
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* @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 <WMS_Interface/json_keys.h>
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
||||
namespace WarehouseGuez
|
||||
{
|
||||
namespace WsBaseDataInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
using namespace LtsWebSocket::JsonKeys;
|
||||
|
||||
ExerciseRequest::ExerciseRequest()
|
||||
: LtsWebSocket::ReplyMessage(::WebSocketInterface::JsonKeys::EXERCISES_REQUEST(), 1, QStringLiteral("drei")) // Todo: Check whether typeId is correct
|
||||
{}
|
||||
|
||||
ParticipantsRequest::ParticipantsRequest(int exerciseId)
|
||||
: LtsWebSocket::ReplyMessage(::WebSocketInterface::JsonKeys::PARTICIPANTS_REQUEST(), 2, QStringLiteral("drei")) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation[::WebSocketInterface::JsonKeys::EXERCISE_ID()] = exerciseId;
|
||||
}
|
||||
|
||||
// ####### EquipmentTypesMessage begin #######
|
||||
EquipmentTypesMessage::EquipmentTypesMessage(const QJsonObject &data, const QString &uuid)
|
||||
: ReplyMessage (::WebSocketInterface::JsonKeys::EQUIPMENT_TYPES_REPLY(), 3, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### EquipmentTypesMessage end #######
|
||||
|
||||
// ####### ParticipantRegisterInExconRequest begin #######
|
||||
ParticipantRegisterInExconRequest::ParticipantRegisterInExconRequest(const QJsonObject &data, const QString &uuid)
|
||||
: ReplyMessage (::WebSocketInterface::JsonKeys::PARTICIPANT_REGISTER_IN_EXCON_REQUEST(), 4, uuid) // Todo: Check whether typeId is correct
|
||||
{
|
||||
m_jsonRepresentation.insert(DATA(), data);
|
||||
}
|
||||
// ####### ParticipantRegisterInExconRequest end #######
|
||||
|
||||
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WsBaseDataInterface
|
||||
} // namespace WarehouseGuez
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @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>
|
||||
|
||||
|
||||
// outgoing messages
|
||||
// ReplyMessage -> MessageToSend
|
||||
|
||||
namespace WarehouseGuez
|
||||
{
|
||||
namespace WsBaseDataInterface
|
||||
{
|
||||
namespace Messages
|
||||
{
|
||||
|
||||
// WHG -> WMS - requesting data for all exercises
|
||||
class ExerciseRequest : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
ExerciseRequest();
|
||||
};
|
||||
|
||||
class ParticipantsRequest : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantsRequest(int exerciseId);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The EquipmentTypesMessage class represents the equipment types from the svcWarehouseGuez
|
||||
*/
|
||||
class EquipmentTypesMessage final : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
|
||||
explicit EquipmentTypesMessage (const QJsonObject &data, const QString &uuid);
|
||||
}; // class EquipmentTypesMessage
|
||||
|
||||
// ReplyMessage -> message to send
|
||||
class ParticipantRegisterInExconRequest : public LtsWebSocket::ReplyMessage
|
||||
{
|
||||
public:
|
||||
explicit ParticipantRegisterInExconRequest(const QJsonObject &data, const QString &uuid);
|
||||
|
||||
void process();
|
||||
bool hasValidData() const;
|
||||
|
||||
}; // class ParticipantRegisterRequest
|
||||
|
||||
} // namespace Messages
|
||||
} // namespace WsBaseDataInterface
|
||||
} // namespace WarehouseGuez
|
||||
|
||||
Reference in new issue
Block a user