card_base.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef _CARD_BASE_HPP_
  2. #define _CARD_BASE_HPP_
  3. #include <vector>
  4. #include <memory>
  5. #include <atomic>
  6. #include "point.h"
  7. #include "common.h"
  8. #define CARD_LOST_TIME_OUT (60*1000)
  9. struct task;
  10. template<typename T> struct zloop;
  11. struct select_tool;
  12. struct smooth_tool;
  13. struct monkey_person;
  14. struct card_message_handle;
  15. struct card_location_base;
  16. struct message_locinfo;
  17. struct loc_message;
  18. struct mine_tool;
  19. struct location_card;
  20. struct card_pos;
  21. struct area_hover;
  22. struct site_area_hover;
  23. struct site;
  24. struct area_tool;
  25. namespace YA{struct _CARD_POS_;}
  26. struct card:point
  27. {
  28. card(uint32_t id,uint16_t dis,uint64_t type,int32_t deptid,int32_t level_id,uint32_t cid)
  29. :m_type(type)
  30. ,m_time(0)
  31. ,m_id(id)
  32. ,m_cid(cid)
  33. ,m_deptid(deptid)
  34. ,m_level_id(level_id)
  35. ,m_stat(0)
  36. ,m_biz_stat(0)
  37. ,m_display(dis)
  38. ,m_ct(0)
  39. ,m_acc(0)
  40. ,m_speed(0)
  41. {}
  42. uint64_t type_(){return m_type;}
  43. uint64_t time_(){return m_time;}
  44. uint64_t m_type; //类型
  45. uint64_t m_time; //时间戳 ms
  46. uint32_t m_id; //卡号
  47. uint32_t m_cid; //标识id 人staff_id 车 vehicle_id
  48. int32_t m_deptid; //部门编号
  49. int32_t m_level_id; //职务级别
  50. int m_stat; //运动静止状态
  51. int m_biz_stat;
  52. uint16_t m_display; //1显示0不显示,往前端推送
  53. uint16_t m_ct; //ct
  54. ///人卡(加速度状态),其值就是0和1,掘进机和采煤机,其值就是0~255,车辆,其值就需要乘以0.01,用于表示加速度值
  55. double m_acc;
  56. double m_speed; //速度
  57. };
  58. struct card_location_base:card,std::enable_shared_from_this<card_location_base>
  59. {
  60. uint64_t m_timeval=0;
  61. uint16_t m_display_old{0}; //1显示0不显示,往前端推送
  62. void update_display(){m_display_old=m_display;}
  63. bool eq_display(){return m_display_old==m_display;}
  64. std::uint8_t m_event[CARD_EVENT_COUNT_MAX]{0};
  65. std::unique_ptr<select_tool> m_sel_tool;
  66. std::unique_ptr<smooth_tool> m_smo_tool;
  67. std::unique_ptr<card_message_handle> m_message_handle;
  68. std::unique_ptr<location_card> m_his_location_card;
  69. std::atomic<int> m_upmine_flag{0};
  70. time_t m_help_last_time=0;
  71. int m_help_bit=0;
  72. void inc_upmine_flag(int flag)
  73. {
  74. m_upmine_flag=flag;
  75. }
  76. int upmine_flag(){return m_upmine_flag.load();}
  77. card_location_base()=default;
  78. card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t,uint32_t );
  79. virtual void do_business(const std::shared_ptr<site>&site,const point &pt,double acc)=0;
  80. virtual void on_timer()=0;
  81. virtual std::shared_ptr<mine_tool> get_mine_tool()=0;
  82. virtual void clear();
  83. virtual void reset(std::shared_ptr<monkey_person> mp){}
  84. virtual int get_vehicle_type_id(){return 0;}
  85. virtual void set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)=0;
  86. virtual int get_area(){return -1;}
  87. virtual std::shared_ptr<area_tool> get_area_tool()=0;
  88. virtual int get_vehicle_category_id(){return -1;}
  89. virtual int get_workline(){return -1;}
  90. virtual void get_card(bool f)=0;
  91. virtual void site_hover(int sid){}
  92. void make_his_location(uint64_t t,const point & pt,bool bclose = false);
  93. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  94. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  95. void do_status(int st);
  96. void upt_card_pos(YA::_CARD_POS_&cp, point &pt);
  97. void del_card_pos();
  98. int get_stat();
  99. void put_three_rates(card_pos &);
  100. void set_event_flag(EVENT_TYPE et,std::uint8_t f=1){m_event[et]=f;}
  101. bool get_event_flag(EVENT_TYPE et){return m_event[et];}
  102. bool is_person() const;
  103. bool is_vehicle() const;
  104. virtual ~card_location_base();
  105. static std::shared_ptr<card_location_base> make_person(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,
  106. int32_t deptid,int32_t level_id,uint32_t cid,int wl,const std::string & sname,const std::string & dname,int worktype_id);
  107. static std::shared_ptr<card_location_base> make_car(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,
  108. int32_t deptid, int32_t categoryid, int type_id,int32_t level_id,uint32_t cid);
  109. };
  110. #endif