ws_common.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. namespace YA
  18. {
  19. const int MIN_SEND_INTERVAL = 1;//最小发送时间间隔
  20. /**
  21. * @brief
  22. 线程配置结构体。
  23. */
  24. struct _THREAD_CONFIG_
  25. {
  26. int SendInterval;//发送间隔(单位:秒)
  27. void Clear()
  28. {
  29. SendInterval = 0;
  30. }
  31. _THREAD_CONFIG_()
  32. {
  33. Clear();
  34. }
  35. };
  36. // 传感器,加速度,角速度
  37. struct sensor{
  38. double m_acc; // 加速度
  39. double m_ang; // 角速度
  40. double m_tri_acc[3]; // 三轴,0-x,1-y,2-z轴
  41. double m_tri_ang[3]; // 三轴,
  42. uint8_t m_walking_step; // 行进步数
  43. uint8_t m_jump_count; // 跳跃次数
  44. double m_hang_time; // 滞空时间
  45. double m_hang_height; // 滞空高度
  46. 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)
  47. {
  48. 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;
  49. }
  50. };
  51. /**
  52. * @brief
  53. 基础卡信息结构体。
  54. */
  55. struct _BASE_CARD_: public sensor
  56. {
  57. int Type; //卡类型
  58. int ID; //卡ID
  59. double x; //x坐标
  60. double y; //y坐标
  61. double z; //z坐标
  62. double down_time; //入井时间戳
  63. double enter_area_time; //进入区域时间戳
  64. double rec_time; //最后接收时间戳
  65. double work_time; //工作时长
  66. int map_id; //地图编号
  67. int area_id; //区域ID
  68. int dept_id; //部门编号
  69. int stat; //状态
  70. int running_stat; //运行状态: 包括上猴车状态
  71. int biz_stat; //业务状态
  72. double speed; //速度
  73. double m_freq; // 卡频率
  74. _BASE_CARD_()
  75. {
  76. Type = 0;
  77. ID = 0;
  78. x = 0;
  79. y = 0;
  80. z = 0;
  81. down_time = 0;
  82. enter_area_time = 0;
  83. rec_time = 0;
  84. work_time = 0;
  85. map_id = 0;
  86. area_id = 0;
  87. dept_id = 0;
  88. stat = 0;
  89. running_stat = 0;
  90. biz_stat = 0;
  91. speed = 0.0;
  92. m_freq = 0.0;
  93. }
  94. };
  95. /**
  96. * @brief
  97. 卡位置结构体。
  98. */
  99. struct _CARD_POS_ : public _BASE_CARD_
  100. {
  101. std::map<int,std::tuple<int,int,int,double,uint64_t>> area_info;
  102. int landmark_id;//地标编号
  103. int lm_direction;//地标方向
  104. int landmark_dis;//距离地标的距离
  105. int level_id;//级别编号
  106. int is_on_duty;//车辆是否是当天出勤的标识(1:出勤,0:不出勤)
  107. int display;//是否显示(1:显示,0:不显示)
  108. void Clear()
  109. {
  110. landmark_id = 0;
  111. lm_direction = 0;
  112. landmark_dis = 0;
  113. level_id = 0;
  114. is_on_duty = 0;
  115. display = 1;//默认显示
  116. }
  117. _CARD_POS_()
  118. {
  119. Clear();
  120. }
  121. };
  122. /**
  123. * @brief
  124. 统计部门结构体。
  125. */
  126. struct _STAT_DEPT_ITEM_
  127. {
  128. int DeptID;//部门ID
  129. std::map<int, int> Area;//区域数量列表(key是区域ID,value是区域里的卡数)
  130. std::map<int, int> Dept;//部门数量列表(key是区域ID,value是部门里的卡数)
  131. std::map<int, int> OcptLvl;//职务级别数量列表(key是区域ID,value是职务级别里的卡数)
  132. int Sum;//卡总数
  133. _STAT_DEPT_ITEM_()
  134. {
  135. DeptID = 0;
  136. Sum = 0;
  137. }
  138. };
  139. struct light_state{
  140. int m_group_id;
  141. int m_light_id;
  142. int m_light_state;
  143. std::string m_card_id;
  144. light_state(): m_group_id(0), m_light_id(0), m_light_state(0), m_card_id("")
  145. {}
  146. light_state(const int& gid, const int& lid, const int& state, const std::string& cid)
  147. : m_group_id(gid),
  148. m_light_id(lid),
  149. m_light_state(state),
  150. m_card_id(cid)
  151. {}
  152. };
  153. }
  154. #endif