ws_common.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. /**
  2. * @brief
  3. websocket公共头文件
  4. * @version
  5. V 1.0.0
  6. * @author
  7. * @date
  8. 创建时间: 2018-08-17\n
  9. * @note
  10. 2018-08-17 初次创建。\n
  11. * @warning
  12. * @bug
  13. */
  14. #ifndef _WS_COMMON_INC_H_
  15. #define _WS_COMMON_INC_H_
  16. #include <map>
  17. #include <array>
  18. #include <string>
  19. namespace sys
  20. {
  21. const int MIN_SEND_INTERVAL = 1;//最小发送时间间隔
  22. /**
  23. * @brief
  24. 线程配置结构体。
  25. */
  26. struct _THREAD_CONFIG_
  27. {
  28. int SendInterval;//发送间隔(单位:秒)
  29. void Clear()
  30. {
  31. SendInterval = 0;
  32. }
  33. _THREAD_CONFIG_()
  34. {
  35. Clear();
  36. }
  37. };
  38. // 传感器,加速度,角速度
  39. struct sensor{
  40. double m_acc; // 加速度
  41. double m_ang; // 角速度
  42. double m_tri_acc[3]; // 三轴,0-x,1-y,2-z轴
  43. double m_tri_ang[3]; // 三轴,
  44. uint8_t m_walking_step; // 行进步数
  45. uint8_t m_jump_count; // 跳跃次数
  46. double m_hang_time; // 滞空时间
  47. double m_hang_height; // 滞空高度
  48. sensor(): m_acc(0.0), m_ang(0.0),m_walking_step(0), m_jump_count(0),m_hang_time(0), m_hang_height(0)
  49. {
  50. m_tri_acc[0] = m_tri_acc[1] = m_tri_acc[2] = m_tri_ang[0] = m_tri_ang[1] = m_tri_ang[2] = 0.0;
  51. }
  52. };
  53. /**
  54. * @brief
  55. 基础卡信息结构体。
  56. */
  57. struct _BASE_CARD_: public sensor
  58. {
  59. int Type; //卡类型
  60. int ID; //卡ID
  61. double x; //x坐标
  62. double y; //y坐标
  63. double z; //z坐标
  64. double down_time; //入井时间戳
  65. double enter_area_time; //进入区域时间戳
  66. double rec_time; //最后接收时间戳
  67. double work_time; //工作时长
  68. int map_id; //地图编号
  69. int area_id; //区域ID
  70. int dept_id; //部门编号
  71. int stat; //状态
  72. int running_stat; //运行状态: 包括上猴车状态
  73. int biz_stat; //业务状态
  74. double speed; //速度
  75. double m_freq; // 卡频率
  76. _BASE_CARD_()
  77. {
  78. Type = 0;
  79. ID = 0;
  80. x = 0;
  81. y = 0;
  82. z = 0;
  83. down_time = 0;
  84. enter_area_time = 0;
  85. rec_time = 0;
  86. work_time = 0;
  87. map_id = 0;
  88. area_id = 0;
  89. dept_id = 0;
  90. stat = 0;
  91. running_stat = 0;
  92. biz_stat = 0;
  93. speed = 0.0;
  94. m_freq = 0.0;
  95. }
  96. };
  97. /**
  98. * @brief
  99. 卡位置结构体。
  100. */
  101. struct _CARD_POS_ : public _BASE_CARD_
  102. {
  103. std::map<int,std::tuple<int,int,int,double,uint64_t>> area_info;
  104. int landmark_id; //地标编号
  105. int lm_direction; //地标方向
  106. int landmark_dis; //距离地标的距离
  107. int level_id; //级别编号
  108. int is_on_duty; //车辆是否是当天出勤的标识(1:出勤,0:不出勤)
  109. int display; //是否显示(1:显示,0:不显示)
  110. int battery_stat; //卡电量状态
  111. int battery_val; //卡电量值
  112. void Clear()
  113. {
  114. landmark_id = 0;
  115. lm_direction = 0;
  116. landmark_dis = 0;
  117. level_id = 0;
  118. is_on_duty = 0;
  119. display = 1;//默认显示
  120. battery_stat = 0;
  121. battery_val = 10;
  122. }
  123. _CARD_POS_()
  124. {
  125. Clear();
  126. }
  127. };
  128. /**
  129. * @brief
  130. 统计部门结构体。
  131. */
  132. struct _STAT_DEPT_ITEM_
  133. {
  134. int DeptID;//部门ID
  135. std::map<int, int> Area;//区域数量列表(key是区域ID,value是区域里的卡数)
  136. std::map<int, int> Dept;//部门数量列表(key是区域ID,value是部门里的卡数)
  137. std::map<int, int> OcptLvl;//职务级别数量列表(key是区域ID,value是职务级别里的卡数)
  138. int Sum;//卡总数
  139. _STAT_DEPT_ITEM_()
  140. {
  141. DeptID = 0;
  142. Sum = 0;
  143. }
  144. };
  145. struct light_state{
  146. int m_group_id;
  147. int m_light_id;
  148. int m_light_state;
  149. std::string m_card_id;
  150. light_state(): m_group_id(0), m_light_id(0), m_light_state(0), m_card_id("")
  151. {}
  152. light_state(const int& gid, const int& lid, const int& state, const std::string& cid)
  153. : m_group_id(gid),
  154. m_light_id(lid),
  155. m_light_state(state),
  156. m_card_id(cid)
  157. {}
  158. };
  159. // 设备状态信息,基站类设备
  160. struct device_state{
  161. uint32_t m_id; // 设备ID
  162. uint8_t m_type; // 设备类型
  163. uint8_t m_state; // 设备状态
  164. uint64_t m_cur_time; // 接收时间
  165. device_state(uint32_t id, uint8_t type, uint8_t state, uint64_t ctime)
  166. : m_id(id)
  167. , m_type(type)
  168. , m_state(state)
  169. , m_cur_time(ctime)
  170. {}
  171. device_state()
  172. : m_id(0)
  173. , m_type(0)
  174. , m_state(0)
  175. , m_cur_time(0)
  176. {}
  177. };
  178. // tof_data 数据
  179. struct tof_data{
  180. std::string cid; // 卡号
  181. double y; // 一维坐标
  182. std::array<double, 2> ant_dist; // 天线的测距距离
  183. int sid; // 基站号
  184. std::string cur_time; // 当前时间
  185. double ant_diff;
  186. tof_data()
  187. : cid("")
  188. , y(0.0)
  189. , sid(0)
  190. , cur_time("")
  191. , ant_diff(0)
  192. {
  193. ant_dist.fill(0);
  194. }
  195. ~tof_data(){
  196. reset();
  197. }
  198. void reset()
  199. {
  200. cid = cur_time = "";
  201. y = 0;
  202. sid = 0;
  203. ant_diff = 0;
  204. ant_dist.fill(0);
  205. }
  206. /*tof_data& operator=(const tof_data v){
  207. this->cid = v.cid;
  208. this->y = v.y;
  209. this->sid = v.sid;
  210. this->cur_time = v.cur_time;
  211. this->ant_dist = ant_dist;
  212. this->ant_diff = v.ant_diff;
  213. return *this;
  214. }*/
  215. };
  216. // tof_data 数据
  217. struct tof_data_oneAntenna {
  218. std::string cid; // 卡号
  219. std::map<int, double> map_site_id_dist;
  220. double x;
  221. double y;
  222. // double dist1; // 距离
  223. // int sid1; // 基站号
  224. // double dist2; // 距离
  225. // int sid2; // 基站号
  226. // double dist3; // 距离
  227. // int sid3; // 基站号
  228. // double dist4; // 距离
  229. // int sid4; // 基站号
  230. std::string cur_time; // 当前时间
  231. tof_data_oneAntenna()
  232. : cid("")
  233. , cur_time("")
  234. {
  235. }
  236. ~tof_data_oneAntenna() {
  237. reset();
  238. }
  239. void reset()
  240. {
  241. cid = cur_time = "";
  242. map_site_id_dist.clear();
  243. }
  244. };
  245. struct sb_data{
  246. double x;
  247. double y;
  248. double z;
  249. std::string cid;
  250. double speed;
  251. std::string site_info;
  252. double acc;
  253. std::array<double ,3> m_acc_data;
  254. double ang;
  255. std::array<double ,3> m_ang_data;
  256. std::string cur_time;
  257. sb_data()
  258. : x(0.0)
  259. , y(0.0)
  260. , z(0.0)
  261. , cid("")
  262. , speed(0.0)
  263. , site_info("")
  264. , acc(0.0)
  265. , ang(0.0)
  266. , cur_time("")
  267. {
  268. m_acc_data.fill(0);
  269. m_ang_data.fill(0);
  270. }
  271. void reset()
  272. {
  273. cid = cur_time = site_info = "";
  274. x = y = z = speed = acc = ang = 0.0;
  275. m_acc_data.fill(0);
  276. m_ang_data.fill(0);
  277. }
  278. };
  279. struct tdoa_2d_data {
  280. double x;
  281. double y;
  282. double dx_v;
  283. double dy_v;
  284. double dz_v;
  285. double acc;
  286. double ang;
  287. std::array<double, 3> m_acc_data;
  288. std::array<double, 3> m_ang_data;
  289. std::string cid;
  290. double d1;
  291. double d2;
  292. double d3;
  293. std::string site_info;
  294. std::string cur_time;
  295. int move_state;
  296. tdoa_2d_data()
  297. : x(0.0)
  298. , y(0.0)
  299. , dx_v(0.0)
  300. , dy_v(0.0)
  301. , acc(0.0)
  302. , ang(0.0)
  303. , cid("")
  304. , d1(0.0)
  305. , d2(0.0)
  306. , d3(0.0)
  307. , site_info("")
  308. , cur_time("")
  309. , move_state(0)
  310. {
  311. m_acc_data.fill(0);
  312. m_ang_data.fill(0);
  313. }
  314. tdoa_2d_data(double x, double y, double dx, double dy, double acc, double acc_x, double acc_y, double acc_z, double ang, double ang_x, double ang_y, double ang_z, std::string cid, double d1, double d2, double d3, std::string ctime, std::string sinfo, int state)
  315. {
  316. this->x = x;
  317. this->y = y;
  318. this->dx_v = dx;
  319. this->dy_v = dy;
  320. this->acc = acc;
  321. this->ang = ang;
  322. this->cid = cid;
  323. this->d1 = d1;
  324. this->d2 = d2;
  325. this->d3 = d3;
  326. this->cur_time = ctime;
  327. this->site_info = sinfo;
  328. m_acc_data[0] = acc_x;
  329. m_acc_data[1] = acc_y;
  330. m_acc_data[2] = acc_z;
  331. m_ang_data[0] = ang_x;
  332. m_ang_data[1] = ang_y;
  333. m_ang_data[2] = ang_z;
  334. this->move_state = state;
  335. }
  336. void reset()
  337. {
  338. cid = site_info = cur_time = "";
  339. move_state = x = y = dx_v = dy_v = acc = ang = d1 = d2 = d3 = 0;
  340. m_acc_data.fill(0);
  341. m_ang_data.fill(0);
  342. }
  343. };
  344. struct tof_3d_data{
  345. double x;
  346. double y;
  347. double z;
  348. double dx_v;
  349. double dy_v;
  350. double dz_v;
  351. double acc;
  352. double ang;
  353. std::array<double, 3> m_acc_data;
  354. std::array<double, 3> m_ang_data;
  355. std::string cid;
  356. std::string site_info;
  357. std::string cur_time;
  358. int move_state;
  359. tof_3d_data()
  360. : x(0.0)
  361. , y(0.0)
  362. , z(0.0)
  363. , dx_v(0.0)
  364. , dy_v(0.0)
  365. , dz_v(0.0)
  366. , acc(0.0)
  367. , ang(0.0)
  368. , cid("")
  369. , site_info("")
  370. , cur_time("")
  371. , move_state(0)
  372. {
  373. m_acc_data.fill(0);
  374. m_ang_data.fill(0);
  375. }
  376. tof_3d_data(double x, double y, double z, double dx, double dy, double dz, double acc, double acc_x, double acc_y, double acc_z, double ang, double ang_x, double ang_y, double ang_z, std::string cid, std::string ctime, std::string sinfo, int state)
  377. {
  378. this->x = x;
  379. this->y = y;
  380. this->z = z;
  381. this->dx_v = dx;
  382. this->dy_v = dy;
  383. this->dz_v = dz;
  384. this->acc = acc;
  385. this->ang = ang;
  386. this->cid = cid;
  387. this->cur_time = ctime;
  388. this->site_info = sinfo;
  389. m_acc_data[0] = acc_x;
  390. m_acc_data[1] = acc_y;
  391. m_acc_data[2] = acc_z;
  392. m_ang_data[0] = ang_x;
  393. m_ang_data[1] = ang_y;
  394. m_ang_data[2] = ang_z;
  395. this->move_state = state;
  396. }
  397. void reset()
  398. {
  399. cid = site_info = cur_time = "";
  400. move_state = x = y = z = dx_v = dy_v = dz_v = acc = ang = 0;
  401. m_acc_data.fill(0);
  402. m_ang_data.fill(0);
  403. }
  404. };
  405. }
  406. #endif