GlobalVariable.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. }