message.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #include <math.h>
  2. #include "zstream.h"
  3. #include "message.h"
  4. #include "log.h"
  5. void message_locinfo::zero_this()
  6. {
  7. // m_time_stamp=
  8. // m_site_id=
  9. m_site_time=
  10. m_tof=
  11. m_card_type=
  12. m_card_id=
  13. m_card_ct=
  14. m_batty_status=
  15. m_callinfo=
  16. m_rav=
  17. m_acc=
  18. m_ant_id=
  19. m_sync_ct=
  20. m_rssi=0;
  21. }
  22. void message_locinfo::load(zistream&is,bool tdoa)
  23. {
  24. zero_this();
  25. uint8_t b;
  26. uint32_t i;
  27. //卡类型、卡号、CT、电池状态
  28. is>>b>>m_card_id>>m_card_ct>>m_batty_status;
  29. m_card_type=b;
  30. m_batty_status&=0x3;
  31. is>>b;
  32. if(m_card_type==1)
  33. {
  34. m_callinfo=b;
  35. }
  36. else
  37. {
  38. m_rav=((b&0x80)?-1.:1.)*(b&0x7f)*3;
  39. }
  40. //加速度
  41. is>>b;
  42. if(m_card_type == 1 || m_card_type==4 || m_card_type==5)
  43. m_acc=b;
  44. else
  45. m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*0.01;
  46. //TOF
  47. is>>b>>i;
  48. m_tof=b;
  49. m_tof=(m_tof<<32)|i;
  50. //天线号
  51. is>>m_ant_id;
  52. --m_ant_id;
  53. if(tdoa)
  54. {
  55. //同步序号,冲击响应丢弃
  56. is>>m_sync_ct>>skip(2);
  57. }
  58. //信号电平值
  59. uint16_t sp1=0,sp2=0;
  60. is>>sp1>>sp2;
  61. m_rssi=10*log10(1.*sp1*(1<<17)/pow(sp2-64.,2))-121.74;
  62. log_info("timestamp=%llu,type:%d,card_id:%d,site:%d,ct:%d,status:%d,acc=%d,tof=%llu,ant_id:%d,spq=%d",
  63. m_time_stamp,m_card_type,m_card_id,m_site_id,m_card_ct,m_batty_status,m_acc,m_tof,m_ant_id,m_rssi);
  64. }
  65. void message_tdoasync::zero_this()
  66. {
  67. m_local_site_id=
  68. m_parent_site_id=
  69. m_local_ant_id=
  70. m_parent_ant_id=
  71. m_sync_ct=
  72. m_local_level=
  73. m_recv_time=
  74. m_send_time=0;
  75. }
  76. void message_tdoasync::load(zistream&is)
  77. {
  78. zero_this();
  79. uint8_t b;
  80. //本地分站ID和天线ID
  81. is>>m_local_site_id>>b; m_local_ant_id=b;
  82. //上级分站ID和天线ID
  83. is>>m_parent_site_id>>b; m_parent_ant_id=b;
  84. //根分站CT和本机级别
  85. is>>m_sync_ct>>m_local_level;
  86. uint32_t i;
  87. //本级发出的时间
  88. is>>b>>i;
  89. m_send_time=b;
  90. m_send_time=(m_send_time<<32)|i;
  91. //本级收到的时间
  92. is>>b>>i;
  93. m_recv_time=b;
  94. m_recv_time=(m_recv_time<<32)|i;
  95. }