dommessage
This commit is contained in:
@@ -50,7 +50,9 @@ public:
|
||||
const auto addr = static_cast<std::uint16_t>(baseAddress + static_cast<std::uint16_t>(i));
|
||||
const auto compKey = buildCompositeKey(
|
||||
rawContext.endpointHash, rawContext.protocol, resp->unitId, addr);
|
||||
const auto mapRule = m_context.mappingLookup ? m_context.mappingLookup->find(compKey) : std::nullopt;
|
||||
const auto mapRule = m_context.mappingLookup
|
||||
? m_context.mappingLookup->find(rawContext, compKey)
|
||||
: std::nullopt;
|
||||
const double rawValue = static_cast<double>(resp->registers[static_cast<qsizetype>(i)]);
|
||||
if (!mapRule.has_value()) {
|
||||
if (m_context.discoverySink) {
|
||||
@@ -64,8 +66,10 @@ public:
|
||||
rec.lastSeenMs = rawContext.timestampMs;
|
||||
m_context.discoverySink->reportUnmapped(rec);
|
||||
}
|
||||
// 无 metadata 映射时仍产出 DOM,便于 DynamicRuleRegistry 的 transform 等下游逻辑生效
|
||||
// (compositeKey 仍按与映射表相同的算法计算,便于后续在 UI 里绑定映射)
|
||||
const bool sniff = m_context.sniffingEnabled ? m_context.sniffingEnabled() : false;
|
||||
if (!sniff) {
|
||||
continue;
|
||||
}
|
||||
softbus::core::models::DOMMessage pass;
|
||||
pass.messageId = QStringLiteral("modbus.unmapped:%1").arg(compKey);
|
||||
pass.timestamp = rawContext.timestampMs;
|
||||
@@ -81,6 +85,8 @@ public:
|
||||
}
|
||||
softbus::core::models::DOMMessage msg;
|
||||
msg.messageId = mapRule->domPath;
|
||||
msg.pointId = mapRule->pointId.isEmpty() ? mapRule->domPath : mapRule->pointId;
|
||||
msg.metadataId = mapRule->metadataId;
|
||||
msg.timestamp = rawContext.timestampMs;
|
||||
msg.value = (rawValue * mapRule->scale) + mapRule->offset;
|
||||
msg.quality = softbus::core::models::DataQuality::GOOD;
|
||||
@@ -88,6 +94,7 @@ public:
|
||||
msg.attributes.insert(QStringLiteral("compositeKey"), QString::number(compKey));
|
||||
msg.attributes.insert(QStringLiteral("slaveId"), static_cast<int>(resp->unitId));
|
||||
msg.attributes.insert(QStringLiteral("registerAddress"), static_cast<int>(addr));
|
||||
msg.attributes.insert(QStringLiteral("mappingSource"), mapRule->sourceTag);
|
||||
if (!mapRule->unit.isEmpty()) {
|
||||
msg.attributes.insert(QStringLiteral("unit"), mapRule->unit);
|
||||
}
|
||||
@@ -142,4 +149,3 @@ softbus::core::plugin_system::IProtocolMapperPlugin* createModbusRtuProtocolMapp
|
||||
}
|
||||
|
||||
} // namespace softbus::message_bus::pipeline::protocol::modbusrtu
|
||||
|
||||
|
||||
Reference in New Issue
Block a user