123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef FUNCBASE_H
- #define FUNCBASE_H
- #include <memory>
- #include "GlobalVariable.h"
- #include "GlobalFuncThread.h"
- #include "spdlog/spdlog.h"
- class FromRedis;
- class FromWebAPI;
- struct FuncThreadInfo;
- /**
- * @brief 功能基础类,包含读取Redis数据和写入EQM数据库的功能
- *
- */
- class FuncBase
- {
- public:
- FuncBase();
- ~FuncBase();
- /* 任务线程 */
- void thread_task();
- /* 设置功能信息 */
- void setFuncThreadInfo(FuncThreadInfo* pFuncAct);
- void setFuncThreadInfo(FuncThreadInfo& FuncAct);
- /* 获取该实例的功能 */
- AppFunction getApp();
- /* 获取线程运行状态 */
- bool getThreadRunning() const;
- protected:
- /* 真正执行任务的地方 */
- virtual void task() = 0;
- /* 初始化数据接口 */
- bool initDataInterface();
- /* 读取Redis数据 */
- void readRedisData(ListAlarmInfo& listAlarm);
- /* 更新检测时间范围,一定时间更新一次,不是每次都更新 */
- inline bool updateDetectTime(DetectPeriodInfo& periodInfo);
- /* 判断是否在检测时间内,重载版,会自动打印日志 */
- bool isInDetectTime(const DetectPeriodInfo& periodInfo);
- /* 判断报警数据有效时间 */
- bool isEventTimeVaild(const QDateTime& eventTime);
- /* 打印一些原始数据信息 */
- void printRawDataInfo(const RoomCamActInfo& roomInfo, const std::string& strKey, const AlarmInfo& alarmInfo);
-
- protected:
- std::shared_ptr<spdlog::logger> m_logger = nullptr;
- /* 读取Redis的实例 */
- std::shared_ptr<FromRedis> m_fromRedis = nullptr;
- /* 写入EQM数据库的实例 */
- std::shared_ptr<FromWebAPI> m_fromWebAPI = nullptr;
- /* 线程信息 */
- FuncThreadInfo m_funcThreadInfo;
-
- std::atomic_bool m_bRunning = false; /* 线程运行状态 */
- std::string m_baseLog; /* 带有频道功能信息的基础字符串 */
- DetectPeriodInfo m_periodInfo; /* 检测时间段 */
- QDateTime m_nowTime; /* 当前时间 */
- };
- #endif // FUNCBASE_H
|