message.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #ifndef __MESSAGE_HPP__
  2. #define __MESSAGE_HPP__
  3. #include <stdint.h>
  4. #include <time.h>
  5. #include "worker.h"
  6. #include "protocol.h"
  7. struct zistream;
  8. /*
  9. * tdoa协议之分站数据
  10. * */
  11. struct message_site{
  12. uint16_t m_time_stamp; // 分站时间戳
  13. time_t m_site_time; // 分站时间
  14. uint32_t m_site_id; // 分站号
  15. uint8_t m_status; // 状态
  16. uint8_t m_reverse; // 保留
  17. uint8_t m_power_status; // 电源状态
  18. message_site():m_time_stamp(0), m_site_time(0), m_site_id(0), m_status(0), m_reverse(0), m_power_status(0)
  19. {}
  20. void clear()
  21. {
  22. m_time_stamp = m_site_time = m_site_id = m_status = m_reverse = m_power_status = 0;
  23. }
  24. };
  25. /*
  26. * tdoa协议之卡数据,支持以下三种数据协议:
  27. * 1.tdoa实时定位数据协议;
  28. * 2.扩展tdoa实时定位数据协议;
  29. * 3.扩展tdoa实时定位数据协议(带惯导数据);
  30. * */
  31. struct message_tdoa_card{
  32. uint8_t m_type; // 卡类型
  33. uint32_t m_id; // 卡id
  34. uint16_t m_time_stamp; // 卡报文时间戳
  35. uint8_t m_battery_status; // 电池状态
  36. uint8_t m_call_info; // 0x80-呼救,0x01-一般呼叫,0x02-紧急呼叫
  37. int8_t m_rav; // 角速度
  38. uint8_t m_acc; // 加速度
  39. uint64_t m_loc_stamp; // 定位时间戳
  40. uint8_t m_ant_id; // 天线号
  41. uint16_t m_sync_num; // 同步序列号
  42. int16_t m_rssi; // 脉冲信道响应值
  43. int16_t m_strength; // 信号强度
  44. int16_t m_rxpacc; // 接收信号功率
  45. // 以下参数用于tdoa带惯导数据输出
  46. int16_t m_acc_data[3]; // 加速度三轴数据,0-x,1-y,2-z
  47. int16_t m_rav_data[3]; // 角速度三轴数据,0-x,1-y,2-z
  48. uint8_t m_walk_steps; // 行进步数
  49. uint8_t m_jump_counts; // 跳跃次数
  50. uint8_t m_hang_time; // 滞空时间
  51. uint8_t m_hang_height; // 滞空高度
  52. message_tdoa_card():m_type(0), m_id(0), m_time_stamp(0), m_battery_status(0), m_call_info(0), m_rav(0), m_acc(0), m_loc_stamp(0), m_ant_id(0), m_sync_num(0), m_rssi(0), m_strength(0), m_rxpacc(0), m_walk_steps(0), m_jump_counts(0), m_hang_time(0), m_hang_height(0)
  53. {
  54. m_acc_data[0] = m_acc_data[1] = m_acc_data[2] = 0;
  55. m_rav_data[0] = m_rav_data[1] = m_rav_data[2] = 0;
  56. }
  57. int64_t get_long_id()const
  58. {
  59. return (((int64_t)m_type) << 32) | m_id;
  60. }
  61. void clear()
  62. {
  63. m_type = m_id = m_time_stamp = m_battery_status =
  64. m_call_info = m_rav = m_acc = m_loc_stamp = m_ant_id =
  65. m_sync_num = m_rssi = m_strength = m_rxpacc = m_walk_steps =
  66. m_jump_counts = m_hang_time = m_hang_height = 0;
  67. }
  68. };
  69. /*
  70. * tdoa消息虚基类,主要定义子类重载的方法
  71. *
  72. * */
  73. struct message_loc{
  74. virtual void zero_this() = 0;
  75. virtual void load(zistream& is, uint16_t& cmd) = 0;
  76. virtual int64_t long_id()const = 0;
  77. };
  78. struct message_tdoa_locinfo:task{
  79. message_site m_site_msg;
  80. message_tdoa_card m_card_msg;
  81. uint64_t m_interpolation;
  82. uint8_t m_loc_type;
  83. uint8_t m_loc_dimension;
  84. virtual void zero_this();
  85. virtual void load(zistream& is, uint16_t& cmd);
  86. virtual int64_t long_id()const
  87. {
  88. return m_card_msg.get_long_id();
  89. }
  90. };
  91. // 分站传上来的卡定位数据,包括tof,tdoa
  92. struct message_locinfo:task
  93. {
  94. uint64_t m_time_stamp; // 分站时间戳
  95. time_t m_site_time; // 分站时间
  96. uint64_t m_tof; // 卡tof值
  97. uint32_t m_site_id; // 分站号
  98. uint32_t m_card_type; // 卡类型
  99. uint32_t m_card_id; // 卡id
  100. uint16_t m_card_ct; // 卡报文时间戳
  101. uint8_t m_batty_status;// 电池状态
  102. uint8_t m_callinfo; // 0x80-呼救,0x01-一般呼叫,0x02-紧急呼叫
  103. int8_t m_rav; // 角速度
  104. uint8_t m_acc; // 加速度
  105. uint8_t m_ant_id; // 天线号
  106. uint16_t m_sync_ct; // 同步序列号
  107. int16_t m_rssi; //
  108. //优化协议
  109. float m_distance;
  110. uint8_t m_loc_type; // 数据类型,tof,tdoa,pdoa
  111. void zero_this();
  112. void load(zistream&is,bool tdoa);
  113. void set_rav(uint8_t rav){m_rav=rav;}
  114. static std::vector<task*> load_opt(zistream&is);
  115. static task* clone(message_locinfo* ml);
  116. int64_t long_id()const
  117. {
  118. return (((int64_t)m_card_type)<<32)|m_card_id;
  119. }
  120. };
  121. //tdoa分站同步数据
  122. struct message_tdoasync:task
  123. {
  124. uint32_t m_local_site_id; // 本地分站号
  125. uint32_t m_parent_site_id; // 上一级分站号
  126. uint16_t m_local_ant_id; // 分站分站天线号
  127. uint16_t m_parent_ant_id; // 上一级分站天线号
  128. uint16_t m_sync_num; // 同步序列号
  129. uint16_t m_local_level; // 分站本地层级
  130. uint64_t m_recv_time; // 接收时间
  131. uint64_t m_send_time; // 发送时间
  132. uint64_t m_root_site_id; // 本次同步root节点分站号
  133. uint16_t m_root_ant_id; // 本次同步root节点天线号
  134. void zero_this();
  135. void load(zistream&is);
  136. };
  137. // pdoa分站数据
  138. struct message_pdoa_locinfo: public message_locinfo{
  139. uint8_t m_loc_type;
  140. uint8_t m_loc_dimension;
  141. float m_poa[3];
  142. void zero_this();
  143. void load(zistream& is);
  144. };
  145. struct message_light: task{
  146. uint32_t m_light_id;
  147. uint8_t m_type;
  148. uint16_t m_stamp;
  149. uint64_t m_recv_time;
  150. uint8_t m_status;
  151. message_light(): m_light_id(0), m_type(0), m_stamp(0), m_recv_time(0), m_status(0)
  152. {}
  153. message_light(const uint32_t& lid, const uint16_t& type, const uint8_t& stamp, const uint64_t& rtime): m_status(0)
  154. {}
  155. };
  156. #endif