1
0

loc_point.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #include <memory.h>
  2. #include "loc_point.h"
  3. #include "ant.h"
  4. #include "log.h"
  5. #include "loc_message.h"
  6. loc_point::loc_point()
  7. :m_time(0)
  8. ,m_ct(-1)
  9. ,m_cid(-1)
  10. ,m_type(-1)
  11. ,m_sid(-1)
  12. ,m_acc(0)
  13. ,m_rav(0)
  14. ,m_cred_level(0)
  15. ,m_dist(0)
  16. ,m_speed(0)
  17. ,m_angle(0)
  18. ,m_stat(0)
  19. ,m_useless(false)
  20. ,m_dist1(0)
  21. ,m_dist2(0)
  22. ,m_smooth_x(0)
  23. ,m_smooth_y(0)
  24. {
  25. memset(&m_tof,0,sizeof(m_tof));
  26. memset(&m_rsp,0,sizeof(m_rsp));
  27. }
  28. loc_point& loc_point::reset()
  29. {
  30. memset(this,0,sizeof(*this));
  31. return *this;
  32. }
  33. inline const char* now(char*date_str,uint64_t time)
  34. {
  35. time_t ntime=time/1000;
  36. struct tm buff;
  37. const struct tm*t=localtime_r(&ntime, &buff);
  38. sprintf(date_str,"%d-%02d-%02d %02d:%02d:%02d.%03d" ,
  39. t->tm_year+1900,t->tm_mon+1,t->tm_mday,
  40. t->tm_hour,t->tm_min,t->tm_sec,(int)(time%1000));
  41. return date_str;
  42. }
  43. void loc_point::debug_out(const char *str)const
  44. {
  45. char time_buff[128];
  46. #if 1
  47. logn_info(3,"t=%s,sit=%d,card=%d,ct=%d,cred=%d,type=%d,tof1=%d,tof2=%d,pt=(%.2lf,%.2lf),"
  48. "rsp=%d,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed=%lf",
  49. now(time_buff,m_time), m_sid, m_cid, m_ct, m_cred_level,m_type, m_tof[0], m_tof[1], x, y ,
  50. (m_rsp[0]+m_rsp[1])>>1,m_acc, m_dist1,m_dist,m_dist2, m_rav,m_speed
  51. );
  52. #else
  53. printf("[%s]t=%s,sit=%d,ct=%d,cred=%d,"
  54. "tof1=%d,tof2=%d,pt=(%.2lf,"
  55. "%.2lf),rsp=,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed=%.2f\n",
  56. str,now(time_buff,m_time), m_sid, m_ct, m_cred_level,
  57. m_tof[0], m_tof[1], m_smooth_x,
  58. m_smooth_y ,m_acc,
  59. m_dist1,m_dist,m_dist2, m_rav, m_speed
  60. );
  61. #endif
  62. }
  63. int loc_point::inc_cl(int cred_level)
  64. {
  65. return m_cred_level += cred_level;
  66. }
  67. int loc_point::set_cl(int cred_level)
  68. {
  69. return m_cred_level = cred_level;
  70. }
  71. int loc_point::cl()const
  72. {
  73. return m_cred_level;
  74. }
  75. void loc_point::set_source(const loc_message&li,const loc_message&li2)
  76. {
  77. m_sid = li.m_sit->m_id;
  78. m_cid = li.m_card_id;
  79. m_type=li.m_card_type;
  80. m_time=std::min(li.m_loc_time,li2.m_loc_time);
  81. m_ct=li.m_card_ct;
  82. m_acc=li.m_acc *10;// 1270.;
  83. m_rav=li.m_rav;
  84. m_tof[li.m_ant_id]=li.m_num_ticks;
  85. m_tof[li2.m_ant_id]=li2.m_num_ticks;
  86. m_rsp[li.m_ant_id]=li.m_rssi;
  87. m_rsp[li2.m_ant_id]=li2.m_rssi;
  88. m_step=0;
  89. }
  90. void loc_point::set_source(const loc_message&li)
  91. {
  92. m_sid = li.m_sit->m_id;
  93. m_cid = li.m_card_id;
  94. m_type = li.m_card_type;
  95. m_time = li.m_loc_time;
  96. m_ct = li.m_card_ct;
  97. m_acc = li.m_acc * 10;// 1270.;
  98. m_rav = li.m_rav;
  99. m_tof[li.m_ant_id] = li.m_num_ticks;
  100. m_tof[li.m_ant_id?0:1] = 0;
  101. m_rsp[li.m_ant_id] = li.m_rssi;
  102. m_rsp[li.m_ant_id?0:1] = 0;
  103. m_step = 0;
  104. }