GlobalConfig.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef GLOBALCONFIG_H
  2. #define GLOBALCONFIG_H
  3. #include <QString>
  4. #include "GlobalVariable.h"
  5. /* ====================================================================================
  6. * ***************************** GlobalConfig ***********************************
  7. * ====================================================================================*/
  8. #define GConfig GlobalConfig::getInstance()
  9. /**
  10. * @brief 配置文件信息
  11. *
  12. */
  13. class GlobalConfig
  14. {
  15. GlobalConfig();
  16. ~GlobalConfig() = default;
  17. GlobalConfig(const GlobalConfig& other) = delete;
  18. GlobalConfig& operator=(const GlobalConfig& other) = delete;
  19. public:
  20. static GlobalConfig& getInstance()
  21. {
  22. static GlobalConfig gc;
  23. return gc;
  24. }
  25. /* 读取配置文件 */
  26. bool readConfig(const QString& strConfigFile);
  27. /* 打印读取到的值 */
  28. void printValue();
  29. int AppUpdateOnWorkTimeInterval;/* 更新在岗信息的时间间隔 */
  30. int AppPeopleOnWork; /* 离岗时间 */
  31. int Contraband; /* 违禁物品出现的时间 */
  32. int AppBadMan; /* 非法入侵 */
  33. int AppTired; /* 疲劳检测时间 */
  34. int AppPeopleCont; /* 区域人员统计 */
  35. int AppPlayPhone; /* 玩手机识别 */
  36. int AppMouse; /* 老鼠识别 */
  37. int AppMask; /* 戴口罩识别 */
  38. int CheckSet; /* 服务端多久检测一次配置 */
  39. int EventTimeValid; /* 事件时间有效期 */
  40. int ThreadSleepMS; /* 任务线程休眠时间,单位是ms */
  41. std::string Key; /* Key */
  42. std::string Secret; /* Secret */
  43. };
  44. /* ====================================================================================
  45. * ************************ GlobalThreadInfo成员函数 ****************************
  46. * ====================================================================================*/
  47. #define GThreadInfo GlobalThreadInfo::getInstance()
  48. /**
  49. * @brief 线程信息,也是应用功能块列表,每个频率下的每个功能就是一个线程
  50. *
  51. */
  52. class GlobalThreadInfo
  53. {
  54. GlobalThreadInfo() {}
  55. ~GlobalThreadInfo() {}
  56. GlobalThreadInfo(const GlobalThreadInfo& other) = delete;
  57. GlobalThreadInfo& operator=(const GlobalThreadInfo& other) = delete;
  58. public:
  59. static GlobalThreadInfo& getInstance()
  60. {
  61. static GlobalThreadInfo instance;
  62. return instance;
  63. }
  64. /* 获取线程运行标志位 */
  65. bool getRunning() const;
  66. /* 设置线程运行标志位 */
  67. void setRunning(bool bRunning);
  68. /* 手动给功能块列表加锁 */
  69. void lockRunFAI();
  70. /* 手动解锁 */
  71. void unlockRunFAI();
  72. /* 添加功能信息 */
  73. bool addFuncActionInfo(const AppAndTimeInfo& func);
  74. /* 添加算法信息 */
  75. bool addActionInfo(const ActionInfo& info);
  76. /* 清空无用的功能信息 */
  77. void clearNoneFuncActionInfo();
  78. /* 清空房间和算法列表 */
  79. void clearActionList();
  80. /* 设置没有配置摄像机的功能退出 */
  81. void setNoneCameraFuncStop();
  82. /* 获取容器 */
  83. std::list<FuncActionInfo*>& getList() {
  84. return m_listFuncActionInfo;
  85. }
  86. /* 查找应用信息 */
  87. bool findAppFunction(const AppFunction func);
  88. FuncActionInfo* findAppFunction(const int ChannelID, const AppFunction func);
  89. FuncActionInfo* findAppFunction(const FuncActionInfo& func);
  90. /* 设置线程状态 */
  91. void setThreadState(FuncActionInfo* pInfo, RunTimeState state);
  92. /* 更新算法的摄像机ID */
  93. bool updateFuncInfo(FuncActionInfo* pInfo);
  94. private:
  95. std::atomic_bool m_bRunning; /* 线程运行状态 */
  96. /* 运行时应用线程功能相关信息 */
  97. std::mutex m_mutexRunFAI;
  98. std::list<FuncActionInfo*> m_listFuncActionInfo; /* 功能信息列表 */
  99. };
  100. #endif /* GLOBALCONFIG_H */