GlobalInfo.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. #ifndef GLOBALINFO_H
  2. #define GLOBALINFO_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 AlarmRuleInfo
  350. {
  351. bool LiveMinEnable; /* 启用直播间最小人数 */
  352. bool LiveMaxEnable; /* 启用直播间最大人数 */
  353. bool DicMinEnable; /* 启用导播间最小人数 */
  354. bool DicMaxEnable; /* 启用导播间最大人数 */
  355. bool LiveDicMinEnable; /* 启用直播间和导播间最小人数 */
  356. bool LiveDicMaxEnable; /* 启用直播间和导播间最大人数 */
  357. int LiveMin; /* 直播间最小人数 */
  358. int LiveMax; /* 直播间最大人数 */
  359. int DicMin; /* 导播间最小人数 */
  360. int DicMax; /* 导播间最大人数 */
  361. int LiveDicMin; /* 直播间和导播间最小人数 */
  362. int LiveDicMax; /* 直播间和导播间最大人数 */
  363. std::string RuleName; /* 规则名称 */
  364. AlarmRuleInfo();
  365. AlarmRuleInfo& operator=(AlarmRuleInfo& other);
  366. };
  367. /**
  368. * @brief 房间和摄像机关联信息,这个是从客户端配置的
  369. * 一个房间对应多个摄像机
  370. *
  371. */
  372. struct RoomCameraInfo
  373. {
  374. int RoomID; /* 房间ID */
  375. std::list<int> listCameraID; /* 摄像机列表 */
  376. RoomCameraInfo() = default;
  377. RoomCameraInfo& operator=(const RoomCameraInfo& other) {
  378. if (this != &other) {
  379. RoomID = other.RoomID;
  380. listCameraID = other.listCameraID;
  381. }
  382. return *this;
  383. }
  384. /* 这里只对比RoomID */
  385. bool operator==(const RoomCameraInfo& other) const {
  386. if(RoomID != other.RoomID) {
  387. return false;
  388. }
  389. return true;
  390. }
  391. };
  392. /* ====================================================================================
  393. * **************************** 线程功能需要的结构体 *****************************
  394. * ====================================================================================*/
  395. /**
  396. * @brief 单个算法信息,包括包含的摄像机,房间、频率信息
  397. *
  398. */
  399. struct ActionInfo
  400. {
  401. RunTimeState RunState; /* 线程运行状态 */
  402. int ChannelID; /* 通道ID */
  403. int RoomID; /* 房间ID */
  404. int CameraID; /* 摄像机ID */
  405. int RoomType; /* 房间类型 */
  406. std::string ActionID; /* 算法ID */
  407. std::string strRoomName; /* 房间名称 */
  408. std::string strActionName; /* 算法名称,这个是自定义的,不需要对比 */
  409. ActionInfo();
  410. ActionInfo& operator=(const ActionInfo& other);
  411. /* 对比是否相等,这个需要完全相等,包括算法信息和摄像机信息 */
  412. bool operator==(const ActionInfo& other);
  413. /* 对比除摄像机外的基础信息是否相等 */
  414. bool isEqualBaseInfo(const ActionInfo& other);
  415. };
  416. /**
  417. * @brief 算法信息列表,这个列表既可以存储房间和算法ID的关联信息,也可以用来存储运行线程的信息
  418. *
  419. */
  420. class ListActionInfo
  421. {
  422. public:
  423. ListActionInfo() = default;
  424. /* 添加关联信息,会自动进行重复判断,如果已有相同的信息,则跳过 */
  425. bool insertActionInfo(ActionInfo* info);
  426. /* 删除信息 */
  427. bool deleteActionInfo(ActionInfo* info);
  428. /* 给算法添加摄像机,原有的会被替换掉 */
  429. bool addActionCamera(ActionInfo* pInfo);
  430. /* 清空算法中的摄像机信息 */
  431. void clearCameraList();
  432. /* 清空设置成STOP或ERROR的Action */
  433. void clearStopAction();
  434. /* 查找算法ID是否已在列表中 */
  435. ActionInfo* findActionInList(ActionInfo* pInfo);
  436. /* 查找算法ID是否在列表中,这里查找不会对比摄像机ID */
  437. ActionInfo* findActionIDInListNoCamera(ActionInfo* pInfo);
  438. /* 获取容器 */
  439. std::list<ActionInfo*>& getData() {
  440. return listActionInfo;
  441. }
  442. /* 清空容器 */
  443. void clear();
  444. std::list<ActionInfo*> listActionInfo; /* 房间和算法ID关联列表 */
  445. };
  446. /**
  447. * @brief 算法信息,以房间分类,算法包含在这干房间内所需要的摄像机ID
  448. *
  449. */
  450. struct RoomActionInfo
  451. {
  452. int ChannelID; /* 通道ID */
  453. int RoomID; /* 房间ID */
  454. int RoomType; /* 房间类型 */
  455. std::string ActionID; /* 算法ID */
  456. std::string strRoomName; /* 房间名称 */
  457. std::list<int> listCameraID; /* 摄像机ID */
  458. RoomActionInfo() {
  459. ChannelID = -1;
  460. RoomID = -1;
  461. RoomType = -1;
  462. ActionID = "";
  463. strRoomName = "";
  464. listCameraID.clear();
  465. }
  466. RoomActionInfo(const RoomActionInfo& other)
  467. : ChannelID(other.ChannelID), RoomID(other.RoomID),
  468. RoomType(other.RoomType), ActionID(other.ActionID),
  469. strRoomName(other.strRoomName), listCameraID(other.listCameraID) {}
  470. RoomActionInfo& operator=(const RoomActionInfo& other) {
  471. if (this != &other) {
  472. ChannelID = other.ChannelID;
  473. RoomID = other.RoomID;
  474. RoomType = other.RoomType;
  475. ActionID = other.ActionID;
  476. strRoomName = other.strRoomName;
  477. listCameraID = other.listCameraID;
  478. }
  479. return *this;
  480. }
  481. /* 对比频道信息、房间信息、算法ID是否相等 */
  482. bool isEqualBaseInfo(const RoomActionInfo& other);
  483. };
  484. /* 房间和算法ID关联列表 */
  485. class ListRoomActionInfo
  486. {
  487. public:
  488. ListRoomActionInfo() = default;
  489. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  490. bool insertRoomActionInfo(const RoomActionInfo& info);
  491. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  492. bool insertRoomActionInfo(const int ChannelID, const int RoomID, const std::string& strActionID);
  493. /* 删除一个容器,注意,这个不能在别的for循环中删除,只能单独删除 */
  494. bool deleteRoomActionInfo(RoomActionInfo* pInfo);
  495. /* 清空容器 */
  496. void clear();
  497. /* 添加算法信息,根据传入的算法信息,自动将其加入到对应的容器中 */
  498. void addActionInfo(const ActionInfo& info);
  499. /* 清空算法对应的摄像机列表 */
  500. void clearCameraList();
  501. /* 清理设置为STOP或者ERROR的RoomAction */
  502. // void clearStopRoomAction();
  503. /* 查找算法ID是否已在列表中 */
  504. RoomActionInfo* findActionIDInList(const int chnID, const int RoomID, const std::string& strActionID);
  505. /* 获取容器 */
  506. std::list<RoomActionInfo*>& getData() {
  507. return listRoomActionInfo;
  508. }
  509. std::list<RoomActionInfo*> listRoomActionInfo; /* 房间和算法ID关联列表 */
  510. };
  511. /**
  512. * @brief 房间内的摄像机和算法关联信息
  513. *
  514. */
  515. struct RoomCamActInfo
  516. {
  517. int RoomID; /* 房间ID */
  518. int RoomType; /* 房间类型 */
  519. std::multimap<int, std::string> mapCameraAction; /* 摄像机ID和算法ID关联信息 */
  520. };
  521. /**
  522. * @brief 读取到的应用信息和启用时段
  523. *
  524. */
  525. struct AppAndTimeInfo
  526. {
  527. uint8_t AppType; /* 应用信息,按位计算 */
  528. int ChannelID; /* 通道ID */
  529. QDateTime StartTime; /* 开始时间 */
  530. QDateTime EndTime; /* 结束时间 */
  531. AppAndTimeInfo() = default;
  532. AppAndTimeInfo& operator=(AppAndTimeInfo& other) {
  533. if (this != &other) {
  534. AppType = other.AppType;
  535. ChannelID = other.ChannelID;
  536. StartTime = other.StartTime;
  537. EndTime = other.EndTime;
  538. }
  539. return *this;
  540. }
  541. };
  542. /**
  543. * @brief 按照功能分类的线程信息,一个实例就是一个功能,
  544. 比如区域入侵检测,需要多个算法多个摄像机共同配合
  545. *
  546. */
  547. struct FuncActionInfo
  548. {
  549. int ChannelID; /* 通道ID */
  550. AppFunction appFunction; /* 任务功能 */
  551. RunTimeState RunState; /* 线程运行状态 */
  552. std::string strFunctionName; /* 功能名称 */
  553. QDateTime StartTime; /* 开始时间 */
  554. QDateTime EndTime; /* 结束时间 */
  555. std::list<RoomCamActInfo> listRoomCamActInfo; /* 房间内的摄像机和算法关联信息 */
  556. FuncActionInfo();
  557. FuncActionInfo& operator=(FuncActionInfo& other);
  558. /* 添加算法信息 */
  559. bool addActionInfo(const ActionInfo& info);
  560. /* 清空算法信息 */
  561. void clearActionList();
  562. };
  563. /**
  564. * @brief
  565. *
  566. */
  567. struct ListFuncActInfo
  568. {
  569. ListFuncActInfo() = default;
  570. /* 添加功能信息 */
  571. bool addFuncActionInfo(const AppAndTimeInfo& func);
  572. /* 添加算法信息 */
  573. bool addActionInfo(const ActionInfo& info);
  574. /* 清空无用的功能信息 */
  575. void clearNoneFuncActionInfo();
  576. /* 清空房间和算法列表 */
  577. void clearActionList();
  578. /* 获取容器 */
  579. std::list<FuncActionInfo*>& getData() {
  580. return listFuncActionInfo;
  581. }
  582. /* 查找应用信息 */
  583. bool findAppFunction(const AppFunction func);
  584. FuncActionInfo* findAppFunction(const int ChannelID, const AppFunction func);
  585. FuncActionInfo* findAppFunction(const FuncActionInfo& func);
  586. std::list<FuncActionInfo*> listFuncActionInfo; /* 功能信息列表 */
  587. };
  588. /**
  589. * @brief 读取配置文件
  590. *
  591. */
  592. class GlobalConfig
  593. {
  594. public:
  595. GlobalConfig();
  596. ~GlobalConfig() = default;
  597. /* 读取配置文件 */
  598. bool readConfig(const QString& strConfigFile);
  599. /* 打印读取到的值 */
  600. void printValue();
  601. int AppUpdateOnWorkTimeInterval;/* 更新在岗信息的时间间隔 */
  602. int AppPeopleOnWork; /* 离岗时间 */
  603. int Contraband; /* 违禁物品出现的时间 */
  604. int AppBadMan; /* 非法入侵 */
  605. int AppTired; /* 疲劳检测时间 */
  606. int AppPeopleCont; /* 区域人员统计 */
  607. int AppPlayPhone; /* 玩手机识别 */
  608. int AppMouse; /* 老鼠识别 */
  609. int AppMask; /* 戴口罩识别 */
  610. int CheckSet; /* 服务端多久检测一次配置 */
  611. int EventTimeValid; /* 事件时间有效期 */
  612. int ThreadSleepMS; /* 任务线程休眠时间,单位是ms */
  613. std::string Key; /* Key */
  614. std::string Secret; /* Secret */
  615. };
  616. extern GlobalConfig g_config;
  617. #endif /* GLOBALINFO_H */