Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/TrainingAreaBase/WebSocketInterface/Messages/reply_message.cpp
T
berrux-dev cfe15c72c4 Merge story/release-validation-scope
Bring the validation-scope line (in-tree Jenkins CI copy, lcov coverage
wiring, step-by-step release-scope README, TetraIF unit tests, the
LogView runtime icon/resource fix, Dockerfile, rpmbuild and the
new_docker_build.sh driver with the DEB output path) on top of the
XmlPatterns branch pruned to the Release 2 scope.

Conflict policy:
- Out-of-scope targets/modules: keep the prune (deletion wins).
- In-scope files that validation had deleted: restored from
  story/release-2-cleanup (the Release 2 closure, with the
  pruned-module guards).
- In-scope sources carrying migration work: XmlPatterns versions
  (Qt XmlPatterns rework on QDomDocument, DDS member and logger
  fixes, first-build fixes).
- Scope-aware CMakeLists (top level, PluginInterfaces, LtsWidgets)
  and .envrc: story/release-2-cleanup / ours versions.
2026-11-16 18:49:14 +01:00

129 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}
}));
}
}
}
}