12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- // // ******************************************************************
- // // /\ /| @File edge_pulse.h
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-06-24
- // // *(__\_\
- // // ******************************************************************
- #pragma once
- #include <cstdint>
- #include "BaseEnums/protocol_enums.h"
- #include "BaseEnums/edge_pulse_enums.h"
- namespace Protocol
- {
- //基结构体,仅用于继承,不会实际使用
- struct EdgePulse
- {
- int32_t start_index = -1; //时域起始帧号
- int32_t end_index = -1; //时域结束帧号
- Edge edge = Edge::NONE; //边沿类型 上升 or 下降
- // virtual uint32_t LevelCount() const { return 0; } //电平数量 2or3
- // virtual int32_t GetLength() const; //时域长度
- // virtual ~EdgePulse() = default;
- };
- //双电平边沿脉宽
- struct TwoLevelEdgePulse final : EdgePulse
- {
- //电平类型 Low, High, None,
- TwoLevelEdgePulseStatusType current_level = TwoLevelEdgePulseStatusType::None;
- static uint32_t LevelCount() { return 2; }
- int32_t GetLength() const
- {
- return end_index > start_index && start_index >= 0 ? end_index - start_index : 0;
- }
- // uint32_t LevelCount() const override { return 2; }
- //
- // int32_t GetLength() const override
- // {
- // return EndIndex > StartIndex && StartIndex > 0 ? EndIndex - StartIndex : 0;
- // }
- //
- // explicit TwoLevelEdgePulse(TwoLevelEdgePulseStatusType current);
- };
- //三电平边沿脉宽
- struct ThreeLevelEdgePulse final : EdgePulse
- {
- //电平类型 High = 0b11,Middle = 0b01,Low = 0b00,None = 0b10,
- static ThreeLevelEdgePulseStatusType ConvertToStatus(bool high_level, bool low_loglevel);
- //uint32_t LevelCount() const override { return 3; }
- static uint32_t LevelCount() { return 3; }
- explicit ThreeLevelEdgePulse(ThreeLevelEdgePulseStatusType current);
- ThreeLevelEdgePulseStatusType current_level = ThreeLevelEdgePulseStatusType::None;
- };
- //初查节点有效
- bool CheckNodeValid(const EdgePulse* edge);
- //初查节点有效
- bool CheckNodeValid(EdgePulse edge);
- //电平反转
- void ReversalLevel(Edge& edge);
- //电平反转
- void ReversalLevel(std::vector<EdgePulse>& edge_pulses);
-
- }
|