12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // // ******************************************************************
- // // /\ /| @File edge_pulse.cc
- // // \ V/ @Brief
- // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
- // // / | @Creation 2024-05-16
- // // / \\ @Modified 2024-06-24
- // // *(__\_\
- // // ******************************************************************
- #include "edge_pulse.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(const ThreeLevelEdgePulseStatusType current)
- {
- current_level = current;
- }
- bool CheckNodeValid(const EdgePulse* edge)
- {
- if (edge == nullptr)
- {
- return false;
- }
- return CheckNodeValid(edge[0]);
- }
- bool CheckNodeValid(const EdgePulse edge)
- {
- if (edge.start_index < 0 || edge.end_index < 0 || edge.end_index <= edge.start_index
- || edge.edge == Edge::NONE)
- {
- return false;
- }
- return true;
- }
- void ReversalLevel(Edge& edge)
- {
- if (edge == Edge::FALL)
- {
- edge = Edge::RISE;
- }
- else if (edge == Edge::RISE)
- {
- edge = Edge::FALL;
- }
- }
- void ReversalLevel(std::vector<EdgePulse>& edge_pulses)
- {
- for (int i = 0; i < static_cast<int>(edge_pulses.size()); i++)
- {
- ReversalLevel(edge_pulses[i].edge);
- }
- }
-
- }
|