#ifndef FUNCBASE_H #define FUNCBASE_H #include #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(); /* 判断是否在检测时间内,不检测日期,只检测时间 */ bool isInDetectTime(const QDateTime& start, const QDateTime& end); /* 更新检测时间范围,一定时间更新一次,不是每次都更新 */ inline bool updateDetectTime(DetectPeriodInfo& periodInfo); /* 判断是否在检测时间内,重载版,会自动打印日志 */ bool isInDetectTime(const DetectPeriodInfo& periodInfo); protected: std::shared_ptr m_logger = nullptr; /* 读取Redis的实例 */ std::shared_ptr m_fromRedis = nullptr; /* 写入EQM数据库的实例 */ std::shared_ptr 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