GlobalVariable.h 22 KB

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