1
0

card.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. struct task;
  9. template<typename T> struct zloop;
  10. struct select_tool;
  11. struct smooth_tool;
  12. enum STA_TYPE
  13. {
  14. STATUS_HELP=0,
  15. STATUS_LOW_POWER,
  16. };
  17. struct card_message_handle;
  18. struct card:point
  19. {
  20. card(uint32_t id,uint16_t dis,int16_t type)
  21. :m_id(id)
  22. ,m_type(type)
  23. ,m_display(dis)
  24. ,m_speed(0)
  25. ,m_is_attendance(0)
  26. ,m_stat(0)
  27. {}
  28. uint32_t m_id; //卡号
  29. int16_t m_type; //类型
  30. uint16_t m_display; //1显示0不显示,往前端推送
  31. double m_speed; //速度
  32. int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下
  33. int m_stat; //运动静止状态
  34. };
  35. struct card_location_base:card
  36. {
  37. std::shared_ptr<select_tool> m_sel_tool=nullptr;
  38. std::shared_ptr<smooth_tool> m_smo_tool=nullptr;
  39. card_message_handle *m_message_handle=nullptr;
  40. ev::dynamic_loop * m_loop = nullptr;
  41. ev::timer m_timer;
  42. card_location_base()=default;
  43. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t);
  44. void set(ev::dynamic_loop * loop);
  45. void on_timer();
  46. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  47. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  48. void do_status(STA_TYPE st)
  49. {
  50. }
  51. virtual ~card_location_base();
  52. };
  53. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  54. {
  55. void init_staffer();
  56. void init_vehicle();
  57. uint64_t getId(uint32_t cardid,uint64_t);
  58. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  59. void init_card_from_db();
  60. ~card_list(){}
  61. };
  62. #endif