card_car.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 "site_area.h"
  7. #include "three_rates.h"
  8. #include "select_tool.h"
  9. #include "websocket/ws_common.h"
  10. #include "special_area.h"
  11. #include "websocket/wsClientMgr.h"
  12. car::car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
  13. int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
  14. :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
  15. ,m_vehicle_category_id(categoryid)
  16. ,m_vehicle_type_id(type_id)
  17. {
  18. m_message_handle.reset(new card_message_handle(this));
  19. m_his_location_card.reset(new location_vehicle(m_id,m_type));
  20. }
  21. car::~car(){}
  22. void car::site_hover(int sid)
  23. {
  24. if(m_time<=0)
  25. {
  26. return;
  27. }
  28. m_site_area->on_point(m_id,sid,0, m_type);
  29. }
  30. std::shared_ptr<area_hover> car::get_area_hover()
  31. {
  32. return m_area_tool->m_area_hover;
  33. }
  34. std::shared_ptr<mine_tool> car::get_mine_tool()
  35. {
  36. return m_mine_tool;
  37. }
  38. std::shared_ptr<site_area_hover> car::get_site_area()
  39. {
  40. return m_site_area;
  41. }
  42. void car::do_business(const point &pt,double acc)
  43. {
  44. m_acc=acc;
  45. m_area_tool->on_point(m_id,pt,m_speed,m_type);
  46. m_site_area->on_point(m_id,0,this, m_type);
  47. m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
  48. handle_three_rates(pt);
  49. }
  50. int car::get_vehicle_type_id()
  51. {
  52. return m_vehicle_type_id;
  53. }
  54. void car::handle_three_rates(const point &pt)
  55. {
  56. card_pos cp;
  57. cp.biz_stat = get_stat();
  58. cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;
  59. const auto lm = m_area_tool->getLandmark();
  60. cp.enter_time = std::get<0>(lm)*1000;
  61. cp.area_id = std::get<3>(lm);
  62. cp.map_id = std::get<2>(lm);
  63. cp.vibration=m_acc;
  64. put_three_rates(cp);
  65. }
  66. void car::on_timer()
  67. {
  68. make_package();
  69. }
  70. int car::statbiz(int32_t special_id)
  71. {
  72. int status = get_stat();
  73. if(status == STATUS_LOST)
  74. {
  75. if(!m_area_tool->special_area())
  76. {
  77. special_id = special_area_list::instance()->get_special_id(m_id,*this,m_vehicle_category_id);
  78. log_info("enter_special_area:%.2f,%2.f,id:%d,special_area_id:%d",x,y,m_id,special_id);
  79. if(special_id != -1)
  80. m_area_tool->change_area(m_id,m_speed,m_type,special_id);//自动拖车
  81. }
  82. }
  83. return status;
  84. }
  85. void car::make_package()
  86. {
  87. int32_t special_id=-1;
  88. YA::_CARD_POS_ cp;
  89. loc_point pt = getSmoothPoint();
  90. const auto lm = m_area_tool->getLandmark();
  91. cp.enter_area_time = std::get<0>(lm);
  92. cp.rec_time = std::get<1>(lm);
  93. uint32_t map_id = std::get<2>(lm);
  94. uint32_t area_id = std::get<3>(lm);
  95. cp.map_id =map_id;cp.area_id=area_id;
  96. cp.landmark_id = std::get<4>(lm);
  97. cp.lm_direction = std::get<5>(lm);
  98. cp.landmark_dis=std::get<6>(lm);
  99. int32_t biz_stat=statbiz(special_id);
  100. cp.biz_stat=biz_stat;
  101. cp.down_time = m_mine_tool->get_down_time();
  102. cp.work_time = m_mine_tool->get_work_time();
  103. //for now
  104. cp.is_on_duty=m_mine_tool->is_on_duty();
  105. upt_card_pos(cp,pt);
  106. m_his_location_card->push(pt.m_time,pt,area_id,map_id);
  107. if(biz_stat==STATUS_LOST && special_id != -1 && m_display==1)
  108. {
  109. cp.area_id = special_id;
  110. swsClientMgr.SendSpecialAreaProcess(cp);
  111. }
  112. }
  113. loc_point car::getSmoothPoint()
  114. {
  115. loc_point lp = m_smo_tool->smooth_strategy();
  116. m_speed = lp.m_speed;
  117. m_stat = lp.m_stat;
  118. lp.y = -lp.y;
  119. return lp;
  120. }