GlobalVariable.cpp 11 KB

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