123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- #ifndef GLOBALFUNCTHREAD_H
- #define GLOBALFUNCTHREAD_H
- #include "GlobalVariable.h"
- /**
- * @brief 按照功能分类的线程信息,一个实例就是一个功能,
- 比如区域入侵检测,需要多个算法多个摄像机共同配合
- *
- */
- struct FuncThreadInfo
- {
- int ChannelID; /* 频率ID */
- std::string strChannelName; /* 频率名称 */
- AppFunction appFunction; /* 任务功能 */
- RunTimeState RunState; /* 线程运行状态 */
- std::string strFunctionName; /* 功能名称 */
-
- // QDateTime StartTime; /* 开始时间 */
- // QDateTime EndTime; /* 结束时间 */
- std::list<RoomCamActInfo> listRoomCamActInfo; /* 房间内的摄像机和算法关联信息 */
- std::map<int, std::string> mapCameraName; /* 摄像机名称 */
- FuncThreadInfo();
- ~FuncThreadInfo();
- FuncThreadInfo& operator=(FuncThreadInfo& other);
- /* 添加算法信息 */
- bool addActionInfo(const ActionInfo& info);
- /* 清空算法信息 */
- void clearActionList();
- /* 根据房间ID查找房间信息 */
- RoomCamActInfo findRoomInfo(const int RoomID);
- /* 获取摄像机名称 */
- std::string getCameraName(int CameraID);
- };
- /**
- * @brief 线程功能块
- *
- */
- struct ListFuncActInfo
- {
- ListFuncActInfo() = default;
- // /* 添加功能信息 */
- // bool addFuncThreadInfo(const AppAndTimeInfo& func);
- /* 添加算法信息 */
- bool addActionInfo(const ActionInfo& info);
- /* 清空无用的功能信息 */
- void clearNoneFuncThreadInfo();
- /* 清空房间和算法列表 */
- void clearActionList();
- /* 获取容器 */
- std::list<FuncThreadInfo*>& getData() {
- return listFuncThreadInfo;
- }
- /* 查找应用信息 */
- bool findAppFunction(const AppFunction func);
- FuncThreadInfo* findAppFunction(const int ChannelID, const AppFunction func);
- FuncThreadInfo* findAppFunction(const FuncThreadInfo& func);
- std::list<FuncThreadInfo*> listFuncThreadInfo; /* 功能信息列表 */
- };
- /* ====================================================================================
- * ************************ GlobalThreadInfo成员函数 ****************************
- * ====================================================================================*/
- #define GThreadInfo GlobalThreadInfo::getInstance()
- /**
- * @brief 线程信息,也是应用功能块列表,每个频率下的每个功能就是一个线程
- *
- */
- class GlobalThreadInfo
- {
- GlobalThreadInfo() {}
- ~GlobalThreadInfo() {}
- GlobalThreadInfo(const GlobalThreadInfo& other) = delete;
- GlobalThreadInfo& operator=(const GlobalThreadInfo& other) = delete;
- public:
- static GlobalThreadInfo& getInstance()
- {
- static GlobalThreadInfo instance;
- return instance;
- }
- /* 获取线程运行标志位 */
- bool getRunning() const;
- /* 设置线程运行标志位 */
- void setRunning(bool bRunning);
-
- /* 手动给功能块列表加锁 */
- void lockRunFAI();
- /* 手动解锁 */
- void unlockRunFAI();
- /* 添加功能信息 */
- bool addFuncThreadInfo(const ChannelAppInfo& func);
- /* 添加算法信息 */
- bool addActionInfo(const ActionInfo& info);
- /* 清空无用的功能信息 */
- void clearNoneFuncThreadInfo();
- /* 清空房间和算法列表 */
- void clearActionList();
- /* 设置没有配置摄像机的功能退出 */
- void setNoneCameraFuncStop();
- /* 获取容器 */
- std::list<FuncThreadInfo*>& getList() {
- return m_listFuncThreadInfo;
- }
- /* 查找应用信息 */
- bool findAppFunction(const AppFunction func);
- FuncThreadInfo* findAppFunction(const int ChannelID, const AppFunction func);
- FuncThreadInfo* findAppFunction(const FuncThreadInfo& func);
- /* 设置应用信息 */
- inline void setAppFunction(const ActionInfo& info, const AppFunction func);
- /* 设置线程状态 */
- void setThreadState(FuncThreadInfo* pInfo, RunTimeState state);
- void setThreadState(FuncThreadInfo& pInfo, RunTimeState state);
- /* 更新算法的摄像机ID */
- bool updateFuncInfo(FuncThreadInfo* pInfo);
- bool updateFuncInfo(FuncThreadInfo& pInfo);
- /* 更新频率信息 */
- // void setChannelInfo(std::map<int, std::string> mapChannelName);
- /* 设置摄像机信息 */
- void setCameraInfo(std::map<int, std::string> mapCameraName);
- private:
- std::atomic_bool m_bRunning; /* 线程运行状态 */
- /* 运行时应用线程功能相关信息 */
- std::mutex m_mutexRunFAI;
- std::list<FuncThreadInfo*> m_listFuncThreadInfo; /* 功能信息列表 */
-
- };
- #endif // GLOBALFUNCTHREAD_H
|