123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /**
- * @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>
- 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坐标
- int cell_index;
- 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;
- cell_index = 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;
- bool m_state_changed; // 状态有变化,立马更新状态,否则隔30秒再更新一次
- light_state(): m_group_id(0), m_light_id(0), m_light_state(0), m_card_id(""), m_state_changed(false)
- {}
- light_state(const int& gid, const int& lid, const int& state, const std::string& cid,bool state_changed)
- : m_group_id(gid),
- m_light_id(lid),
- m_light_state(state),
- m_card_id(cid),
- m_state_changed(state_changed)
- {}
- };
- // 设备状态信息,基站类设备
- 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)
- {}
- };
- }
- #endif
|