card.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef _CARD_HPP_
  2. #define _CARD_HPP_
  3. #include <message.h>
  4. #include <ev++.h>
  5. #include "point.h"
  6. #include "write-copy.h"
  7. #include "websocket/ws_common.h"
  8. #include "common.h"
  9. #include "ant.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,uint64_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. uint64_t type_(){return m_type;}
  31. uint64_t time_(){return m_time;}
  32. uint32_t m_id; //卡号
  33. uint64_t m_type; //类型
  34. uint16_t m_display; //1显示0不显示,往前端推送
  35. double m_speed; //速度
  36. int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下
  37. int m_stat; //运动静止状态
  38. uint16_t m_ct; //ct
  39. uint64_t m_time; //时间戳
  40. int32_t m_deptid; //部门编号
  41. };
  42. struct card_location_base:card
  43. {
  44. std::unique_ptr<select_tool> m_sel_tool;
  45. std::unique_ptr<smooth_tool> m_smo_tool;
  46. card_message_handle *m_message_handle=nullptr;
  47. ev::dynamic_loop * m_loop = nullptr;
  48. ev::timer m_timer;
  49. card_location_base()=default;
  50. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t );
  51. virtual void do_business(const point &pt)=0;
  52. virtual void set(ev::dynamic_loop * loop)=0;
  53. virtual void site_hover(int sid)=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. if(STATUS_HELP_==st)
  60. {
  61. //module_call_help::ins
  62. }
  63. }
  64. void upt_card_pos(YA::_CARD_POS_ &,const point &pt);
  65. int get_stat();
  66. virtual ~card_location_base();
  67. };
  68. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  69. {
  70. void init_staffer();
  71. void init_vehicle();
  72. uint64_t getId(uint32_t cardid,uint64_t);
  73. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  74. void init_card_from_db();
  75. ~card_list(){}
  76. };
  77. #endif