ws_common.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. struct sb_data{
  217. double x;
  218. double y;
  219. double z;
  220. std::string cid;
  221. double speed;
  222. std::string site_info;
  223. double acc;
  224. std::array<double ,3> m_acc_data;
  225. double ang;
  226. std::array<double ,3> m_ang_data;
  227. std::string cur_time;
  228. sb_data()
  229. : x(0.0)
  230. , y(0.0)
  231. , z(0.0)
  232. , cid("")
  233. , speed(0.0)
  234. , site_info("")
  235. , acc(0.0)
  236. , ang(0.0)
  237. , cur_time("")
  238. {
  239. m_acc_data.fill(0);
  240. m_ang_data.fill(0);
  241. }
  242. void reset()
  243. {
  244. cid = cur_time = site_info = "";
  245. x = y = z = speed = acc = ang = 0.0;
  246. m_acc_data.fill(0);
  247. m_ang_data.fill(0);
  248. }
  249. };
  250. }
  251. #endif