dommessage
This commit is contained in:
44
src/message_bus/pipeline/derivation/DerivationEngine.cpp
Normal file
44
src/message_bus/pipeline/derivation/DerivationEngine.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "message_bus/pipeline/derivation/DerivationEngine.h"
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace softbus::message_bus::pipeline::derivation
|
||||
{
|
||||
|
||||
DerivationEngine& DerivationEngine::instance()
|
||||
{
|
||||
static DerivationEngine eng;
|
||||
return eng;
|
||||
}
|
||||
|
||||
void DerivationEngine::deriveFromEnriched(const softbus::core::models::EnrichedMessage& in,
|
||||
std::vector<softbus::core::models::EnrichedMessage>& outAppend) const
|
||||
{
|
||||
if (!m_enabled) {
|
||||
return;
|
||||
}
|
||||
if (!in.attributes.value(QStringLiteral("sb.deriveMirror")).toBool()) {
|
||||
return;
|
||||
}
|
||||
const QString srcPoint = in.attributes.value(QStringLiteral("pointId")).toString();
|
||||
if (srcPoint.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// MVP:若存在派生后缀配置则复制一份工程值到派生点(示例约定:pointId + ".mirror")
|
||||
const QString mirrorId = srcPoint + QStringLiteral(".mirror");
|
||||
softbus::core::models::EnrichedMessage derived;
|
||||
derived.sourceMessageId = mirrorId;
|
||||
derived.logicalName = in.logicalName + QStringLiteral(" (derived)");
|
||||
derived.unit = in.unit;
|
||||
derived.engineeringValue = in.engineeringValue;
|
||||
derived.quality = in.quality;
|
||||
derived.attributes = in.attributes;
|
||||
derived.traceLog = in.traceLog;
|
||||
derived.attributes.insert(QStringLiteral("pointId"), mirrorId);
|
||||
derived.attributes.insert(QStringLiteral("derivedFrom"), QJsonArray{srcPoint});
|
||||
derived.attributes.insert(QStringLiteral("derivationRuleId"), QStringLiteral("builtin.mirror"));
|
||||
derived.attributes.insert(QStringLiteral("derivationVersion"), QStringLiteral("1"));
|
||||
outAppend.push_back(std::move(derived));
|
||||
}
|
||||
|
||||
} // namespace softbus::message_bus::pipeline::derivation
|
||||
Reference in New Issue
Block a user