// // ****************************************************************** // // /\ /| @File EdgePulse.h // // \ V/ @Brief // // | "") @Author lijinwen, ghz005@uni-trend.com.cn // // / | @Creation 2024-3-14 // // / \\ @Modified 2024-5-13 // // *(__\_\ // // ****************************************************************** #pragma once #include #include "BaseEnums/ProtocolEnums.h" #include "BaseEnums/EdgePulseEnums.h" namespace Protocol { //基结构体,仅用于继承,不会实际使用 struct EdgePulse { int32_t StartIndex = -1; //时域起始帧号 int32_t EndIndex = -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 CurrentLevel = TwoLevelEdgePulseStatusType::None; static uint32_t LevelCount() { return 2; } int32_t GetLength() const { return EndIndex > StartIndex && StartIndex > 0 ? EndIndex - StartIndex : 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 highLevel, bool lowLoglevel); //uint32_t LevelCount() const override { return 3; } static uint32_t LevelCount() { return 3; } explicit ThreeLevelEdgePulse(ThreeLevelEdgePulseStatusType current); ThreeLevelEdgePulseStatusType CurrentLevel = ThreeLevelEdgePulseStatusType::None; }; }