GlobalVariable.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #include "GlobalVariable.h"
  2. /* ====================================================================
  3. * CompareItemInfo_t对比项结构体
  4. * ==================================================================== */
  5. bool CompareItemRoadInfo_t::operator==(const CompareItemRoadInfo_t &other) const
  6. {
  7. return (isEnableRecord == other.isEnableRecord &&
  8. nCompareRoadNum == other.nCompareRoadNum &&
  9. strCompareRoadName == other.strCompareRoadName &&
  10. scRoadInfo.nSoundCardNum == other.scRoadInfo.nSoundCardNum &&
  11. scRoadInfo.strSoundCardID == other.scRoadInfo.strSoundCardID &&
  12. scRoadInfo.strSoundCardName == other.scRoadInfo.strSoundCardName &&
  13. scRoadInfo.roadInfo.nRoadNum == other.scRoadInfo.roadInfo.nRoadNum &&
  14. scRoadInfo.roadInfo.nChannelID == other.scRoadInfo.roadInfo.nChannelID &&
  15. scRoadInfo.roadInfo.strChannelName == other.scRoadInfo.roadInfo.strChannelName
  16. );
  17. }
  18. CompareItemDetectParam_t& CompareItemDetectParam_t::operator=(const CompareItemDetectParam_t &other)
  19. {
  20. if(this == &other)
  21. {
  22. return *this;
  23. }
  24. isEnable = other.isEnable;
  25. threshold = other.threshold;
  26. nLen = other.nLen;
  27. nSensitivity = other.nSensitivity;
  28. return *this;
  29. }
  30. CompareItemInfo_t::CompareItemInfo_t(const CompareItemInfo_t &other)
  31. {
  32. *this = other;
  33. }
  34. CompareItemInfo_t& CompareItemInfo_t::operator=(const CompareItemInfo_t &other)
  35. {
  36. if(this == &other)
  37. {
  38. return *this;
  39. }
  40. nID = other.nID;
  41. strName = other.strName;
  42. isEnable = other.isEnable;
  43. mapRoad = other.mapRoad;
  44. paramMute = other.paramMute;
  45. paramOverload = other.paramOverload;
  46. paramPhase = other.paramPhase;
  47. return *this;
  48. }
  49. /* 判断对比想基础部分是否相等,不包含通道信息 */
  50. bool CompareItemInfo_t::isEqualBase(const CompareItemInfo_t &other) const
  51. {
  52. if(nID != other.nID || strName != other.strName || isEnable != other.isEnable)
  53. {
  54. return false;
  55. }
  56. if(mapRoad.size() != other.mapRoad.size())
  57. {
  58. return false; // 通道数量不同
  59. }
  60. if(paramMute.isEnable != other.paramMute.isEnable ||
  61. paramMute.threshold.nThreshold != other.paramMute.threshold.nThreshold ||
  62. paramMute.nLen != other.paramMute.nLen ||
  63. paramMute.nSensitivity != other.paramMute.nSensitivity)
  64. {
  65. return false;
  66. }
  67. if(paramOverload.isEnable != other.paramOverload.isEnable ||
  68. paramOverload.threshold.nThreshold != other.paramOverload.threshold.nThreshold ||
  69. paramOverload.nLen != other.paramOverload.nLen ||
  70. paramOverload.nSensitivity != other.paramOverload.nSensitivity)
  71. {
  72. return false;
  73. }
  74. if(paramPhase.isEnable != other.paramPhase.isEnable ||
  75. paramPhase.threshold.dThreshold != other.paramPhase.threshold.dThreshold ||
  76. paramPhase.nLen != other.paramPhase.nLen ||
  77. paramPhase.nSensitivity != other.paramPhase.nSensitivity)
  78. {
  79. return false;
  80. }
  81. return true;
  82. }
  83. /* 判断对比项的通道是否相同 */
  84. bool CompareItemInfo_t::isEqualRoads(const CompareItemInfo_t &other) const
  85. {
  86. if(mapRoad.size() != other.mapRoad.size())
  87. {
  88. return false;
  89. }
  90. for(auto it = mapRoad.cbegin(); it != mapRoad.cend(); ++it)
  91. {
  92. auto otherIt = other.mapRoad.find(it.key());
  93. if(otherIt == other.mapRoad.cend())
  94. {
  95. return false; // 在other中找不到对应的通道
  96. }
  97. if(it.value() == otherIt.value())
  98. {
  99. }else {
  100. return false; // 通道信息不相同
  101. }
  102. }
  103. return true;
  104. }
  105. bool DetectPeriodConfig_t::operator==(const DetectPeriodConfig_t &other) const
  106. {
  107. if(&other == this)
  108. {
  109. return true; // 自身比较
  110. }
  111. if( nID != other.nID ||
  112. isApplySlient != other.isApplySlient ||
  113. isApplyOverload != other.isApplyOverload ||
  114. isApplyPhase != other.isApplyPhase ||
  115. isApplyNoise != other.isApplyNoise ||
  116. listDetect.size() != other.listDetect.size() ||
  117. listNoDetect.size() != other.listNoDetect.size())
  118. {
  119. return false;
  120. }
  121. /* 详细对比列表中的每一项 */
  122. for(int i = 0; i < listDetect.size(); ++i)
  123. {
  124. const OnePlan_t& plan1 = listDetect.at(i);
  125. bool found = false;
  126. for(int j = 0; j < other.listDetect.size(); ++j)
  127. {
  128. const OnePlan_t& plan2 = other.listDetect.at(j);
  129. if(plan1 == plan2)
  130. {
  131. found = true;
  132. break; // 找到相同的计划
  133. }
  134. }
  135. if(!found)
  136. {
  137. return false; // 在other中找不到相同的检测计划
  138. }
  139. }
  140. /* 对比非检测计划 */
  141. for(int i = 0; i < listNoDetect.size(); ++i)
  142. {
  143. const OnePlan_t& plan1 = listNoDetect.at(i);
  144. bool found = false;
  145. for(int j = 0; j < other.listNoDetect.size(); ++j)
  146. {
  147. const OnePlan_t& plan2 = other.listNoDetect.at(j);
  148. if(plan1 == plan2)
  149. {
  150. found = true;
  151. break; // 找到相同的计划
  152. }
  153. }
  154. if(!found)
  155. {
  156. return false; // 在other中找不到相同的非检测计划
  157. }
  158. }
  159. return true;
  160. }
  161. /* 判断基础信息是否更改 */
  162. bool DetectPeriodConfig_t::isBaseInfoChanged(const DetectPeriodConfig_t &other) const
  163. {
  164. if(&other == this)
  165. {
  166. return false; // 自身比较
  167. }
  168. if(nID == other.nID &&
  169. isApplySlient == other.isApplySlient &&
  170. isApplyOverload == other.isApplyOverload &&
  171. isApplyPhase == other.isApplyPhase &&
  172. isApplyNoise == other.isApplyNoise)
  173. {
  174. return false;
  175. }
  176. return true;
  177. }