1
0

card.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. 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. enum STA_TYPE
  16. {
  17. STATUS_HELP=0,
  18. STATUS_LOW_POWER,
  19. };
  20. struct card:point
  21. {
  22. card(uint32_t id,uint16_t dis,int16_t type,int32_t deptid)
  23. :m_id(id)
  24. ,m_type(type)
  25. ,m_display(dis)
  26. ,m_speed(0)
  27. ,m_is_attendance(0)
  28. ,m_stat(0)
  29. ,m_ct(0)
  30. ,m_time(0)
  31. ,m_deptid(deptid)
  32. {}
  33. uint32_t m_id; //卡号
  34. int16_t m_type; //类型
  35. uint16_t m_display; //1显示0不显示,往前端推送
  36. double m_speed; //速度
  37. int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下
  38. int m_stat; //运动静止状态
  39. uint16_t m_ct; //ct
  40. uint64_t m_time; //时间戳
  41. int32_t m_deptid; //部门编号
  42. };
  43. struct card_location_base:card
  44. {
  45. std::shared_ptr<select_tool> m_sel_tool=nullptr;
  46. std::shared_ptr<smooth_tool> m_smo_tool=nullptr;
  47. card_message_handle *m_message_handle=nullptr;
  48. ev::dynamic_loop * m_loop = nullptr;
  49. ev::timer m_timer;
  50. card_location_base()=default;
  51. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t );
  52. virtual void do_business(const point &pt)=0;
  53. virtual void set(ev::dynamic_loop * loop)=0;
  54. virtual void reset(std::shared_ptr<monkey_person> mp){}
  55. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  56. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  57. void do_status(STA_TYPE st)
  58. {
  59. }
  60. void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
  61. virtual ~card_location_base();
  62. };
  63. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  64. {
  65. void init_staffer();
  66. void init_vehicle();
  67. uint64_t getId(uint32_t cardid,uint64_t);
  68. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  69. void init_card_from_db();
  70. ~card_list(){}
  71. };
  72. #endif