card_car.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. uint64_t id=tool_other::type_id_to_u64(m_type,m_id);
  39. mine_business::inst()->make_arg(id,pt,m_time);
  40. }
  41. int car::get_vehicle_type_id()
  42. {
  43. return m_vehicle_type_id;
  44. }
  45. void car::handle_three_rates(const point &pt)
  46. {
  47. card_pos cp;
  48. m_biz_stat=get_stat();
  49. cp.biz_stat = m_biz_stat;
  50. cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;
  51. //const auto lm = m_area_tool->getLandmark();
  52. // cp.enter_time = std::get<0>(lm)*1000;
  53. // cp.area_id = std::get<3>(lm);
  54. cp.map_id = m_area_tool->get_mapid();
  55. cp.vibration=m_acc;
  56. put_three_rates(cp);
  57. }
  58. void car::on_timer()
  59. {
  60. if(!empty())
  61. make_package();
  62. }
  63. int car::get_area()
  64. {
  65. int status = m_biz_stat;
  66. int special_id = -1;
  67. if(status == STATUS_LOST)
  68. {
  69. special_id = special_area_list::instance()->get_special_id(m_id,*this,m_vehicle_category_id);
  70. log_info("enter_special_area:%.2f,%2.f,id:%d,special_area_id:%d",x,y,m_id,special_id);
  71. }
  72. return special_id;
  73. }
  74. void car::make_package()
  75. {
  76. YA::_CARD_POS_ cp;
  77. loc_point pt = getSmoothPoint();
  78. cp.area_info=m_area_tool->m_area_info;
  79. cp.map_id =m_area_tool->get_mapid();
  80. int32_t biz_stat=m_biz_stat;
  81. cp.biz_stat=biz_stat;
  82. cp.down_time = m_mine_tool->get_down_time();
  83. cp.work_time = m_mine_tool->get_work_time();
  84. uint32_t on_duty=0;
  85. // if(m_mine_tool->m_is_attendance)
  86. on_duty=m_mine_tool->is_on_duty();
  87. cp.is_on_duty=on_duty;
  88. upt_card_pos(cp,pt);
  89. make_his_location(pt.m_time,pt);
  90. uint64_t _now=tool_time::now_to_ms();
  91. uint64_t t=_now>m_timeval?_now-m_timeval:m_timeval-_now;
  92. if(t>10*1000)
  93. {
  94. m_area_tool->on_point(shared_from_this(),pt);
  95. m_biz_stat=get_stat();
  96. }
  97. // if(biz_stat==STATUS_LOST && special_id != -1 && m_display==1)
  98. // {
  99. // cp.area_id = special_id;
  100. // swsClientMgr.SendSpecialAreaProcess(cp);
  101. // }
  102. }
  103. void car::get_card(bool f)
  104. {
  105. if(f)
  106. mine_business::inst()->put(shared_from_this());
  107. }
  108. loc_point car::getSmoothPoint()
  109. {
  110. loc_point lp = m_smo_tool->smooth_strategy();
  111. m_speed = lp.m_speed;
  112. m_stat = lp.m_stat;
  113. lp.y = -lp.y;
  114. return lp;
  115. }