classdef.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. #ifndef YASERVER_CLASSDEF_H_
  2. #define YASERVER_CLASSDEF_H_
  3. #define MAX_DIST_CACHE 4 //5
  4. #define DIST_COUNT 4
  5. #define ANCHOR_COUNT 4
  6. #define KALMAN_OFFSET_COOR 0.01
  7. #define KALMAN_OFFSET_MOVE 1
  8. #define KALMAN_OFFSET_RANGING 0.01
  9. #define KALMAN_INTERVAL 0.3
  10. #define KALMAN_OFFSET_COOR_TRI 0.01
  11. #define KALMAN_OFFSET_MOVE_TRI 1
  12. #define KALMAN_OFFSET_RANGING_TRI 0.09
  13. #define KALMAN_INTERVAL_TRI 1
  14. #define ANTENNA_COUNT 2
  15. #define ADHOC_COUNT 10
  16. #define READER_TIMEOUT 20
  17. #define OVER_TIME 480 * 60
  18. //#define CARD_TYPE_ADHOC 3
  19. #define MAX_SEMACOUNT 64
  20. #define INVALID_COORDINATE -1
  21. //算法类型
  22. //#define ALGORITHM_TYPE_TOF
  23. #define ALGORITHM_TYPE_TDOA
  24. //#define ALGORITHM_TYPE_INS //使用惯导判断
  25. //滤波功能开启
  26. //#define FILTER_KALMAN
  27. #include <string>
  28. #include <ctime>
  29. #include <map>
  30. #include <iostream>
  31. #include <string>
  32. #include <vector>
  33. #include <unordered_map>
  34. #include <deque>
  35. //#include "winsock2.h"
  36. #include <kalman\locate.h>
  37. #include "Filter\KalmanFilter.h"
  38. #define MIN(x,y) (x < y ? x : y)
  39. #define MAX(x,y) (x > y ? x : y)
  40. using namespace std;
  41. const int MAX_CALC_POINTS = 30;
  42. const double INS_WEIGHT = 9.0; //惯导权重
  43. const double UWB_WEIGHT = 1.0; //UWB权重
  44. enum TIMER_ID
  45. {
  46. TMR_SEND_COUNTING = 1,
  47. TMR_SEND_ALARM,
  48. TMR_SEND_DEVICE_STATE,
  49. TMR_SEND_POSTION,
  50. TMR_SYNC_READER_TIME,
  51. TMR_CLEAR_CALL_TIMER,
  52. TMR_SEND_CALL
  53. };
  54. enum ALARM_FLAG{
  55. AF_CARD_OVER_COUNT = 1,
  56. AF_CARD_OVER_TIME,
  57. AF_CARD_OVER_SPEED,
  58. AF_CARD_AREA_OVER_TIME,
  59. AF_CARD_AREA_OVER_COUNT,
  60. AF_CARD_AREA_FORBIDDEN,//1 这两个需要处理s
  61. AF_AREA_OVER_COUNT,
  62. AF_AREA_OVER_TIME,
  63. AF_AREA_FORBIDDEN //2
  64. };
  65. enum EDIT_TYPE_ID{
  66. ET_INSERT = 0,
  67. ET_UPDATE,
  68. ET_DELETE
  69. };
  70. enum ALARM_TYPE_ID
  71. {
  72. ATID_OVER_COUNT_PERSON = 1,
  73. ATID_OVER_TIME_PERSON,
  74. ATID_AREA_OVER_COUNT_PERSON,
  75. ATID_AREA_OVER_TIME_PERSON,
  76. ATID_AREA_LIMIT_PERSON,
  77. ATID_AREA_FORBIDDEN_PERSON,
  78. ATID_READER,
  79. ATID_OVER_SPEED,
  80. ATID_RUN_THE_RED_LIGHT,
  81. ATID_POWER,
  82. ATID_OVER_COUNT_VEHICLE,
  83. ATID_OVER_TIME_VEHICLE,
  84. ATID_AREA_OVER_COUNT_VEHICLE,
  85. ATID_AREA_OVER_TIME_VEHICLE,
  86. ATID_AREA_LIMIT_VEHICLE,
  87. ATID_AREA_FORBIDDEN_VEHICLE
  88. };
  89. enum STATUS_DEVICE{
  90. STATUS_DEVICE_NORMAL = 1,
  91. STATUS_DEVICE_ERROR,
  92. };
  93. enum STATUS_CARD
  94. {
  95. STATUS_NORMAL = 0, //正常
  96. STATUS_ERROR = 1,
  97. STATUS_ERROR_SERIOUS = 2,
  98. STATUS_POWER_LOWER = 1, //电量低
  99. STATUS_POWER_LOWER_SERIOUS = 2, //电量极低
  100. STATUS_OVER_TIME = 4, //超时
  101. //STATUS_OVER_COUNT = 1,
  102. STATUS_OVER_SPEED = 8, //超速
  103. STATUS_AREA_OVER_TIME = 16, //区域超时
  104. //STATUS_AREA_OVER_COUNT = 1,
  105. STATUS_AREA_OVER_SPEED = 32, //区域超速
  106. STATUS_AREA_FORBIDDEN = 64, //进入限制区域
  107. STATUS_HELP = 128, //呼救
  108. STATUS_HELP_DEALED = 256, //
  109. STATUS_CALL = 512, //呼叫
  110. STATUS_LOST = 1024 //清除盲区
  111. //STATUS_ERROR_DEALED,
  112. };
  113. enum STORE_CARD_DATA_FLAG{
  114. TEST_LOCATE_COMPARE = 0,
  115. TEST_LOCATE_DATA,
  116. HIS_LOCATION,
  117. HIS_RAW_DATA,
  118. HIS_AREA_LOCATION_ENTER,
  119. HIS_AREA_LOCATION_LEAVE,
  120. RPT_ATTEND_DOWN,
  121. RPT_ATTEND_UP,
  122. ALARM_CARD_OVER_TIME_START,
  123. ALARM_CARD_OVER_TIME_END,
  124. ALARM_CARD_OVER_SPEED_START,
  125. ALARM_CARD_OVER_SPEED_END,
  126. //ALARM_CARD_LOST_START,
  127. //ALARM_CARD_LOST_END,
  128. ALARM_CARD_LOW_POWER_START,
  129. ALARM_CARD_LOW_POWER_END,
  130. ALARM_CARD_OVER_TIME_AREA_START,
  131. ALARM_CARD_OVER_TIME_AREA_END,
  132. ALARM_CARD_OVER_SPEED_AREA_START,
  133. ALARM_CARD_OVER_SPEED_AREA_END,
  134. ALARM_CARD_AREA_FORBIDDEN_START,
  135. ALARM_CARD_AREA_FORBIDDEN_END,
  136. ALARM_CARD_HELP_START,
  137. ALARM_CARD_HELP_END
  138. };
  139. enum STORE_AREA_DATA_FLAG{
  140. ALARM_AREA_OVER_COUNT_PERSON_START = 0,
  141. ALARM_AREA_OVER_COUNT_PERSON_END,
  142. ALARM_AREA_OVER_COUNT_VEHICLE_START,
  143. ALARM_AREA_OVER_COUNT_VEHICLE_END,
  144. ALARM_AREA_FORBIDDEN_PERSON_START,
  145. ALARM_AREA_FORBIDDEN_PERSON_END,
  146. ALARM_AREA_FORBIDDEN_VEHICLE_START,
  147. ALARM_AREA_FORBIDDEN_VEHICLE_END,
  148. };
  149. enum STORE_READER_DATA_FLAG{
  150. ALARM_READER = 0,
  151. ALARM_READER_LOST_START,
  152. ALARM_READER_LOST_END
  153. };
  154. enum STORE_MINE_DATA_FLAG{
  155. ALARM_MINE_OVER_COUNT_PERSON_START = 0,
  156. ALARM_MINE_OVER_COUNT_PERSON_END,
  157. ALARM_MINE_OVER_COUNT_VEHICLE_START,
  158. ALARM_MINE_OVER_COUNT_VEHICLE_END
  159. };
  160. enum LOCATE_TYPE
  161. {
  162. LT_COORDINATE = 0,
  163. LT_READER,
  164. LT_TDOA,
  165. };
  166. enum FILTER_TYPE{
  167. NO_FILTER = 0,
  168. FILTER_KALMAN = 1,
  169. };
  170. struct SQLTHREAD_DATA//写数据库线程传递的参数
  171. {
  172. char* pText;//数据库语句地址指针
  173. int nRepeatTimes;//已经重试几次
  174. };
  175. // 定位坐标
  176. struct _coordinate{
  177. _coordinate(){
  178. t = 0;
  179. reader_id = 0;
  180. tt = 0;
  181. d = 0.0;
  182. st = 0;
  183. x = 0.0;
  184. y = 0.0;
  185. z = 0.0;
  186. a = 0.0;
  187. v = 0.0;
  188. antenna_id = 0;
  189. d_offset = 0.0;
  190. special = 0;
  191. acceleration = 0;
  192. acce_state = 0;
  193. }
  194. int t; // 定位时间戳
  195. int reader_id;
  196. unsigned long long tt;
  197. double d; // 距离
  198. double x; // x坐标
  199. double y; // y坐标
  200. double z; // z坐标
  201. double a; // 平面角度
  202. double v; // 速度
  203. int antenna_id;
  204. double d_offset; // 与显示距离的偏移,用来修正单基站的情况
  205. int st; //同步序号
  206. double acceleration; //加速度
  207. int acce_state; //加速度状态
  208. int special; //分站是否属于特殊分站,0属于特殊分站,1普通分站
  209. _coordinate& operator=(_coordinate &tmp){
  210. t = tmp.t;
  211. reader_id = tmp.reader_id;
  212. tt = tmp.tt;
  213. d = tmp.d;
  214. st = tmp.st;
  215. x = tmp.x;
  216. y = tmp.y;
  217. z = tmp.z;
  218. a = tmp.a;
  219. v = tmp.v;
  220. antenna_id = tmp.antenna_id;
  221. d_offset = tmp.d_offset;
  222. special = tmp.special;
  223. acceleration = tmp.acceleration;
  224. acce_state = tmp.acce_state;
  225. return *this;
  226. }
  227. };
  228. struct _point{ // 坐标
  229. double x;
  230. double y;
  231. double z;
  232. };
  233. struct sync_data{
  234. double x;
  235. double y;
  236. double vx;
  237. double vy;
  238. int sync_num; //本次同步号
  239. bool update;
  240. sync_data(){
  241. x = 0.0;
  242. y = 0.0;
  243. vx = 0.0;
  244. vy = 0.0;
  245. sync_num = 0;
  246. update = false;
  247. }
  248. sync_data& operator=(sync_data&tmp){
  249. x = tmp.x;
  250. y = tmp.y;
  251. vx = tmp.vx;
  252. vy = tmp.vy;
  253. sync_num = tmp.sync_num;
  254. update = tmp.update;
  255. return *this;
  256. }
  257. };
  258. struct _call_info_card
  259. {
  260. int card_id;
  261. int card_type;
  262. int call_type;
  263. string str_card_id;
  264. time_t start_time;
  265. int time_out;
  266. bool is_success;
  267. };
  268. typedef map<std::string, _call_info_card*> CallInfoCardMap;
  269. struct _call_info_reader
  270. {
  271. bool is_call_all;
  272. bool is_start_call; //true,开始呼叫;false,取消呼叫
  273. BYTE call_type;
  274. int cards_count;
  275. CallInfoCardMap mpCard;
  276. };
  277. typedef map<int, _call_info_reader*> CallInfoReaderMap;
  278. // 分站接收时间定义
  279. struct ReceiveData{
  280. unsigned int reader_id; // 分站号
  281. unsigned short antenna_id; // 天线号
  282. long long rec_time_stamp; // 分站接收时间,一个5字节的无符号数
  283. int special;
  284. double x; //分站的x坐标
  285. double y; //分站的y坐标
  286. double z; //分站的z坐标
  287. ReceiveData(){
  288. reader_id = -1;
  289. antenna_id = -1;
  290. rec_time_stamp = 0;
  291. x = y = z = 0.0;
  292. special = -1;
  293. };
  294. };
  295. typedef unordered_map<int,ReceiveData> ReceiveDataMap;
  296. //typedef unordered_map<int,ReceiveData*> ReceiveDataMap;
  297. struct INFO_PRE{
  298. int t;
  299. long long detaT;
  300. double dist;
  301. int ant;
  302. int sta_num;
  303. };
  304. struct POS{
  305. double posx;
  306. double posy;
  307. double posz;
  308. double pos_radius;
  309. //保存定位结果的两个分站信息
  310. int nFirstReader;
  311. int nSecondReader;
  312. //精度参考
  313. double dFirstDiff;
  314. double dSecondDiff;
  315. POS(){
  316. nFirstReader = INVALID_COORDINATE;
  317. nSecondReader = INVALID_COORDINATE;
  318. posx = 0;
  319. posy = 0;
  320. posz = 0;
  321. dFirstDiff = 0;
  322. dSecondDiff = 0;
  323. pos_radius = 0;
  324. }
  325. POS& operator=(POS& tmp){
  326. nFirstReader = tmp.nFirstReader;
  327. nSecondReader = tmp.nSecondReader;
  328. posx = tmp.posx;
  329. posy = tmp.posy;
  330. posz = tmp.posz;
  331. dFirstDiff = tmp.dFirstDiff;
  332. dSecondDiff = tmp.dSecondDiff;
  333. pos_radius = tmp.pos_radius;
  334. return *this;
  335. }
  336. };
  337. struct RESULT{
  338. double x[3];
  339. double y[3];
  340. double z[3];
  341. int nCount;
  342. };
  343. class Mine;
  344. class Area;
  345. class Reader;
  346. class Card;
  347. class MapInfo;
  348. class Dept;
  349. class ReaderPath;
  350. typedef map<string, Card*> CardMap;
  351. typedef map<int, Area*> AreaMap;
  352. typedef map<int, Reader*> ReaderMap;
  353. typedef map<int, MapInfo*> MapInfoMap;
  354. typedef map<int, Dept*> DeptMap;
  355. typedef map<int, string> AlarmTypeMap;
  356. typedef map<int,ReaderPath*> ReaderPathMap;
  357. typedef unordered_map<int,ReaderPathMap*> TDOAReaderPathMap;
  358. typedef unordered_map<string, _coordinate*> DistMap;
  359. struct DistQueMapItem
  360. {
  361. WORD cardstamp;
  362. DistMap distmap;
  363. };
  364. typedef deque<DistQueMapItem> DistQueMap;
  365. // 地图
  366. class MapInfo{
  367. public:
  368. MapInfo(void);
  369. ~MapInfo(void);
  370. public:
  371. int map_id;
  372. string map_path;
  373. string map_name;
  374. double map_width;
  375. double map_height;
  376. double map_scale;
  377. int map_type;
  378. AreaMap map_area_list;
  379. ReaderMap map_reader_list;
  380. CardMap map_card_list_person;
  381. CardMap map_card_list_vehicle;
  382. };
  383. // 区域
  384. class Area // 矩形
  385. {
  386. private:
  387. std::vector<std::string> split(std::string str,std::string pattern);
  388. double get_vertex(std::string src); // 顶点
  389. public:
  390. Area(void);
  391. ~Area(void);
  392. void init_border(string sz_path);
  393. bool is_in_polygon(_point p);
  394. public:
  395. int map_id;
  396. int area_id;
  397. string area_name;
  398. string area_type_name;
  399. int area_type_id;
  400. string path; // 多边形
  401. // 人员
  402. int over_count_person;
  403. int over_time_person;
  404. int under_count_person;
  405. int under_time_person;
  406. // 车辆
  407. int over_count_vehicle;
  408. int over_time_vehicle;
  409. int under_count_vehicle;
  410. int under_time_vehicle;
  411. int polygon_count;
  412. _point* polygon;
  413. // 坐标
  414. //double x;
  415. //double y;
  416. //double z;
  417. //double sr; // 短半径
  418. //double lr; // 长半径
  419. //double x1, y1, z1; // 矩形四个顶点
  420. //double x2, y2, z2;
  421. //double x3, y3, z3;
  422. //double x4, y4, z4;
  423. double rect_left;
  424. double rect_right;
  425. double rect_top;
  426. double rect_bottom;
  427. // 区域人数
  428. int count_person;
  429. int count_vehicle;
  430. int count_card;
  431. // 是否写考勤
  432. int is_att; // 0 停车场外,1 停车场内
  433. //
  434. bool is_area_over_time_person; // 车辆超时
  435. bool is_area_over_time_vehicle; // 人员超时
  436. int count_area_over_time_person; // 超时人数
  437. int count_area_over_time_vehicle; // 超时车数
  438. time_t time_over_time_person; // 开始超时时间
  439. time_t time_over_time_vehicle; // 开始超时时间
  440. bool is_area_over_count_person; // 人员超员
  441. bool is_area_over_count_vehicle; // 车辆超员
  442. int count_area_over_count_person;
  443. int count_area_over_count_vehicle;
  444. time_t time_over_count_person; // 开始时间
  445. time_t time_over_count_vehicle; // 开始时间
  446. bool is_area_forbidden_person;
  447. bool is_area_forbidden_vehicle;
  448. int count_area_forbidden_person;
  449. int count_area_forbidden_vehicle;
  450. time_t time_forbidden_person; // 开始时间
  451. time_t time_forbidden_vehicle; // 开始时间
  452. CardMap area_card_list_person;
  453. CardMap area_card_list_vehicle;
  454. };
  455. // 自组网预置坐标
  456. class Adhoc
  457. {
  458. public:
  459. Adhoc();
  460. ~Adhoc();
  461. public:
  462. int adhoc_id;
  463. double x;
  464. double y;
  465. double z;
  466. int idx;
  467. };
  468. // 天线
  469. class Antenna
  470. {
  471. public:
  472. Antenna(void);
  473. ~Antenna(void);
  474. public:
  475. int antenna_id;
  476. double antenna_x;
  477. double antenna_y;
  478. double antenna_z;
  479. double antenna_angle;
  480. };
  481. // 分站
  482. class Reader
  483. {
  484. public:
  485. Reader(void);
  486. ~Reader(void);
  487. public:
  488. int reader_id; // 分站号
  489. string reader_name; // 分站名称
  490. int device_type_id;
  491. int pos_state; // 位置状态 1井上,2井下
  492. string ip;
  493. double reader_x;
  494. double reader_y;
  495. double reader_z;
  496. double reader_angle;
  497. double reader_interval_time;
  498. int map_id; // 所在地图
  499. int area_id; // 所属区域
  500. double map_scale; // 比例尺
  501. //double rec_time; // 接收数据时间
  502. time_t rec_time;
  503. time_t reader_time; // 分站时间
  504. time_t lost_time;
  505. int temperature; // 温度
  506. int tick_count; // 计数器
  507. int state; // 状态 0 正常, 1 故障
  508. int sync_level;
  509. int state_old; // 上一次状态
  510. Antenna* ant[ANTENNA_COUNT]; // 两个天线
  511. Adhoc* adhoc[ADHOC_COUNT];// 自组网节点预置坐标
  512. map<int,_point> readerCoveragePath;
  513. bool bIsInitCoverage;
  514. int m_nIsSpecial;
  515. public:
  516. string get_state_text();
  517. };
  518. // 卡
  519. class Card
  520. {
  521. public:
  522. Card(void);
  523. ~Card(void);
  524. Card(string cardid, int cardtype,double z_offset, double offset_x = 12.0, double offset_y =12.0);
  525. public:
  526. CRITICAL_SECTION m_csCard;
  527. public:
  528. int card_type; // 卡类型 0x01人, 0x02车
  529. //int64_t card_id; // 卡唯一标识, 高位为卡号,低位为卡类型, ((card_id << 8) | card_type)
  530. string card_id;
  531. // 人员
  532. string level; // 级别
  533. string occupation; // 职务
  534. // 人员、车辆
  535. string id; // 编号,人员或车辆
  536. string name; // 姓名、车辆名称
  537. string number; // 身份证号码,车牌号码
  538. string photo; // 照片
  539. string company; // 单位
  540. string department; // 部门
  541. int dept_id;
  542. int group_id;
  543. string group; // 班组
  544. string worktype; // 工种、车辆类型
  545. //time_t deal_time; // 最后处理卡逻辑时间
  546. SYSTEMTIME deal_time;
  547. time_t rec_time; // 最后接收时间
  548. time_t down_time; // 入井时间
  549. time_t up_time; // 升井时间
  550. time_t enter_area_time; // 进入区域时间
  551. time_t enter_reader_time; // 进入分站时间
  552. time_t low_power_time; // 电量低开始时间
  553. //time_t enter_park_time; // 回场时间
  554. //time_t leave_park_time; // 出场时间, 开始工作时间
  555. double coor_offset_x;
  556. double coor_offset_y;
  557. double x;
  558. double y;
  559. double z;
  560. double a; // 上次定位时的角度
  561. int t; // 上次定位时的时间戳
  562. double z_offset;
  563. bool init_postion;
  564. bool is_first_location;
  565. double v; //速度
  566. double m_dAverageV; //平均速度
  567. double xx;
  568. double yy;
  569. double zz;
  570. double x1, x2, x3, x4;
  571. double y1, y2, y3, y4;
  572. double z1, z2, z3, z4;
  573. double last_x;
  574. double last_y;
  575. double last_z;
  576. double stored_x;
  577. double stored_y;
  578. double stored_z;
  579. double last_vx;
  580. double last_vy;
  581. int state; // 0 正常, 共32bit,每个bit代表一个状态,从右起:
  582. // 第一位 0x01 井下超时, 第二位 0x02 区域超时, 第三位 0x04 超速, 第四位 0x08, 进入限制区域
  583. // 状态,故障、电量低等
  584. int state_moving; // 运动状态, 0 静止,1 启动
  585. int state_biz; //业务状态,呼叫/超时/进入禁区等
  586. // 电量低、 呼叫、呼救
  587. int status_over_time; // 0 未超时,1 超时
  588. int status_over_speed; // 0 未超速,1 超速
  589. int status_area_over_time; // 0 未区域超时, 1 区域超时
  590. int status_area_over_speed; // 0 未区域超速, 1 区域超速
  591. int status_area_forbidden; // 0 未进入限制区域, 1 进入限制区域
  592. int status_help; // 0 未呼救, 1 呼救, 2 已处理呼救
  593. int status_call; // 0 未呼叫 1 呼叫
  594. int status_power; // 0 电量正常,1 电量低
  595. int status_lost; // 0 未进入盲区,1 盲区状态
  596. int map_id; // 当前地图
  597. double map_scale; // 地图比例尺
  598. int map_id_old; // 上次测距所在地图
  599. int area_id; // 当前区域
  600. int reader_id; // 当前分站
  601. Reader* p_reader;
  602. ReaderPathMap* pReaderPathMap;
  603. TDOAReaderPathMap* pTdoaReaderPathMap;
  604. _coordinate** p_dists;
  605. _coordinate** p_dists_locate;
  606. _coordinate last_locate;
  607. _coordinate origin_locate;
  608. double m_dFirstDiff;
  609. double m_dSecondDiff;
  610. DistQueMap _dists;
  611. int time_stamp_max; // 最大时间戳,即需要计算定位的时间戳
  612. int time_stamp_cal;
  613. //int get_pos_state() const { return pos_state; }
  614. //void set_pos_state(int val) ;
  615. //int get_pos_state_count() const { return pos_state_count; }
  616. int pos_state; // 位置状态,0初始化,1井下,2井上,3车场分站
  617. int pos_state_old;
  618. //int pos_state_last;
  619. int pos_state_count; // 当前位置状态确认次数
  620. int pos_state_park; // 在停车场区域状态
  621. int pos_state_park_old;
  622. //int pos_state_park_last;
  623. int pos_state_park_count;
  624. int m_nFilterType;
  625. int m_nLastLocateT;
  626. int m_nCalcSyncNum; //卡在算法中的同步号,此同步号和卡的实时同步号并不一定一致
  627. int m_nSyncNumInList; //从队列中取出的大于5的同步号
  628. //int last_area_type_id;
  629. //int cur_area_type_id;
  630. bool issent; // true 已发送至客户端,false 新数据,需要发送至客户端
  631. bool issaved; //true 已保存到数据库,false 生成新的考勤记录,需要保存到数据库
  632. bool isdealed; // 已经处理
  633. bool isreceive; // 接收到
  634. bool is_pos_changed;
  635. bool is_deal_by_algo;
  636. bool is_hist;
  637. bool is_need_cal;
  638. bool m_bUseFilter;
  639. bool is_mine_over_time; // 是否井下超时
  640. bool is_area_over_time; // 是否区域超时, 区域超时分车辆超时、人员超时
  641. time_t time_area_over_time; // 区域超时开始时间
  642. time_t time_over_time; // 井下超时开始时间
  643. time_t time_area_forbidden; // 进入限制区域时间
  644. time_t time_over_speed; // 超速开始时间
  645. time_t time_low_power;
  646. void set_reader(Reader* preader);
  647. bool is_pos_state_changed(int nval); // 入\升井状态变化
  648. bool is_pos_state_pack_changed(int nval);
  649. void add_dist(_coordinate* dist);
  650. void remove_dist_head();
  651. string concat(int reader_id, int ant_id);
  652. time_t get_working_time();
  653. string get_state_text();
  654. string get_acc_text();
  655. double get_speed();
  656. int get_effictive_dist_count(int offset = 0);
  657. void set_reader_path(ReaderPathMap *rpm);
  658. void set_reader_path(TDOAReaderPathMap* trpm);
  659. public:
  660. // 滤波算法相关
  661. //CalLocation* cal_location;
  662. CalLocation3* cal_location3;
  663. //Point2* p2_anchors;
  664. Point3* p3_anchors;
  665. //bool is_init_kalman;
  666. CKalmanFilter* m_pKalmanFilter;
  667. //int m_max_stamp; // 最大的时间戳,即最近采集的数据
  668. list<sync_data> m_syncNumList;
  669. int last_s_locate_reader[2]; //上一次定位成功的分站信息
  670. double ins_weight;
  671. double uwb_weight;
  672. double weight;
  673. bool is_anchor_changed;
  674. void get_coordinate();
  675. void get_coordinate(int cnt);
  676. void get_coordinate_3d(int cnt);
  677. void get_coordinate_2d(int cnt);
  678. void set_anchors(int cnt);
  679. void EnableFilter(int nType);
  680. int FindDistMap(int cardstamp);
  681. public: // 采集到的底层数据
  682. int reader_tickcount;
  683. int time_stamp; // 定位时间戳
  684. int ranging_type; // 报文类型 tof,tdoa
  685. int accelerate_state; // 加速度
  686. int antenna_id; // 天线号
  687. double antenna_angle; // 天线角度
  688. double distance; // 距离
  689. int64_t flying_time; // 飞行时间
  690. int power_state; // 电量
  691. unsigned short sync_num;
  692. int time_stamp_last; // 定位时间戳
  693. int context_type_last; // 报文类型 tof,tdoa
  694. int accelerate_state_last; // 加速度
  695. int antenna_id_last; // 天线号
  696. double antenna_angle_last; // 天线角度
  697. double distance_last; // 距离
  698. int64_t flying_time_last; // 飞行时间
  699. int power_state_last; // 电量
  700. int reader_id_last; //上一次定位时间戳的分站id
  701. string str_his_time;
  702. string str_rec_time;
  703. };
  704. class Dept
  705. {
  706. public:
  707. Dept();
  708. ~Dept();
  709. Dept(int id, string name);
  710. private:
  711. public:
  712. int dept_id;
  713. string dept_name;
  714. CardMap dept_card_list_person;
  715. CardMap dept_card_list_vehicle;
  716. };
  717. /*
  718. * 地图集路径描述
  719. */
  720. class ReaderPath{
  721. public:
  722. ReaderPath(){
  723. bIsInit = false;
  724. nRealCalcPoints = 0;
  725. x[0] = x[1] = y[0] = y[1] = 0;
  726. for(int i=0;i<MAX_CALC_POINTS;i++){
  727. px[i] = py[i] = pz[i] = 0;
  728. }
  729. }
  730. public:
  731. //对于TOF而言,x,y表示1,2天线对应的坐标
  732. //对于TDOA而言,x,y表示焦点F1,F2(等同于分站i,i+1)的坐标
  733. int nRealCalcPoints;
  734. double x[2];
  735. double y[2];
  736. double z[2];
  737. double px[MAX_CALC_POINTS];
  738. double py[MAX_CALC_POINTS];
  739. double pz[MAX_CALC_POINTS];
  740. bool bIsInit;
  741. };
  742. #endif //YASERVER_CLASSDEF_H_