classdef.h 46 KB

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