ChannelParam.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef _CHANNEL_PARAM_H_
  2. #define _CHANNEL_PARAM_H_
  3. /* =========================================================================================
  4. * 宏定义
  5. * =========================================================================================*/
  6. // 1秒钟30个音量值,相位值同样是30个
  7. #define VOLUME_INFO_NUM 30
  8. // 音量有效范围
  9. #define VOLUME_MAX_BD 0
  10. #define VOLUME_MIN_BD -90
  11. // 反相值范围
  12. #define REVERSED_MAX_VALUE 100
  13. #define REVERSED_MIN_VALUE -100
  14. // 数据库字符串长度
  15. #define DB_VARCHAR_LEN 32
  16. // 一次比较最多可得到多少个值(相似度)
  17. #define RESULT_NUM_OF_ONETIME_COMPARE 1
  18. /************************** 缩放比较相关宏 **************************/
  19. // 静音默认值
  20. #define SILENCE_DEF_VALUE true
  21. // 最大缓存180秒,3分钟
  22. #define CACHE_DATA_SECOND_MAX 180
  23. /**
  24. * @brief 音量设置参数
  25. *
  26. */
  27. struct StVolumeParam
  28. {
  29. StVolumeParam();
  30. StVolumeParam(const StVolumeParam& obj);
  31. StVolumeParam& operator=(const StVolumeParam& obj);
  32. void Init();
  33. /* -------------------- 静音 -------------------- */
  34. void SetSilentSwitch(bool b) { m_bSilentSwitch = b; }
  35. // 静音持续时间为0不进行静音判定
  36. bool GetSilentSwitch() const { return m_bSilentSwitch && m_iSilentDuration > 0; }
  37. int GetSilentThreshold() const { return m_iSilentThreshold; }
  38. void SetSilentThreshold(int ival) { m_iSilentThreshold = ival; }
  39. int GetSilentDuration() const { return m_iSilentDuration; }
  40. void SetSilentDuration(int ival) { m_iSilentDuration = ival; }
  41. int GetSilentNum() const;
  42. int GetSilentSensitivity() const { return m_nSilentSensitivity; }
  43. void SetSilentSensitivity(int ival) { m_nSilentSensitivity = ival; }
  44. /* -------------------- 过载 -------------------- */
  45. void SetOverloadSwitch(bool b) { m_bOverloadSwitch = b; }
  46. bool GetOverloadSwitch() const { return m_bOverloadSwitch && m_iOverloadDuration > 0; }
  47. int GetOverloadThreshold() const { return m_iOverloadThreshold; }
  48. void SetOverloadThreshold(int ival) { m_iOverloadThreshold = ival; }
  49. int GetOverloadDuration() const { return m_iOverloadDuration; }
  50. void SetOverloadDuration(int ival) { m_iOverloadDuration = ival; }
  51. int GetOverloadSensitivity() const { return m_nOverloadSensitivity; }
  52. void SetOverloadSensitivity(int ival) { m_nOverloadSensitivity = ival; }
  53. int GetOverloadNum() const;
  54. /* -------------------- 反相 -------------------- */
  55. void SetPhaseSwitch(bool b) { m_bPhaseSwitch = b; }
  56. bool GetPhaseSwitch() const { return m_bPhaseSwitch && m_iPhaseSensitivity > 0; }
  57. float GetPhaseThreshold() const { return m_iPhaseThreshold; }
  58. void SetPhaseThreshold(float ival) { m_iPhaseThreshold = ival; }
  59. int GetPhaseDuration() const { return m_iPhaseDuration; }
  60. void SetPhaseDuration(int ival) { m_iPhaseDuration = ival; }
  61. int GetPhaseSensitivity() const { return m_iPhaseSensitivity; }
  62. void SetPhaseSensitivity(int ival) { m_iPhaseSensitivity = ival; }
  63. int GetPhaseNum() const;
  64. int GetNoiseDuration() const { return 3; }
  65. private:
  66. /* -------------------- 静音 -------------------- */
  67. // 静音监测开关
  68. bool m_bSilentSwitch;
  69. int m_iSilentThreshold;
  70. // 持续时间(秒)
  71. int m_iSilentDuration;
  72. // 过载灵敏度(百分比)
  73. int m_nSilentSensitivity;
  74. /* -------------------- 过载 -------------------- */
  75. // 过载监测开关
  76. bool m_bOverloadSwitch;
  77. int m_iOverloadThreshold;
  78. // 持续时间(秒)
  79. int m_iOverloadDuration;
  80. // 过载灵敏度(百分比)
  81. int m_nOverloadSensitivity;
  82. /* -------------------- 反相 -------------------- */
  83. // 反相监测开关
  84. bool m_bPhaseSwitch;
  85. // 反相阀值(-1.0 – 1.0)
  86. float m_iPhaseThreshold;
  87. // 持续时间(秒)
  88. int m_iPhaseDuration;
  89. // 反相灵敏度(0 - 100%)
  90. int m_iPhaseSensitivity;
  91. };
  92. /**
  93. * @brief 一致性检测参数
  94. *
  95. */
  96. struct StConsistencyParam
  97. {
  98. StConsistencyParam();
  99. StConsistencyParam(const StConsistencyParam& obj);
  100. StConsistencyParam& operator=(const StConsistencyParam& obj);
  101. void Init();
  102. // ********* 一致性 ********* [[
  103. void SetConsistencySwitch(bool b) { m_bConsistencySwitch = b; }
  104. bool GetConsistencySwitch() { return m_bConsistencySwitch; }
  105. int GetConsistencyThreshold() const { return m_iConsistencyThreshold; }
  106. void SetConsistencyThreshold(int ival) { m_iConsistencyThreshold = ival; }
  107. int GetConsistencyThresholdNum() const { return m_iConsistencyThresholdNum; }
  108. void SetConsistencyThresholdNum(int ival) { m_iConsistencyThresholdNum = ival; }
  109. int GetConsistencyThresholdNot() const { return m_iConsistencyThresholdNot; }
  110. void SetConsistencyThresholdNot(int ival) { m_iConsistencyThresholdNot = ival; }
  111. int GetConsistencyThresholdNotNum() const { return m_iConsistencyThresholdNotNum; }
  112. // 不一致的判定更严谨,全部为不一致时,才判定为不一致
  113. int GetConsistencyThresholdNotNumEx() const { return m_iConsistencyThresholdNotNum * 2; }
  114. void SetConsistencyThresholdNotNum(int ival) { m_iConsistencyThresholdNotNum = ival; }
  115. int GetConsistencyThresholdWarningNum() const { return m_nConsistencyThresholdWarningNum; }
  116. void SetConsistencyThresholdWarningNum(int ival) { m_nConsistencyThresholdWarningNum = ival; }
  117. private:
  118. // 一致性监测开关
  119. bool m_bConsistencySwitch;
  120. // 一致性阀值
  121. // 持续时间内,如果有m_iConsistencyThresholdNum相似度个比阀值大,就表示一致性
  122. int m_iConsistencyThreshold;
  123. int m_iConsistencyThresholdNum;
  124. // 一致性阀值预警次数: 多少个不一致时,开启不一致预警
  125. int m_nConsistencyThresholdWarningNum;
  126. // 不一致性阀值
  127. // 持续时间内,如果有m_iConsistencyThresholdNotNum相似度个比阀值小,就表示不一致性
  128. int m_iConsistencyThresholdNot;
  129. int m_iConsistencyThresholdNotNum;
  130. };
  131. #endif /* _CHANNEL_PARAM_H_ */