loc_point.cpp 2.4 KB

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