GlobalInfo.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. #ifndef GLOBALINFO_H
  2. #define GLOBALINFO_H
  3. #include <QString>
  4. #include <vector>
  5. #include <list>
  6. #include <map>
  7. #include "nlohmann/json.hpp"
  8. /* ====================================================================================
  9. * ******************************* 全局变量定义 **********************************
  10. * ====================================================================================*/
  11. extern int g_eventTimeVaild;
  12. /**
  13. * @brief 全局信息
  14. *
  15. */
  16. using nJson = nlohmann::json;
  17. /* 算法相关信息 */
  18. struct AlgorithmInfo
  19. {
  20. int PKID; /* 主键ID */
  21. int ActionTaskID; /* 算法任务ID */
  22. std::string ActionID; /* 算法ID */
  23. std::string ActionName; /* 算法名称 */
  24. AlgorithmInfo() = default;
  25. AlgorithmInfo(const AlgorithmInfo& other)
  26. : PKID(other.PKID), ActionID(other.ActionID), ActionName(other.ActionName), ActionTaskID(other.ActionTaskID) {}
  27. AlgorithmInfo& operator=(const AlgorithmInfo& other) {
  28. if (this != &other) {
  29. ActionID = other.ActionID;
  30. ActionName = other.ActionName;
  31. ActionTaskID = other.ActionTaskID;
  32. PKID = other.PKID;
  33. }
  34. return *this;
  35. }
  36. /* 对比是否相等 */
  37. bool operator==(const AlgorithmInfo& other) const {
  38. if(ActionID != other.ActionID) {
  39. return false;
  40. }
  41. if(ActionName != other.ActionName || ActionTaskID != other.ActionTaskID) {
  42. return false;
  43. }
  44. return true;
  45. }
  46. };
  47. /* 设备列表 */
  48. struct DeviceInfo
  49. {
  50. int PKID; /* 主键ID */
  51. int DeviceID; /* 设备ID */
  52. int DevicePort; /* 设备端口 */
  53. std::string DeviceName; /* 设备名称 */
  54. std::string DeviceIP; /* 设备IP */
  55. std::string DeviceSerial; /* 设备序列号 */
  56. std::string DeviceType; /* 设备类型 */
  57. std::string UserAccount; /* 用户账号 */
  58. std::string UserPassword; /* 用户密码 */
  59. std::vector<AlgorithmInfo> vecAlgorithmInfo; /* 算法信息 */
  60. DeviceInfo() = default;
  61. DeviceInfo(const DeviceInfo& other)
  62. : PKID(other.PKID),
  63. DeviceID(other.DeviceID),
  64. DevicePort(other.DevicePort),
  65. DeviceName(other.DeviceName),
  66. DeviceSerial(other.DeviceSerial),
  67. DeviceType(other.DeviceType),
  68. DeviceIP(other.DeviceIP),
  69. UserAccount(other.UserAccount),
  70. UserPassword(other.UserPassword),
  71. vecAlgorithmInfo(other.vecAlgorithmInfo) {}
  72. DeviceInfo& operator=(const DeviceInfo& other) {
  73. if (this != &other) {
  74. DeviceID = other.DeviceID;
  75. DevicePort = other.DevicePort;
  76. DeviceName = other.DeviceName;
  77. DeviceSerial = other.DeviceSerial;
  78. DeviceType = other.DeviceType;
  79. DeviceIP = other.DeviceIP;
  80. UserAccount = other.UserAccount;
  81. UserPassword = other.UserPassword;
  82. vecAlgorithmInfo = other.vecAlgorithmInfo;
  83. }
  84. return *this;
  85. }
  86. /* 对比是否相等 */
  87. bool operator==(const DeviceInfo& other);
  88. /* 对比设备关联的算法信息是否相等 */
  89. bool isEqualAlgorithmInfo(const std::vector<AlgorithmInfo>& other);
  90. };
  91. /* 算法和设备关联的相关信息 */
  92. struct DeviceAlgorithmInfo
  93. {
  94. int DeviceID; /* 设备ID */
  95. int ActionTaskID; /* 算法任务ID */
  96. std::string ActionID; /* 算法ID */
  97. std::string ActionName; /* 算法名称 */
  98. };
  99. /**
  100. * @brief 摄像机线程需要的信息
  101. *
  102. */
  103. struct CameraThreadInfo
  104. {
  105. std::string RedisIP; /* Redis IP */
  106. int RedisPort; /* Redis Port */
  107. std::string RedisPWD; /* Redis Password */
  108. int DeviceID; /* 设备ID */
  109. std::vector<std::string> vecAction; /* Redis Key,一个设备可能会有多个算法ID */
  110. CameraThreadInfo() = default;
  111. CameraThreadInfo& operator=(const CameraThreadInfo& other) {
  112. if (this != &other) {
  113. RedisIP = other.RedisIP;
  114. RedisPort = other.RedisPort;
  115. RedisPWD = other.RedisPWD;
  116. DeviceID = other.DeviceID;
  117. vecAction = other.vecAction;
  118. }
  119. return *this;
  120. }
  121. };
  122. /**
  123. * @brief 人员信息
  124. *
  125. */
  126. struct PersonInfo
  127. {
  128. std::string PersonID; /* 人员ID */
  129. std::string PersonName; /* 人员名称 */
  130. };
  131. /**
  132. * @brief 报警信息
  133. *
  134. */
  135. struct AlarmInfo
  136. {
  137. bool Is_Alarm; /* 是否报警 */
  138. int AlarmID; /* 报警ID */
  139. int DeviceID; /* 设备ID,数据库表格中对应的是CamerID */
  140. int RoomID; /* 房间ID */
  141. int ChannelID; /* 通道ID */
  142. int OnWork; /* 是否在工作 */
  143. std::string ActionID; /* 算法ID */
  144. std::string StartTime; /* 报警开始时间 */
  145. std::string EndTime; /* 报警结束时间 */
  146. std::string EventTime; /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
  147. std::string PicUrl; /* 报警图片URL */
  148. std::string ImageInfo; /* 图片信息 */
  149. std::string AppID; /* 客户端应用ID */
  150. std::string ActionDes; /* 算法描述信息 */
  151. std::string FaceIDList; /* 人脸ID列表 */
  152. std::string FaceNameList; /* 人脸名称列表 */
  153. std::string BboxList; /* Bbox列表,应该图片中的报警位置 */
  154. std::vector<PersonInfo> vecPersonInfo; /* 人员信息 */
  155. };
  156. /**
  157. * @brief 房间和摄像机关联信息,这个是从客户端配置的
  158. * 一个房间对应多个摄像机
  159. *
  160. */
  161. struct RoomCameraInfo
  162. {
  163. int RoomID; /* 房间ID */
  164. std::list<int> listCameraID; /* 摄像机列表 */
  165. RoomCameraInfo() = default;
  166. RoomCameraInfo& operator=(const RoomCameraInfo& other) {
  167. if (this != &other) {
  168. RoomID = other.RoomID;
  169. listCameraID = other.listCameraID;
  170. }
  171. return *this;
  172. }
  173. /* 这里只对比RoomID */
  174. bool operator==(const RoomCameraInfo& other) const {
  175. if(RoomID != other.RoomID) {
  176. return false;
  177. }
  178. return true;
  179. }
  180. };
  181. /**
  182. * @brief 单个算法信息,包括包含的摄像机,房间、频率信息
  183. *
  184. */
  185. struct ActionInfo
  186. {
  187. int ChannelID; /* 通道ID */
  188. int RoomID; /* 房间ID */
  189. int CameraID; /* 摄像机ID */
  190. int RoomType; /* 房间类型 */
  191. std::string ActionID; /* 算法ID */
  192. std::string strRoomName; /* 房间名称 */
  193. ActionInfo() = default;
  194. ActionInfo& operator=(const ActionInfo& other) {
  195. if (this != &other) {
  196. ChannelID = other.ChannelID;
  197. RoomID = other.RoomID;
  198. CameraID = other.CameraID;
  199. ActionID = other.ActionID;
  200. strRoomName = other.strRoomName;
  201. RoomType = other.RoomType;
  202. }
  203. return *this;
  204. }
  205. /* 对比 */
  206. bool operator==(const ActionInfo& other) const {
  207. if(ChannelID != other.ChannelID) {
  208. return false;
  209. }
  210. if(RoomID != other.RoomID) {
  211. return false;
  212. }
  213. if(CameraID != other.CameraID) {
  214. return false;
  215. }
  216. if(ActionID != other.ActionID) {
  217. return false;
  218. }
  219. if(RoomType != other.RoomType) {
  220. return false;
  221. }
  222. return true;
  223. }
  224. };
  225. /**
  226. * @brief 算法信息列表
  227. *
  228. */
  229. class ListActionInfo
  230. {
  231. public:
  232. ListActionInfo() = default;
  233. /* 添加关联信息,会自动进行重复判断,如果已有相同的信息,则跳过 */
  234. bool insertActionInfo(ActionInfo* info);
  235. /* 删除信息 */
  236. bool deleteActionInfo(ActionInfo* info);
  237. /* 查找算法ID是否已在列表中 */
  238. ActionInfo* findActionInList(ActionInfo* pInfo);
  239. /* 获取容器 */
  240. std::list<ActionInfo*>& getData() {
  241. return listActionInfo;
  242. }
  243. /* 清空容器 */
  244. void clear();
  245. std::list<ActionInfo*> listActionInfo; /* 房间和算法ID关联列表 */
  246. };
  247. /**
  248. * @brief 房间ID和算法ID关联的信息,里面也包含该算法使用了哪些摄像机
  249. *
  250. */
  251. struct RoomActionInfo
  252. {
  253. int ChannelID; /* 通道ID */
  254. int RoomID; /* 房间ID */
  255. int RoomType; /* 房间类型 */
  256. std::string ActionID; /* 算法ID */
  257. std::string strRoomName; /* 房间名称 */
  258. std::list<int> listCameraID; /* 摄像机ID */
  259. RoomActionInfo() = default;
  260. RoomActionInfo(const RoomActionInfo& other)
  261. : ChannelID(other.ChannelID), RoomID(other.RoomID), RoomType(other.RoomType), ActionID(other.ActionID), strRoomName(other.strRoomName), listCameraID(other.listCameraID) {}
  262. RoomActionInfo& operator=(const RoomActionInfo& other) {
  263. if (this != &other) {
  264. ChannelID = other.ChannelID;
  265. RoomID = other.RoomID;
  266. RoomType = other.RoomType;
  267. ActionID = other.ActionID;
  268. strRoomName = other.strRoomName;
  269. listCameraID = other.listCameraID;
  270. }
  271. return *this;
  272. }
  273. };
  274. /* 房间和算法ID关联列表 */
  275. class ListRoomActionInfo
  276. {
  277. public:
  278. ListRoomActionInfo() = default;
  279. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  280. bool insertRoomActionInfo(const RoomActionInfo& info);
  281. /* 添加关联信息,会自动进行重复判断,如果已有相同的room和action关联信息,则跳过 */
  282. bool insertRoomActionInfo(const int RoomID, const std::string& strActionID);
  283. /* 清空容器 */
  284. void clear();
  285. /* 添加算法信息,根据传入的算法信息,自动将其加入到对应的容器中 */
  286. void addActionInfo(const ActionInfo& info);
  287. /* 查找算法ID是否已在列表中 */
  288. RoomActionInfo* findActionIDInList(const int chnID, const int RoomID, const std::string& strActionID);
  289. /* 获取容器 */
  290. std::list<RoomActionInfo*>& getData() {
  291. return listRoomActionInfo;
  292. }
  293. std::list<RoomActionInfo*> listRoomActionInfo; /* 房间和算法ID关联列表 */
  294. };
  295. #endif /* GLOBALINFO_H */