#ifndef __GLOBAL_VARIABLE_H__ #define __GLOBAL_VARIABLE_H__ #include #include #include #include #include #include /** * @brief 星期枚举定义,星期八是带有日期的特殊日 * */ enum class eWeekType { Week_Monday = 1, /* 星期一 */ Week_Tuesday, /* 星期二 */ Week_Wednesday, /* 星期三 */ Week_Thursday, /* 星期四 */ Week_Friday, /* 星期五 */ Week_Saturday, /* 星期六 */ Week_Sunday, /* 星期日 */ Week_Special, /* 特殊日期 */ }; Q_DECLARE_METATYPE(eWeekType) extern const QMap MapWeekTypeToString; /** * @brief 录音通道类型 * */ enum class ERoadType { RoadType_Main = 0, /* 主输出 */ RoadType_SpaceReceive, /* 空间接收 */ RoadType_SpaceSend, /* 空间发送 */ }; /** * @brief 报警类型 * */ enum class EAlarmType { EAT_None = 0, /* 无报警 */ EAT_Silent, /* 静音报警 */ EAT_Overload, /* 过载报警 */ EAT_Reversed, /* 反相报警 */ EAR_Consistency, /* 一致性报警 */ EAT_Noise, /* 噪音报警 */ EAT_Unknown, /* 未知报警 */ }; /** * @brief 一条计划 * */ struct OnePlan_t { eWeekType weekType; /* 星期类型 */ QDate date; /* 日期,格式为YYYY-MM-DD */ QTime timeStart; /* 时间,格式为HH:mm:ss */ QTime timeEnd; /* 时间,格式为HH:mm:ss */ bool operator==(const OnePlan_t &other) const { return (weekType == other.weekType) && (date == other.date) && (timeStart == other.timeStart) && (timeEnd == other.timeEnd); } bool operator!=(const OnePlan_t &other) const { return !(*this == other); } }; /* ==================================================================== * 声卡相关信息结构体 * ==================================================================== */ /* 单个录音通道信息,带有频道信息 */ struct OneRoadInfo_t { int nRoadNum = -1; /* 录音通道编号,是声卡在系统中的物理编号 */ int nChannelID = -1; /* 频道ID */ QString strChannelName; /* 频道名称 */ }; /** * @brief 声卡信息,这里的信息都是设备上和物理声卡相关的 * */ struct SoundCardInfo_t { int nSoundCardNum = -1; /* 声卡编号,系统上的物理编号 */ QString strSoundCardID; /* 声卡ID,这个是声卡名称,可以用来打开 */ QString strSoundCardName; /* 声卡名称 */ QString strSoundCardDriver; /* 声卡驱动名称 */ QList listRoad; /* 录音通道列表,存储通道编号 */ }; /** * @brief 单个声卡通道信息,带有声卡自身的信息 * */ struct SoundCardRoadInfo_t { int nSoundCardNum = -1; /* 声卡编号 */ QString strSoundCardID; /* 声卡ID,这个是声卡名称,可以用来打开 */ QString strSoundCardName; /* 声卡名称 */ OneRoadInfo_t roadInfo; /* 单个通道信息 */ bool operator<(const SoundCardRoadInfo_t &other) const; }; /* 使用声卡通道最为Key的结构体 */ struct SoundCardRoadKey_t { int nSoundCardNum = -1; /* 声卡编号 */ int nRoadNum = -1; /* 通道编号 */ bool operator==(const SoundCardRoadKey_t &other) const { return (nSoundCardNum == other.nSoundCardNum) && (nRoadNum == other.nRoadNum); } bool operator<(const SoundCardRoadKey_t &other) const { if(nSoundCardNum < other.nSoundCardNum) return true; if(nSoundCardNum > other.nSoundCardNum) return false; return nRoadNum < other.nRoadNum; } }; /* 注册数据类型到系统 */ Q_DECLARE_METATYPE(SoundCardRoadInfo_t) /* ==================================================================== * CompareItemInfo_t对比项结构体 * ==================================================================== */ /** * @brief 对比项信息在表格中的显示结构体 * */ struct CompareItemTableItem_t { int nSerialNum; /* 序号,在表格中的序号 */ int nID; /* 对比项ID */ QString strName; /* 对比项名称 */ bool isEnable; /* 对比项状态,是否启用 */ int nChannelCount; /* 通道数 */ }; /* 对比项的通道信息 */ struct CompareItemRoadInfo_t { bool isEnableRecord; /* 是否开启录音 */ int nCompareRoadNum; /* 对比通道编号,1是主通道,其余往后排 */ QString strCompareRoadName; /* 对比项通道名称,不是声卡的通道名 */ SoundCardRoadInfo_t scRoadInfo; /* 声卡通道信息,包含声卡编号和通道编号 */ bool operator==(const CompareItemRoadInfo_t &other) const; }; /* 检测阈值,静音和过载是整数,反相是小数 */ union Threshold_t { uint64_t nThreshold; /* 静音和过载的阈值 */ double dThreshold; /* 反相的阈值 */ }; /** * @brief 静音、过载、反相检测参数 * */ struct CompareItemDetectParam_t { bool isEnable = false; /* 是否启用检测 */ Threshold_t threshold; /* 检测阈值 */ int nLen = 0; /* 检测长度,单位秒 */ int nSensitivity = 0; /* 敏感度,0-100,0最不敏感,100最敏感 */ CompareItemDetectParam_t() = default; CompareItemDetectParam_t(const CompareItemDetectParam_t &other); CompareItemDetectParam_t& operator=(const CompareItemDetectParam_t &other); }; /** * @brief 对比项信息 * */ struct CompareItemInfo_t { int nID = -1; /* 对比项ID,对比项唯一识别号,不可更改 */ QString strName; /* 对比项名称 */ bool isEnable = false; /* 对比项状态,是否启用 */ QMap mapRoad; /* 通道信息列表,int是通道编号,在对比项中的编号 */ CompareItemDetectParam_t paramMute; /* 静音检测参数 */ CompareItemDetectParam_t paramOverload; /* 过载检测参数 */ CompareItemDetectParam_t paramPhase; /* 反相检测参数 */ CompareItemInfo_t() = default; CompareItemInfo_t(const CompareItemInfo_t &other); CompareItemInfo_t& operator=(const CompareItemInfo_t &other); /* 判断对比想基础部分是否相等,不包含通道信息 */ bool isEqualBase(const CompareItemInfo_t &other) const; /* 判断对比项的通道是否相同 */ bool isEqualRoads(const CompareItemInfo_t &other) const; }; /* ============================================================================= * 检测时段配置 * ============================================================================= */ /** * @brief 一个对比项的检测计划 * */ struct DetectPeriodConfig_t { int nID = 0; /* ID */ bool isApplySlient = false; /* 计划日期是否应用静音 */ bool isApplyOverload = false; /* 计划日期是否应用超载 */ bool isApplyPhase = false; /* 计划日期是否应用反相 */ bool isApplyNoise = false; /* 计划日期是否应用噪音 */ QList listDetect; /* 检测计划列表 */ QList listNoDetect; /* 非检测计划列表 */ bool operator==(const DetectPeriodConfig_t &other) const; /* 判断基础信息是否更改 */ bool isBaseInfoChanged(const DetectPeriodConfig_t &other) const; }; /** * @brief 非检测计划应用清空 * */ struct NoDetectPlanApply_t { int nID = 0; /* ID */ bool isApplySlient = false; /* 非检测计划日期是否应用静音 */ bool isApplyOverload = false; /* 非检测计划日期是否应用超载 */ bool isApplyPhase = false; /* 非检测计划日期是否应用反相 */ bool isApplyNoise = false; /* 非检测计划日期是否应用噪音 */ }; /* ========================================================================================= * 线程信息相关枚举和结构体 * =========================================================================================*/ /** * @brief 线程状态枚举 * */ enum class EThreadState { State_None = 0, /* 无状态 */ State_Inited, /* 已初始化 */ State_Running, /* 运行中 */ State_Stopped, /* 已停止 */ State_Error /* 错误状态 */ }; /** * @brief 线程类型枚举 * */ enum class EThreadType { Type_None = 0, /* 无类型 */ Type_RecordSrc, /* 录音源线程 */ Type_AssignSrcData, /* 分派数据线程 */ Type_CreateWAV, /* 生成WAV文件线程 */ Type_CreateDB, /* 生成音量包的线程 */ // Type_CreateNoise, /* 生成噪音数据线程 */ Type_CreateLongWAV, /* 生成长文件线程 */ Type_RtpSend, /* RTP发送线程 */ Type_ConsistencyCheck, /* 一致性检查线程 */ Type_CalculateDB, /* 计算音量的线程 */ Type_CompareItem, /* 对比项线程 */ }; /** * @brief 录音线程信息结构体 */ struct RecordThreadInfo_t { SoundCardRoadInfo_t cardRoadInfo; /* 录音通道信息 */ EThreadType threadType; /* 线程类型 */ EThreadState threadState; /* 线程状态 */ // BaseRecordThread* pThread = nullptr; /* 线程对象 */ }; /* ========================================================================================= * 报警信息结构体 * =========================================================================================*/ class BaseCalculateThread; /** * @brief 计算线程信息结构体 * */ struct CalculateThreadInfo_t { CompareItemInfo_t compareItemInfo; /* 对比项信息 */ EThreadType threadType; /* 线程类型 */ EThreadState threadState; /* 线程状态 */ // BaseCalculateThread* pThread = nullptr; /* 计算线程对象 */ CalculateThreadInfo_t() = default; CalculateThreadInfo_t(const CalculateThreadInfo_t& info); CalculateThreadInfo_t& operator=(const CalculateThreadInfo_t& info); }; /** * @brief 报警结构体 * */ struct AlarmInfo_t { bool isAlarm = false; /* 是否报警 */ int CompareItemID = 0; /* 对比项ID */ std::string strCompareItemName; /* 对比项名称 */ CompareItemRoadInfo_t RoadInfo; /* 录音通道信息 */ ERoadType RoadType; /* 录音通道类型 */ EAlarmType AlarmType = EAlarmType::EAT_None; /* 报警类型 */ QDateTime StartTime; /* 报警开始时间 */ QDateTime EndTime; /* 报警结束时间 */ // std::string strAlarmStartTime; /* 报警发生时间 */ // std::string strAlarmEndTime; /* 报警结束时间 */ // std::string strAlarmExistTime; /* 报警持续时间 */ std::string strAlarmFilePath; /* 报警文件路径 */ int AlarmStartPos = 0; /* 报警开始位置 */ QDateTime AlarmFileStartTime; /* 录音文件开始时间 */ AlarmInfo_t() = default; AlarmInfo_t(const AlarmInfo_t& obj) { *this = obj; } AlarmInfo_t& operator=(const AlarmInfo_t& obj); /* 比较是否相等,主要是比较是否报警、通道ID,报警类型,报警时间 */ bool operator==(const AlarmInfo_t& other) const; }; #endif // __GLOBAL_VARIABLE_H__