GlobalVariable.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #ifndef __GLOBAL_VARIABLE_H__
  2. #define __GLOBAL_VARIABLE_H__
  3. #include <QString>
  4. #include <QList>
  5. #include <QChar>
  6. #include <QMap>
  7. #include <QDateTime>
  8. /**
  9. * @brief 星期枚举定义,星期八是带有日期的特殊日
  10. *
  11. */
  12. enum class eWeekType
  13. {
  14. Week_Monday = 1, /* 星期一 */
  15. Week_Tuesday, /* 星期二 */
  16. Week_Wednesday, /* 星期三 */
  17. Week_Thursday, /* 星期四 */
  18. Week_Friday, /* 星期五 */
  19. Week_Saturday, /* 星期六 */
  20. Week_Sunday, /* 星期日 */
  21. Week_Special, /* 特殊日期 */
  22. };
  23. Q_DECLARE_METATYPE(eWeekType)
  24. const QMap<eWeekType, QString> MapWeekTypeToString = {
  25. {eWeekType::Week_Monday, "星期一"},
  26. {eWeekType::Week_Tuesday, "星期二"},
  27. {eWeekType::Week_Wednesday, "星期三"},
  28. {eWeekType::Week_Thursday, "星期四"},
  29. {eWeekType::Week_Friday, "星期五"},
  30. {eWeekType::Week_Saturday, "星期六"},
  31. {eWeekType::Week_Sunday, "星期日"},
  32. {eWeekType::Week_Special, "特殊日期"}
  33. };
  34. /**
  35. * @brief 一条计划
  36. *
  37. */
  38. struct OnePlan_t
  39. {
  40. eWeekType weekType; /* 星期类型 */
  41. QDate date; /* 日期,格式为YYYY-MM-DD */
  42. QTime timeStart; /* 时间,格式为HH:mm:ss */
  43. QTime timeEnd; /* 时间,格式为HH:mm:ss */
  44. bool operator==(const OnePlan_t &other) const
  45. {
  46. return (weekType == other.weekType) && (date == other.date) && (timeStart == other.timeStart) && (timeEnd == other.timeEnd);
  47. }
  48. bool operator!=(const OnePlan_t &other) const
  49. {
  50. return !(*this == other);
  51. }
  52. };
  53. /* ====================================================================
  54. * 声卡相关信息结构体
  55. * ==================================================================== */
  56. /* 单个录音通道信息,带有频道信息 */
  57. struct OneRoadInfo_t
  58. {
  59. int nRoadNum = -1; /* 录音通道编号 */
  60. int nChannelID = -1; /* 频道ID */
  61. QString strChannelName; /* 频道名称 */
  62. };
  63. /**
  64. * @brief 声卡信息,这里的信息都是设备上和物理声卡相关的
  65. *
  66. */
  67. struct SoundCardInfo_t
  68. {
  69. int nSoundCardNum = -1; /* 声卡编号 */
  70. QString strSoundCardID; /* 声卡ID,这个是声卡名称,可以用来打开 */
  71. QString strSoundCardName; /* 声卡名称 */
  72. QString strSoundCardDriver; /* 声卡驱动名称 */
  73. QList<OneRoadInfo_t> listRoad; /* 录音通道列表,存储通道编号 */
  74. };
  75. /**
  76. * @brief 单个声卡通道信息,带有声卡自身的信息
  77. *
  78. */
  79. struct SoundCardRoadInfo_t
  80. {
  81. int nSoundCardNum = -1; /* 声卡编号 */
  82. QString strSoundCardID; /* 声卡ID,这个是声卡名称,可以用来打开 */
  83. QString strSoundCardName; /* 声卡名称 */
  84. OneRoadInfo_t roadInfo; /* 单个通道信息 */
  85. };
  86. /* 注册数据类型到系统 */
  87. Q_DECLARE_METATYPE(SoundCardRoadInfo_t)
  88. /* ====================================================================
  89. * CompareItemInfo_t对比项结构体
  90. * ==================================================================== */
  91. /**
  92. * @brief 对比项信息在表格中的显示结构体
  93. *
  94. */
  95. struct CompareItemTableItem_t
  96. {
  97. int nSerialNum; /* 序号,在表格中的序号 */
  98. int nID; /* 对比项ID */
  99. QString strName; /* 对比项名称 */
  100. bool isEnable; /* 对比项状态,是否启用 */
  101. int nChannelCount; /* 通道数 */
  102. };
  103. /* 对比项的通道信息 */
  104. struct CompareItemRoadInfo_t
  105. {
  106. bool isEnableRecord; /* 是否开启录音 */
  107. int nCompareRoadNum; /* 对比通道编号,1是主通道,其余往后排 */
  108. QString strCompareRoadName; /* 通道名称 */
  109. SoundCardRoadInfo_t scRoadInfo; /* 声卡通道信息,包含声卡编号和通道编号 */
  110. bool operator==(const CompareItemRoadInfo_t &other) const;
  111. };
  112. /* 检测阈值,静音和过载是整数,反相是小数 */
  113. union Threshold_t
  114. {
  115. uint64_t nThreshold; /* 静音和过载的阈值 */
  116. double dThreshold; /* 反相的阈值 */
  117. };
  118. /**
  119. * @brief 静音、过载、反相检测参数
  120. *
  121. */
  122. struct CompareItemDetectParam_t
  123. {
  124. bool isEnable = false; /* 是否启用检测 */
  125. Threshold_t threshold; /* 检测阈值 */
  126. int nLen = 0; /* 检测长度,单位秒 */
  127. int nSensitivity = 0; /* 敏感度,0-100,0最不敏感,100最敏感 */
  128. CompareItemDetectParam_t() = default;
  129. CompareItemDetectParam_t(const CompareItemDetectParam_t &other);
  130. CompareItemDetectParam_t& operator=(const CompareItemDetectParam_t &other);
  131. };
  132. /**
  133. * @brief 对比项信息
  134. *
  135. */
  136. struct CompareItemInfo_t
  137. {
  138. int nID = -1; /* 对比项ID,对比项唯一识别号,不可更改 */
  139. QString strName; /* 对比项名称 */
  140. bool isEnable = false; /* 对比项状态,是否启用 */
  141. QMap<int, CompareItemRoadInfo_t> mapRoad; /* 通道信息列表,int是通道编号 */
  142. CompareItemDetectParam_t paramMute; /* 静音检测参数 */
  143. CompareItemDetectParam_t paramOverload; /* 过载检测参数 */
  144. CompareItemDetectParam_t paramPhase; /* 反相检测参数 */
  145. CompareItemInfo_t() = default;
  146. CompareItemInfo_t(const CompareItemInfo_t &other);
  147. CompareItemInfo_t& operator=(const CompareItemInfo_t &other);
  148. /* 判断对比想基础部分是否相等,不包含通道信息 */
  149. bool isEqualBase(const CompareItemInfo_t &other) const;
  150. /* 判断对比项的通道是否相同 */
  151. bool isEqualRoads(const CompareItemInfo_t &other) const;
  152. };
  153. /* =============================================================================
  154. * 检测时段配置
  155. * ============================================================================= */
  156. /**
  157. * @brief 一个对比项的检测计划
  158. *
  159. */
  160. struct DetectPeriodConfig_t
  161. {
  162. int nID = 0; /* ID */
  163. bool isApplySlient = false; /* 非检测计划日期是否应用静音 */
  164. bool isApplyOverload = false; /* 非检测计划日期是否应用超载 */
  165. bool isApplyPhase = false; /* 非检测计划日期是否应用反相 */
  166. bool isApplyNoise = false; /* 非检测计划日期是否应用噪音 */
  167. QList<OnePlan_t> listDetect; /* 检测计划列表 */
  168. QList<OnePlan_t> listNoDetect; /* 非检测计划列表 */
  169. bool operator==(const DetectPeriodConfig_t &other) const;
  170. /* 判断基础信息是否更改 */
  171. bool isBaseInfoChanged(const DetectPeriodConfig_t &other) const;
  172. };
  173. /**
  174. * @brief 非检测计划应用清空
  175. *
  176. */
  177. struct NoDetectPlanApply_t
  178. {
  179. int nID = 0; /* ID */
  180. bool isApplySlient = false; /* 非检测计划日期是否应用静音 */
  181. bool isApplyOverload = false; /* 非检测计划日期是否应用超载 */
  182. bool isApplyPhase = false; /* 非检测计划日期是否应用反相 */
  183. bool isApplyNoise = false; /* 非检测计划日期是否应用噪音 */
  184. };
  185. #endif // __GLOBAL_VARIABLE_H__