loc_point.cpp 2.6 KB

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