GlobalInfo.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #ifndef GLOBALINFO_H
  2. #define GLOBALINFO_H
  3. #include <mutex>
  4. /* 示波器通道 */
  5. enum class OscChannel
  6. {
  7. CH_A = 0,
  8. CH_B,
  9. };
  10. /* 示波器通道耦合方式 */
  11. enum class OscChannelCoupling
  12. {
  13. AC = 0,
  14. DC,
  15. };
  16. /* 示波器采样率,目前就只要这些 */
  17. enum class OscSampleRate
  18. {
  19. SR_49KHZ = 0,
  20. SR_96KHZ,
  21. SR_781KHZ,
  22. SR_12_5MHZ,
  23. SR_100MHZ,
  24. };
  25. /* 示波器通道的输入档位 */
  26. enum class OscChannelRange
  27. {
  28. CR_100MV = 0,
  29. CR_250MV,
  30. CR_500MV,
  31. CR_1V,
  32. CR_2V5,
  33. CR_5V,
  34. CR_8V,
  35. };
  36. /* 触发方式 */
  37. enum class OscTriggerMode
  38. {
  39. TM_RISE = 0, /* 上升沿触发 */
  40. TM_DOWN, /* 下降沿触发 */
  41. TM_DOUBLE, /* 双边沿触发 */
  42. };
  43. /* 触发灵敏度 */
  44. enum class OscTriggerSensitivity
  45. {
  46. TS_LOW = 0, /* 低灵敏度 */
  47. TS_HIGH, /* 高灵敏度 */
  48. };
  49. struct EyeDataT
  50. {
  51. bool isEyeData;
  52. unsigned char value;
  53. EyeDataT() : isEyeData(false), value(0) {}
  54. EyeDataT(bool isOpen, unsigned char val) : isEyeData(isOpen), value(val) {}
  55. EyeDataT& operator=(const EyeDataT& data)
  56. {
  57. isEyeData = data.isEyeData;
  58. value = data.value;
  59. return *this;
  60. }
  61. };
  62. /* 眼图数据点 */
  63. struct EyeDataSample
  64. {
  65. int x;
  66. int y;
  67. double fCnt;
  68. int Cnt;
  69. unsigned char data;
  70. EyeDataSample() : x(0), y(0), fCnt(0.0), Cnt(0), data(0) {}
  71. EyeDataSample(int x, int y, double fCnt, int Cnt, unsigned char data)
  72. : x(x), y(y), fCnt(fCnt), Cnt(Cnt), data(data) {}
  73. EyeDataSample& operator=(const EyeDataSample& data)
  74. {
  75. x = data.x;
  76. y = data.y;
  77. fCnt = data.fCnt;
  78. Cnt = data.Cnt;
  79. this->data = data.data;
  80. return *this;
  81. }
  82. };
  83. /**
  84. * @brief 眼图数据
  85. *
  86. */
  87. class EyeDataMatrix
  88. {
  89. public:
  90. EyeDataMatrix();
  91. ~EyeDataMatrix();
  92. EyeDataSample dataMatrix[1000][256];
  93. std::mutex mutexEyeData;
  94. void addData(int x, int y);
  95. void eyeStatisticalWeight();
  96. void eyeLessenTheBurden();
  97. EyeDataSample** eyeZoomOut();
  98. private:
  99. double eyenWeightCoefficient = 0.99;
  100. bool eyeIsLessenTheBurden = true;
  101. double eyenWeightCoefficientMIN = 1E-06;
  102. };
  103. extern EyeDataMatrix g_eyeDataMatrix;
  104. #endif /* GLOBALINFO_H */