card.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _CARD_HPP_
  2. #define _CARD_HPP_
  3. #include <message.h>
  4. #include <ev++.h>
  5. #include "point.h"
  6. #include "ant.h"
  7. #include "write-copy.h"
  8. #include "websocket/ws_common.h"
  9. #include "common.h"
  10. #define CARD_LOST_TIME_OUT (30*1000)
  11. struct task;
  12. template<typename T> struct zloop;
  13. struct select_tool;
  14. struct smooth_tool;
  15. struct monkey_person;
  16. struct card_message_handle;
  17. struct card:point
  18. {
  19. card(uint32_t id,uint16_t dis,int16_t type,int32_t deptid)
  20. :m_id(id)
  21. ,m_type(type)
  22. ,m_display(dis)
  23. ,m_speed(0)
  24. ,m_is_attendance(0)
  25. ,m_stat(0)
  26. ,m_ct(0)
  27. ,m_time(0)
  28. ,m_deptid(deptid)
  29. {}
  30. uint32_t m_id; //卡号
  31. int16_t m_type; //类型
  32. uint16_t m_display; //1显示0不显示,往前端推送
  33. double m_speed; //速度
  34. int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下
  35. int m_stat; //运动静止状态
  36. uint16_t m_ct; //ct
  37. uint64_t m_time; //时间戳
  38. int32_t m_deptid; //部门编号
  39. };
  40. struct card_location_base:card
  41. {
  42. std::unique_ptr<select_tool> m_sel_tool;
  43. std::unique_ptr<smooth_tool> m_smo_tool;
  44. card_message_handle *m_message_handle=nullptr;
  45. ev::dynamic_loop * m_loop = nullptr;
  46. ev::timer m_timer;
  47. card_location_base()=default;
  48. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t );
  49. virtual void do_business(const point &pt)=0;
  50. virtual void set(ev::dynamic_loop * loop)=0;
  51. virtual void site_hover(int sid)=0;
  52. virtual void reset(std::shared_ptr<monkey_person> mp){}
  53. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  54. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  55. void do_status(STA_TYPE st)
  56. {
  57. if(STATUS_HELP_==st)
  58. {
  59. //module_call_help::ins
  60. }
  61. }
  62. void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
  63. int get_stat();
  64. virtual ~card_location_base();
  65. };
  66. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  67. {
  68. void init_staffer();
  69. void init_vehicle();
  70. uint64_t getId(uint32_t cardid,uint64_t);
  71. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  72. void init_card_from_db();
  73. ~card_list(){}
  74. };
  75. #endif