#ifndef _CARD_HPP_ #define _CARD_HPP_ #include #include #include "point.h" #include "write-copy.h" #include "websocket/ws_common.h" #include "common.h" #include "area.h" #include "site_area.h" #include "loc_message.h" #define CARD_LOST_TIME_OUT (30*1000) struct task; template struct zloop; struct select_tool; struct smooth_tool; struct monkey_person; struct card_message_handle; struct mine_tool; struct card:point { card(uint32_t id,uint16_t dis,uint64_t type,int32_t deptid,int32_t level_id) :m_id(id) ,m_type(type) ,m_display(dis) ,m_speed(0) ,m_is_attendance(0) ,m_stat(0) ,m_ct(0) ,m_time(0) ,m_deptid(deptid) ,m_level_id(level_id) {} uint64_t type_(){return m_type;} uint64_t time_(){return m_time;} uint32_t m_id; //卡号 uint64_t m_type; //类型 uint16_t m_display; //1显示0不显示,往前端推送 double m_speed; //速度 int m_is_attendance; //井上井下状态 0初始状态 1 井上 2 井下 int m_stat; //运动静止状态 uint16_t m_ct; //ct ///时间戳 ms uint64_t m_time; int32_t m_deptid; //部门编号 int32_t m_level_id; //部门级别 }; struct card_location_base:card { std::unique_ptr m_sel_tool; std::unique_ptr m_smo_tool; card_message_handle *m_message_handle=nullptr; ev::dynamic_loop * m_loop = nullptr; ev::timer m_timer; card_location_base()=default; card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t ); virtual void do_business(const point &pt)=0; virtual void set(ev::dynamic_loop * loop)=0; virtual void site_hover(int sid)=0; virtual std::shared_ptr get_area_hover()=0; virtual std::shared_ptr get_mine_tool()=0; virtual std::shared_ptr get_site_area()=0; virtual void clear(); virtual void reset(std::shared_ptr mp){} virtual int get_vehicle_type_id(){return 0;} void on_message(zloop * loop,const message_locinfo&loc,bool is_history); void on_location(const std::vector&vp,const std::vector &lm ); void do_status(STATUS_CARD st); void upt_card_pos(YA::_CARD_POS_ &,const point &pt); void del_card_pos(); int get_stat(); bool is_person() const { return CT_PERSON == m_type; } bool is_vehicle() const { return CT_VEHICLE == m_type; } virtual ~card_location_base(); }; struct card_list:single_base> { void init_staffer(); void init_vehicle(); uint64_t getId(uint32_t cardid,uint64_t); void on_message(zloop *loop,const message_locinfo&loc,bool is_history); void init_card_from_db(); void load_his_card_postion_vehicle(); void load_his_card_postion_staff(); void load_his_card_postion_from_db(); /// (类型<<32)|卡号 static uint64_t to_id64(int32_t type, uint32_t id) { return (static_cast(type)<<32)|id; } static std::string to_id64_str(int32_t type, uint32_t id) { char sql[15] = {'\0'}; sprintf(sql, "%03d%010d", type, id); return std::string(sql); } ~card_list(){} }; #endif