RS232Decode.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // // ******************************************************************
  2. // // /\ /| @File RS232Decode.h
  3. // // \ V/ @Brief
  4. // // | "") @Author lijinwen, ghz005@uni-trend.com.cn
  5. // // / | @Creation 2024-5-7
  6. // // / \\ @Modified 2024-5-13
  7. // // *(__\_\
  8. // // ******************************************************************
  9. #pragma once
  10. #include <cstdint>
  11. #include <future>
  12. //#include <mutex>
  13. #include "../BaseHelper/CommonHelper.h"
  14. // #include "../CommonBase/EnumTypeInfo.h"
  15. #include "../EdgePulseData.h"
  16. // #include "Constants.h"
  17. #include "ProtocolRS232Enums.h"
  18. #include "RS232Params.h"
  19. #include "RS232DecodeResult.h"
  20. //#include "RS232Packet.h"
  21. #include "../ProtocolDecodeBase.h"
  22. #include "../BaseHelper/Logger.h"
  23. namespace Protocol::ProtocolRS232
  24. {
  25. class RS232Decode : public ProtocolDecodeBase
  26. {
  27. private:
  28. static bool GetRS232Bit(TwoLevelEdgePulse*& edgePulse,
  29. int32_t targetIndex, TwoLevelEdgePulseStatusType& status);
  30. std::vector<const char*> EventInfoTitles_ = {
  31. "Index", "Start Time", "Data", "Parity", "Error"
  32. };
  33. std::vector<const char*> GetEventInfoTitles();
  34. static int32_t GetStartIndex(const RS232DecodeParams& options, TwoLevelEdgePulse*& node,
  35. double count,
  36. double& realCount,
  37. int32_t startIndex,
  38. TwoLevelEdgePulseStatusType& startStatus);
  39. bool ParseData(const RS232DecodeParams& options);
  40. //与对象生命周期一样长的数据存储
  41. RS232DecodeResult RS232DecodeResult_ = {};
  42. DecodeResult DecodeResultBase_ = {};
  43. std::vector<RS232DecodeResultUnit> DecodeResultUnits_;
  44. std::vector<RS232DecodeEventUnit> DecodeEventUnitsStorage_;
  45. std::vector<RS232DecodeEvent> DecodeEvents_;
  46. std::vector<RS232Packet> RS232Packets_;
  47. protected:
  48. void Decode(const DecodeParams* decodeParams) override;
  49. void QuantizeDecode(const QuantizeParams& decodeParams) override;
  50. public:
  51. DecodeResult* GetResult() override;
  52. ~RS232Decode() override;
  53. };
  54. //
  55. // //外部调用
  56. // extern "C" {
  57. // inline __declspec(dllexport) bool DecodeRS232Export(RS232Decode* decoder, const RS232DecodeParams& options);
  58. // }
  59. }