modbus rtu 1.2
This commit is contained in:
@@ -1,14 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// 定义管道上下文 包含设备ID、端点、时间戳、协议提示、跟踪ID、有效载荷、有效载荷大小
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
#include "message_bus/pipeline/PayloadRef.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::pipeline
|
||||
{
|
||||
@@ -19,29 +14,14 @@ enum class FrameKind
|
||||
CompleteFrame,
|
||||
};
|
||||
|
||||
enum class BusDirection
|
||||
using BusDirection = softbus::core::models::BusDirection;
|
||||
|
||||
struct PipelineContext : public softbus::core::models::RawBusMessage
|
||||
{
|
||||
Unknown,
|
||||
Upstream,
|
||||
Downstream,
|
||||
};
|
||||
|
||||
struct PipelineContext
|
||||
{
|
||||
int deviceId{-1}; // 设备ID
|
||||
QString stableKey;
|
||||
QString endpoint; // 端点
|
||||
QDateTime timestamp{QDateTime::currentDateTimeUtc()}; // 时间戳
|
||||
QString protocolHint; // 协议提示
|
||||
QString traceId; // 跟踪ID
|
||||
|
||||
PayloadRef payload; // 有效载荷
|
||||
std::size_t payloadSize{0}; // 有效载荷大小
|
||||
|
||||
FrameKind frameKind{FrameKind::StreamChunk};
|
||||
BusDirection direction{BusDirection::Unknown};
|
||||
std::uint64_t frameSeq{0};
|
||||
|
||||
softbus::core::models::RawBusMessage& raw() { return *this; }
|
||||
const softbus::core::models::RawBusMessage& raw() const { return *this; }
|
||||
};
|
||||
|
||||
} // namespace softbus::message_bus::pipeline
|
||||
|
||||
@@ -113,9 +113,11 @@ void PipelineEngine::start()
|
||||
// 合并队列是用来存储合并的帧的
|
||||
// 合并线程是用来处理合并的帧的
|
||||
if (m_rtConfig.parallelPipeline) {
|
||||
m_framedQ = std::make_unique<softbus::core::threading::MutexQueue<PipelineContext>>(
|
||||
m_rtConfig.framedQueueMax);
|
||||
m_framedQ = std::make_unique<softbus::core::threading::MutexQueue<PipelineContext>>(m_rtConfig.framedQueueMax);
|
||||
for (int i = 0; i < m_rtConfig.parseWorkerCount; ++i) {
|
||||
// 创建解析线程 解析线程从帧队列中取出帧 进行处理
|
||||
// emplace_back 是用来创建解析线程的 参数是 lambda 表达式
|
||||
// [this]() { parseWorkerLoop(); } 是一个 lambda 表达式 用来创建解析线程
|
||||
m_parseThreads.emplace_back([this]() { parseWorkerLoop(); });
|
||||
}
|
||||
if (m_rtConfig.orderedEgress) {
|
||||
@@ -503,7 +505,7 @@ std::vector<softbus::core::models::DOMMessage> PipelineEngine::stage2Parser(cons
|
||||
parserSession = it.value();
|
||||
}
|
||||
softbus::message_bus::pipeline::protocol::ProtocolEnvelope envelope; // 协议封装
|
||||
if (!parserSession->parse(ctx, envelope)) {
|
||||
if (!parserSession->parse(ctx.raw(), envelope)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user