classdef.h.orig 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052
  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 MINE_EVENT_COUNT 3
  7. #define SECTION_EVENT_COUNT 6
  8. #define AREA_EVENT_COUNT 5
  9. #define CARD_EVENT_COUNT 88
  10. #define READER_EVENT_COUNT 12
  11. #define KALMAN_OFFSET_COOR 0.01
  12. #define KALMAN_OFFSET_MOVE 1
  13. #define KALMAN_OFFSET_RANGING 0.01
  14. #define KALMAN_INTERVAL 0.3
  15. #define KALMAN_OFFSET_COOR_TRI 0.01
  16. #define KALMAN_OFFSET_MOVE_TRI 1
  17. #define KALMAN_OFFSET_RANGING_TRI 0.09
  18. #define KALMAN_INTERVAL_TRI 1
  19. #define ANTENNA_COUNT 2
  20. #define ADHOC_COUNT 10
  21. #define READER_TIMEOUT 20
  22. #define CARD_LOST_TIME_OUT 30 // (30 * 60)
  23. #define CARD_LOST_TIME_CAL 5 // 卡未收到数据后,利用缓存的数据计算间隔
  24. #define CARD_LOST_TIME_OUT_SPECIAL_AREA 1800
  25. #define READER_SEND_STATE_TIMEOUT 30 // (2* 60 * 60)
  26. #define OVER_TIME (480 * 60)
  27. #define MAX_SEMACOUNT 64
  28. //算法类型
  29. //#define ALGORITHM_TYPE_TOF
  30. //#define ALGORITHM_TYPE_TDOA
  31. //#define ALGORITHM_TYPE_INS //使用惯导判断
  32. #define ENABLE_MY_LOG
  33. #define NEED_DISPLAY_RULES 1 // lemon 2017/08/01
  34. #define NEED_DISPLAY_VALID 0
  35. #define NEED_DISPLAY_INVALID 1
  36. #define PATROL_LEVEL_ID 3
  37. #define INDEXFORRECONEREADER 10 //如果持续10次都只被一个分站接收,则速度为0
  38. #define SUSTAINEDOVERSPEED 5 // 如果连续5次都是超速,则告警.
  39. #define WRITE_DRIVINGFACE_REAL_PER_TIME 20000
  40. #include <string>
  41. #include <ctime>
  42. #include <map>
  43. #include <iostream>
  44. #include <string>
  45. #include <vector>
  46. #include <unordered_map>
  47. #include <deque>
  48. #include <mutex>
  49. #include <thread>
  50. //#include "winsock2.h"
  51. #include <kalman\locate.h>
  52. #include "Filter\KalmanFilter.h"
  53. #include "algorithm\FittingPosition.h"
  54. #include "algorithm/cell/cell_struct.h"
  55. #include "LocateRecord.h"
  56. #define MIN(x,y) (x < y ? x : y)
  57. #define MAX(x,y) (x > y ? x : y)
  58. using namespace std;
  59. class YaAlgorithmForCell;
  60. //算法中使用的常量定义
  61. const int MAX_CALC_POINTS = 30;
  62. const int ACCELERATE_INIT_STATE = -10;
  63. const int IDLE_CONFIRM_TIME = 4;
  64. const int MAX_READER_TDOA_PATH_NUMS = 10; //主要是因为拐弯处可能存在多解的原因
  65. const int LIGHT_CTRL_DELAY = 1000;
  66. const int MAX_REBOUND_COUNTS = 5;
  67. const double INS_WEIGHT = 9.0; //惯导权重
  68. const double UWB_WEIGHT = 1.0; //UWB权重
  69. const double MAX_VECHILE_SPEED = 30.0; //车卡运动速度阈值,超过此阈值,定位数据被抛弃
  70. const double MAX_PERSON_SPEED = 10.0; //人卡运动速度阈值,超过此阈值,定位数据被抛弃
  71. const double NEAR_READER = 4.0; //定位结果在分站附近4米内
  72. const double MIN_DIFFER_DISTANCE = 10.0; // 使用其他分站校验计算结果时,判断该结果到校验分站的距离差允许的范围
  73. const double MIN_IDLE_THRESHOLD = 0.5;
  74. const double VECHILE_ACCELERATE_THRESHOLD = 10; // 校验加速度阈值
  75. const double PERSON_ACCELERATE_THRESHOLD = 10; // 校验速度阈值
  76. const double INVALID_COORDINATE = -1000.0;
  77. const int POS_NO_CHANGE_TIMES = 15; // lihongzhen 2017/8/19 位置连续未改变次数,每次0.5秒,约7秒
  78. const double CHAMBER_WIDTH = 3.0; //特指前端展现巷道的宽度,单位为像素
  79. <<<<<<< HEAD
  80. const double VEHICLE_WIDTH = 10.0;
  81. const double TOF_HEIGHT_ERROR = 2; //tof定位时的高度误差,单位为米
  82. =======
  83. const double VEHICLE_WIDTH = 20.0;
  84. const int MAX_READER_TDOA_PATH_NUMS = 10; //主要是因为拐弯处可能存在多解的原因
  85. const int LIGHT_CTRL_DELAY = 2000;
  86. const double TOF_HEIGHT_ERROR = 2; //tof定位时的高度误差,单位为米
  87. >>>>>>> newprotocal
  88. const double READER_SYNC_INTERVAL_TIME = 0.2; //分站同步序号的时间差,估计值
  89. #define OFFSET_THRE_IN_LINE 1 //判断是否在线段上,允许的误差为1米,用于isinline
  90. #define ZERO_PRECISION 1E-3 //为零的精度
  91. enum ALARM_FLAG{
  92. //AF_CARD_OVER_COUNT = 1,
  93. //AF_CARD_AREA_OVER_COUNT,
  94. AF_CARD_OVER_TIME,
  95. AF_CARD_OVER_SPEED,
  96. AF_CARD_AREA_OVER_SPEED,
  97. AF_CARD_AREA_OVER_TIME,
  98. AF_CARD_LOW_POWER,
  99. AF_CARD_LOW_POWER_SERIOUS,
  100. AF_CARD_AREA_FORBIDDEN,
  101. AF_AREA_OVER_COUNT,
  102. AF_AREA_OVER_TIME,
  103. AF_AREA_FORBIDDEN,
  104. AF_CARD_OVER_COUNT,
  105. AF_CARD_NEAR_WARNING_POINT,//lemon
  106. AF_CARD_NEAR_DRRIVINGFACE_VEHICLE //lemon 2017/08/01
  107. };
  108. enum AREA_TYPE
  109. {
  110. AREA_TYPE_FORBIDDEN = 3, // 限制区域
  111. AREA_TYPE_NO_COVER = 1000, // 非覆盖区域,车辆信号消失后,定位到附近非覆盖区域内
  112. AREA_TYPE_SPECIAL = 1001 // 特殊区域,只给你前端用来标识是否显示图标,胶轮车硐室
  113. };
  114. enum EDIT_TYPE_ID{
  115. ET_INSERT = 0, // 新增
  116. ET_UPDATE, // 修改
  117. ET_DELETE // 删除
  118. };
  119. //车辆烈性
  120. enum VECHILE_TYPE_ID
  121. {
  122. VT_DIGGINGCOAL_MACHINE=25,
  123. VT_DRIVINGFACE_MACHINE=26
  124. };
  125. enum ALARM_TYPE_ID
  126. {
  127. ATID_OVER_COUNT_PERSON = 1,
  128. ATID_POWER,
  129. ATID_OVER_COUNT_VEHICLE
  130. };
  131. enum STATUS_DEVICE{
  132. STATUS_DEVICE_NORMAL = 0,
  133. STATUS_DEVICE_ERROR
  134. };
  135. enum STATUS_CARD
  136. {
  137. STATUS_NORMAL = 0, //正常
  138. STATUS_ERROR = 1,
  139. STATUS_ERROR_SERIOUS = 2,
  140. STATUS_POWER_LOWER = 1, //电量低
  141. STATUS_POWER_LOWER_SERIOUS = 2, //电量极低
  142. STATUS_OVER_TIME = 4, //超时
  143. //STATUS_OVER_COUNT = 1,
  144. STATUS_OVER_SPEED = 8, //超速
  145. STATUS_AREA_OVER_TIME = 16, //区域超时
  146. //STATUS_AREA_OVER_COUNT = 1,
  147. STATUS_AREA_OVER_SPEED = 32, //区域超速
  148. STATUS_AREA_FORBIDDEN = 64, //进入限制区域
  149. STATUS_HELP = 128, //呼救
  150. STATUS_HELP_DEALED = 256, //呼救已处理
  151. STATUS_CALL = 512, //呼叫
  152. STATUS_LOST = 1024 //进入盲区
  153. //STATUS_ERROR_DEALED,
  154. };
  155. enum STORE_CARD_DATA_FLAG{
  156. HIS_LOCATION = 0,
  157. HIS_RAW_DATA,
  158. HIS_AREA_LOCATION_ENTER,
  159. HIS_AREA_LOCATION_LEAVE,
  160. RPT_ATTEND_DOWN,
  161. RPT_ATTEND_UP
  162. };
  163. enum STORE_MINE_DATA_FLAG{
  164. ALARM_MINE_OVER_COUNT_PERSON_START = 0,
  165. ALARM_MINE_OVER_COUNT_PERSON_END,
  166. ALARM_MINE_OVER_COUNT_VEHICLE_START,
  167. ALARM_MINE_OVER_COUNT_VEHICLE_END
  168. };
  169. enum STORE_LIGHT_DATA_FLAG{
  170. ALARM_LIGHT_FAULT_START= 0, //故障开始
  171. ALARM_LIGHT_FAULT_END, //故障结束
  172. ALARM_LIGHT_NETWORK_START, //网络故障开始
  173. ALARM_LIGHT_NETWORK_END, //网络故障结束
  174. ALARM_LIGHT_CONTROL_FAILE //控制失败
  175. };
  176. enum STORE_SECTION_DATA_FLAG{
  177. ALARM_SECTION_START = 0, // 区段告警开始
  178. ALARM_SECTION_END // 区段告警结束
  179. };
  180. enum LIGHT_STATE{
  181. LIGHT_NORMAL = 0, // 正常
  182. LIGHT_FAULT, // 异常
  183. LIGHT_NETWORK_ERROR, // 网络故障
  184. LIGHT_CONTROL_ERROR // 控制失败
  185. };
  186. enum LOCATE_TYPE
  187. {
  188. LT_COORDINATE = 0, // 使用坐标定位
  189. LT_READER // 使用分站定位
  190. };
  191. enum FILTER_TYPE{
  192. NO_FILTER = 0, // 不使用滤波
  193. FILTER_KALMAN = 1 // 使用kalman滤波
  194. };
  195. enum SECTION_STATE{
  196. SECTION_STATE_NORMAL = 0, //正常
  197. SECTION_STATE_BUSY = 1, //繁忙
  198. SECTION_STATE_CONGESTION = 2 //拥堵
  199. };
  200. enum LIGHT_SHAPE{
  201. RED_CIRCLE_SOLID = 1, //红色实心圆
  202. RED_CIRCLE = 2, //红色空心圆
  203. RED_CROSS = 3, //红色叉形
  204. GREEN_UP = 4, //绿色上箭头
  205. GREEN_DOWN = 5, //绿色下箭头
  206. GREEN_LEFT = 6, //绿色左箭头
  207. GREEN_RIGHT = 7, //绿色右箭头
  208. RED_SPARK = 8, //红色闪烁
  209. GREEN_SPARK = 9 //绿色闪烁
  210. };
  211. enum LIGHT_STREAM{
  212. INIT_STREAM = 0,
  213. UP_STREAM = 1, //上行
  214. DOWN_STREAM = 2 //下行
  215. };
  216. enum LIGHT_COLOR{
  217. COLOR_RED = 1, // 红色
  218. COLOR_GREEN = 2 // 绿色
  219. };
  220. enum LIGHT_CTRL_STATE{
  221. CTRL_STATE_AUTO = 1, // 自动控制
  222. CTRL_STATE_MANUAL = 2 // 手动控制
  223. };
  224. enum LIGHTS_SELECT_TYPE
  225. {
  226. LST_ALL_LIGHTS = 0, // 所有灯
  227. LST_ALL_UP_LIGHTS = 1, // 所有上行
  228. LST_ALL_DWON_LIGHTS = 2,// 所有下行
  229. LST_SOME_LIGHTS = 3 // 指定灯
  230. };
  231. enum AREA_PROPERTY{
  232. MAIN_TUNNEL = 0, // 主巷道
  233. BRANCH_TUNNEL = 1 // 分支巷道
  234. };
  235. enum OUTPUT_POS{
  236. CENTRAL_POS = 0, // 居中
  237. LEFT_POS, // 靠左
  238. RIGHT_POS // 靠右
  239. };
  240. enum PATROL_STATE
  241. {
  242. PS_NORMAL = 0, // 正常
  243. PS_EARLY, // 早到
  244. PS_LATE, // 迟到
  245. PS_NON_ARRIVAL // 未到
  246. };
  247. enum PATROL_STAY_STATE
  248. {
  249. PSS_NORMAL = 0, // 正常
  250. PSS_TOO_LONG, // 停留过长
  251. PSS_TOO_SHORT // 停留太短
  252. };
  253. enum ALGO_LOC_TYPE{
  254. ALGO_LOC_SUCCESSED = 0, //算法定位成功
  255. ALGO_FAILED_CONDITION_1, //同步序号相差大于5
  256. ALGO_FAILED_CONDITION_2, //相同卡序列号,时间同步序号却相差大于5
  257. ALGO_FAILED_CONDITION_3, //时间同步戳值存在异常
  258. ALGO_FAILED_CONDITION_4, //卡的上次时间戳大于卡的本次时间戳
  259. ALGO_FAILED_CONDITION_5, //人卡加速度超限
  260. ALGO_FAILED_CONDITION_6, //车卡加速度超限
  261. ALGO_FAILED_CONDITION_7, //车卡速度超限
  262. ALGO_FAILED_CONDITION_8, //卡尔曼连续2s定位失败等
  263. ALGO_FAILED_CONDITION_9, //分站时间戳的距离差值大于分站之间的距离
  264. ALGO_FAILED_CONDITION_10, //分站之间无地图集
  265. ALGO_FAILED_CONDITION_11, //定位无解or解的个数为0
  266. ALGO_FAILED_CONDITION_12, //分站附近(小于4m),分站不是特殊分站
  267. ALGO_FAILED_CONDITION_13, //解与无地图集两分站之间的距离差(大于10m)
  268. ALGO_FAILED_CONDITION_14, //定位结果距离定位分站之间的距离差大于4
  269. ALGO_FAILED_CONDITION_15, //参与定位的数据条数小于2
  270. ALGO_LOC_TOTAL
  271. };
  272. enum ALGO_RETURN_VALUE{
  273. DIST_COUNT_LESS_THAN_TWO = 10001,
  274. DIST_COUNT_LESS_FOR_TIMESTAMP_ERROR,
  275. DIST_COUNT_LESS_FOR_SYNC_NUM_DIFFER_FIVE,
  276. DIST_COUNT_CARD_CUR_CT_LESS_LAST,
  277. ALGO_CALC_SOLUTION = 30001,
  278. ALGO_CALC_NO_SOLUTION_WITH_TWO_DATA,
  279. ALGO_CALC_ONE_DATA,
  280. SOLUTION_NO_SOLUTION = 40001,
  281. SOLUTION_NOT_EXIST_READRE,
  282. SOLUTION_NEAR_READER,
  283. SOLUTION_TWO_SOLUTION,
  284. SOLUTION_ERROR_STREAM,
  285. POSITION_INVALID,
  286. SOLUTION_IDLE_STATUS,
  287. CHECK_PERSON_ACCE_OVER_SPEED = 50001,
  288. CHECK_VEHICLE_ACCE_OVER_SPEED,
  289. CHECK_VEHICLE_OVER_SPEED,
  290. KALMAN_FILTER_LONG_INTERVAL = 60001,
  291. ALGO_USE_KALMAN_FILTER = 70001,
  292. ALGO_DIVIDE_ZERO = 80001,
  293. };
  294. extern unsigned int g_nAlgoFailedCounts[ALGO_LOC_TOTAL]; //全局的统计所有次数
  295. extern unsigned int g_nAlgoFailedCycleCounts[ALGO_LOC_TOTAL]; //指定周期内的所有统计次数
  296. extern DWORD g_ullCurTime;
  297. #define ALGORITHM_FAILED(nType) { \
  298. g_nAlgoFailedCounts[nType]++; \
  299. }
  300. struct AlgoFailedMsg{
  301. std::string strCardId;
  302. int nCardStamp;
  303. int nType;
  304. SYSTEMTIME st;
  305. bool bStatus;
  306. AlgoFailedMsg(){
  307. strCardId = "";
  308. nCardStamp = 0;
  309. nType = 0;
  310. bStatus = false;
  311. }
  312. };
  313. enum DEVICE_TYPE{
  314. DT_CARD_READER = 0, //读卡分站
  315. DT_CTRL_READER = 1, // 控制分站
  316. DT_LIGHT = 3, // 红绿灯
  317. DT_SPEAKER = 4, // 告警器
  318. DT_TURNOUT = 5, // 道岔
  319. DT_LED = 6 // 显示屏
  320. };
  321. enum CALL_STATE{
  322. CALL_NONE = 0, //无呼叫信息
  323. CALL_SUCCESSED = 1, //呼叫成功
  324. CALL_ING = 2, //呼叫中
  325. CALL_FAILED = 3, //呼叫失败
  326. };
  327. enum CALL_CARD_TYPE
  328. {
  329. CCT_CALL_ALL = 0, // 全员呼叫
  330. CCT_CALL_APOINT, // 定员
  331. };
  332. enum LOCATEDATATYPE // 定位数据类型
  333. {
  334. LDT_TOF = 0,
  335. LDT_TDOA
  336. };
  337. enum CAL_STATUS{
  338. CAL_NO = 0, //不校准
  339. CAL_REQUEST //请求校准
  340. };
  341. enum SEND_CAL_DATA_STATUS{
  342. CAL_DATA_ALL = 0, //所有校准数据
  343. CAL_DATA_POS, //校准坐标
  344. CAL_DATA_ANGLE //校准角度
  345. };
  346. struct SQLTHREAD_DATA//写数据库线程传递的参数
  347. {
  348. char* pText;//数据库语句地址指针
  349. int nRepeatTimes;//已经重试几次
  350. };
  351. // 定位坐标
  352. struct _coordinate{
  353. _coordinate(){
  354. t = 0;
  355. reader_id = 0;
  356. tt = 0;
  357. d = 0.0;
  358. sync_num = 0;
  359. x = 0.0;
  360. y = 0.0;
  361. z = 0.0;
  362. a = 0.0;
  363. v = 0.0;
  364. antenna_id = 0;
  365. d_offset = 0.0;
  366. special = 0;
  367. acceleration = 0;
  368. acce_state = 0;
  369. acce_state_last = 0;
  370. ins_direction = 0;
  371. rangingtype = 1; // 0 tof,1 toda
  372. cur_time = time(NULL);
  373. }
  374. int t; // 定位时间戳
  375. int reader_id; // 分站编号
  376. unsigned long long syncRootId; // tdoa主节点
  377. unsigned long long tt; // 分站接收的时间,为同步及线性插值后的时间
  378. double d; // 距离
  379. double x; // x坐标
  380. double y; // y坐标
  381. double z; // z坐标
  382. double a; // 平面角度
  383. double v; // 速度
  384. int antenna_id;
  385. int sync_num; //同步序号
  386. int acce_state; //加速度状态
  387. int acce_state_last; //加速度计上一次状态
  388. int ins_direction; //惯导方向
  389. int special; //分站是否属于特殊分站,0属于特殊分站,1普通分站
  390. int rangingtype;
  391. int reason;
  392. double acceleration; //加速度
  393. double d_offset; // 与显示距离的偏移,用来修正单基站的情况
  394. time_t cur_time;
  395. _coordinate& operator=(_coordinate &tmp){
  396. t = tmp.t;
  397. reader_id = tmp.reader_id;
  398. tt = tmp.tt;
  399. d = tmp.d;
  400. sync_num = tmp.sync_num;
  401. x = tmp.x;
  402. y = tmp.y;
  403. z = tmp.z;
  404. a = tmp.a;
  405. v = tmp.v;
  406. antenna_id = tmp.antenna_id;
  407. d_offset = tmp.d_offset;
  408. special = tmp.special;
  409. acceleration = tmp.acceleration;
  410. acce_state = tmp.acce_state;
  411. acce_state_last = tmp.acce_state_last;
  412. ins_direction = tmp.ins_direction;
  413. rangingtype = tmp.rangingtype;
  414. reason = ALGO_LOC_SUCCESSED;
  415. cur_time = tmp.cur_time;
  416. return *this;
  417. }
  418. };
  419. struct _point{ // 坐标
  420. double x;
  421. double y;
  422. double z;
  423. _point(){
  424. x = y = z = 0;
  425. }
  426. _point(double a,double b,double c){
  427. x = a;
  428. y = b;
  429. z = c;
  430. }
  431. };
  432. struct sync_data{
  433. double x;
  434. double y;
  435. double z;
  436. double vx;
  437. double vy;
  438. double vz;
  439. int sync_num; //本次同步号
  440. bool update;
  441. std::shared_ptr<nspLocate::LocateRecord> locate;
  442. sync_data(){
  443. x = 0.0;
  444. y = 0.0;
  445. z = 0.0;
  446. vx = 0.0;
  447. vy = 0.0;
  448. vz = 0.0;
  449. sync_num = 0;
  450. update = false;
  451. locate = nullptr;
  452. }
  453. sync_data& operator=(sync_data&tmp){
  454. x = tmp.x;
  455. y = tmp.y;
  456. z = tmp.z;
  457. vx = tmp.vx;
  458. vy = tmp.vy;
  459. vz = tmp.vz;
  460. sync_num = tmp.sync_num;
  461. update = tmp.update;
  462. locate = tmp.locate;
  463. return *this;
  464. }
  465. inline bool operator == (const sync_data& rhs) const
  466. {
  467. return x == rhs.x &&
  468. y == rhs.y &&
  469. vx == rhs.vx &&
  470. vy == rhs.vy &&
  471. sync_num == rhs.sync_num &&
  472. update == rhs.update;
  473. }
  474. };
  475. struct _call_info_card
  476. {
  477. int card_id;
  478. int card_type;
  479. int call_level;
  480. string str_card_id;
  481. time_t start_time;
  482. int time_out;
  483. //bool is_success;
  484. int call_state;
  485. };
  486. //typedef map<std::string, _call_info_card*> CallInfoCardMap;
  487. typedef map<std::string, std::shared_ptr<_call_info_card>> CallInfoCardMap;
  488. struct _call_info_reader
  489. {
  490. bool is_call_all;
  491. bool is_start_call; //true,开始呼叫;false,取消呼叫
  492. BYTE call_level; // 一般,紧急
  493. //int call_type;
  494. int cards_count;
  495. int time_out;
  496. time_t start_time;
  497. CallInfoCardMap mpCard;
  498. };
  499. typedef map<int, std::shared_ptr<_call_info_reader>> CallInfoReaderMap;
  500. struct _call_info_user
  501. {
  502. std::string user_name;
  503. CallInfoReaderMap mpReader;
  504. };
  505. typedef map<string, std::shared_ptr<_call_info_user>> CallInfoUserMap;
  506. // 分站接收时间定义
  507. struct ReceiveData{
  508. unsigned int reader_id; // 分站号
  509. unsigned short antenna_id; // 天线号
  510. long long rec_time_stamp; // 分站接收时间,一个5字节的无符号数
  511. int special;
  512. double x; //分站的x坐标
  513. double y; //分站的y坐标
  514. double z; //分站的z坐标
  515. ReceiveData(){
  516. reader_id = -1;
  517. antenna_id = -1;
  518. rec_time_stamp = 0;
  519. x = y = z = 0.0;
  520. special = -1;
  521. };
  522. };
  523. struct INFO_PRE{
  524. int t;
  525. long long detaT;
  526. double dist;
  527. int ant;
  528. int sta_num;
  529. };
  530. struct TOF_REFER_DATA{
  531. unsigned int nCardTimeStamp; // 卡的ct号
  532. long long llDeltaTime; //
  533. double dDistance; // 距离
  534. unsigned int nAntennaIndex; // 分站天线索引号
  535. unsigned int nReaderId; // 分站id
  536. double x; // 参考点x坐标
  537. double y; // 参考点y坐标
  538. double z; // 参考点z坐标
  539. int a; // 加速度状态
  540. TOF_REFER_DATA(){
  541. nCardTimeStamp = 0;
  542. llDeltaTime = 0;
  543. dDistance = 0.0;
  544. nAntennaIndex = nReaderId = 0;
  545. x = y = z = 0.0;
  546. a = 0;
  547. }
  548. };
  549. struct POS{
  550. double posx; // 以米为单位坐标
  551. double posy;
  552. double posz;
  553. //误差范围
  554. double pos_radius;
  555. //以像素为单位的坐标,米/地图比例尺 = 像素
  556. double cx;
  557. double cy;
  558. double cz;
  559. //三个方向的速度
  560. double cvx;
  561. double cvy;
  562. double cvz;
  563. //加速度
  564. double av;
  565. //保存定位结果的两个分站信息
  566. int nFirstReader;
  567. int nSecondReader;
  568. //精度参考
  569. double dDiff[MAX_READER_TDOA_PATH_NUMS];
  570. double dis_diff;
  571. //定位失败的状态
  572. int reason;
  573. int status;
  574. int card_count; //卡的ct号
  575. bool update; //是否需要保存到同步队列中
  576. bool is_back;
  577. bool is_fit; //是否是拟合数据
  578. //当前分站同步序号与参考数据的分站同步序号时间差值
  579. double diff_reader_sync_num;
  580. double delta_time; //时间差
  581. //参考数据的定位坐标
  582. double ref_x;
  583. double ref_y;
  584. double ref_z;
  585. double origin_speed; //原始定位结果算的速度
  586. double sumVariance; // 保存各定位解之间差值的和
  587. POS(){
  588. nFirstReader = 0;
  589. nSecondReader = 0;
  590. pos_radius = 999999.9;
  591. posx = posy = posz = INVALID_COORDINATE;
  592. cx = cy = cz = cvx = cvy = cvz = 0.0;
  593. av = 0.0;
  594. status = 0;
  595. for (int i=0;i<MAX_READER_TDOA_PATH_NUMS;i++)
  596. {
  597. dDiff[i] = 0;
  598. }
  599. dis_diff = 999999.9;
  600. update = false;
  601. is_fit = false;
  602. is_back = false;
  603. origin_speed = 0;
  604. sumVariance = 0;
  605. diff_reader_sync_num = 0;
  606. delta_time = 0.0;
  607. ref_x = ref_y = ref_z = 0;
  608. reason = -1;
  609. reason = ALGO_LOC_SUCCESSED;
  610. }
  611. POS& operator=(POS& tmp){
  612. nFirstReader = tmp.nFirstReader;
  613. nSecondReader = tmp.nSecondReader;
  614. posx = tmp.posx;
  615. posy = tmp.posy;
  616. posz = tmp.posz;
  617. cx = tmp.cx;
  618. cy = tmp.cy;
  619. cz = tmp.cz;
  620. cvx = tmp.cvx;
  621. cvy = tmp.cvy;
  622. cvz = tmp.cvz;
  623. av = tmp.av;
  624. update = tmp.update;
  625. origin_speed = tmp.origin_speed;
  626. status = tmp.status;
  627. is_back = tmp.is_back;
  628. diff_reader_sync_num = tmp.diff_reader_sync_num;
  629. delta_time = tmp.delta_time;
  630. dis_diff = tmp.dis_diff;
  631. ref_x = tmp.ref_x;
  632. ref_y = tmp.ref_y;
  633. ref_z = tmp.ref_z;
  634. sumVariance = tmp.sumVariance;
  635. for (int i=0;i<MAX_READER_TDOA_PATH_NUMS;i++)
  636. {
  637. dDiff[i] = tmp.dDiff[i];
  638. }
  639. pos_radius = tmp.pos_radius;
  640. reason = ALGO_LOC_SUCCESSED;
  641. return *this;
  642. }
  643. };
  644. //解的结构体
  645. struct SOLUTION{
  646. double x[3];
  647. double y[3];
  648. double z[3];
  649. int nCount;
  650. SOLUTION(){
  651. for (int i =0;i<3;i++)
  652. {
  653. x[i] = y[i] = z[i] = INVALID_COORDINATE;
  654. nCount = 0;
  655. }
  656. }
  657. };
  658. //惯导数据校准的数据结构:坐标(x,y),角度angle
  659. struct CAL_DATA{
  660. float x;
  661. float y;
  662. float angle;
  663. int status;
  664. CAL_DATA(){
  665. x = y = angle = 0.0f;
  666. status = 0;
  667. }
  668. };
  669. class Mine;
  670. class Area;
  671. class SpecialAreaEntry;
  672. class DrivingfaceRender;
  673. class DrivingfaceCard;
  674. class DrivingfaceWarningPoint;
  675. class VehicleTypeAttRule;
  676. class Reader;
  677. class Card;
  678. class MapInfo;
  679. class Dept;
  680. class BanShift;
  681. class OccLevel;
  682. class ReaderPath;
  683. class PatrolPoint;
  684. class PatrolTask;
  685. class LeaderArrange;
  686. class Section;
  687. class Chamber;
  688. class Light;
  689. class LightsGroup;
  690. class LightCallInfo;
  691. class StorePostion;
  692. class LandmarkInfo;
  693. class MapDirectionInfo;
  694. typedef map<string, std::shared_ptr<Card>> CardMap;
  695. typedef map<int, std::shared_ptr<Area>> AreaMap;
  696. typedef map<int, std::shared_ptr<DrivingfaceWarningPoint>>DrivingfaceWarningPointMap;
  697. typedef map<int,std::vector<std::shared_ptr<DrivingfaceWarningPoint>>> DrivingfaceWarningPointMapAll;
  698. typedef map<int, std::shared_ptr<SpecialAreaEntry>> SpecilaAreaEntryMap;
  699. typedef map<int, std::shared_ptr<DrivingfaceRender>> DrivingfaceRenderMap;
  700. typedef map<string,std::shared_ptr<DrivingfaceCard>> DrivingfaceCardMap;
  701. typedef map<int, std::shared_ptr<Reader>> ReaderMap;
  702. typedef map<int, std::shared_ptr<MapInfo>> MapInfoMap;
  703. typedef map<int, std::shared_ptr<MapDirectionInfo>>MapDirectionInfoMap;
  704. typedef map<int, std::shared_ptr<LandmarkInfo>>LandmarkInfoMap;
  705. typedef map<int, std::shared_ptr<Dept>> DeptMap;
  706. typedef map<int, std::shared_ptr<BanShift>> BanShiftMap;
  707. typedef map<int, std::shared_ptr<OccLevel>> OccLevelMap;
  708. typedef map<int, string> AlarmTypeMap;
  709. typedef map<int,std::shared_ptr<ReaderPath>> ReaderPathMap;
  710. typedef map<int,std::shared_ptr<ReaderPath>> TOFReaderPathMap;
  711. typedef unordered_map<int,std::shared_ptr<ReaderPathMap>> TDOAReaderPathMap;
  712. typedef unordered_map<std::string, std::shared_ptr<_coordinate>> DistMap;
  713. typedef map<unsigned long long ,std::shared_ptr<ReceiveData>> ReceiveDataMap;
  714. typedef map<int,std::shared_ptr<Section>> SectionMap; //路段信息
  715. typedef map<int,std::shared_ptr<Chamber>> ChamberMap; //硐室信息
  716. typedef map<int,std::shared_ptr<Light>> LightMap; //红绿灯信息
  717. typedef map<int,std::shared_ptr<LightsGroup>> LightGroupMap; //红绿灯组信息
  718. typedef map<unsigned int, std::shared_ptr<PatrolPoint>> PatrolPointMap;
  719. typedef map<unsigned int, std::shared_ptr<PatrolTask>> PatrolTaskMap;
  720. typedef map<std::string, std::shared_ptr<PatrolTask>> PatrolTaskCheckMap;
  721. typedef map<unsigned int, std::shared_ptr<PatrolPoint>> PatrolPointMap;
  722. typedef map<unsigned int, std::shared_ptr<PatrolTask>> PatrolTaskMap;
  723. typedef map<std::string, std::shared_ptr<PatrolTask>> PatrolTaskCheckMap;
  724. typedef deque<std::shared_ptr<StorePostion>> QueStrorePos;
  725. typedef map<std::string, std::shared_ptr<LeaderArrange>> LeaderArrangeMap;
  726. typedef map<int,string> WorkTypePermissionMap;
  727. typedef map<int,int> RulesMap; //lemon 2017/08/01
  728. typedef map<int, std::shared_ptr<VehicleTypeAttRule>> VehicleTypeAttRuleMap;
  729. typedef map<std::string,std::shared_ptr<CAL_DATA>> CardCalData; //第一个元素string是卡号,第二个元素是此卡的校准数据
  730. typedef map<int,std::shared_ptr<CardCalData>> CalDataMap; //所有的校准数据,int为分站号,第二个元素是通过此分站要下发的所有卡的校准数据
  731. typedef std::map<std::string,std::list<std::shared_ptr<Cell>>> CellPathMap;
  732. typedef struct key_value_pair
  733. {
  734. int key;
  735. int value;
  736. struct key_value_pair* next;
  737. }KeyValuePair;
  738. typedef struct statistic_data_str
  739. {
  740. int index;
  741. KeyValuePair* data_info;
  742. struct statistic_data_str* next;
  743. }StatisticDataStr;
  744. struct DistQueMapItem
  745. {
  746. WORD cardstamp;
  747. DistMap distmap;
  748. };
  749. struct MeetingInfo
  750. {
  751. std::string keyValue; // 卡号组合,小号在前,0020000001011 0020000001022 - > 1011-1022
  752. std::string card_id_first;
  753. std::string card_id_second;
  754. double distance; // 两车之间的距离
  755. int reduce_counter; // 两车靠近计数器
  756. };
  757. typedef deque<DistQueMapItem> DistQueMap;
  758. typedef map<std::string, MeetingInfo> MeetingInfoMap;
  759. // 地图
  760. class MapInfo{
  761. public:
  762. MapInfo(void);
  763. ~MapInfo(void);
  764. public:
  765. int map_id;
  766. string map_path;
  767. string map_name;
  768. double map_width;
  769. double map_height;
  770. double map_scale;
  771. int map_type;
  772. AreaMap map_area_list;
  773. ReaderMap map_reader_list;
  774. ReaderMap map_ctrl_reader_list;
  775. CardMap map_card_list_person;
  776. CardMap map_card_list_vehicle;
  777. ChamberMap map_chamber_list;
  778. SectionMap map_section_list;
  779. LightMap map_light_list;
  780. LightGroupMap map_light_group_list;
  781. };
  782. class LandmarkInfo
  783. {
  784. public:
  785. int landmark_id;
  786. string landmark_name;
  787. int map_id;
  788. int area_id;
  789. double x;
  790. double y;
  791. double z;
  792. };
  793. class MapDirectionInfo
  794. {
  795. public:
  796. MapDirectionInfo(){};
  797. ~MapDirectionInfo(){};
  798. public:
  799. int map_direction_id;
  800. int map_id;
  801. int north_angle;
  802. };
  803. // 区域
  804. class Area // 矩形
  805. {
  806. private:
  807. std::vector<std::string> split(std::string str,std::string pattern);
  808. double get_vertex(std::string src); // 顶点
  809. public:
  810. Area(void);
  811. ~Area(void);
  812. void init_border(string sz_path);
  813. bool is_in_polygon(_point p);
  814. bool is_special(); // 是否为特殊区域
  815. public:
  816. int map_id;
  817. int area_id;
  818. string area_name;
  819. string area_type_name;
  820. string path; // 多边形
  821. int area_type_id;
  822. // 人员
  823. int over_count_person;
  824. int over_time_person;
  825. int under_count_person;
  826. int under_time_person;
  827. // 车辆
  828. int over_count_vehicle;
  829. int over_time_vehicle;
  830. int under_count_vehicle;
  831. int under_time_vehicle;
  832. double over_speed_vehicle; //区域车辆速度阈值
  833. int polygon_count;
  834. _point* polygon;
  835. double rect_left;
  836. double rect_right;
  837. double rect_top;
  838. double rect_bottom;
  839. // 区域人数
  840. int count_person;
  841. int count_vehicle;
  842. int count_card;
  843. // 是否写考勤
  844. int is_att; // 0 停车场外,1 停车场内
  845. bool is_area_over_time_person; // 车辆超时
  846. bool is_area_over_time_vehicle; // 人员超时
  847. int count_area_over_time_person; // 超时人数
  848. int count_area_over_time_vehicle; // 超时车数
  849. time_t time_over_time_person; // 开始超时时间
  850. time_t time_over_time_vehicle; // 开始超时时间
  851. bool is_area_over_count_person; // 人员超员
  852. bool is_area_over_count_vehicle; // 车辆超员
  853. int count_area_over_count_person;
  854. int count_area_over_count_vehicle;
  855. time_t time_over_count_person; // 开始时间
  856. time_t time_over_count_vehicle; // 开始时间
  857. bool is_area_forbidden_person;
  858. bool is_area_forbidden_vehicle;
  859. int count_area_forbidden_person;
  860. int count_area_forbidden_vehicle;
  861. time_t time_forbidden_person; // 开始时间
  862. time_t time_forbidden_vehicle; // 开始时间
  863. std::shared_ptr<CardMap> area_card_list_person;
  864. std::shared_ptr<CardMap> area_card_list_vehicle;
  865. std::shared_ptr<CardMap> area_card_list_over_speed;
  866. INT64 m_event_list[AREA_EVENT_COUNT]; // 保存事件Id
  867. };
  868. class DrivingfaceWarningPoint
  869. {
  870. public:
  871. int warning_point_id;
  872. string warning_point_name;
  873. int driving_face_id;
  874. float point_x;
  875. float point_y;
  876. float point_z;
  877. float warning_threshold;
  878. int is_valid;
  879. };
  880. class SpecialAreaEntry
  881. {
  882. public:
  883. SpecialAreaEntry(){}
  884. public:
  885. double start_point_x;
  886. double start_point_y;
  887. double start_point_z;
  888. double end_point_x;
  889. double end_point_y;
  890. double end_point_z;
  891. int special_area_id;
  892. };
  893. class DrivingfaceRender
  894. {
  895. public:
  896. DrivingfaceRender(){}
  897. public:
  898. INT drivingface_id;
  899. INT reader_id;
  900. double vertical_distance;
  901. double x;
  902. double y;
  903. double z;
  904. };
  905. // 工作面与卡绑定信息
  906. class DrivingfaceCard
  907. {
  908. public:
  909. double x;
  910. double y;
  911. double z;
  912. INT drivingface_id;
  913. string card_id;
  914. INT area_id;
  915. float warning_threshold;
  916. int m_overcount;
  917. int m_mapId;
  918. };
  919. // 自组网预置坐标
  920. class Adhoc
  921. {
  922. public:
  923. Adhoc();
  924. ~Adhoc();
  925. public:
  926. int adhoc_id;
  927. double x;
  928. double y;
  929. double z;
  930. int idx;
  931. };
  932. // 天线
  933. class Antenna
  934. {
  935. public:
  936. Antenna(void);
  937. ~Antenna(void);
  938. public:
  939. int antenna_id;
  940. double antenna_x;
  941. double antenna_y;
  942. double antenna_z;
  943. double antenna_angle;
  944. };
  945. // 分站
  946. class Reader
  947. {
  948. public:
  949. Reader(void);
  950. ~Reader(void);
  951. public:
  952. int reader_id; // 分站号
  953. string reader_name; // 分站名称
  954. int device_type_id;
  955. int pos_state; // 位置状态 1井上,2井下
  956. string ip;
  957. double reader_x;
  958. double reader_y;
  959. double reader_z;
  960. double reader_angle;
  961. double reader_interval_time;
  962. int map_id; // 所在地图
  963. int area_id; // 所属区域
  964. double map_scale; // 比例尺
  965. time_t rec_time;
  966. time_t reader_time; // 分站时间
  967. time_t lost_time;
  968. time_t last_send_time; // 最后向前端发送时间
  969. int temperature; // 温度
  970. int tick_count; // 计数器
  971. int reader_state; // 状态 0 正常, 1 故障
  972. int reader_state_old;
  973. int sync_level;
  974. unsigned long long sync_rootId;
  975. std::shared_ptr<Antenna> ant[ANTENNA_COUNT];
  976. std::shared_ptr<Adhoc> adhoc[ADHOC_COUNT];
  977. map<int,_point> readerCoveragePath;
  978. bool bIsInitCoverage;
  979. int m_nIsSpecial;
  980. bool init_ctrl_reader_state; //当为控制分站时,第一次需要获得此控制分站下的红绿灯状态
  981. INT64 m_event_list[READER_EVENT_COUNT]; // 保存事件Id
  982. public:
  983. string get_state_text();
  984. };
  985. class StorePostion
  986. {
  987. public:
  988. StorePostion(){
  989. x = y = z = 0;
  990. GetLocalTime(&save_time);
  991. };
  992. ~StorePostion();
  993. double x, y, z;
  994. SYSTEMTIME save_time;
  995. };
  996. // 卡
  997. class Card
  998. {
  999. public:
  1000. Card(void);
  1001. ~Card(void);
  1002. Card(string cardid, int cardtype,double z_offset);
  1003. friend class YaAlgorithmForCell;
  1004. public:
  1005. CRITICAL_SECTION m_csCard;
  1006. bool is_registered;
  1007. public:
  1008. int card_type; // 卡类型 0x01人, 0x02车
  1009. string card_id;
  1010. int m_indexCardSpeed;
  1011. // 人员
  1012. int level_id;
  1013. int worktype_id;// 工种lemon 2017/07/31 车辆为vehicle_type_id
  1014. int vehice_type_id;
  1015. // 人员、车辆
  1016. int id; // 编号,人员或车辆
  1017. int dept_id; // 部门
  1018. int occ_id; // 职务id
  1019. int group_id; // 班组
  1020. int need_display;// lemon 2071/08/01 是否在Web端显示
  1021. int shift_type_id; // 人员或者车辆执行的班次类型
  1022. string driver_id; //如果是车辆,则有司机id
  1023. int light_id; // 闯红灯的灯编号
  1024. int shift_id;
  1025. SYSTEMTIME deal_time; // 最后处理卡逻辑时间
  1026. SYSTEMTIME enter_area_time;
  1027. //
  1028. int m_indexForRcvOneReader;
  1029. //driving face write database time
  1030. ULONGLONG drive_face_location_write_time;
  1031. ULONGLONG drive_face_location_end_time;
  1032. //SYSTEMTIME down_time;
  1033. time_t rec_time; // 最后接收时间
  1034. time_t down_time; // 入井时间
  1035. time_t att_start_time_latest; // 最近一次从无信号转为有信号的时间,有可能在考勤区域,有可能在非考勤区域 lihongzhen 2017/8/17 17:20
  1036. time_t att_end_time_latest; // 最后一次从非考勤区域进入考勤区域的时间 lihongzhen 2017/8/17 17:23
  1037. time_t up_time; // 升井时间
  1038. time_t enter_reader_time; // 进入分站时间
  1039. time_t low_power_time; // 电量低开始时间
  1040. double coor_offset_x;
  1041. double coor_offset_y;
  1042. double x;
  1043. double y;
  1044. double z;
  1045. //查看掘进机变量是否为初始化值,如果是不进行插入库操作
  1046. bool is_drivingface_Initialization;
  1047. int driving_face_id;
  1048. double driving_face_cur_shift_start_x; //cur shift start position
  1049. double driving_face_cur_shift_start_y;
  1050. double driving_face_cur_shift_start_z;
  1051. double driving_face_cur_shift_x; //cur shift real point
  1052. double driving_face_cur_shift_y;
  1053. double driving_face_cur_shift_z;
  1054. double drving_face_cur_shift_max_speed;
  1055. double a; // 上次定位时的角度
  1056. int t; // 上次定位时的时间戳
  1057. double v; //速度
  1058. double mileage; // 里程,距离上次保存数据时的距离
  1059. double z_offset;
  1060. bool init_postion;
  1061. bool is_first_location;
  1062. int is_driving_face_start;
  1063. double right_x,right_y,right_z; //分别指卡位置右边偏移的x,y,z坐标
  1064. double left_x,left_y,left_z; //分别指卡位置左边偏移的x,y,z坐标
  1065. double last_x;
  1066. double last_y;
  1067. double last_z;
  1068. double stored_x;
  1069. double stored_y;
  1070. double stored_z;
  1071. double output_x;
  1072. double output_y;
  1073. double last_vx;
  1074. double last_vy;
  1075. int state; // 0 正常, 共32bit,每个bit代表一个状态,从右起:
  1076. // 第一位 0x01 井下超时, 第二位 0x02 区域超时, 第三位 0x04 超速, 第四位 0x08, 进入限制区域
  1077. // 状态,故障、电量低等
  1078. int state_moving; // 运动状态, 0 静止,1 启动, 2怠速
  1079. int state_meeting; // 会车状态,与movingstate合并来表示 3会车,4结束会车,5超车
  1080. // 电量低、 呼叫、呼救
  1081. int status_over_time; // 0 未超时,1 超时
  1082. int status_over_speed; // 0 未超速,1 超速
  1083. int status_area_over_time; // 0 未区域超时, 1 区域超时
  1084. int status_area_over_speed; // 0 未区域超速, 1 区域超速
  1085. int status_area_forbidden; // 0 未进入限制区域, 1 进入限制区域
  1086. int status_help; // 0 未呼救, 1 呼救, 2 已处理呼救
  1087. int status_call; // 0 未呼叫 1 呼叫
  1088. int status_power; // 0 电量正常,1 电量低
  1089. int status_lost; // 0 未进入盲区,1024 盲区状态
  1090. int map_id; // 当前地图
  1091. double map_scale; // 地图比例尺
  1092. int map_id_old; // 上次测距所在地图
  1093. int area_id; // 当前区域
  1094. int landmark_id;
  1095. double landmark_dis;
  1096. int landmark_direction;
  1097. int reader_id; // 当前分站
  1098. Reader* p_reader;
  1099. std::shared_ptr<ReaderPathMap> pTofReaderPathMap;
  1100. std::shared_ptr<TDOAReaderPathMap> pTdoaReaderPathMap;
  1101. map<unsigned long long,std::shared_ptr<_coordinate>> mp_dists_locate;
  1102. _coordinate last_locate;
  1103. _coordinate origin_locate;
  1104. QueStrorePos _storepostions;
  1105. DistQueMap _dists;
  1106. int time_stamp_max; // 最大时间戳,即需要计算定位的时间戳
  1107. int time_stamp_cal; // ct 值
  1108. int m_nFilterType;
  1109. int m_nLastLocateT;
  1110. int m_nCalcSyncNum; //卡在算法中的同步号,此同步号和卡的实时同步号并不一定一致
  1111. int m_nSyncNumInList; //从队列中取出的大于5的同步号
  1112. int m_nStream; //上行、下行
  1113. int m_nLightGroupId;
  1114. int m_nMoveDirection; //1为正向运动,-1为负向运动
  1115. int m_nIsRailroad; //是否为有轨车,0为无轨车,1为有轨车
  1116. int m_nOutputPosState; //0为正常输出中间坐标,1为输出靠左偏移坐标,2为输出靠右偏移坐标
  1117. bool bIsBack;
  1118. bool bInSpecailArea; // 是否在特殊区域
  1119. bool issent; // true 已发送至客户端,false 新数据,需要发送至客户端
  1120. bool issaved; // true 已保存到数据库,false 生成新的考勤记录,需要保存到数据库
  1121. bool isdealed; // 已经处理
  1122. bool isreceive; // 接收到
  1123. bool is_deal_by_algo; //是否经过算法处理
  1124. bool is_hist;
  1125. bool is_need_cal;
  1126. bool m_bUseFilter;
  1127. bool isoutput; //是否输出到json
  1128. bool is_red_light;
  1129. bool is_mine_over_time; // 是否井下超时
  1130. bool is_mine_over_speed; // 是否井下超速
  1131. bool is_area_over_time; // 是否区域超时, 区域超时分车辆超时、人员超时
  1132. bool is_area_over_speed; // 是否区域超速
  1133. time_t time_area_over_time; // 区域超时开始时间
  1134. time_t time_over_time; // 井下超时开始时间
  1135. time_t time_area_forbidden; // 进入限制区域时间
  1136. time_t time_over_speed; // 超速开始时间
  1137. time_t time_area_over_speed;
  1138. time_t time_low_power;
  1139. time_t time_red_light; //闯红灯时间
  1140. time_t last_locate_time; // 最后定位时间
  1141. void reset(); // 重置所有状态
  1142. void resetAllBaseInfo(); //重置基本信息
  1143. void set_reader(std::shared_ptr<Reader> preader);
  1144. void add_dist(std::shared_ptr<_coordinate> dist);
  1145. void cal_pos_by_cache(); // 利用缓存的数据计算位置
  1146. int dist_cache_size(); // 获取缓存数据个数
  1147. void remove_dist_head();
  1148. string concat(int reader_id, int ant_id);
  1149. time_t get_working_time();
  1150. string get_state_text();
  1151. string get_acc_text();
  1152. double get_speed();
  1153. void set_speed(double v);
  1154. int get_effictive_dist_count(int offset = 0);
  1155. void set_reader_path(std::shared_ptr<ReaderPathMap> rpm, std::shared_ptr<TDOAReaderPathMap> trpm);
  1156. void get_coordinate();
  1157. void get_coordinate(int cnt);
  1158. int const PosState();
  1159. void PosState(int val);
  1160. void PosStateOld(int val);
  1161. bool is_pos_state_changed(); // 入\升井状态变化
  1162. int const StateBiz();
  1163. INT64 m_event_list[CARD_EVENT_COUNT]; // 保存事件Id
  1164. public://lemon
  1165. int m_warning_point_id;
  1166. bool m_isWarning; // 0
  1167. double m_minDistanceToWarningpoint; //
  1168. double m_warning_threshold; //limit value
  1169. bool m_CardHasBeenInDrivingfaceAlarm;
  1170. int m_DrivingfaceAlarmFlag;
  1171. CardMap mp_list_over_count;
  1172. //lemon 2017/08/01
  1173. inline double getDrivingfaceCulValue(){return m_drivingface_distance_cul_values;}
  1174. inline double getDrivingfaceLimitValue(){return m_drivingface_distance_limit_values;}
  1175. inline void setDrivingfaceCulValue(double cvalue){m_drivingface_distance_cul_values = cvalue;}
  1176. inline void setDrivingfaceLimitValue(double lvalue){m_drivingface_distance_limit_values = lvalue;}
  1177. //lemon 2017/08/16
  1178. double m_drivingface_start_x;
  1179. double m_drivingface_start_y;
  1180. double m_drivingface_start_z;
  1181. std::string m_drivingface_start_time;
  1182. double m_curshift_finish_length;
  1183. double m_cur_total_finish_length;
  1184. private:
  1185. double m_drivingface_distance_cul_values;
  1186. double m_drivingface_distance_limit_values;
  1187. public:
  1188. //算法相关参数及函数
  1189. bool is_algo_first_location; //表示算法的第一次定位
  1190. bool is_idling; // 是否为怠速状态
  1191. int idle_count; // 连续判断为怠速状态的次数,超过次数阈值则将速度置为0
  1192. std::shared_ptr<nspLocate::LocateRecord> locate;
  1193. std::list<std::shared_ptr<POS>> idle_pos_list;
  1194. void algo_tof(int cnt);
  1195. int algo_tof_1d(int cnt); // tof一维定位
  1196. int algo_tof_2d(int cnt); // tof二维定位
  1197. int algo_tof_3d(int cnt); // tof三维定位
  1198. //tdoa算法
  1199. void algo_tdoa(int cnt);
  1200. int algo_tdoa_1d(int cnt); // tdoa一维定位
  1201. int algo_tdoa_2d(int cnt); // tdoa二维定位
  1202. int algo_tdoa_3d(int cnt); // tdoa三维定位
  1203. int inspect_coordinate(int acce_state);
  1204. int save_card_data();
  1205. void algo_calc_offset(); //计算偏移坐标
  1206. double x_offset_after(); //返回偏移后的X坐标
  1207. double y_offset_after(); //返回偏移后的Y坐标
  1208. double z_offset_after(); //返回偏移后的Z坐标
  1209. bool algo_is_same_direction(double x,double y,double z); //检查此次方向
  1210. int CheckDistData(int cnt);
  1211. int AssembleDistData(std::shared_ptr<ReceiveDataMap> pRdm); //tdoa组装数据
  1212. int AssembleDistData(map<unsigned long long, std::shared_ptr<_coordinate>>& p_dist_locate); //tof组装数据
  1213. int GetDeltaT(map<unsigned long long,std::shared_ptr<_coordinate>> dl);
  1214. int SaveCardAlgoData(std::shared_ptr<POS>& pos);
  1215. int SaveTofData(const std::shared_ptr<POS> pos);
  1216. int SaveTdoaData(const std::shared_ptr<POS> pos);
  1217. int SaveOriginDataBeforeFilter(std::shared_ptr<POS> pos);
  1218. int ChooseOneSolution(std::shared_ptr<ReceiveDataMap> pRdm, std::vector<std::shared_ptr<POS>> udm_pos, std::shared_ptr<POS>& pos);// 输出唯一解
  1219. int calibration_pos_data(std::shared_ptr<POS> pos); //校验坐标数据,并将结果保存到pos中
  1220. int CheckSolution(std::shared_ptr<POS>& p); // 验证唯一解合法性,如速度、加速度
  1221. void saveToSyncNumDataList(int sync_num, double pixelX, double pixelY, double speedX, double speedY, bool updated); // 通过校验后的数据, 保存到 m_syncNumList 容器
  1222. int CheckSulutionByStream(std::shared_ptr<POS> p); // 参数使用非引用,即不可修改其值
  1223. int GetStream(double x1,double y1,double x2,double y2); // 获得上下行方向
  1224. int CalcPositionBySpeed(std::shared_ptr<POS>& pos,double v);
  1225. bool CheckStreamUniformity(double x1,double y1,double x2,double y2,int nStream);
  1226. bool IsExistPath(int left,int right);
  1227. int CopySolution(std::shared_ptr<POS> source,std::shared_ptr<POS>& dest);
  1228. //std::shared_ptr<nspLocate::LocateRecord> locate;
  1229. int CheckCardStatus();
  1230. bool IsIdleStatus(std::shared_ptr<POS> pos);
  1231. bool IsRebound(std::shared_ptr<POS> pos); //判断是否回退
  1232. bool CheckPositionValid(const std::shared_ptr<POS> pos); //检查解的有效性
  1233. double GetDeltaT(); //获取时间差值
  1234. public:
  1235. //tof相关变量及函数
  1236. time_t time_cur_algo; // dist数据进缓存队列的时间
  1237. time_t time_last_tof; // 上次tof定位的时间
  1238. int reader_id_algo; // 算法计算时的分站号
  1239. int get_position_by_one_distance(std::shared_ptr<TOFReaderPathMap> trpm,std::shared_ptr<POS>& pos,const TOF_REFER_DATA refer_data);
  1240. bool CheckSolutionTof(std::shared_ptr<POS>& pos); //通过速度及加速度检查定位结果是否正确
  1241. int get_ref_data_from_dists(map<unsigned long long, std::shared_ptr<_coordinate>> tmp_dists_locate,const int& key,TOF_REFER_DATA& refer_data);
  1242. private:
  1243. void set_reader_path_tof(std::shared_ptr<ReaderPathMap> rpm); // 设置tof路径集
  1244. void set_reader_path_tdoa(std::shared_ptr<TDOAReaderPathMap> trpm); // 设置tdoa路径集
  1245. public:
  1246. list<sync_data> m_syncNumList;
  1247. std::list<std::shared_ptr<POS>> his_idle_pos;
  1248. bool b_long_interval; //上一次定位的间隔时间差大于10s
  1249. int diff_direction_counts;
  1250. int maxSyncTimes;
  1251. public:
  1252. // 滤波算法相关
  1253. std::unique_ptr<CKalmanFilter> m_pKalmanFilter;
  1254. int acce_cur_state; //在算法中保存当前加速度状态,保存这两个值的原因是在多线程情况下accelerate_state和accelerate_state_last状态可能变化
  1255. int acce_last_state; //在算法中保存上一次加速度状态
  1256. double ins_weight; //加速度计状态权重
  1257. double uwb_weight; //uwb状态权重
  1258. std::list<double> vt_his_speed;
  1259. int FindDistMap(int cardstamp);
  1260. int KalmanFilterProcess(std::shared_ptr<POS>& pos);
  1261. void EnableFilter(int nType);
  1262. bool CheckCrossCycle();
  1263. bool isRebound(std::shared_ptr<POS> pos); //判断是否回跳
  1264. public:
  1265. bool b_save_pos;
  1266. //在长时间无法定位的情况下使用拟合算法输出点
  1267. std::list<std::shared_ptr<POS>> his_pos; //保存之前5个点的信息
  1268. std::list<std::shared_ptr<Cell>> lvCells; //拟合队列,用于计算拟合值
  1269. bool is_ref_pos; //判断是否作为参考点
  1270. bool is_fit_pos;
  1271. bool have_fit_pos;
  1272. bool have_long_fit_pos;
  1273. bool is_over_interval; //用于保存modify_card_speed中当前时间和卡的最后接收时间的是否超过指定时间的状态
  1274. int count_idle; //统计坐标连续有多少次没变化了,用于判断车辆是否怠速,统计5次
  1275. int cur_fit_nums; //当前拟合次数,当有新数据放入his_pos即重置它
  1276. int cur_ref_totals;
  1277. int count_change_direction; // 统计方向改变后的的连续定位次数,大于3次,改变行驶方向。
  1278. double fitting_v[REF_POSITION_NUM];
  1279. double fitting_ct[REF_POSITION_NUM];
  1280. double fitting_x[REF_POSITION_NUM];
  1281. double fitting_y[REF_POSITION_NUM];
  1282. double fit_new_x[FIT_POSITION_NUM];
  1283. double fit_new_y[FIT_POSITION_NUM];
  1284. //第二种拟合
  1285. std::list<std::shared_ptr<POS>> long_his_pos; //保存之前20个点的信息,此信息必须是UWB定位信息
  1286. double long_fitting_ct[REF_POSITION_NUM];
  1287. double long_fitting_x[REF_POSITION_NUM];
  1288. double long_fitting_y[REF_POSITION_NUM];
  1289. double long_fit_new_x[FIT_POSITION_NUM*4];
  1290. double long_fit_new_y[FIT_POSITION_NUM*4];
  1291. int UpdateFittingData(std::shared_ptr<POS> pos); //更新拟合基础数据
  1292. int CalcFittingData(); //计算拟合数据
  1293. int CalcLongFittingData();
  1294. int CalcFittingData(int ret,std::shared_ptr<POS>& pos);
  1295. int CalcLongFittingData(int ret,std::shared_ptr<POS>& pos);
  1296. int GetPosFromFittingData(std::shared_ptr<POS>& pos);
  1297. std::shared_ptr<POS> GetPosFromFittingData(); //从拟合数据获取定位坐标
  1298. int CheckSolutionByFit(int ret,std::shared_ptr<POS>& pos);
  1299. int CheckSolutionBySpeed(std::shared_ptr<POS>& pos);
  1300. bool need_reset;// temp add by lyl: 算法是否需要重置
  1301. int cell_station_error_num; // temp add by lyl: 跨基站处理异常
  1302. int speed_limit_after_reset; // temp add by lyl: 重置后, 对拟合算法计算出的速度值做管控
  1303. bool CheckCardCtValid(); //检查卡的ct有效性
  1304. double GetFittingDegree(std::list<std::shared_ptr<Cell>> ltCells); //检查拟合度
  1305. private:
  1306. int state_biz; //业务状态,呼叫/超时/进入禁区等
  1307. int pos_state; // 位置状态,0初始化,1井下,2井上,3车场分站
  1308. int pos_state_old;
  1309. int pos_state_count; // 当前位置状态确认次数
  1310. int pos_state_confirm_times; // 井下、井上状态确认次数,默认为1
  1311. public:
  1312. // 采集到的底层数据
  1313. int time_stamp_last; // 定位时间戳
  1314. int accelerate_state_last; // 上一次加速度状态
  1315. int power_state_last; // 电量
  1316. int ins_direction; // 上一次的惯导合成方向
  1317. int reader_tickcount; // 分站发送数据的计数次数
  1318. int time_stamp; // 定位时间戳
  1319. int ranging_type; // 报文类型 tof,tdoa
  1320. int accelerate_state; // 加速度
  1321. int antenna_id; // 天线号
  1322. int power_state; // 电量
  1323. int sync_num; // 分站同步序号
  1324. int n_pos_no_change_times; // lihongzhen 2017/8/19 位置连续未变化次数
  1325. bool b_pos_change; // 位置发生了改变
  1326. bool b_enter_intersection; // 车辆是否进入过路口区域
  1327. double antenna_angle; // 天线角度
  1328. double distance; // 距离
  1329. int64_t flying_time; // 飞行时间
  1330. string str_his_time;
  1331. string str_rec_time;
  1332. public:
  1333. //呼叫信息
  1334. int call_type_id;
  1335. int call_type;
  1336. std::vector<int> vt_deal_call_reader_id;
  1337. time_t recv_call_time; //卡接收到呼叫的时间戳
  1338. public:
  1339. //惯导数据
  1340. //tof中惯导数据
  1341. int ins_request_check; //uwb带惯导数据的协议中惯导请求校准状态值,0为正常,1为请求校准
  1342. int ins_cal_type; //下发校准类型:0下发校准角度和坐标,1下发校准坐标,2下发校准角度
  1343. bool is_check_ins; //是否已校准惯导数据
  1344. double ins_gyp_angle; //校准后的陀螺仪角度
  1345. std::shared_ptr<POS> cur_ins_pos; //惯导上传的坐标
  1346. std::shared_ptr<POS> ins_gyp_pos; //校准后的惯导初始坐标
  1347. std::list<std::shared_ptr<POS>> lt_uwb_pos; //存储校准两时刻的uwb定位数据
  1348. std::list<std::shared_ptr<POS>> lt_ins_pos; //存储校准两时刻的ins定位数据
  1349. int deal_ins_cal_data(); //处理惯导数据校准
  1350. int calc_slope(std::shared_ptr<POS> start,std::shared_ptr<POS> end,double & slope);
  1351. public:
  1352. //测试及统计功能
  1353. AlgoFailedMsg m_afmData;
  1354. public:
  1355. //格子算法的代码
  1356. bool bInitalCellPath;
  1357. bool isNeedWrited;
  1358. std::shared_ptr<CellPathMap> mpCellPath;
  1359. std::string curCellReaderName; //当前格子所属分站名
  1360. std::string originCellReaderName; //原始定位格子所属分站名
  1361. ULONGLONG calc_cell_time; //保存当前定位的计时器(通过数据和通过500ms补充)
  1362. ULONGLONG data_cell_time; //用于区分两次通过数据进行定位的
  1363. SYSTEMTIME cellDealTime; //格子处理时间
  1364. int curCellId; //当前格子id
  1365. int originCellId; //原始定位格子id
  1366. int nIncrease; //格子是否增长,0为未识别,如果增长为1,如果下降为-1
  1367. int nStartLocateCounts; //启动定位计数统计,根据前5次定位计算是否怠速:如果怠速,则继续不运动;如果运动,则开始加速
  1368. int change_cell_dir; //改变格子方向
  1369. int locateCounts; //统计定位次数,用于取模计算
  1370. int isInsertToDb; //插入数据库
  1371. int nOverThreCounts; //连续大跳次数
  1372. double fit_k; //最新的格子拟合的斜率
  1373. double last_k;
  1374. double delta_ct; //ct的差值
  1375. double fit_b; //最新的格子拟合的截距
  1376. double fit_r; //求斜率时的拟合度
  1377. double cell_a; //格子算法中的加速度值
  1378. int cell_id_delta_for_idling; // 格子算法: 怠速判断累计值
  1379. bool isIdling; //怠速状态
  1380. int idling_count; // lyl add: for cell
  1381. int m_reverse_direction_count; // 用于算法路径14, 统计转向数据数量
  1382. int last_direction; // 运动方向
  1383. std::thread* pThread;
  1384. std::shared_ptr<Cell> last_cell;
  1385. std::list<std::shared_ptr<Cell>> his_cell;
  1386. std::list<std::shared_ptr<Cell>> history_cell_for_idling;
  1387. std::list<std::shared_ptr<Cell>> locate_cells;
  1388. int DiscreteLocate(int cnt);
  1389. int PersonLocation(int cnt);
  1390. bool CheckIdleStatus();
  1391. bool CheckStartRule();
  1392. bool isOverThreshold();
  1393. bool isRebound(std::shared_ptr<Cell> cell);
  1394. bool Position2Cell(std::shared_ptr<POS>& pos, std::shared_ptr<Cell>& cell); //点转化为格子信息
  1395. std::shared_ptr<POS> Cell2Position(std::shared_ptr<Cell>& cell); //格子信息转化坐标输出
  1396. std::shared_ptr<Cell> GetNextCell(std::shared_ptr<Cell> lastCell,int increase,int nIndex);
  1397. std::shared_ptr<Cell> GetNextCell(std::shared_ptr<Cell> lastCell,int increase,int nIndex,std::shared_ptr<Cell> newCell);
  1398. int SetCellPathMap(std::shared_ptr<CellPathMap> pCellPath);
  1399. int ChangeSystemTime(SYSTEMTIME& st,const int condition);
  1400. int ChangeSystemTime(SYSTEMTIME& st); //在st基础上加500ms
  1401. int ChangeSystemTimeBySecond(SYSTEMTIME& st); //按1s的方式更改st时间
  1402. int MappingCell2FitLinear(std::shared_ptr<Cell>& cell); //将格子拟合到线上
  1403. bool cftool(float *data_x, float *data_y, int data_n, std::vector<float> &vResult);
  1404. int SaveCardAlgoData(std::shared_ptr<Cell>& cell);
  1405. std::shared_ptr<Cell> FindCell(std::string strReaderName,int cellid);
  1406. //刘思平修订的代码Part 3/Sum 3:begin
  1407. //以下函数的声明:将当前时刻的毫秒四舍五入为0ms或者500ms
  1408. //by lsp on 2017.07.09 @山西长治
  1409. int ChangeMsTimeToZeroOrFive(SYSTEMTIME& st);
  1410. int colourfulCloudsChasingTheMoon(std::shared_ptr<Cell> &cell, std::list<std::shared_ptr<Cell>> &myCellList);
  1411. //结束:刘思平修订的代码Part 3/Sum 3
  1412. public:
  1413. //测试参数及相关函数
  1414. int OutputCmdLog(int n);
  1415. double dTestDelatT; //测试时间差
  1416. double dTestDistance; //测试两次的定位的距离差
  1417. };
  1418. class BanShift
  1419. {
  1420. public:
  1421. BanShift();
  1422. ~BanShift();
  1423. BanShift(int id, std::string s, std::string e, int tid);
  1424. int shift_id;
  1425. int shift_type_id;
  1426. std::string start_time;
  1427. std::string end_time;
  1428. };
  1429. class LeaderArrange
  1430. {
  1431. public:
  1432. LeaderArrange( string cardid);
  1433. ~ LeaderArrange();
  1434. int staff_id;
  1435. string card_id;
  1436. int shift_id;
  1437. int shift_type_id;
  1438. time_t starttime;
  1439. time_t endtime;
  1440. };
  1441. class Dept
  1442. {
  1443. public:
  1444. Dept(){};
  1445. ~Dept(){};
  1446. Dept(int id, string name);
  1447. private:
  1448. public:
  1449. int dept_id;
  1450. string dept_name;
  1451. CardMap dept_card_list_person;
  1452. CardMap dept_card_list_vehicle;
  1453. };
  1454. class OccLevel
  1455. {
  1456. public:
  1457. OccLevel(){};
  1458. ~OccLevel(){};
  1459. OccLevel(int id);
  1460. private:
  1461. public:
  1462. int occlevel_id;
  1463. CardMap level_card_list_person;
  1464. CardMap level_card_list_vehicle;
  1465. };
  1466. /*
  1467. * 地图集路径描述
  1468. */
  1469. class ReaderPath{
  1470. public:
  1471. ReaderPath(){
  1472. bIsInit = false;
  1473. nRealCalcPoints = 0;
  1474. x[0] = x[1] = y[0] = y[1] = 0;
  1475. for(int i = 0;i < MAX_CALC_POINTS;i++){
  1476. px[i] = py[i] = pz[i] = 0;
  1477. }
  1478. }
  1479. public:
  1480. //对于TOF而言,x,y表示1,2天线对应的坐标
  1481. //对于TDOA而言,x,y表示焦点F1,F2(等同于分站i,i+1)的坐标
  1482. int nRealCalcPoints;
  1483. double x[2];
  1484. double y[2];
  1485. double z[2];
  1486. double px[MAX_CALC_POINTS];
  1487. double py[MAX_CALC_POINTS];
  1488. double pz[MAX_CALC_POINTS];
  1489. bool bIsInit;
  1490. };
  1491. //红绿灯
  1492. class Light{
  1493. public:
  1494. int m_nID; //红绿灯id
  1495. int m_nMapID; //地图id
  1496. int m_nReaderID; //传输分站id
  1497. int m_nAreaID; //区域id
  1498. int m_nSectionID; //路段id
  1499. int m_nLightsGroupID; //红绿灯组id
  1500. int m_nPort; //与分站之间通信的路数
  1501. int m_nState; //红绿灯是否可用状态,0可用,1不可用
  1502. int m_nOldState;
  1503. int device_type_id; //设备类型
  1504. double x; //x坐标
  1505. double y; //y坐标
  1506. double z; //z坐标
  1507. std::string m_strIP; //红绿灯ip
  1508. std::string m_strName; //红绿灯名字
  1509. std::string m_strLabel;
  1510. time_t rec_time;
  1511. time_t last_send_time;
  1512. public:
  1513. Light();
  1514. ~Light(){}
  1515. public:
  1516. int get_light_state();
  1517. public:
  1518. int m_nStream; //0为上行,1为下行
  1519. int m_nColor; //0x01 红色, 0x02 绿色
  1520. int m_nShape; // 形状 0x01 实心圆形,0x02 空心圆形,0x03 叉形,0x04 - 0x07 上下左右箭头,0xFF 警告闪烁
  1521. int m_nStateBiz; //0为正常,1为网络故障,2为控制失败,3为灯故障
  1522. int m_nIsCtrl; // 设备控制状态 0x01 自动控制,0x02手动控制
  1523. time_t alarm_start_time;
  1524. };
  1525. class LightsGroup{
  1526. public:
  1527. int m_nID;
  1528. int m_nState;
  1529. bool m_bIsUsed;
  1530. std::string m_strName;
  1531. std::string m_strLabel;
  1532. public:
  1533. int m_nSectionId; //灯组所在的路口区域
  1534. std::string m_strVechileId; //控制此灯组的车辆id
  1535. map<int,std::shared_ptr<Light>> mp_lights_list;
  1536. public:
  1537. LightsGroup();
  1538. ~LightsGroup(){};
  1539. public:
  1540. bool isExist(std::shared_ptr<Light> pLight);
  1541. bool isAllLightColor(int nColor);
  1542. };
  1543. class BaseArea{
  1544. public:
  1545. BaseArea(){
  1546. m_nPolygonCount = 0;
  1547. m_pPolygon = NULL;
  1548. }
  1549. ~BaseArea(){
  1550. if (m_pPolygon)
  1551. {
  1552. delete[] m_pPolygon;
  1553. m_pPolygon = NULL;
  1554. }
  1555. }
  1556. public:
  1557. int init_border(string path);
  1558. bool IsInPolygon(_point p);
  1559. private:
  1560. double GetVertex(std::string src); // 顶点
  1561. std::vector<std::string> Split(std::string str,std::string pattern);
  1562. public:
  1563. int m_nProperty;
  1564. int m_nPolygonCount;
  1565. _point* m_pPolygon;
  1566. };
  1567. //硐室
  1568. class Chamber:public BaseArea{
  1569. public:
  1570. int m_nID; //硐室编号
  1571. int m_nState; //使用状态,特指此硐室是否处于可用
  1572. int m_nIsUsed; //硐室内是否有车
  1573. int m_nSectionID; //硐室所属路段ID
  1574. int m_nMapID; //硐室所属地图ID
  1575. std::string m_strPath; //硐室区域
  1576. std::string m_strName; //硐室名称
  1577. std::string m_strLabel; //硐室描述
  1578. public:
  1579. Chamber();
  1580. ~Chamber();
  1581. };
  1582. //路段
  1583. class Section:public BaseArea{
  1584. public:
  1585. int m_nID;
  1586. int m_nMapId;
  1587. std::string m_strPath;
  1588. std::string m_strName;
  1589. std::string m_strLabel;
  1590. public:
  1591. int m_nState; //0---正常,1---繁忙,2---拥堵
  1592. time_t alarm_start_time;
  1593. ChamberMap mp_champer_list;
  1594. LightMap mp_light_list;
  1595. CardMap mp_vehicle_list;
  1596. CardMap mp_staffer_list;
  1597. INT64 m_event_list[SECTION_EVENT_COUNT];
  1598. public:
  1599. Section();
  1600. ~Section(){}
  1601. public:
  1602. bool is_has_chamber(); //是否有未使用的躲避硐室
  1603. int get_section_state(); //路段状态
  1604. int get_section_vehicle_counts(); //路段内车辆总数
  1605. int get_section_staffer_counts(); //路段内人员总数
  1606. };
  1607. class PatrolTask
  1608. {
  1609. public:
  1610. PatrolTask();
  1611. ~PatrolTask();
  1612. private:
  1613. public:
  1614. int patrol_task_id;
  1615. int patrol_path_id;
  1616. string card_id;
  1617. string starffer_id;
  1618. time_t start_time;
  1619. time_t end_time;
  1620. PatrolPointMap mpPoint;
  1621. bool is_in_cur_point;
  1622. int cur_point_idx;
  1623. int state; // 巡检状态
  1624. int stay_state; // 停留时长状态
  1625. int duration_stay; //停留时长
  1626. time_t enter_time; // 进入该节点时间
  1627. time_t leave_time; // 离开当前节点时间
  1628. };
  1629. class PatrolPoint
  1630. {
  1631. public:
  1632. PatrolPoint();
  1633. ~PatrolPoint();
  1634. private:
  1635. public:
  1636. int idx; // 在路径中的索引
  1637. int patrol_point_id;
  1638. int map_id;
  1639. double x; // 区域范围圆心
  1640. double y;
  1641. double z;
  1642. double ranging; // 距离范围
  1643. int duration_last; // 距离上个节点时长
  1644. int duration_stay_min; // 本节点最小时长
  1645. int duration_stay_max; // 本节点最大时长
  1646. int duration_ranging; // 距离上个节点时长最大偏差,含正负
  1647. };
  1648. enum EVENT_TYPE{ // 事件类型
  1649. ET_UNKNOWN = 0,
  1650. ET_OVER_COUNT_PERSON = 1, // 井下人员超员mp_card_list_over_count_person
  1651. ET_OVER_COUNT_VEHICLE = 2, // 井下车辆超员mp_card_list_over_count_person
  1652. ET_AREA_OVER_COUNT_PERSON = 3, // 区域人员超员
  1653. ET_AREA_OVER_COUNT_VEHICLE = 4, // 区域车辆超员
  1654. ET_SECTION_OVER_COUNT = 5, // 路段拥堵
  1655. ET_READER_ERROR = 6, // 分站通信异常
  1656. ET_ctrl_reader_ERROR = 7, // 控制分站异常
  1657. ET_LIGHT_ERROR = 8, // 交通灯异常
  1658. ET_READER_CALL = 9, // 分站呼叫标识卡
  1659. ET_READER_CALL_CANCEL = 10, // 取消呼叫分站
  1660. ET_CARD_LOW_POWER = 11, // 电量低
  1661. ET_CARD_LOW_POWER_SERIOUS = 12, // 电量极低
  1662. ET_CARD_OVER_TIME_PERSON = 13, // 人员井下超时mp_card_list_over_time_person
  1663. ET_CARD_OVER_TIME_VEHICLE = 14, // 车辆井下超时mp_card_list_over_time_vehicle
  1664. ET_CARD_AREA_OVER_TIME_PERSON = 15, // 人员区域超时
  1665. ET_CARD_AREA_OVER_TIME_VEHICLE = 16, // 车辆区域超时
  1666. ET_CARD_AREA_LIMIT_PERSON = 17, // 人员进入限制区域
  1667. ET_CARD_AREA_LIMIT_VEHICLE = 18, // 车辆进入限制区域
  1668. ET_CARD_AREA_FORBIDDEN_PERSON = 19, // 人员进入禁止区域
  1669. ET_CARD_AREA_FORBIDDEN_VEHICLE = 20, // 车辆进入禁止区域
  1670. ET_CARD_OVER_SPEED = 21, // 车辆超速
  1671. ET_CARD_AREA_OVER_SPEED = 22, // 车辆区域超速
  1672. ET_CARD_RUN_THE_RED_LIGHT = 23, // 车辆闯红灯
  1673. ET_CARD_HELP = 24, // 人员呼救
  1674. ET_CARD_CALLED = 25, // 人员已被呼叫
  1675. ET_CARD_PATROL_ERROR = 26, // 人员巡检异常
  1676. ET_CARD_LOST = 27, // 标识卡信号丢失
  1677. ET_CARD_DRIVINGFACE_WARNING_AREA = 28, // 掘进面靠近预警区域告警
  1678. ET_CARD_NEAR_DRIVINGFACE_VEHICLE=29,// 人员靠近掘进机告警
  1679. ET_CARD_NEAR_DRIVINGFACE_OVERCOUNT=30,//掘进机附近人员超员
  1680. CARD_EVENT_COUNT_MAX,
  1681. };
  1682. enum OBJECT_TYPE // 对象类型
  1683. {
  1684. OT_MINE = 1, // 矿井
  1685. OT_AREA = 2, // 区域
  1686. OT_SECTION = 3, // 路段
  1687. OT_DEVICE_READER = 4, // 分站
  1688. OT_DEVICE_LIGHT = 5, // 交通灯
  1689. OT_DEVICE_ctrl_reader = 6, // 控制分站
  1690. OT_DEVICE_LED = 7, // led屏
  1691. OT_DEVICE_SPEAKER = 8, // 防爆音箱
  1692. OT_CARD = 9, // 标识卡,包括人员、车辆、自组网等
  1693. OT_DRIVINGFACE_AREA=10
  1694. };
  1695. enum EVENT_STATUS{ // 事件状态
  1696. ES_START = 0, // 事件开始
  1697. ES_DEAL_HELP = 1, // lihongzhen 2017/8/19 呼救已处理状态
  1698. ES_END = 100 // 事件结束
  1699. };
  1700. enum REQUEST_COUNTS_TYPE{
  1701. REQUEST_ALL = 0,
  1702. REQUEST_ALL_OVER_TIME_PERSON,
  1703. REQUEST_AREA_OVER_TIME_PERSON,
  1704. REQUEST_SPECIAL_ERROR_PERSON,
  1705. REQUEST_ALL_OVER_TIME_VEHICLE,
  1706. REQUEST_AREA_OVER_TIME_VEHICLE,
  1707. REQUEST_ALL_OVER_PERSON,
  1708. REQUEST_AREA_OVER_PERSON,
  1709. REQUEST_ALL_OVER_VEHICLE,
  1710. REQUEST_AREA_OVER_VEHICLE
  1711. };
  1712. class YaEvent
  1713. {
  1714. private:
  1715. INT64 ev_id;
  1716. public:
  1717. YaEvent(){};
  1718. YaEvent(INT64 e_id){
  1719. ev_id = e_id;
  1720. obj_id = "";
  1721. cur_time = time(NULL);
  1722. map_id = 0;
  1723. area_id = 0;
  1724. x = 0;
  1725. y = 0;
  1726. limit_value = 0;
  1727. cur_value = 0;
  1728. desc = "";
  1729. landmarkid = 0;
  1730. landmarkdirect = 0;
  1731. landmarkdist = 0;
  1732. is_count = false;
  1733. };
  1734. ~YaEvent(){};
  1735. public:
  1736. EVENT_STATUS status;
  1737. EVENT_TYPE ev_type;
  1738. OBJECT_TYPE obj_type;
  1739. std::string obj_id;
  1740. time_t cur_time;
  1741. int map_id;
  1742. int area_id;
  1743. double x;
  1744. double y;
  1745. double limit_value;
  1746. double cur_value;
  1747. std::string desc;
  1748. int landmarkid;
  1749. int landmarkdirect;
  1750. int landmarkdist;
  1751. bool is_sent; // 已发送
  1752. bool is_count;
  1753. INT64 get_id(){return ev_id;};
  1754. };
  1755. class LightCallInfo{
  1756. public:
  1757. LightCallInfo(){
  1758. light_id = 0;
  1759. ctrl_type = 0;
  1760. ctrl_color = 0;
  1761. light_state = 0;
  1762. task_id = "";
  1763. }
  1764. public:
  1765. int light_id;
  1766. int ctrl_type;
  1767. int ctrl_color;
  1768. int light_state;
  1769. std::string task_id;
  1770. };
  1771. enum DIRECTION_TYPE{
  1772. NODIRECTORY = 0,
  1773. EAST = 1,
  1774. SOURTH = 2,
  1775. WEST = 3,
  1776. NORTH = 4
  1777. };
  1778. class VehicleTypeAttRule
  1779. {
  1780. public:
  1781. VehicleTypeAttRule(int vtid, int pre, int back);
  1782. ~VehicleTypeAttRule();
  1783. int vehicle_type_id;
  1784. int offset_pre;
  1785. int offset_back;
  1786. std::vector<int> vecArea;
  1787. void Clear();
  1788. void AddArea(int area_id);
  1789. };
  1790. #ifdef DEBUG
  1791. #define TEST_FROM_FILE 1
  1792. #else
  1793. #endif // DEBUG
  1794. #endif //YASERVER_CLASSDEF_H_