modbus rtu 1.2
This commit is contained in:
@@ -12,12 +12,14 @@ DriverIngressAdapter::DriverIngressAdapter(std::shared_ptr<softbus::core::memory
|
||||
{
|
||||
}
|
||||
|
||||
bool DriverIngressAdapter::push(softbus::message_bus::pipeline::PipelineContext ctx)
|
||||
bool DriverIngressAdapter::push(softbus::core::models::RawBusMessage ctx)
|
||||
{
|
||||
if (!m_engine) {
|
||||
return false;
|
||||
}
|
||||
return m_engine->enqueueIngress(std::move(ctx));
|
||||
softbus::message_bus::pipeline::PipelineContext pipelineCtx;
|
||||
pipelineCtx.raw() = std::move(ctx);
|
||||
return m_engine->enqueueIngress(std::move(pipelineCtx));
|
||||
}
|
||||
|
||||
void DriverIngressAdapter::reportError(const QString& endpoint, const QString& error)
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
DriverIngressAdapter(std::shared_ptr<softbus::core::memory::MemoryPool> pool,
|
||||
softbus::message_bus::pipeline::PipelineEngine* engine);
|
||||
|
||||
bool push(softbus::message_bus::pipeline::PipelineContext ctx) override;
|
||||
bool push(softbus::core::models::RawBusMessage ctx) override;
|
||||
void reportError(const QString& endpoint, const QString& error) override;
|
||||
|
||||
softbus::core::memory::MemoryPool& pool() const { return *m_pool; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "message_bus/pipeline/PipelineContext.h"
|
||||
#include "core/models/RawBusMessage.h"
|
||||
|
||||
namespace softbus::message_bus::ingress
|
||||
{
|
||||
@@ -12,7 +12,7 @@ class IIngressPort
|
||||
public:
|
||||
virtual ~IIngressPort() = default;
|
||||
|
||||
virtual bool push(softbus::message_bus::pipeline::PipelineContext ctx) = 0;
|
||||
virtual bool push(softbus::core::models::RawBusMessage ctx) = 0;
|
||||
virtual void reportError(const QString& endpoint, const QString& error) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -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