1
0

card_base.h 3.7 KB

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