card_car.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #include "card_car.h"
  2. #include "card_message_handle.h"
  3. #include "his_location.h"
  4. #include "area.h"
  5. #include "mine.h"
  6. #include "three_rates.h"
  7. #include "select_tool.h"
  8. #include "websocket/ws_common.h"
  9. #include "special_area.h"
  10. #include "common_tool.h"
  11. #include "tool_time.h"
  12. #include "mine_business.h"
  13. #include "loc_point.h"
  14. car::car(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
  15. int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
  16. :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
  17. ,m_vehicle_category_id(categoryid)
  18. ,m_vehicle_type_id(type_id)
  19. {
  20. m_message_handle.reset(new card_message_handle(this));
  21. //m_his_location_card.reset(new location_vehicle(m_id,m_type,cid));
  22. }
  23. car::~car(){}
  24. std::shared_ptr<mine_tool> car::get_mine_tool()
  25. {
  26. return m_mine_tool;
  27. }
  28. void car::set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)
  29. {
  30. m_area_tool->set_area_info(mapid,scale,areaid,*this,t,type);
  31. }
  32. void car::do_business(const std::shared_ptr<site>&site,const point &pt,double acc)
  33. {
  34. m_acc=acc;
  35. m_area_tool->on_point(shared_from_this(),pt);
  36. m_timeval=m_time;
  37. handle_three_rates(pt);
  38. handle_traffic_light(pt);
  39. uint64_t id=tool_other::type_id_to_u64(m_type,m_id);
  40. mine_business::inst()->make_arg(id,pt,m_time);
  41. }
  42. int car::get_vehicle_type_id()
  43. {
  44. return m_vehicle_type_id;
  45. }
  46. void car::handle_three_rates(const point &pt)
  47. {
  48. card_pos cp;
  49. m_biz_stat = get_stat();
  50. cp.biz_stat = m_biz_stat;
  51. cp.x = pt.x;
  52. cp.y = pt.y;
  53. cp.z = pt.z;
  54. //const auto lm = m_area_tool->getLandmark();
  55. // cp.enter_time = std::get<0>(lm)*1000;
  56. // cp.area_id = std::get<3>(lm);
  57. cp.map_id = m_area_tool->get_mapid();
  58. cp.vibration = m_acc;
  59. put_three_rates(cp);
  60. }
  61. void car::handle_traffic_light(const point& p)
  62. {
  63. card_pos cp;
  64. cp.x = p.x;
  65. cp.y = p.y;
  66. cp.z = p.z;
  67. cp.map_id = m_area_tool->get_mapid();
  68. cp.vibration = m_acc;
  69. put_traffic_light(cp);
  70. }
  71. void car::on_timer()
  72. {
  73. if(!empty())
  74. make_package();
  75. }
  76. int car::get_area()
  77. {
  78. int status = m_biz_stat;
  79. int special_id = -1;
  80. if(status == STATUS_LOST)
  81. {
  82. special_id = special_area_list::instance()->get_special_id(m_id,*this,m_vehicle_category_id);
  83. log_info("enter_special_area:%.2f,%2.f,id:%d,special_area_id:%d",x,y,m_id,special_id);
  84. }
  85. return special_id;
  86. }
  87. void car::make_package()
  88. {
  89. YA::_CARD_POS_ cp;
  90. loc_point pt = getSmoothPoint();
  91. cp.area_info=m_area_tool->m_area_info;
  92. cp.map_id =m_area_tool->get_mapid();
  93. int32_t biz_stat=m_biz_stat;
  94. cp.biz_stat=biz_stat;
  95. cp.down_time = m_mine_tool->get_down_time();
  96. cp.work_time = m_mine_tool->get_work_time();
  97. uint32_t on_duty=0;
  98. // if(m_mine_tool->m_is_attendance)
  99. on_duty=m_mine_tool->is_on_duty();
  100. cp.is_on_duty=on_duty;
  101. upt_card_pos(cp,pt);
  102. make_his_location(pt.m_time,pt);
  103. uint64_t _now=tool_time::now_to_ms();
  104. uint64_t t=_now>m_timeval?_now-m_timeval:m_timeval-_now;
  105. if(t>10*1000)
  106. {
  107. m_area_tool->on_point(shared_from_this(),pt);
  108. m_biz_stat=get_stat();
  109. }
  110. // if(biz_stat==STATUS_LOST && special_id != -1 && m_display==1)
  111. // {
  112. // cp.area_id = special_id;
  113. // swsClientMgr.SendSpecialAreaProcess(cp);
  114. // }
  115. }
  116. void car::get_card(bool f)
  117. {
  118. if(f)
  119. mine_business::inst()->put(shared_from_this());
  120. }
  121. loc_point car::getSmoothPoint()
  122. {
  123. loc_point lp = m_smo_tool->smooth_strategy();
  124. m_speed = lp.m_speed;
  125. m_stat = lp.m_stat;
  126. lp.y = -lp.y;
  127. return lp;
  128. }