GlobalVariable.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. * CompareItemInfo_t对比项结构体
  14. * ==================================================================== */
  15. bool CompareItemRoadInfo_t::operator==(const CompareItemRoadInfo_t &other) const
  16. {
  17. return (isEnableRecord == other.isEnableRecord &&
  18. nCompareRoadNum == other.nCompareRoadNum &&
  19. strCompareRoadName == other.strCompareRoadName &&
  20. scRoadInfo.nSoundCardNum == other.scRoadInfo.nSoundCardNum &&
  21. scRoadInfo.strSoundCardID == other.scRoadInfo.strSoundCardID &&
  22. scRoadInfo.strSoundCardName == other.scRoadInfo.strSoundCardName &&
  23. scRoadInfo.roadInfo.nRoadNum == other.scRoadInfo.roadInfo.nRoadNum &&
  24. scRoadInfo.roadInfo.nChannelID == other.scRoadInfo.roadInfo.nChannelID &&
  25. scRoadInfo.roadInfo.strChannelName == other.scRoadInfo.roadInfo.strChannelName
  26. );
  27. }
  28. CompareItemDetectParam_t& CompareItemDetectParam_t::operator=(const CompareItemDetectParam_t &other)
  29. {
  30. if(this == &other)
  31. {
  32. return *this;
  33. }
  34. isEnable = other.isEnable;
  35. threshold = other.threshold;
  36. nLen = other.nLen;
  37. nSensitivity = other.nSensitivity;
  38. return *this;
  39. }
  40. CompareItemInfo_t::CompareItemInfo_t(const CompareItemInfo_t &other)
  41. {
  42. *this = other;
  43. }
  44. CompareItemInfo_t& CompareItemInfo_t::operator=(const CompareItemInfo_t &other)
  45. {
  46. if(this == &other)
  47. {
  48. return *this;
  49. }
  50. nID = other.nID;
  51. strName = other.strName;
  52. isEnable = other.isEnable;
  53. mapRoad = other.mapRoad;
  54. paramMute = other.paramMute;
  55. paramOverload = other.paramOverload;
  56. paramPhase = other.paramPhase;
  57. return *this;
  58. }
  59. /* 判断对比想基础部分是否相等,不包含通道信息 */
  60. bool CompareItemInfo_t::isEqualBase(const CompareItemInfo_t &other) const
  61. {
  62. if(nID != other.nID || strName != other.strName || isEnable != other.isEnable)
  63. {
  64. return false;
  65. }
  66. if(mapRoad.size() != other.mapRoad.size())
  67. {
  68. return false; // 通道数量不同
  69. }
  70. if(paramMute.isEnable != other.paramMute.isEnable ||
  71. paramMute.threshold.nThreshold != other.paramMute.threshold.nThreshold ||
  72. paramMute.nLen != other.paramMute.nLen ||
  73. paramMute.nSensitivity != other.paramMute.nSensitivity)
  74. {
  75. return false;
  76. }
  77. if(paramOverload.isEnable != other.paramOverload.isEnable ||
  78. paramOverload.threshold.nThreshold != other.paramOverload.threshold.nThreshold ||
  79. paramOverload.nLen != other.paramOverload.nLen ||
  80. paramOverload.nSensitivity != other.paramOverload.nSensitivity)
  81. {
  82. return false;
  83. }
  84. if(paramPhase.isEnable != other.paramPhase.isEnable ||
  85. paramPhase.threshold.dThreshold != other.paramPhase.threshold.dThreshold ||
  86. paramPhase.nLen != other.paramPhase.nLen ||
  87. paramPhase.nSensitivity != other.paramPhase.nSensitivity)
  88. {
  89. return false;
  90. }
  91. return true;
  92. }
  93. /* 判断对比项的通道是否相同 */
  94. bool CompareItemInfo_t::isEqualRoads(const CompareItemInfo_t &other) const
  95. {
  96. if(mapRoad.size() != other.mapRoad.size())
  97. {
  98. return false;
  99. }
  100. for(auto it = mapRoad.cbegin(); it != mapRoad.cend(); ++it)
  101. {
  102. auto otherIt = other.mapRoad.find(it.key());
  103. if(otherIt == other.mapRoad.cend())
  104. {
  105. return false; // 在other中找不到对应的通道
  106. }
  107. if(it.value() == otherIt.value())
  108. {
  109. }else {
  110. return false; // 通道信息不相同
  111. }
  112. }
  113. return true;
  114. }
  115. bool DetectPeriodConfig_t::operator==(const DetectPeriodConfig_t &other) const
  116. {
  117. if(&other == this)
  118. {
  119. return true; // 自身比较
  120. }
  121. if( nID != other.nID ||
  122. isApplySlient != other.isApplySlient ||
  123. isApplyOverload != other.isApplyOverload ||
  124. isApplyPhase != other.isApplyPhase ||
  125. isApplyNoise != other.isApplyNoise ||
  126. listDetect.size() != other.listDetect.size() ||
  127. listNoDetect.size() != other.listNoDetect.size())
  128. {
  129. return false;
  130. }
  131. /* 详细对比列表中的每一项 */
  132. for(int i = 0; i < listDetect.size(); ++i)
  133. {
  134. const OnePlan_t& plan1 = listDetect.at(i);
  135. bool found = false;
  136. for(int j = 0; j < other.listDetect.size(); ++j)
  137. {
  138. const OnePlan_t& plan2 = other.listDetect.at(j);
  139. if(plan1 == plan2)
  140. {
  141. found = true;
  142. break; // 找到相同的计划
  143. }
  144. }
  145. if(!found)
  146. {
  147. return false; // 在other中找不到相同的检测计划
  148. }
  149. }
  150. /* 对比非检测计划 */
  151. for(int i = 0; i < listNoDetect.size(); ++i)
  152. {
  153. const OnePlan_t& plan1 = listNoDetect.at(i);
  154. bool found = false;
  155. for(int j = 0; j < other.listNoDetect.size(); ++j)
  156. {
  157. const OnePlan_t& plan2 = other.listNoDetect.at(j);
  158. if(plan1 == plan2)
  159. {
  160. found = true;
  161. break; // 找到相同的计划
  162. }
  163. }
  164. if(!found)
  165. {
  166. return false; // 在other中找不到相同的非检测计划
  167. }
  168. }
  169. return true;
  170. }
  171. /* 判断基础信息是否更改 */
  172. bool DetectPeriodConfig_t::isBaseInfoChanged(const DetectPeriodConfig_t &other) const
  173. {
  174. if(&other == this)
  175. {
  176. return false; // 自身比较
  177. }
  178. if(nID == other.nID &&
  179. isApplySlient == other.isApplySlient &&
  180. isApplyOverload == other.isApplyOverload &&
  181. isApplyPhase == other.isApplyPhase &&
  182. isApplyNoise == other.isApplyNoise)
  183. {
  184. return false;
  185. }
  186. return true;
  187. }
  188. /* =========================================================================================
  189. * 计算线程信息结构体
  190. * =========================================================================================*/
  191. CalculateThreadInfo_t::CalculateThreadInfo_t(const CalculateThreadInfo_t& info)
  192. {
  193. *this = info; // 使用赋值运算符进行深拷贝
  194. }
  195. CalculateThreadInfo_t& CalculateThreadInfo_t::operator=(const CalculateThreadInfo_t& info)
  196. {
  197. if(&info == this)
  198. {
  199. return *this; // 防止自赋值
  200. }
  201. compareItemInfo = info.compareItemInfo;
  202. threadState = info.threadState;
  203. threadType = info.threadType;
  204. // pThread = info.pThread;
  205. return *this;
  206. }