GlobalVariable.h 22 KB

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