GlobalInfo.h 6.6 KB

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