GlobalVariable.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. #include "GlobalVariable.h"
  2. const QMap<eWeekType, QString> MapWeekTypeToString = {
  3. {eWeekType::Week_Monday, "星期一"},
  4. {eWeekType::Week_Tuesday, "星期二"},
  5. {eWeekType::Week_Wednesday, "星期三"},
  6. {eWeekType::Week_Thursday, "星期四"},
  7. {eWeekType::Week_Friday, "星期五"},
  8. {eWeekType::Week_Saturday, "星期六"},
  9. {eWeekType::Week_Sunday, "星期日"},
  10. {eWeekType::Week_Special, "特殊日期"}
  11. };
  12. /* ====================================================================
  13. * 声卡相关信息结构体
  14. * ==================================================================== */
  15. bool SoundCardRoadInfo_t::operator<(const SoundCardRoadInfo_t &other) const
  16. {
  17. if(nSoundCardNum < other.nSoundCardNum)
  18. {
  19. return true; // 声卡编号小的排在前面
  20. }
  21. if(nSoundCardNum > other.nSoundCardNum)
  22. {
  23. return false; // 声卡编号大的排在后面
  24. }
  25. // 声卡编号相同,比较通道编号
  26. return roadInfo.nRoadNum < other.roadInfo.nRoadNum;
  27. }
  28. /* ====================================================================
  29. * CompareItemInfo_t对比项结构体
  30. * ==================================================================== */
  31. bool CompareItemRoadInfo_t::operator==(const CompareItemRoadInfo_t &other) const
  32. {
  33. return (isEnableRecord == other.isEnableRecord &&
  34. nCompareRoadNum == other.nCompareRoadNum &&
  35. strCompareRoadName == other.strCompareRoadName &&
  36. scRoadInfo.nSoundCardNum == other.scRoadInfo.nSoundCardNum &&
  37. scRoadInfo.strSoundCardID == other.scRoadInfo.strSoundCardID &&
  38. scRoadInfo.strSoundCardName == other.scRoadInfo.strSoundCardName &&
  39. scRoadInfo.roadInfo.nRoadNum == other.scRoadInfo.roadInfo.nRoadNum &&
  40. scRoadInfo.roadInfo.nChannelID == other.scRoadInfo.roadInfo.nChannelID &&
  41. scRoadInfo.roadInfo.strChannelName == other.scRoadInfo.roadInfo.strChannelName
  42. );
  43. }
  44. OneCompareItemRoadInfo_t::OneCompareItemRoadInfo_t(const OneCompareItemRoadInfo_t &other)
  45. {
  46. *this = other;
  47. }
  48. OneCompareItemRoadInfo_t& OneCompareItemRoadInfo_t::operator=(const OneCompareItemRoadInfo_t &other)
  49. {
  50. if(this == &other)
  51. {
  52. return *this; // 自身比较
  53. }
  54. nCompareItemID = other.nCompareItemID;
  55. nCompareRoadNum = other.nCompareRoadNum;
  56. nSoundCardNum = other.nSoundCardNum;
  57. nSoundCardRoadNum = other.nSoundCardRoadNum;
  58. strCompareItemName = other.strCompareItemName;
  59. strCompareRoadName = other.strCompareRoadName;
  60. return *this;
  61. }
  62. bool OneCompareItemRoadInfo_t::operator==(const OneCompareItemRoadInfo_t &other) const
  63. {
  64. return (nCompareItemID == other.nCompareItemID &&
  65. nCompareRoadNum == other.nCompareRoadNum &&
  66. nSoundCardNum == other.nSoundCardNum &&
  67. nSoundCardRoadNum == other.nSoundCardRoadNum &&
  68. strCompareItemName == other.strCompareItemName &&
  69. strCompareRoadName == other.strCompareRoadName
  70. );
  71. }
  72. CompareItemDetectParam_t& CompareItemDetectParam_t::operator=(const CompareItemDetectParam_t &other)
  73. {
  74. if(this == &other)
  75. {
  76. return *this;
  77. }
  78. isEnable = other.isEnable;
  79. threshold = other.threshold;
  80. nLen = other.nLen;
  81. nSensitivity = other.nSensitivity;
  82. return *this;
  83. }
  84. CompareItemInfo_t::CompareItemInfo_t(const CompareItemInfo_t &other)
  85. {
  86. *this = other;
  87. }
  88. CompareItemInfo_t& CompareItemInfo_t::operator=(const CompareItemInfo_t &other)
  89. {
  90. if(this == &other)
  91. {
  92. return *this;
  93. }
  94. nID = other.nID;
  95. strName = other.strName;
  96. isEnable = other.isEnable;
  97. mapRoad = other.mapRoad;
  98. paramMute = other.paramMute;
  99. paramOverload = other.paramOverload;
  100. paramPhase = other.paramPhase;
  101. return *this;
  102. }
  103. /* 判断对比想基础部分是否相等,不包含通道信息 */
  104. bool CompareItemInfo_t::isEqualBase(const CompareItemInfo_t &other) const
  105. {
  106. if(nID != other.nID || strName != other.strName || isEnable != other.isEnable)
  107. {
  108. return false;
  109. }
  110. if(mapRoad.size() != other.mapRoad.size())
  111. {
  112. return false; // 通道数量不同
  113. }
  114. if(paramMute.isEnable != other.paramMute.isEnable ||
  115. paramMute.threshold.nThreshold != other.paramMute.threshold.nThreshold ||
  116. paramMute.nLen != other.paramMute.nLen ||
  117. paramMute.nSensitivity != other.paramMute.nSensitivity)
  118. {
  119. return false;
  120. }
  121. if(paramOverload.isEnable != other.paramOverload.isEnable ||
  122. paramOverload.threshold.nThreshold != other.paramOverload.threshold.nThreshold ||
  123. paramOverload.nLen != other.paramOverload.nLen ||
  124. paramOverload.nSensitivity != other.paramOverload.nSensitivity)
  125. {
  126. return false;
  127. }
  128. if(paramPhase.isEnable != other.paramPhase.isEnable ||
  129. paramPhase.threshold.dThreshold != other.paramPhase.threshold.dThreshold ||
  130. paramPhase.nLen != other.paramPhase.nLen ||
  131. paramPhase.nSensitivity != other.paramPhase.nSensitivity)
  132. {
  133. return false;
  134. }
  135. return true;
  136. }
  137. /* 判断对比项的通道是否相同 */
  138. bool CompareItemInfo_t::isEqualRoads(const CompareItemInfo_t &other) const
  139. {
  140. if(mapRoad.size() != other.mapRoad.size())
  141. {
  142. return false;
  143. }
  144. for(auto it = mapRoad.cbegin(); it != mapRoad.cend(); ++it)
  145. {
  146. auto otherIt = other.mapRoad.find(it.key());
  147. if(otherIt == other.mapRoad.cend())
  148. {
  149. return false; // 在other中找不到对应的通道
  150. }
  151. if(it.value() == otherIt.value())
  152. {
  153. }else {
  154. return false; // 通道信息不相同
  155. }
  156. }
  157. return true;
  158. }
  159. bool DetectPeriodConfig_t::operator==(const DetectPeriodConfig_t &other) const
  160. {
  161. if(&other == this)
  162. {
  163. return true; // 自身比较
  164. }
  165. if( nID != other.nID ||
  166. isApplySlient != other.isApplySlient ||
  167. isApplyOverload != other.isApplyOverload ||
  168. isApplyPhase != other.isApplyPhase ||
  169. isApplyNoise != other.isApplyNoise ||
  170. listDetect.size() != other.listDetect.size() ||
  171. listNoDetect.size() != other.listNoDetect.size())
  172. {
  173. return false;
  174. }
  175. /* 详细对比列表中的每一项 */
  176. for(int i = 0; i < listDetect.size(); ++i)
  177. {
  178. const OnePlan_t& plan1 = listDetect.at(i);
  179. bool found = false;
  180. for(int j = 0; j < other.listDetect.size(); ++j)
  181. {
  182. const OnePlan_t& plan2 = other.listDetect.at(j);
  183. if(plan1 == plan2)
  184. {
  185. found = true;
  186. break; // 找到相同的计划
  187. }
  188. }
  189. if(!found)
  190. {
  191. return false; // 在other中找不到相同的检测计划
  192. }
  193. }
  194. /* 对比非检测计划 */
  195. for(int i = 0; i < listNoDetect.size(); ++i)
  196. {
  197. const OnePlan_t& plan1 = listNoDetect.at(i);
  198. bool found = false;
  199. for(int j = 0; j < other.listNoDetect.size(); ++j)
  200. {
  201. const OnePlan_t& plan2 = other.listNoDetect.at(j);
  202. if(plan1 == plan2)
  203. {
  204. found = true;
  205. break; // 找到相同的计划
  206. }
  207. }
  208. if(!found)
  209. {
  210. return false; // 在other中找不到相同的非检测计划
  211. }
  212. }
  213. return true;
  214. }
  215. /* 判断基础信息是否更改 */
  216. bool DetectPeriodConfig_t::isBaseInfoChanged(const DetectPeriodConfig_t &other) const
  217. {
  218. if(&other == this)
  219. {
  220. return false; // 自身比较
  221. }
  222. if(nID == other.nID &&
  223. isApplySlient == other.isApplySlient &&
  224. isApplyOverload == other.isApplyOverload &&
  225. isApplyPhase == other.isApplyPhase &&
  226. isApplyNoise == other.isApplyNoise)
  227. {
  228. return false;
  229. }
  230. return true;
  231. }
  232. /* =========================================================================================
  233. * 计算线程信息结构体
  234. * =========================================================================================*/
  235. CalculateThreadInfo_t::CalculateThreadInfo_t(const CalculateThreadInfo_t& info)
  236. {
  237. *this = info; // 使用赋值运算符进行深拷贝
  238. }
  239. CalculateThreadInfo_t& CalculateThreadInfo_t::operator=(const CalculateThreadInfo_t& info)
  240. {
  241. if(&info == this)
  242. {
  243. return *this; // 防止自赋值
  244. }
  245. compareItemInfo = info.compareItemInfo;
  246. threadState = info.threadState;
  247. threadType = info.threadType;
  248. // pThread = info.pThread;
  249. return *this;
  250. }
  251. /* =========================================================================================
  252. * 报警信息结构体
  253. * =========================================================================================*/
  254. AlarmInfo_t& AlarmInfo_t::operator=(const AlarmInfo_t& obj)
  255. {
  256. if (this == &obj)
  257. {
  258. return *this; // 防止自赋值
  259. }
  260. isAlarm = obj.isAlarm;
  261. CompareItemID = obj.CompareItemID;
  262. strCompareItemName = obj.strCompareItemName;
  263. RoadInfo = obj.RoadInfo;
  264. RoadType = obj.RoadType;
  265. AlarmType = obj.AlarmType;
  266. StartTime = obj.StartTime;
  267. EndTime = obj.EndTime;
  268. strAlarmFilePath = obj.strAlarmFilePath;
  269. AlarmStartPos = obj.AlarmStartPos;
  270. AlarmFileStartTime = obj.AlarmFileStartTime;
  271. return *this;
  272. }
  273. /* 比较是否相等,主要是比较是否报警、通道ID,报警类型,报警时间 */
  274. bool AlarmInfo_t::operator==(const AlarmInfo_t& other) const
  275. {
  276. return (isAlarm == other.isAlarm) &&
  277. (RoadInfo == other.RoadInfo) &&
  278. (AlarmType == other.AlarmType) &&
  279. (StartTime == other.StartTime) &&
  280. (EndTime == other.EndTime);
  281. }
  282. /* =========================================================================================
  283. * 录音文件结构体
  284. * =========================================================================================*/
  285. RecordFileInfo_t& RecordFileInfo_t::operator=(const RecordFileInfo_t& obj)
  286. {
  287. if (this == &obj)
  288. {
  289. return *this; // 防止自赋值
  290. }
  291. ItemID = obj.ItemID;
  292. ItemName = obj.ItemName;
  293. ItemRoadNum = obj.ItemRoadNum;
  294. ItemRoadName = obj.ItemRoadName;
  295. SoundCardNum = obj.SoundCardNum;
  296. SoundCardRoadNum = obj.SoundCardRoadNum;
  297. FileStartTime = obj.FileStartTime;
  298. FileEndTime = obj.FileEndTime;
  299. FileDuration = obj.FileDuration;
  300. FilePath = obj.FilePath;
  301. return *this;
  302. }