123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // // ******************************************************************
- // // /\ /| @File EdgePulse.cpp
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-06-05
- // // *(__\_\
- // // ******************************************************************
- #include "EdgePulse.h"
- namespace Protocol
- {
- // int32_t EdgePulse::GetLength() const
- // {
- // return EndIndex > StartIndex && StartIndex > 0 ? EndIndex - StartIndex : 0;
- // }
- // TwoLevelEdgePulse::TwoLevelEdgePulse(TwoLevelEdgePulseStatusType current)
- // {
- // CurrentLevel = current;
- // }
- ThreeLevelEdgePulseStatusType ThreeLevelEdgePulse::ConvertToStatus(const bool high_level, const bool low_loglevel)
- {
- return static_cast<ThreeLevelEdgePulseStatusType>((high_level ? 1 : 0) << 1 | (low_loglevel ? 1 : 0));
- }
- ThreeLevelEdgePulse::ThreeLevelEdgePulse(ThreeLevelEdgePulseStatusType current)
- {
- CurrentLevel = current;
- }
- bool CheckNodeValid(const EdgePulse* edge)
- {
- if (edge == nullptr)
- {
- return false;
- }
- return CheckNodeValid(edge[0]);
- }
- bool CheckNodeValid(EdgePulse edge)
- {
- if (edge.StartIndex < 0 || edge.EndIndex < 0 || edge.EndIndex <= edge.StartIndex
- || edge.Edge == Edge::None)
- {
- return false;
- }
- return true;
- }
- void ReversalLevel(Edge& edge)
- {
- if (edge == Edge::Falling)
- {
- edge = Edge::Rise;
- }
- else if (edge == Edge::Rise)
- {
- edge = Edge::Falling;
- }
- }
- void ReversalLevel(std::vector<Protocol::EdgePulse>& edge_pulses)
- {
- for (int i = 0; i < static_cast<int>(edge_pulses.size()); i++)
- {
- ReversalLevel(edge_pulses[i].Edge);
- }
- }
- }
|