card.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. /**
  21. * @brief 0初始状态 1 没在考勤 2 考勤
  22. */
  23. enum ATTENDANCE_STATUS
  24. {
  25. ///初始状态
  26. AS_INIT=0,
  27. ///没在考勤
  28. AS_NOT_ATTENDANCE=1,
  29. ///考勤
  30. AS_ATTENDANCE=2,
  31. };
  32. /**
  33. * @brief 卡类型 人卡 车卡
  34. */
  35. enum CARD_TYPE
  36. {
  37. ///卡类型 人卡
  38. CT_PERSON=1,
  39. ///卡类型 车卡
  40. CT_VEHICLE=2,
  41. };
  42. struct card:point
  43. {
  44. card(uint32_t id,uint16_t dis,int16_t type,int32_t deptid)
  45. :m_id(id)
  46. ,m_type(type)
  47. ,m_display(dis)
  48. ,m_speed(0)
  49. ,m_is_attendance(0)
  50. ,m_stat(0)
  51. ,m_ct(0)
  52. ,m_time(0)
  53. ,m_deptid(deptid)
  54. {}
  55. uint32_t m_id; //卡号
  56. int16_t m_type; //类型
  57. uint16_t m_display; //1显示0不显示,往前端推送
  58. double m_speed; //速度
  59. int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下
  60. int m_stat; //运动静止状态
  61. uint16_t m_ct; //ct
  62. uint64_t m_time; //时间戳
  63. int32_t m_deptid; //部门编号
  64. };
  65. struct card_location_base:card
  66. {
  67. std::unique_ptr<select_tool> m_sel_tool;
  68. std::unique_ptr<smooth_tool> m_smo_tool;
  69. card_message_handle *m_message_handle=nullptr;
  70. ev::dynamic_loop * m_loop = nullptr;
  71. ev::timer m_timer;
  72. card_location_base()=default;
  73. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t );
  74. virtual void do_business(const point &pt)=0;
  75. virtual void set(ev::dynamic_loop * loop)=0;
  76. virtual void reset(std::shared_ptr<monkey_person> mp){}
  77. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  78. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  79. void do_status(STA_TYPE st)
  80. {
  81. if(STATUS_HELP==st)
  82. {
  83. //module_call_help::ins
  84. }
  85. }
  86. void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
  87. virtual ~card_location_base();
  88. };
  89. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  90. {
  91. void init_staffer();
  92. void init_vehicle();
  93. uint64_t getId(uint32_t cardid,uint64_t);
  94. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  95. void init_card_from_db();
  96. ~card_list(){}
  97. };
  98. #endif