#ifndef _CARD_BASE_HPP_ #define _CARD_BASE_HPP_ #include #include #include #include #include "point.h" #include "common.h" #include #include "websocket/ws_common.h" struct task; template struct zloop; struct select_tool; struct smooth_tool; struct monkey_person; struct card_message_handle; struct card_location_base; struct message_locinfo; struct loc_message; struct mine_tool; struct location_card; struct card_pos; struct area_hover; struct site_area_hover; struct site; struct area_tool; struct message_tdoa_locinfo; struct message_pdoa_locinfo; struct message_ins_locinfo; namespace sys{ struct _CARD_POS_; } struct card:point { card(uint32_t id,uint16_t dis,uint64_t type,int32_t deptid,int32_t level_id,uint32_t cid) :m_type(type) ,m_time(0) ,m_id(id) ,m_cid(cid) ,m_deptid(deptid) ,m_level_id(level_id) ,m_stat(0) ,m_biz_stat(0) ,m_pwr_stat(0) ,m_display(dis) ,m_ct(0) ,m_freq_id(0) ,m_freq(0.0) ,m_acc(0) ,m_speed(0) ,m_v_point(0, 0, 0) {} uint64_t type_(){return m_type;} uint64_t time_(){return m_time;} uint64_t m_type; //类型 uint64_t m_time; //时间戳 ms uint32_t m_id; //卡号 uint32_t m_cid; //标识id 人staff_id 车 vehicle_id int32_t m_deptid; //部门编号 int32_t m_level_id; //职务级别 int m_stat; //运动静止状态 int m_biz_stat; int m_pwr_stat; //电量状态 int m_battery_value = 10; //电量值 uint16_t m_display; //1显示0不显示,往前端推送 uint16_t m_ct; //ct uint8_t m_freq_id; // 频率索引 double m_freq; // 频率值 ///人卡(加速度状态),其值就是0和1,掘进机和采煤机,其值就是0~255,车辆,其值就需要乘以0.01,用于表示加速度值 double m_acc; double m_speed; //速度 double m_last_x = 0.0; double m_last_y = 0.0; point m_v_point; //车辆定位系统的定位结果 bool m_isVehicleMap = false; }; struct card_location_base:card,std::enable_shared_from_this { uint64_t m_timeval=0; uint16_t m_display_old{0}; //1显示0不显示,往前端推送 void update_display() { m_display_old = m_display; } bool eq_display() { return m_display_old == m_display; } std::uint8_t m_event[CARD_EVENT_COUNT_MAX]{0}; std::unique_ptr m_sel_tool; std::unique_ptr m_smo_tool; std::unique_ptr m_message_handle; std::unique_ptr m_his_location_card; std::atomic m_upmine_flag{0}; time_t m_help_last_time = 0; // 呼救持续时间 int m_help_bit = 0; // 基站对应的数据信息:距离+时间戳 struct sinfo{ int sct; double sdist; double angle; double pdoa; sinfo() : sct(0) , sdist(0.0) , angle(0.0) , pdoa(0.0) {} }; std::map last_site_info; std::map d3_last_site_info; // 3维上一次基站数据 //pdoa int m_last_ct = -1; float m_last_dist = 0.0; uint16_t m_last_site_id = 0; // 卡上一次定位的分站id uint64_t m_last_recv_time = 0; // 卡上一次接收时间 int m_last_site_dir = -1; // 卡上一次定位的分站天线1朝向 bool m_last_over_site = false; // 卡是否过分站 int m_cache_nums = 0; // 过分站后缓存的数据个数 int m_buff_size = 0; float m_pdoa_diff = 100.0; // pdoa分站当前上传相位差 float m_last_pdoa_diff = 100.0; // pdoa 分站上一帧数据的相位差 boost::circular_buffer m_cb_pdoa; // the list of current pdoa's different of phase; boost::circular_buffer m_cb_tof; // the list of tof that is pdoa history value boost::circular_buffer m_cb_point; point m_last_point; int m_cur_site_counts = 0; // 当前基站缓存数据总数 std::vector m_vtp_dist; // 相同分站存储距离数据 bool m_over_site = false; // 过分站状态 //int m_last_down_stream_idx = 0; boost::circular_buffer m_cb_stream_idx; // 分站下行方向的索引号 bool m_enable_anti_collision = false; int m_call_level = 0; std::map> m_msg_list; card_location_base()=default; card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t,uint32_t ); void inc_upmine_flag(int flag){m_upmine_flag=flag;} int upmine_flag(){return m_upmine_flag.load();} virtual void do_business(const std::shared_ptr&site,const point &pt)=0; virtual void on_timer()=0; virtual std::shared_ptr get_mine_tool()=0; virtual void clear(); virtual void reset(std::shared_ptr mp){} virtual int get_vehicle_type_id(){return 0;} virtual void set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)=0; virtual int get_area(){return -1;} virtual std::shared_ptr get_area_tool()=0; virtual int get_vehicle_category_id(){return -1;} virtual int get_workline(){return -1;} virtual void get_card(bool f)=0; virtual void site_hover(int sid){} virtual void handle_message(uint16_t ct,uint8_t& value){} void make_his_location(uint64_t t,const point & pt,bool bclose = false); void make_his_location_cell_card_tdoa(uint64_t t, const sys::tdoa_2d_data& tdoa2d); void on_message(zloop* loop, message_locinfo&loc, bool is_history); void on_message(zloop* loop, message_tdoa_locinfo& loc, bool is_history); void on_message(zloop* loop, message_pdoa_locinfo& loc, bool is_history); void on_message(zloop* loop, message_ins_locinfo& loc, bool is_history); void on_location(const std::vector&vp, const std::vector &lm); void do_status(int st); void upt_card_pos(sys::_CARD_POS_&cp, point &pt); void del_card_pos(); int get_stat(); void put_traffic_light(card_pos& cp); void set_event_flag(EVENT_TYPE et,std::uint8_t f=1){m_event[et]=f;} bool get_event_flag(EVENT_TYPE et){return m_event[et];} void do_site_coverage(message_pdoa_locinfo& loc); void do_card_locate_event(const message_pdoa_locinfo& loc); void do_site_locate_event(const message_pdoa_locinfo& loc); bool is_person() const; bool is_vehicle() const; void set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id); virtual ~card_location_base(); static std::shared_ptr make_person(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t, int32_t deptid,int32_t level_id,uint32_t cid,int wl,const std::string & sname,const std::string & dname,int worktype_id); static std::shared_ptr make_car(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t, int32_t deptid, int32_t categoryid, int type_id,int32_t level_id,uint32_t cid); void set_freq_id(const uint8_t& val) { m_freq_id = val; } }; #endif