Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/TrainingAreaBase/WebSocketInterface/Messages/reply_message.cpp
T
berrux-dev 84f8cfb41f Remove unused code from the Release 2 scope modules
Trim mostly-deletion changes (~700 lines) across the modules the Release
2 build compiles: unused telegrams and receiver/handler code in
TrainingAreaBase (telegrams, recv_from_dds_aes/fts, ism/main/pdm/position
handlers), dead members in SqlBrowser and ProjectDataManagement,
unused LtsPluginManager loader paths, LtsSession unit-test, WlsTetra and
DdsView cleanups, plus the stale include_directories removal in
Lts/CMakeLists.txt. Continues the Release 2 source prune (keep only what
the build compiles).

Excluded from this commit by design: the machine-specific .envrc
(MIGRATE_PIPELINE_ROOT path fix stays uncommitted) and the untracked
qt5-before/ reference tree.
2026-11-17 17:28:48 +01:00

114 lines
2.8 KiB
C++
Executable File

/**
* @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 Hannes Fritsche, SLSE, 2017-09-07
*/
#include "WebSocketInterface/Messages/reply_message.h"
#include "WebSocketInterface/json_keys.h"
#include <QtCore/QUuid>
#include <QtCore/QJsonDocument>
#include <QtGlobal>
namespace TrainingAreaBase
{
namespace WebSocketInterface
{
using namespace JsonKeys;
namespace Messages
{
QString ReplyMessage::toJsonString() const
{
return QString::fromUtf8(QJsonDocument(m_jsonRepresentation).toJson(QJsonDocument::Compact));
}
ReplyMessage::ReplyMessage(const QString &type, const int typeId, const QString &uuid)
: LtsWebSocket::ReplyMessage(type, typeId, uuid)
{
}
OkMessage::OkMessage(const OkMessage::OkData &data)
: ReplyMessage(OK(), 1, data.uuid)
{
m_jsonRepresentation.insert(DATA(),
QJsonObject({
{MESSAGE_TYPE(), data.messageType},
{INFO(), data.info}
}));
}
ErrorMessage::ErrorMessage(const ErrorMessage::ErrorData &data)
: ReplyMessage(ERROR_(), -1, data.uuid)
{
m_jsonRepresentation.insert(DATA(),
QJsonObject({
{ERROR_CLASS(), data.errorClass},
{ERROR_MESSAGE(), data.errorMessage}
}));
}
QJsonObject BiteDataMessage::ErrorText::toJson() const
{
return QJsonObject({{LANG(), lang},
{_TEXT(), text}
});
}
QJsonObject BiteDataMessage::ConfigurationError::toJson() const
{
return QJsonObject({{COMPONENT_NAME(), componentName},
{_TEXT(), text}
});
}
QJsonObject BiteDataMessage::BasicError::toJson() const
{
return QJsonObject({{ERROR_TEXT(), text}});
}
QJsonObject BiteDataMessage::BiteError::toJson() const
{
return QJsonObject({{ERROR_TEXT(), vecToPath(errorTexts)},
{DEVICE_ID(), deviceId},
{SUBDEVICE(), subDevice},
{UNIQUE_ID(), uniqueId},
{ERROR_NO(), errorNo},
});
}
BiteDataMessage::BiteDataMessage(const BiteDataMessage::BiteData &data, const QString &uuid)
: ReplyMessage(BITE_DATA(), 2, uuid)
{
m_jsonRepresentation.insert(DATA(),
QJsonObject({{EQUIP_NO(), data.equipNo},
{BOX(), data.box},
{LAST_UPDATE(), data.lastUpdate},
{BITE_ERRORS(), vecToPath(data.biteErrors)},
{CONFIGURATION_ERRORS(), vecToPath(data.configurationErrors)},
{BASIC_ERRORS(), vecToPath(data.basicErrors)},
{LAST_POSITION_UPDATE(), data.lastPositionUpdate},
{IS_LICENSED(), data.isLicensed}
}));
}
PositionMessage::PositionMessage(const PositionMessage::PositionData &data, const QString &uuid)
: ReplyMessage(POSITION_DATA(), 3, uuid)
{
m_jsonRepresentation.insert(DATA(),
QJsonObject({{EQUIP_NO(), data.equipNo},
{POS_LAT(), data.pos.lat},
{POS_LON(), data.pos.lon},
{POS_Z(), data.pos.z},
{LAST_POSITION_UPDATE(), data.gpsTime}
}));
}
}
}
}