card.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #include"area.h"
  11. #define CARD_LOST_TIME_OUT (30*1000)
  12. struct task;
  13. template<typename T> struct zloop;
  14. struct select_tool;
  15. struct smooth_tool;
  16. struct monkey_person;
  17. struct card_message_handle;
  18. struct card:point
  19. {
  20. card(uint32_t id,uint16_t dis,int16_t type,int32_t deptid)
  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. ,m_ct(0)
  28. ,m_time(0)
  29. ,m_deptid(deptid)
  30. ,m_stat_attendance(AS_INIT)
  31. ,m_attendance_start_time(std::chrono::seconds(0))
  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. ///考勤状态 0初始状态 1 没在考勤 2 考勤;参看ATTENDANCE_STATUS
  43. int m_stat_attendance;
  44. ///考勤开始时间
  45. std::chrono::system_clock::time_point m_attendance_start_time;
  46. };
  47. struct card_location_base:card
  48. {
  49. std::unique_ptr<select_tool> m_sel_tool;
  50. std::unique_ptr<smooth_tool> m_smo_tool;
  51. card_message_handle *m_message_handle=nullptr;
  52. ev::dynamic_loop * m_loop = nullptr;
  53. ev::timer m_timer;
  54. card_location_base()=default;
  55. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t );
  56. virtual void do_business(const point &pt)=0;
  57. virtual void set(ev::dynamic_loop * loop)=0;
  58. virtual void site_hover(int sid)=0;
  59. virtual std::shared_ptr<area_hover> get_area_hover()=0;
  60. virtual void reset(std::shared_ptr<monkey_person> mp){}
  61. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  62. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  63. void do_status(STA_TYPE st)
  64. {
  65. if(STATUS_HELP_==st)
  66. {
  67. //module_call_help::ins
  68. }
  69. }
  70. void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
  71. int get_stat();
  72. virtual ~card_location_base();
  73. };
  74. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  75. {
  76. void init_staffer();
  77. void init_vehicle();
  78. uint64_t getId(uint32_t cardid,uint64_t);
  79. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  80. void init_card_from_db();
  81. ~card_list(){}
  82. };
  83. #endif