FuncBase.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef FUNCBASE_H
  2. #define FUNCBASE_H
  3. #include <memory>
  4. #include "GlobalVariable.h"
  5. #include "GlobalFuncThread.h"
  6. #include "spdlog/spdlog.h"
  7. class FromRedis;
  8. class FromWebAPI;
  9. struct FuncThreadInfo;
  10. /**
  11. * @brief 功能基础类,包含读取Redis数据和写入EQM数据库的功能
  12. *
  13. */
  14. class FuncBase
  15. {
  16. public:
  17. FuncBase();
  18. ~FuncBase();
  19. /* 任务线程 */
  20. void thread_task();
  21. /* 设置功能信息 */
  22. void setFuncThreadInfo(FuncThreadInfo* pFuncAct);
  23. void setFuncThreadInfo(FuncThreadInfo& FuncAct);
  24. /* 获取该实例的功能 */
  25. AppFunction getApp();
  26. /* 获取线程运行状态 */
  27. bool getThreadRunning() const;
  28. protected:
  29. /* 真正执行任务的地方 */
  30. virtual void task() = 0;
  31. /* 判断是否在检测时间内 */
  32. bool isInDetectTime(const QDateTime& start, const QDateTime& end);
  33. protected:
  34. std::shared_ptr<spdlog::logger> m_logger = nullptr;
  35. /* 读取Redis的实例 */
  36. std::shared_ptr<FromRedis> m_fromRedis = nullptr;
  37. /* 写入EQM数据库的实例 */
  38. std::shared_ptr<FromWebAPI> m_fromWebAPI = nullptr;
  39. /* 线程信息 */
  40. FuncThreadInfo m_funcThreadInfo;
  41. std::atomic_bool m_bRunning = false; /* 线程运行状态 */
  42. };
  43. #endif // FUNCBASE_H