GlobalInfo.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. #ifndef GLOBALINFO_H
  2. #define GLOBALINFO_H
  3. #include <QString>
  4. #include <vector>
  5. #include "nlohmann/json.hpp"
  6. /* ====================================================================================
  7. * ******************************* 全局变量定义 **********************************
  8. * ====================================================================================*/
  9. extern int g_eventTimeVaild;
  10. /**
  11. * @brief 全局信息
  12. *
  13. */
  14. using nJson = nlohmann::json;
  15. /* 算法相关信息 */
  16. struct AlgorithmInfo
  17. {
  18. int PKID; /* 主键ID */
  19. int ActionTaskID; /* 算法任务ID */
  20. std::string ActionID; /* 算法ID */
  21. std::string ActionName; /* 算法名称 */
  22. AlgorithmInfo() = default;
  23. AlgorithmInfo(const AlgorithmInfo& other)
  24. : PKID(other.PKID), ActionID(other.ActionID), ActionName(other.ActionName), ActionTaskID(other.ActionTaskID) {}
  25. AlgorithmInfo& operator=(const AlgorithmInfo& other) {
  26. if (this != &other) {
  27. ActionID = other.ActionID;
  28. ActionName = other.ActionName;
  29. ActionTaskID = other.ActionTaskID;
  30. PKID = other.PKID;
  31. }
  32. return *this;
  33. }
  34. /* 对比是否相等 */
  35. bool operator==(const AlgorithmInfo& other) const {
  36. if(ActionID != other.ActionID)
  37. {
  38. return false;
  39. }
  40. if(ActionName != other.ActionName || ActionTaskID != other.ActionTaskID)
  41. {
  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) const {
  88. if(DeviceID != other.DeviceID) {
  89. return false;
  90. }
  91. else if(DeviceName != other.DeviceName || DeviceIP != other.DeviceIP) {
  92. return false;
  93. }
  94. else if(DeviceSerial != other.DeviceSerial || DeviceType != other.DeviceType) {
  95. return false;
  96. }
  97. else if(DevicePort != other.DevicePort || UserAccount != other.UserAccount || UserPassword != other.UserPassword) {
  98. return false;
  99. }
  100. return true;
  101. }
  102. /* 对比设备关联的算法信息是否相等 */
  103. bool isEqualAlgorithmInfo(const std::vector<AlgorithmInfo>& other) const {
  104. /* 算法数目不相等,直接返回false */
  105. if(vecAlgorithmInfo.size() != other.size()) {
  106. return false;
  107. }else {
  108. /* 算法数目相等,进一步对比算法信息 */
  109. bool isEquality = true;
  110. /* 逐步对比算法信息 */
  111. for(const auto& it0 : vecAlgorithmInfo) {
  112. bool isEq2 = true;
  113. for(const auto& it1 : other) {
  114. if(it0 == it1) {
  115. continue;
  116. }else {
  117. isEq2 = false;
  118. break;
  119. }
  120. }
  121. if(!isEq2) {
  122. isEquality = false;
  123. break;
  124. }
  125. }
  126. if(!isEquality) {
  127. return false;
  128. }
  129. }
  130. return true;
  131. }
  132. };
  133. /* 算法和设备关联的相关信息 */
  134. struct DeviceAlgorithmInfo
  135. {
  136. int DeviceID; /* 设备ID */
  137. int ActionTaskID; /* 算法任务ID */
  138. std::string ActionID; /* 算法ID */
  139. std::string ActionName; /* 算法名称 */
  140. };
  141. /**
  142. * @brief 摄像机线程需要的信息
  143. *
  144. */
  145. struct CameraThreadInfo
  146. {
  147. std::string RedisIP; /* Redis IP */
  148. int RedisPort; /* Redis Port */
  149. std::string RedisPWD; /* Redis Password */
  150. int DeviceID; /* 设备ID */
  151. std::vector<std::string> vecAction; /* Redis Key,一个设备可能会有多个算法ID */
  152. CameraThreadInfo() = default;
  153. CameraThreadInfo& operator=(const CameraThreadInfo& other) {
  154. if (this != &other) {
  155. RedisIP = other.RedisIP;
  156. RedisPort = other.RedisPort;
  157. RedisPWD = other.RedisPWD;
  158. DeviceID = other.DeviceID;
  159. vecAction = other.vecAction;
  160. }
  161. return *this;
  162. }
  163. };
  164. /**
  165. * @brief 人员信息
  166. *
  167. */
  168. struct PersonInfo
  169. {
  170. std::string PersonID; /* 人员ID */
  171. std::string PersonName; /* 人员名称 */
  172. };
  173. /**
  174. * @brief 报警信息
  175. *
  176. */
  177. struct AlarmInfo
  178. {
  179. bool Is_Alarm; /* 是否报警 */
  180. int AlarmID; /* 报警ID */
  181. int DeviceID; /* 设备ID,数据库表格中对应的是CamerID */
  182. int RoomID; /* 房间ID */
  183. int ChannelID; /* 通道ID */
  184. int OnWork; /* 是否在工作 */
  185. std::string ActionID; /* 算法ID */
  186. std::string StartTime; /* 报警开始时间 */
  187. std::string EndTime; /* 报警结束时间 */
  188. std::string EventTime; /* 事件时间(报警发生时间,在数据库里对应的是CreateTime) */
  189. std::string PicUrl; /* 报警图片URL */
  190. std::string ImageInfo; /* 图片信息 */
  191. std::string AppID; /* 客户端应用ID */
  192. std::string ActionDes; /* 算法描述信息 */
  193. std::string FaceIDList; /* 人脸ID列表 */
  194. std::string FaceNameList; /* 人脸名称列表 */
  195. std::string BboxList; /* Bbox列表,应该图片中的报警位置 */
  196. std::vector<PersonInfo> vecPersonInfo; /* 人员信息 */
  197. };
  198. #endif /* GLOBALINFO_H */