rs232_decoder.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // // ******************************************************************
  2. // // /\ /| @File rs232_decoder.h
  3. // // \ V/ @Brief
  4. // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
  5. // // / | @Creation 2024-06-26
  6. // // / \\ @Modified 2024-07-16
  7. // // *(__\_\
  8. // // ******************************************************************
  9. #pragma once
  10. #include <cstdint>
  11. #include <future>
  12. #include "../BaseHelper/common_helper.h"
  13. // #include "../CommonBase/EnumTypeInfo.h"
  14. #include "../edge_pulse_data.h"
  15. // #include "Constants.h"
  16. #include "protocol_rs232_enums.h"
  17. #include "rs232_decode_result.h"
  18. //#include "rs232_packet.h"
  19. #include "../protocol_decode_base.h"
  20. #include "protocol_rs232_options.h"
  21. #include "../BaseHelper/loger.h"
  22. namespace Protocol
  23. {
  24. class Rs232Decoder
  25. {
  26. public:
  27. std::vector<const char*> GetEventInfoTitles();
  28. bool DecodeRs232(const ProtocolRs232Options& options, TwoLevelEdgePulse* edge_pulses,
  29. uint64_t edge_pulse_count,
  30. uint64_t waveform_data_count, double sample_rate,
  31. Rs232DecodeResult& decode_result);
  32. bool QuantizeParamsDecodeRs232(const QuantizeParams& quantize_params, const ProtocolRs232Options& options,
  33. Rs232DecodeResult& decode_result);
  34. private:
  35. bool* is_cancel_ptr_ = nullptr;
  36. std::vector<const char*> event_info_titles_ = {
  37. "Index", "Start Time", "Data", "Parity", "Error"
  38. };
  39. std::vector<Rs232DecodeResultCell> decode_result_units_;
  40. std::vector<Rs232DecodeEventUnit> decode_event_units_storage_;
  41. std::vector<Rs232DecodeEvent> decode_events_;
  42. static bool GetRs232Bit(TwoLevelEdgePulse*& edge_pulse,
  43. int32_t target_index, TwoLevelEdgePulseStatusType& status);
  44. static int32_t GetStartIndex(const ProtocolRs232Options& options, TwoLevelEdgePulse*& node,
  45. double count,
  46. double& real_count,
  47. int32_t start_index,
  48. TwoLevelEdgePulseStatusType& start_status);
  49. bool ParseRs232(const ProtocolRs232Options& options,
  50. const EdgePulseDataTwoLevels& edge_pulse_data,
  51. Rs232DecodeResult& decode_result);
  52. };
  53. }