dommessage

This commit is contained in:
flower_linux
2026-04-28 21:56:56 +08:00
parent 7459cc0f36
commit 7280fca08d
24 changed files with 848 additions and 115 deletions

View 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