GlobalVariable.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #ifndef GLOBALVARIABLE_H
  2. #define GLOBALVARIABLE_H
  3. #include <QString>
  4. #include <vector>
  5. #include <list>
  6. #include <map>
  7. #include <mutex>
  8. #include <QDateTime>
  9. #include <QReadWriteLock>
  10. #include "nlohmann/json.hpp"
  11. /* ====================================================================================
  12. * ******************************* 全局变量定义 **********************************
  13. * ====================================================================================*/
  14. /**
  15. * @brief 全局信息
  16. *
  17. */
  18. using nJson = nlohmann::json;
  19. /* Rides数据时间有效性 */
  20. extern int g_eventTimeVaild;
  21. /* 线程运行时的状态 */
  22. enum class RunTimeState
  23. {
  24. RUN_STATE_NONE = 0, /* 无状态 */
  25. RUN_STATE_INIT, /* 初始化 */
  26. RUN_STATE_RUN, /* 运行 */
  27. RUN_STATE_STOP, /* 停止,是外部给子线程的信号,让其退出 */
  28. RUN_STATE_ERROR, /* 错误 */
  29. RUN_STATE_EXITCOMPLET, /* 退出完成 */
  30. };
  31. /* 应用功能 */
  32. enum class AppFunction
  33. {
  34. APP_NONE = 0, /* 无功能 */
  35. APP_OnWork = 1, /* 人员在岗识别(需要多个摄像机配合) */
  36. APP_Contraband, /* 违禁品识别 */
  37. APP_Illegal, /* 非法入侵检测 */
  38. APP_Fatigue, /* 疲劳检测 */
  39. APP_Regional, /* 区域人员检测,人员计数(需要多个摄像机配合) */
  40. APP_Mouse, /* 老鼠识别 */
  41. APP_PlayPhone, /* 玩手机识别 */
  42. APP_NoMask, /* 未戴口罩识别 */
  43. APP_AllDown, /* 摔倒识别 */
  44. };
  45. /* 全局算法列表 */
  46. class ActionList
  47. {
  48. public:
  49. /* 全局算法ID */
  50. // std::mutex mutexActionID; /* 算法ID的互斥锁 */
  51. QReadWriteLock mutexRW; /* 读写锁 */
  52. std::string ActFace; /* 人脸识别 */
  53. std::string ActPersonNumber; /* 人员计数 */
  54. std::string ActPlayPhone; /* 玩手机 */
  55. std::string ActContraband; /* 违禁品物品 */
  56. std::string ActSleep; /* 睡岗识别 */
  57. std::string ActFatigueDetection; /* 疲劳检测 */
  58. std::string ActAnimalDetect; /* 动物识别 */
  59. std::string ActMouseDetect; /* 老鼠识别 */
  60. std::string ActMask; /* 口罩识别 */
  61. std::map<std::string, std::string> mapAction; /* 算法ID和算法名称的对应关系 */
  62. ActionList() = default;
  63. std::string getActionName(const std::string& actionID) {
  64. std::string actionName;
  65. mutexRW.lockForRead();
  66. auto it = mapAction.find(actionID);
  67. if(it != mapAction.end()) {
  68. actionName = it->second;
  69. }
  70. mutexRW.unlock();
  71. return actionName;
  72. }
  73. };
  74. extern ActionList g_actionList;
  75. /* 算法相关信息 */
  76. struct AlgorithmInfo
  77. {
  78. int PKID; /* 主键ID */
  79. int ActionTaskID; /* 算法任务ID */
  80. std::string ActionID; /* 算法ID */
  81. std::string ActionName; /* 算法名称 */
  82. AlgorithmInfo() = default;
  83. AlgorithmInfo(const AlgorithmInfo& other)
  84. : PKID(other.PKID), ActionID(other.ActionID), ActionName(other.ActionName), ActionTaskID(other.ActionTaskID) {}
  85. AlgorithmInfo& operator=(const AlgorithmInfo& other) {
  86. if (this != &other) {
  87. ActionID = other.ActionID;
  88. ActionName = other.ActionName;
  89. ActionTaskID = other.ActionTaskID;
  90. PKID = other.PKID;
  91. }
  92. return *this;
  93. }
  94. /* 对比是否相等 */
  95. bool operator==(const AlgorithmInfo& other) const {
  96. if(ActionID != other.ActionID) {
  97. return false;
  98. }
  99. if(ActionName != other.ActionName || ActionTaskID != other.ActionTaskID) {
  100. return false;
  101. }
  102. return true;
  103. }
  104. };
  105. /* 设备列表 */
  106. struct DeviceInfo
  107. {
  108. int PKID; /* 主键ID */
  109. int DeviceID; /* 设备ID */
  110. int DevicePort; /* 设备端口 */
  111. std::string DeviceName; /* 设备名称 */
  112. std::string DeviceIP; /* 设备IP */
  113. std::string DeviceSerial; /* 设备序列号 */
  114. std::string DeviceType; /* 设备类型 */
  115. std::string UserAccount; /* 用户账号 */
  116. std::string UserPassword; /* 用户密码 */
  117. std::vector<AlgorithmInfo> vecAlgorithmInfo; /* 算法信息 */
  118. DeviceInfo() = default;
  119. DeviceInfo(const DeviceInfo& other)
  120. : PKID(other.PKID),
  121. DeviceID(other.DeviceID),
  122. DevicePort(other.DevicePort),
  123. DeviceName(other.DeviceName),
  124. DeviceSerial(other.DeviceSerial),
  125. DeviceType(other.DeviceType),
  126. DeviceIP(other.DeviceIP),
  127. UserAccount(other.UserAccount),
  128. UserPassword(other.UserPassword),
  129. vecAlgorithmInfo(other.vecAlgorithmInfo) {}
  130. DeviceInfo& operator=(const DeviceInfo& other) {
  131. if (this != &other) {
  132. DeviceID = other.DeviceID;
  133. DevicePort = other.DevicePort;
  134. DeviceName = other.DeviceName;
  135. DeviceSerial = other.DeviceSerial;
  136. DeviceType = other.DeviceType;
  137. DeviceIP = other.DeviceIP;
  138. UserAccount = other.UserAccount;
  139. UserPassword = other.UserPassword;
  140. vecAlgorithmInfo = other.vecAlgorithmInfo;
  141. }
  142. return *this;
  143. }
  144. /* 对比是否相等 */
  145. bool operator==(const DeviceInfo& other);
  146. /* 对比设备关联的算法信息是否相等 */
  147. bool isEqualAlgorithmInfo(const std::vector<AlgorithmInfo>& other);
  148. };
  149. /* 算法和设备关联的相关信息 */
  150. struct DeviceAlgorithmInfo
  151. {
  152. int DeviceID; /* 设备ID */
  153. int ActionTaskID; /* 算法任务ID */
  154. std::string ActionID; /* 算法ID */
  155. std::string ActionName; /* 算法名称 */
  156. };
  157. /**
  158. * @brief 摄像机线程需要的信息
  159. *
  160. */
  161. struct CameraThreadInfo
  162. {
  163. std::string RedisIP; /* Redis IP */
  164. int RedisPort; /* Redis Port */
  165. std::string RedisPWD; /* Redis Password */
  166. int DeviceID; /* 设备ID */
  167. std::vector<std::string> vecAction; /* Redis Key,一个设备可能会有多个算法ID */
  168. CameraThreadInfo() = default;
  169. CameraThreadInfo& operator=(const CameraThreadInfo& other) {
  170. if (this != &other) {
  171. RedisIP = other.RedisIP;
  172. RedisPort = other.RedisPort;
  173. RedisPWD = other.RedisPWD;
  174. DeviceID = other.DeviceID;
  175. vecAction = other.vecAction;
  176. }
  177. return *this;
  178. }
  179. };
  180. /* ====================================================================================
  181. * ******************************* 各种报警信息 **********************************
  182. * ====================================================================================*/
  183. /**
  184. * @brief 人员信息
  185. *
  186. */
  187. struct PersonInfo
  188. {
  189. std::string PersonID; /* 人员ID,等于-1就是无法识别出身份的人员 */
  190. std::string PersonName; /* 人员名称 */
  191. QDateTime lastOnWork; /* 最后在岗时间 */
  192. };
  193. /**
  194. * @brief 报警信息
  195. *
  196. */
  197. struct AlarmInfo
  198. {
  199. bool Is_Alarm; /* 是否报警 */
  200. int AlarmID; /* 报警ID */
  201. int DeviceID; /* 设备ID,数据库表格中对应的是CamerID */
  202. int RoomID; /* 房间ID */
  203. int ChannelID; /* 通道ID */
  204. int State; /* 状态 */
  205. int OnWork; /* 是否在工作 */
  206. std::string ActionID; /* 算法ID */
  207. std::string StartTime; /* 报警开始时间 */
  208. std::string EndTime; /* 报警结束时间 */
  209. std::string EventTime; /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
  210. std::string PicUrl; /* 报警图片URL */
  211. std::string ImageInfo; /* 图片信息 */
  212. std::string AppID; /* 客户端应用ID */
  213. std::string ActionDes; /* 算法描述信息 */
  214. std::string FaceIDList; /* 人脸ID列表 */
  215. std::string FaceNameList; /* 人脸名称列表 */
  216. std::list<std::string> listBbox; /* Bbox列表,应该是图片中的报警位置 */
  217. std::vector<PersonInfo> vecPersonInfo; /* 人员信息 */
  218. AlarmInfo();
  219. AlarmInfo(const AlarmInfo& other);
  220. AlarmInfo& operator=(AlarmInfo& other);
  221. void reInit();
  222. };
  223. /**
  224. * @brief 报警信息容器,并提供一些函数
  225. *
  226. */
  227. struct ListAlarmInfo
  228. {
  229. std::list<AlarmInfo> listAlarmInfo; /* 报警信息列表 */
  230. /* 添加报警信息 */
  231. bool addAlarmInfo(AlarmInfo& info);
  232. AlarmInfo* findAlarmInfo(AlarmInfo& info);
  233. };
  234. /**
  235. * @brief 房间内的人脸信息
  236. *
  237. */
  238. struct RoomFaceInfo
  239. {
  240. int ChannelID = 0;
  241. int RoomID = 0;
  242. int CameraID = 0;
  243. int MaxNum = 0;
  244. int MinNum = 0;
  245. QDateTime StartTime;
  246. QDateTime EndTime;
  247. std::list<PersonInfo> listPersonInfo;
  248. RoomFaceInfo() = default;
  249. RoomFaceInfo& operator=(const RoomFaceInfo& other) {
  250. if (this != &other) {
  251. ChannelID = other.ChannelID;
  252. RoomID = other.RoomID;
  253. CameraID = other.CameraID;
  254. MaxNum = other.MaxNum;
  255. MinNum = other.MinNum;
  256. StartTime = other.StartTime;
  257. EndTime = other.EndTime;
  258. listPersonInfo = other.listPersonInfo;
  259. }
  260. return *this;
  261. }
  262. /* 查找是否有相同的人脸信息 */
  263. bool findPersonInfo(const PersonInfo& info);
  264. };
  265. /**
  266. * @brief 房间内的人脸信息
  267. *
  268. */
  269. struct ListRoomFaceInfo
  270. {
  271. std::list<RoomFaceInfo> listRoomFaceInfo;
  272. void addRoomFaceInfo(RoomFaceInfo& info);
  273. void addRoomFaceInfo(AlarmInfo& info);
  274. RoomFaceInfo* findRoomFaceInfo(RoomFaceInfo& info);
  275. RoomFaceInfo* findRoomFaceInfo(int ChannelID, int RoomID, int CameraID);
  276. };
  277. /**
  278. * @brief 非法入侵检测信息结构体,作为缓存存储正在报警的信息
  279. *
  280. */
  281. struct IllegalInvasionInfo
  282. {
  283. bool isInsertEQM = false; /* 是否已经插入到EQM数据库的报警信息中 */
  284. int PKID = 0;
  285. int CameraID = 0;
  286. int RoomID = 0;
  287. int ChannelID = 0;
  288. int RoomType = 0; /* 房间类型 */
  289. QDateTime FirstTime; /* 最开始的报警时间 */
  290. std::string strActionDec; /* 算法描述 */
  291. std::string strImageInfo; /* 图片信息 */
  292. IllegalInvasionInfo() = default;
  293. IllegalInvasionInfo(const IllegalInvasionInfo& other);
  294. IllegalInvasionInfo& operator=(const IllegalInvasionInfo& other);
  295. };
  296. /**
  297. * @brief 非法入侵报警列表
  298. *
  299. */
  300. struct ListIllegalInvasionInfo
  301. {
  302. std::list<IllegalInvasionInfo> listIll;
  303. std::list<IllegalInvasionInfo>& getData() { return listIll; }
  304. /* 添加信息 */
  305. void addIllInfo(IllegalInvasionInfo& info);
  306. /* 查找相同的信息 */
  307. IllegalInvasionInfo* findIllInfo(IllegalInvasionInfo& info);
  308. IllegalInvasionInfo* findIllInfo(int roomID, int roomType);
  309. /* 删除报警信息 */
  310. void deleteIllInfo(IllegalInvasionInfo& info);
  311. void deleteIllInfo(int roomID, int roomType);
  312. };
  313. /**
  314. * @brief 房间为单位的非法入侵信息
  315. *
  316. */
  317. struct RoomIllegalInvasionInfo
  318. {
  319. bool isAlarm = false; /* 是否在报警 */
  320. int RoomID = 0; /* 房间ID */
  321. int RoomType = 0; /* 房间类型 */
  322. int numMaxFace = 0; /* 最大人脸数 */
  323. int numMaxPerson = 0; /* 最大人员数 */
  324. int CameraID = 0; /* 摄像机ID,这个存储的是使用的哪个报警信息的ID */
  325. std::list<std::string> strBoxList; /* box */
  326. std::string strMessage; /* 报警信息字符串 */
  327. std::string strImage; /* 报警图片 */
  328. std::vector<PersonInfo> vecPersonInfo; /* 人员信息 */
  329. RoomIllegalInvasionInfo() = default;
  330. RoomIllegalInvasionInfo(const RoomIllegalInvasionInfo& o);
  331. RoomIllegalInvasionInfo& operator=(const RoomIllegalInvasionInfo& o);
  332. };
  333. /**
  334. * @brief 房间报警数据,以房间为单位
  335. *
  336. */
  337. struct ListRoomIll
  338. {
  339. std::list<RoomIllegalInvasionInfo> listRoomIll;
  340. std::list<RoomIllegalInvasionInfo>& getData() { return listRoomIll; }
  341. /* 添加房间 */
  342. void addRoom(int RoomID, int RoomType);
  343. /* 查找是否有相同的房间 */
  344. RoomIllegalInvasionInfo* findRoom(int RoomID, int RoomType);
  345. };
  346. /**
  347. * @brief 报警规则
  348. *
  349. */
  350. struct PersonCountRuleInfo
  351. {
  352. int ChannelID; /* 通道ID */
  353. std::string PeriodName; /* 时间段名称 */
  354. QDateTime StartTime; /* 开始时间 */
  355. QDateTime EndTime; /* 结束时间 */
  356. int week; /* 星期 */
  357. int RuleType; /* 规则类型,0表示所有时段,1表示按天,2表示按周 */
  358. bool LiveMinEnable; /* 启用直播间最小人数 */
  359. bool LiveMaxEnable; /* 启用直播间最大人数 */
  360. bool DicMinEnable; /* 启用导播间最小人数 */
  361. bool DicMaxEnable; /* 启用导播间最大人数 */
  362. bool LiveDicMinEnable; /* 启用直播间和导播间最小人数 */
  363. bool LiveDicMaxEnable; /* 启用直播间和导播间最大人数 */
  364. int LiveMin; /* 直播间最小人数 */
  365. int LiveMax; /* 直播间最大人数 */
  366. int DicMin; /* 导播间最小人数 */
  367. int DicMax; /* 导播间最大人数 */
  368. int LiveDicMin; /* 直播间和导播间最小人数 */
  369. int LiveDicMax; /* 直播间和导播间最大人数 */
  370. std::string RuleName; /* 规则名称 */
  371. PersonCountRuleInfo();
  372. PersonCountRuleInfo& operator=(PersonCountRuleInfo& other);
  373. };
  374. /**
  375. * @brief 房间和摄像机关联信息,这个是从客户端配置的
  376. * 一个房间对应多个摄像机
  377. *
  378. */
  379. struct RoomCameraInfo
  380. {
  381. int RoomID; /* 房间ID */
  382. std::list<int> listCameraID; /* 摄像机列表 */
  383. RoomCameraInfo() = default;
  384. RoomCameraInfo& operator=(const RoomCameraInfo& other) {
  385. if (this != &other) {
  386. RoomID = other.RoomID;
  387. listCameraID = other.listCameraID;
  388. }
  389. return *this;
  390. }
  391. /* 这里只对比RoomID */
  392. bool operator==(const RoomCameraInfo& other) const {
  393. if(RoomID != other.RoomID) {
  394. return false;
  395. }
  396. return true;
  397. }
  398. };
  399. /* ====================================================================================
  400. * **************************** 线程功能需要的结构体 *****************************
  401. * ====================================================================================*/
  402. /**
  403. * @brief 单个算法信息,包括包含的摄像机,房间、频率信息
  404. *
  405. */
  406. struct ActionInfo
  407. {
  408. RunTimeState RunState; /* 线程运行状态 */
  409. int ChannelID; /* 通道ID */
  410. int RoomID; /* 房间ID */
  411. int CameraID; /* 摄像机ID */
  412. int RoomType; /* 房间类型 */
  413. std::string ActionID; /* 算法ID */
  414. std::string strRoomName; /* 房间名称 */
  415. std::string strActionName; /* 算法名称,这个是自定义的,不需要对比 */
  416. ActionInfo();
  417. ActionInfo& operator=(const ActionInfo& other);
  418. /* 对比是否相等,这个需要完全相等,包括算法信息和摄像机信息 */
  419. bool operator==(const ActionInfo& other);
  420. /* 对比除摄像机外的基础信息是否相等 */
  421. bool isEqualBaseInfo(const ActionInfo& other);
  422. };
  423. /**
  424. * @brief 算法信息列表,这个列表既可以存储房间和算法ID的关联信息,也可以用来存储运行线程的信息
  425. *
  426. */
  427. class ListActionInfo
  428. {
  429. public:
  430. ListActionInfo() = default;
  431. /* 添加关联信息,会自动进行重复判断,如果已有相同的信息,则跳过 */
  432. bool insertActionInfo(ActionInfo* info);
  433. /* 删除信息 */
  434. bool deleteActionInfo(ActionInfo* info);
  435. /* 给算法添加摄像机,原有的会被替换掉 */
  436. bool addActionCamera(ActionInfo* pInfo);
  437. /* 清空算法中的摄像机信息 */
  438. void clearCameraList();
  439. /* 清空设置成STOP或ERROR的Action */
  440. void clearStopAction();
  441. /* 查找算法ID是否已在列表中 */
  442. ActionInfo* findActionInList(ActionInfo* pInfo);
  443. /* 查找算法ID是否在列表中,这里查找不会对比摄像机ID */
  444. ActionInfo* findActionIDInListNoCamera(ActionInfo* pInfo);
  445. /* 获取容器 */
  446. std::list<ActionInfo*>& getData() {
  447. return listActionInfo;
  448. }
  449. /* 清空容器 */
  450. void clear();
  451. std::list<ActionInfo*> listActionInfo; /* 房间和算法ID关联列表 */
  452. };
  453. /**
  454. * @brief 算法信息,以房间分类,算法包含在这干房间内所需要的摄像机ID
  455. *
  456. */
  457. struct RoomActionInfo
  458. {
  459. int ChannelID; /* 通道ID */
  460. int RoomID; /* 房间ID */
  461. int RoomType; /* 房间类型 */
  462. std::string ActionID; /* 算法ID */
  463. std::string strRoomName; /* 房间名称 */
  464. std::list<int> listCameraID; /* 摄像机ID */
  465. RoomActionInfo() {
  466. ChannelID = -1;
  467. RoomID = -1;
  468. RoomType = -1;
  469. ActionID = "";
  470. strRoomName = "";
  471. listCameraID.clear();
  472. }
  473. RoomActionInfo(const RoomActionInfo& other)
  474. : ChannelID(other.ChannelID), RoomID(other.RoomID),
  475. RoomType(other.RoomType), ActionID(other.ActionID),
  476. strRoomName(other.strRoomName), listCameraID(other.listCameraID) {}
  477. RoomActionInfo& operator=(const RoomActionInfo& other) {
  478. if (this != &other) {
  479. ChannelID = other.ChannelID;
  480. RoomID = other.RoomID;
  481. RoomType = other.RoomType;
  482. ActionID = other.ActionID;
  483. strRoomName = other.strRoomName;
  484. listCameraID = other.listCameraID;
  485. }
  486. return *this;
  487. }
  488. /* 对比频道信息、房间信息、算法ID是否相等 */
  489. bool isEqualBaseInfo(const RoomActionInfo& other);
  490. };
  491. /* 房间和算法ID关联列表 */
  492. class ListRoomActionInfo
  493. {
  494. public:
  495. ListRoomActionInfo() = default;
  496. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  497. bool insertRoomActionInfo(const RoomActionInfo& info);
  498. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  499. bool insertRoomActionInfo(const int ChannelID, const int RoomID, const std::string& strActionID);
  500. /* 删除一个容器,注意,这个不能在别的for循环中删除,只能单独删除 */
  501. bool deleteRoomActionInfo(RoomActionInfo* pInfo);
  502. /* 清空容器 */
  503. void clear();
  504. /* 添加算法信息,根据传入的算法信息,自动将其加入到对应的容器中 */
  505. void addActionInfo(const ActionInfo& info);
  506. /* 清空算法对应的摄像机列表 */
  507. void clearCameraList();
  508. /* 清理设置为STOP或者ERROR的RoomAction */
  509. // void clearStopRoomAction();
  510. /* 查找算法ID是否已在列表中 */
  511. RoomActionInfo* findActionIDInList(const int chnID, const int RoomID, const std::string& strActionID);
  512. /* 获取容器 */
  513. std::list<RoomActionInfo*>& getData() {
  514. return listRoomActionInfo;
  515. }
  516. std::list<RoomActionInfo*> listRoomActionInfo; /* 房间和算法ID关联列表 */
  517. };
  518. /**
  519. * @brief 房间内的摄像机和算法关联信息
  520. *
  521. */
  522. struct RoomCamActInfo
  523. {
  524. int RoomID; /* 房间ID */
  525. int RoomType; /* 房间类型 */
  526. std::multimap<int, std::string> mapCameraAction; /* 摄像机ID和算法ID关联信息 */
  527. };
  528. /**
  529. * @brief 读取到的应用信息和启用时段
  530. *
  531. */
  532. struct AppAndTimeInfo
  533. {
  534. uint8_t AppType; /* 应用信息,按位计算 */
  535. int ChannelID; /* 通道ID */
  536. QDateTime StartTime; /* 开始时间 */
  537. QDateTime EndTime; /* 结束时间 */
  538. AppAndTimeInfo() = default;
  539. AppAndTimeInfo& operator=(AppAndTimeInfo& other) {
  540. if (this != &other) {
  541. AppType = other.AppType;
  542. ChannelID = other.ChannelID;
  543. StartTime = other.StartTime;
  544. EndTime = other.EndTime;
  545. }
  546. return *this;
  547. }
  548. };
  549. /**
  550. * @brief 按照功能分类的线程信息,一个实例就是一个功能,
  551. 比如区域入侵检测,需要多个算法多个摄像机共同配合
  552. *
  553. */
  554. struct FuncActionInfo
  555. {
  556. int ChannelID; /* 通道ID */
  557. AppFunction appFunction; /* 任务功能 */
  558. RunTimeState RunState; /* 线程运行状态 */
  559. std::string strFunctionName; /* 功能名称 */
  560. QDateTime StartTime; /* 开始时间 */
  561. QDateTime EndTime; /* 结束时间 */
  562. std::list<RoomCamActInfo> listRoomCamActInfo; /* 房间内的摄像机和算法关联信息 */
  563. FuncActionInfo();
  564. FuncActionInfo& operator=(FuncActionInfo& other);
  565. /* 添加算法信息 */
  566. bool addActionInfo(const ActionInfo& info);
  567. /* 清空算法信息 */
  568. void clearActionList();
  569. };
  570. /**
  571. * @brief 线程功能块
  572. *
  573. */
  574. struct ListFuncActInfo
  575. {
  576. ListFuncActInfo() = default;
  577. /* 添加功能信息 */
  578. bool addFuncActionInfo(const AppAndTimeInfo& func);
  579. /* 添加算法信息 */
  580. bool addActionInfo(const ActionInfo& info);
  581. /* 清空无用的功能信息 */
  582. void clearNoneFuncActionInfo();
  583. /* 清空房间和算法列表 */
  584. void clearActionList();
  585. /* 获取容器 */
  586. std::list<FuncActionInfo*>& getData() {
  587. return listFuncActionInfo;
  588. }
  589. /* 查找应用信息 */
  590. bool findAppFunction(const AppFunction func);
  591. FuncActionInfo* findAppFunction(const int ChannelID, const AppFunction func);
  592. FuncActionInfo* findAppFunction(const FuncActionInfo& func);
  593. std::list<FuncActionInfo*> listFuncActionInfo; /* 功能信息列表 */
  594. };
  595. #endif /* GLOBALVARIABLE_H */