ws_common.h 4.6 KB

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