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,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