card.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 "atomic"
  9. #include "area.h"
  10. //#include "module_service/module_call_help.h"
  11. struct task;
  12. template<typename T> struct zloop;
  13. struct select_tool;
  14. struct smooth_tool;
  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_message_handle;
  43. struct card:point
  44. {
  45. card(uint32_t id,uint16_t dis,int16_t type)
  46. :m_id(id)
  47. ,m_type(type)
  48. ,m_display(dis)
  49. ,m_speed(0)
  50. ,m_stat_attendance(0)
  51. ,m_stat(0)
  52. {}
  53. ///卡号
  54. uint32_t m_id;
  55. ///类型 CARD_TYPE
  56. int16_t m_type;
  57. ///1显示0不显示,往前端推送
  58. uint16_t m_display;
  59. ///速度
  60. double m_speed;
  61. ///考勤状态 0初始状态 1 没在考勤 2 考勤;参看ATTENDANCE_STATUS
  62. std::atomic<int> m_stat_attendance;
  63. ///考勤开始时间
  64. std::chrono::system_clock::time_point m_attendance_start_time;
  65. ///运动静止状态
  66. int m_stat;
  67. ///
  68. std::shared_ptr<area_hover> m_area_hover;
  69. ///分站id
  70. int m_site_id;
  71. /// 天线号
  72. int m_antenna_id;
  73. /// 分站发送数据的计数次数
  74. int m_reader_tickcount;
  75. /// 飞行时间
  76. int64_t flying_time;
  77. /// 天线角度
  78. double m_antenna_angle;
  79. /// 距离
  80. double m_distance;
  81. /// 飞行时间
  82. int64_t m_flying_time;
  83. // 分站接收到卡时的时间
  84. std::string m_str_his_time;
  85. // 采集程序接收到数据的时间
  86. std::string m_str_rec_time;
  87. /// 定位时间戳
  88. unsigned short m_time_stamp;
  89. /// 报文类型 tof,tdoa
  90. int m_ranging_type;
  91. // 加速度
  92. int m_accelerate_state;
  93. /// 电量
  94. int m_power_state;
  95. /// 上一次加速度状态
  96. int m_accelerate_state_last;
  97. ///呼救状态:事件开始(0),呼救已处理状态(1),事件结束(100);参看EVENT_STATUS
  98. std::atomic<int> m_stat_call_help;
  99. ///最后处理时间
  100. std::chrono::system_clock::time_point m_deal_time;
  101. /// 地标信息
  102. int m_landmarkid;
  103. /// 与地标的距离
  104. double m_landmarkdist;
  105. /// 所处地标的方向
  106. int m_landmarkdirect;
  107. };
  108. struct card_location_base:card
  109. {
  110. std::unique_ptr <select_tool> m_sel_tool;
  111. std::unique_ptr <smooth_tool> m_smo_tool;
  112. std::unique_ptr <card_message_handle> m_message_handle;
  113. ev::dynamic_loop * m_loop = nullptr;
  114. ev::timer m_timer;
  115. card_location_base()=default;
  116. card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t);
  117. void set(ev::dynamic_loop * loop);
  118. void on_timer();
  119. void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
  120. void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
  121. void do_status(STA_TYPE st)
  122. {
  123. if(STATUS_HELP==st)
  124. {
  125. //module_call_help::ins
  126. }
  127. }
  128. virtual ~card_location_base();
  129. };
  130. struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
  131. {
  132. void init_staffer();
  133. void init_vehicle();
  134. uint64_t getId(uint32_t cardid,uint64_t);
  135. void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
  136. void init_card_from_db();
  137. ~card_list(){}
  138. };
  139. #endif