#include "GlobalVariable.h" const QMap MapWeekTypeToString = { {eWeekType::Week_Monday, "星期一"}, {eWeekType::Week_Tuesday, "星期二"}, {eWeekType::Week_Wednesday, "星期三"}, {eWeekType::Week_Thursday, "星期四"}, {eWeekType::Week_Friday, "星期五"}, {eWeekType::Week_Saturday, "星期六"}, {eWeekType::Week_Sunday, "星期日"}, {eWeekType::Week_Special, "特殊日期"} }; /* ==================================================================== * 声卡相关信息结构体 * ==================================================================== */ bool SoundCardRoadInfo_t::operator<(const SoundCardRoadInfo_t &other) const { if(nSoundCardNum < other.nSoundCardNum) { return true; // 声卡编号小的排在前面 } if(nSoundCardNum > other.nSoundCardNum) { return false; // 声卡编号大的排在后面 } // 声卡编号相同,比较通道编号 return roadInfo.nRoadNum < other.roadInfo.nRoadNum; } /* ==================================================================== * CompareItemInfo_t对比项结构体 * ==================================================================== */ bool CompareItemRoadInfo_t::operator==(const CompareItemRoadInfo_t &other) const { return (isEnableRecord == other.isEnableRecord && nCompareRoadNum == other.nCompareRoadNum && strCompareRoadName == other.strCompareRoadName && scRoadInfo.nSoundCardNum == other.scRoadInfo.nSoundCardNum && scRoadInfo.strSoundCardID == other.scRoadInfo.strSoundCardID && scRoadInfo.strSoundCardName == other.scRoadInfo.strSoundCardName && scRoadInfo.roadInfo.nRoadNum == other.scRoadInfo.roadInfo.nRoadNum && scRoadInfo.roadInfo.nChannelID == other.scRoadInfo.roadInfo.nChannelID && scRoadInfo.roadInfo.strChannelName == other.scRoadInfo.roadInfo.strChannelName ); } CompareItemDetectParam_t& CompareItemDetectParam_t::operator=(const CompareItemDetectParam_t &other) { if(this == &other) { return *this; } isEnable = other.isEnable; threshold = other.threshold; nLen = other.nLen; nSensitivity = other.nSensitivity; return *this; } CompareItemInfo_t::CompareItemInfo_t(const CompareItemInfo_t &other) { *this = other; } CompareItemInfo_t& CompareItemInfo_t::operator=(const CompareItemInfo_t &other) { if(this == &other) { return *this; } nID = other.nID; strName = other.strName; isEnable = other.isEnable; mapRoad = other.mapRoad; paramMute = other.paramMute; paramOverload = other.paramOverload; paramPhase = other.paramPhase; return *this; } /* 判断对比想基础部分是否相等,不包含通道信息 */ bool CompareItemInfo_t::isEqualBase(const CompareItemInfo_t &other) const { if(nID != other.nID || strName != other.strName || isEnable != other.isEnable) { return false; } if(mapRoad.size() != other.mapRoad.size()) { return false; // 通道数量不同 } if(paramMute.isEnable != other.paramMute.isEnable || paramMute.threshold.nThreshold != other.paramMute.threshold.nThreshold || paramMute.nLen != other.paramMute.nLen || paramMute.nSensitivity != other.paramMute.nSensitivity) { return false; } if(paramOverload.isEnable != other.paramOverload.isEnable || paramOverload.threshold.nThreshold != other.paramOverload.threshold.nThreshold || paramOverload.nLen != other.paramOverload.nLen || paramOverload.nSensitivity != other.paramOverload.nSensitivity) { return false; } if(paramPhase.isEnable != other.paramPhase.isEnable || paramPhase.threshold.dThreshold != other.paramPhase.threshold.dThreshold || paramPhase.nLen != other.paramPhase.nLen || paramPhase.nSensitivity != other.paramPhase.nSensitivity) { return false; } return true; } /* 判断对比项的通道是否相同 */ bool CompareItemInfo_t::isEqualRoads(const CompareItemInfo_t &other) const { if(mapRoad.size() != other.mapRoad.size()) { return false; } for(auto it = mapRoad.cbegin(); it != mapRoad.cend(); ++it) { auto otherIt = other.mapRoad.find(it.key()); if(otherIt == other.mapRoad.cend()) { return false; // 在other中找不到对应的通道 } if(it.value() == otherIt.value()) { }else { return false; // 通道信息不相同 } } return true; } bool DetectPeriodConfig_t::operator==(const DetectPeriodConfig_t &other) const { if(&other == this) { return true; // 自身比较 } if( nID != other.nID || isApplySlient != other.isApplySlient || isApplyOverload != other.isApplyOverload || isApplyPhase != other.isApplyPhase || isApplyNoise != other.isApplyNoise || listDetect.size() != other.listDetect.size() || listNoDetect.size() != other.listNoDetect.size()) { return false; } /* 详细对比列表中的每一项 */ for(int i = 0; i < listDetect.size(); ++i) { const OnePlan_t& plan1 = listDetect.at(i); bool found = false; for(int j = 0; j < other.listDetect.size(); ++j) { const OnePlan_t& plan2 = other.listDetect.at(j); if(plan1 == plan2) { found = true; break; // 找到相同的计划 } } if(!found) { return false; // 在other中找不到相同的检测计划 } } /* 对比非检测计划 */ for(int i = 0; i < listNoDetect.size(); ++i) { const OnePlan_t& plan1 = listNoDetect.at(i); bool found = false; for(int j = 0; j < other.listNoDetect.size(); ++j) { const OnePlan_t& plan2 = other.listNoDetect.at(j); if(plan1 == plan2) { found = true; break; // 找到相同的计划 } } if(!found) { return false; // 在other中找不到相同的非检测计划 } } return true; } /* 判断基础信息是否更改 */ bool DetectPeriodConfig_t::isBaseInfoChanged(const DetectPeriodConfig_t &other) const { if(&other == this) { return false; // 自身比较 } if(nID == other.nID && isApplySlient == other.isApplySlient && isApplyOverload == other.isApplyOverload && isApplyPhase == other.isApplyPhase && isApplyNoise == other.isApplyNoise) { return false; } return true; } /* ========================================================================================= * 计算线程信息结构体 * =========================================================================================*/ CalculateThreadInfo_t::CalculateThreadInfo_t(const CalculateThreadInfo_t& info) { *this = info; // 使用赋值运算符进行深拷贝 } CalculateThreadInfo_t& CalculateThreadInfo_t::operator=(const CalculateThreadInfo_t& info) { if(&info == this) { return *this; // 防止自赋值 } compareItemInfo = info.compareItemInfo; threadState = info.threadState; threadType = info.threadType; // pThread = info.pThread; return *this; } /* ========================================================================================= * 报警信息结构体 * =========================================================================================*/ AlarmInfo_t& AlarmInfo_t::operator=(const AlarmInfo_t& obj) { if (this == &obj) { return *this; // 防止自赋值 } isAlarm = obj.isAlarm; CompareItemID = obj.CompareItemID; strCompareItemName = obj.strCompareItemName; RoadInfo = obj.RoadInfo; RoadType = obj.RoadType; AlarmType = obj.AlarmType; StartTime = obj.StartTime; EndTime = obj.EndTime; strAlarmFilePath = obj.strAlarmFilePath; AlarmStartPos = obj.AlarmStartPos; AlarmFileStartTime = obj.AlarmFileStartTime; return *this; } /* 比较是否相等,主要是比较是否报警、通道ID,报警类型,报警时间 */ bool AlarmInfo_t::operator==(const AlarmInfo_t& other) const { return (isAlarm == other.isAlarm) && (RoadInfo == other.RoadInfo) && (AlarmType == other.AlarmType) && (StartTime == other.StartTime) && (EndTime == other.EndTime); }