/** * @brief websocket公共头文件 * @version V 1.0.0 * @author * @date 创建时间: 2018-08-17\n * @note 2018-08-17 初次创建。\n * @warning * @bug */ #ifndef _WS_COMMON_INC_H_ #define _WS_COMMON_INC_H_ #include #include #include namespace sys { const int MIN_SEND_INTERVAL = 1;//最小发送时间间隔 /** * @brief 线程配置结构体。 */ struct _THREAD_CONFIG_ { int SendInterval;//发送间隔(单位:秒) void Clear() { SendInterval = 0; } _THREAD_CONFIG_() { Clear(); } }; // 传感器,加速度,角速度 struct sensor{ double m_acc; // 加速度 double m_ang; // 角速度 double m_tri_acc[3]; // 三轴,0-x,1-y,2-z轴 double m_tri_ang[3]; // 三轴, uint8_t m_walking_step; // 行进步数 uint8_t m_jump_count; // 跳跃次数 double m_hang_time; // 滞空时间 double m_hang_height; // 滞空高度 sensor(): m_acc(0.0), m_ang(0.0),m_walking_step(0), m_jump_count(0),m_hang_time(0), m_hang_height(0) { m_tri_acc[0] = m_tri_acc[1] = m_tri_acc[2] = m_tri_ang[0] = m_tri_ang[1] = m_tri_ang[2] = 0.0; } }; /** * @brief 基础卡信息结构体。 */ struct _BASE_CARD_: public sensor { int Type; //卡类型 int ID; //卡ID double x; //x坐标 double y; //y坐标 double z; //z坐标 double down_time; //入井时间戳 double enter_area_time; //进入区域时间戳 double rec_time; //最后接收时间戳 double work_time; //工作时长 int map_id; //地图编号 int area_id; //区域ID int dept_id; //部门编号 int stat; //状态 int running_stat; //运行状态: 包括上猴车状态 int biz_stat; //业务状态 double speed; //速度 double m_freq; // 卡频率 _BASE_CARD_() { Type = 0; ID = 0; x = 0; y = 0; z = 0; down_time = 0; enter_area_time = 0; rec_time = 0; work_time = 0; map_id = 0; area_id = 0; dept_id = 0; stat = 0; running_stat = 0; biz_stat = 0; speed = 0.0; m_freq = 0.0; } }; /** * @brief 卡位置结构体。 */ struct _CARD_POS_ : public _BASE_CARD_ { std::map> area_info; int landmark_id; //地标编号 int lm_direction; //地标方向 int landmark_dis; //距离地标的距离 int level_id; //级别编号 int is_on_duty; //车辆是否是当天出勤的标识(1:出勤,0:不出勤) int display; //是否显示(1:显示,0:不显示) int battery_stat; //卡电量状态 int battery_val; //卡电量值 void Clear() { landmark_id = 0; lm_direction = 0; landmark_dis = 0; level_id = 0; is_on_duty = 0; display = 1;//默认显示 battery_stat = 0; battery_val = 10; } _CARD_POS_() { Clear(); } }; /** * @brief 统计部门结构体。 */ struct _STAT_DEPT_ITEM_ { int DeptID;//部门ID std::map Area;//区域数量列表(key是区域ID,value是区域里的卡数) std::map Dept;//部门数量列表(key是区域ID,value是部门里的卡数) std::map OcptLvl;//职务级别数量列表(key是区域ID,value是职务级别里的卡数) int Sum;//卡总数 _STAT_DEPT_ITEM_() { DeptID = 0; Sum = 0; } }; struct light_state{ int m_group_id; int m_light_id; int m_light_state; std::string m_card_id; light_state(): m_group_id(0), m_light_id(0), m_light_state(0), m_card_id("") {} light_state(const int& gid, const int& lid, const int& state, const std::string& cid) : m_group_id(gid), m_light_id(lid), m_light_state(state), m_card_id(cid) {} }; // 设备状态信息,基站类设备 struct device_state{ uint32_t m_id; // 设备ID uint8_t m_type; // 设备类型 uint8_t m_state; // 设备状态 uint64_t m_cur_time; // 接收时间 device_state(uint32_t id, uint8_t type, uint8_t state, uint64_t ctime) : m_id(id) , m_type(type) , m_state(state) , m_cur_time(ctime) {} device_state() : m_id(0) , m_type(0) , m_state(0) , m_cur_time(0) {} }; // tof_data 数据 struct tof_data{ std::string cid; // 卡号 double y; // 一维坐标 std::array ant_dist; // 天线的测距距离 int sid; // 基站号 std::string cur_time; // 当前时间 double ant_diff; tof_data() : cid("") , y(0.0) , sid(0) , cur_time("") , ant_diff(0) { ant_dist.fill(0); } ~tof_data(){ reset(); } void reset() { cid = cur_time = ""; y = 0; sid = 0; ant_diff = 0; ant_dist.fill(0); } /*tof_data& operator=(const tof_data v){ this->cid = v.cid; this->y = v.y; this->sid = v.sid; this->cur_time = v.cur_time; this->ant_dist = ant_dist; this->ant_diff = v.ant_diff; return *this; }*/ }; // tof_data 数据 struct tof_data_oneAntenna { std::string cid; // 卡号 std::map map_site_id_dist; double x; double y; // double dist1; // 距离 // int sid1; // 基站号 // double dist2; // 距离 // int sid2; // 基站号 // double dist3; // 距离 // int sid3; // 基站号 // double dist4; // 距离 // int sid4; // 基站号 std::string cur_time; // 当前时间 tof_data_oneAntenna() : cid("") , cur_time("") { } ~tof_data_oneAntenna() { reset(); } void reset() { cid = cur_time = ""; map_site_id_dist.clear(); } }; struct sb_data{ double x; double y; double z; std::string cid; double speed; std::string site_info; double acc; std::array m_acc_data; double ang; std::array m_ang_data; std::string cur_time; sb_data() : x(0.0) , y(0.0) , z(0.0) , cid("") , speed(0.0) , site_info("") , acc(0.0) , ang(0.0) , cur_time("") { m_acc_data.fill(0); m_ang_data.fill(0); } void reset() { cid = cur_time = site_info = ""; x = y = z = speed = acc = ang = 0.0; m_acc_data.fill(0); m_ang_data.fill(0); } }; struct tdoa_2d_data { double x; double y; double dx_v; double dy_v; double dz_v; double acc; double ang; std::array m_acc_data; std::array m_ang_data; std::string cid; double d1; double d2; double d3; std::string site_info; std::string cur_time; int move_state; tdoa_2d_data() : x(0.0) , y(0.0) , dx_v(0.0) , dy_v(0.0) , acc(0.0) , ang(0.0) , cid("") , d1(0.0) , d2(0.0) , d3(0.0) , site_info("") , cur_time("") , move_state(0) { m_acc_data.fill(0); m_ang_data.fill(0); } tdoa_2d_data(double x, double y, double dx, double dy, double acc, double acc_x, double acc_y, double acc_z, double ang, double ang_x, double ang_y, double ang_z, std::string cid, double d1, double d2, double d3, std::string ctime, std::string sinfo, int state) { this->x = x; this->y = y; this->dx_v = dx; this->dy_v = dy; this->acc = acc; this->ang = ang; this->cid = cid; this->d1 = d1; this->d2 = d2; this->d3 = d3; this->cur_time = ctime; this->site_info = sinfo; m_acc_data[0] = acc_x; m_acc_data[1] = acc_y; m_acc_data[2] = acc_z; m_ang_data[0] = ang_x; m_ang_data[1] = ang_y; m_ang_data[2] = ang_z; this->move_state = state; } void reset() { cid = site_info = cur_time = ""; move_state = x = y = dx_v = dy_v = acc = ang = d1 = d2 = d3 = 0; m_acc_data.fill(0); m_ang_data.fill(0); } }; struct tof_3d_data{ double x; double y; double z; double dx_v; double dy_v; double dz_v; double acc; double ang; std::array m_acc_data; std::array m_ang_data; std::string cid; std::string site_info; std::string cur_time; int move_state; tof_3d_data() : x(0.0) , y(0.0) , z(0.0) , dx_v(0.0) , dy_v(0.0) , dz_v(0.0) , acc(0.0) , ang(0.0) , cid("") , site_info("") , cur_time("") , move_state(0) { m_acc_data.fill(0); m_ang_data.fill(0); } tof_3d_data(double x, double y, double z, double dx, double dy, double dz, double acc, double acc_x, double acc_y, double acc_z, double ang, double ang_x, double ang_y, double ang_z, std::string cid, std::string ctime, std::string sinfo, int state) { this->x = x; this->y = y; this->z = z; this->dx_v = dx; this->dy_v = dy; this->dz_v = dz; this->acc = acc; this->ang = ang; this->cid = cid; this->cur_time = ctime; this->site_info = sinfo; m_acc_data[0] = acc_x; m_acc_data[1] = acc_y; m_acc_data[2] = acc_z; m_ang_data[0] = ang_x; m_ang_data[1] = ang_y; m_ang_data[2] = ang_z; this->move_state = state; } void reset() { cid = site_info = cur_time = ""; move_state = x = y = z = dx_v = dy_v = dz_v = acc = ang = 0; m_acc_data.fill(0); m_ang_data.fill(0); } }; } #endif