// // ****************************************************************** // // /\ /| @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((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& edge_pulses) { for (int i = 0; i < static_cast(edge_pulses.size()); i++) { ReversalLevel(edge_pulses[i].edge); } } }