123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455 |
- /**
- * @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 <map>
- #include <array>
- #include <string>
- 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<int,std::tuple<int,int,int,double,uint64_t>> 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<int, int> Area;//区域数量列表(key是区域ID,value是区域里的卡数)
- std::map<int, int> Dept;//部门数量列表(key是区域ID,value是部门里的卡数)
- std::map<int, int> 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<double, 2> 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<int, double> 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<double ,3> m_acc_data;
- double ang;
- std::array<double ,3> 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<double, 3> m_acc_data;
- std::array<double, 3> 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<double, 3> m_acc_data;
- std::array<double, 3> 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
|