card_base.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. #include <memory>
  2. #include <message.h>
  3. #include "card_message_handle.h"
  4. #include "card_person.h"
  5. #include "card_car.h"
  6. #include "config_file.h"
  7. #include "select_tool.h"
  8. #include "module_service/module_mgr.h"
  9. #include "websocket/wsClientMgr.h"
  10. #include "websocket/wsTimerThread.h"
  11. #include "three_rates.h"
  12. #include "his_location.h"
  13. #include "event.h"
  14. #include "module_service/module_call.h"
  15. #include "mine.h"
  16. #include "common_tool.h"
  17. #include "ant.h"
  18. #include "area.h"
  19. #include "loc_point.h"
  20. #include "loc_message.h"
  21. #include "module_service/module_traffic_light_manager.h"
  22. #include "db/db_tool.h"
  23. #include "tool_time.h"
  24. #include "tool_byte.h"
  25. extern config_file config;
  26. card_location_base::card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid)
  27. :card(id, dis, t, deptid, level_id, cid)
  28. ,m_display_old(dis)
  29. {
  30. select_tool_manage::instance()->create_tool(type, m_sel_tool, m_smo_tool);
  31. m_his_location_card.reset(new location_card(m_id, m_type, cid));
  32. m_cb_pdoa.set_capacity(5);
  33. m_cb_tof.set_capacity(5);
  34. m_cb_point.set_capacity(5);
  35. for(int index = 0; index < 5; ++index){
  36. m_cb_pdoa.push_back(100);
  37. m_cb_tof.push_back(0);
  38. m_cb_point.push_back(point(0,0));
  39. }
  40. m_cb_stream_idx.set_capacity(2);
  41. m_cb_stream_idx.push_back(0);
  42. m_cb_stream_idx.push_back(0);
  43. }
  44. void card_location_base::do_status(int st)
  45. {
  46. time_t now = time(0);
  47. bool help_flag = false;
  48. log_info("[help-battery] card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
  49. // 呼救
  50. if((m_help_bit & 1) && (st & STATUS_HELP))
  51. {
  52. // 1111111111
  53. // ^
  54. m_help_last_time = now;
  55. }
  56. else if((m_help_bit & 1) && (st & STATUS_HELP)==0)
  57. {
  58. // 11111111100000
  59. // ^
  60. m_help_bit<<=1;
  61. }
  62. else if((m_help_bit & 1)==0 && (st & STATUS_HELP))
  63. {
  64. // 00000000011111
  65. // ^
  66. // 呼救开始
  67. if((m_help_bit&0x3)==2)
  68. {
  69. //log_warn("[help-battery] handle_m_help, card_id=%d",m_id);
  70. help_flag=true;
  71. }
  72. m_help_last_time = now;
  73. m_help_bit<<=1;
  74. m_help_bit|=1;
  75. log_info("[help-battery] begin help, card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
  76. }
  77. else
  78. {
  79. // 11111111100000
  80. // ^
  81. // 呼救结束后持续1分钟
  82. if(now - m_help_last_time > 60)
  83. {
  84. m_help_bit = 0;
  85. log_info("[help-battery] end help, card_id=%d, help_bit=%d, status=%d", m_id, m_help_bit, st);
  86. }
  87. }
  88. /*if(!help_flag)
  89. {
  90. st = st & (0xFFFFFFFF ^ STATUS_HELP);
  91. }*/
  92. if((STATUS_POWER_LOWER_SERIOUS & st) != 0)
  93. {
  94. m_pwr_stat = STATUS_POWER_LOWER_SERIOUS;
  95. }
  96. else
  97. {
  98. m_pwr_stat = 0;
  99. }
  100. module_mgr::do_status((STATUS_CARD)st, m_id, m_type);
  101. }
  102. //写入历史轨迹
  103. void card_location_base::make_his_location(uint64_t t,const point & pt,bool bclose /*= false*/)
  104. {
  105. int area_id = 0, map_id = 0, site_id = 0;
  106. double scale = 0.0;
  107. if(auto site_ptr = get_area_tool()->m_site)
  108. {
  109. area_id = site_ptr->m_area_id;
  110. map_id = site_ptr->m_map_id;
  111. site_id = site_ptr->m_id;
  112. scale = site_ptr->m_scale;
  113. }
  114. auto mine_ptr = get_mine_tool();
  115. if(m_time < mine_ptr->get_down_time())
  116. {
  117. return;
  118. }
  119. m_his_location_card->push(t, pt, area_id, map_id, site_id, bclose);
  120. m_his_location_card->insert(t, pt, area_id, map_id, site_id, scale);
  121. }
  122. //坐标点输入业务入口
  123. void card_location_base::on_location(const std::vector<point>&vp, const std::vector<loc_message> &lm, bool is_v_map)
  124. {
  125. m_isVehicleMap = false;
  126. if (is_vehicle())
  127. {
  128. if (!is_v_map)
  129. {
  130. return;
  131. }
  132. }
  133. if (is_person())
  134. {
  135. if (is_v_map)
  136. {
  137. m_isVehicleMap = true;
  138. }
  139. }
  140. loc_point pt = m_sel_tool->select_solution(vp, lm);
  141. //pt.y = pt.y;
  142. auto site_ptr = get_area_tool()->m_site;
  143. int sid = 0;
  144. if(site_ptr)
  145. sid = site_ptr->m_id;
  146. if(pt.m_useless)
  147. {
  148. if (is_person())
  149. {
  150. if (!is_v_map)
  151. {
  152. x = tool_other::round(pt.x, 3);
  153. y = tool_other::round(pt.y, 3);
  154. }
  155. else
  156. {
  157. m_v_point.x = tool_other::round(pt.x, 3);
  158. m_v_point.y = tool_other::round(pt.y, 3);
  159. log_info("useful loc m_v_point: type=%d, card=%d, site=%d, ct=%d, timestamp=%llu, x=%f, y=%f, speed=%.2f, acc=%.2f", m_type, m_id, sid, m_ct, m_time, m_v_point.x, m_v_point.y, m_speed, lm[0].m_acc);
  160. return;
  161. }
  162. }
  163. else if (is_vehicle())
  164. {
  165. if (is_v_map)
  166. {
  167. x = tool_other::round(pt.x, 3);
  168. y = tool_other::round(pt.y, 3);
  169. }
  170. else
  171. {
  172. return;
  173. }
  174. }
  175. double acc = lm[0].m_acc;
  176. m_acc = lm[0].m_acc;
  177. log_info("useful loc point: type=%d, card=%d, site=%d, ct=%d, timestamp=%llu, x=%f, y=%f, speed=%.2f, acc=%.2f",m_type,m_id,sid,m_ct,m_time,x,y, m_speed, acc);
  178. do_business(lm.front().m_sit, pt, acc);
  179. // 呼救128,正常0
  180. int val = (lm[0].m_rav?STATUS_HELP:STATUS_NORMAL);
  181. if(m_battery_value > 3){
  182. val += STATUS_POWER_NORMAL;
  183. }else{
  184. val += STATUS_POWER_LOWER_SERIOUS;
  185. }
  186. log_info("[help-battery] card_id=%d, battery=%d, val=%d", m_id, m_battery_value, val);
  187. do_status(val);
  188. }
  189. else
  190. {
  191. log_warn("坐标不可用:site=%d, type=%d, card=%d, ct=%d, x=%f, y=%f", sid, m_type, m_id, m_ct, pt.x, pt.y);
  192. }
  193. }
  194. void card_location_base::on_message(zloop<task*>* loop, message_locinfo& loc,bool is_history)
  195. {
  196. m_ct = loc.m_card_ct;
  197. m_time = loc.m_time_stamp;
  198. auto site_ptr = sit_list::instance()->get(loc.m_site_id);
  199. if(!site_ptr)
  200. {
  201. log_warn("接收到分站的数据,site=%d,card=%d,ct=%d,但是分站未定义",loc.m_site_id,m_id,loc.m_card_ct);
  202. return;
  203. }
  204. auto area_tool=get_area_tool();
  205. area_tool->set_site(site_ptr);
  206. handle_message(loc.m_card_ct,loc.m_batty_status);
  207. if(site_ptr->is_up_site())
  208. {
  209. log_info("card=%d被井上分站[site=%d]收到",m_id,site_ptr->id());
  210. area_tool->on_point(shared_from_this(),point(1,1));
  211. this->site_hover(loc.m_site_id);
  212. }
  213. else
  214. {
  215. if(site_ptr->is_path_empty())
  216. {
  217. log_warn("接收到分站的数据,site=%d,card=%d,ct=%d,但是分站路径为空",site_ptr->id(),m_id,loc.m_card_ct);
  218. return;
  219. }
  220. m_message_handle->on_message(loop,loc,is_history);
  221. }
  222. }
  223. /*
  224. * tdoa 调用算法库定位
  225. * */
  226. void card_location_base::on_message(zloop<task*>* loop, message_tdoa_locinfo& loc, bool is_history)
  227. {
  228. log_info("[tdoa] start calc location.");
  229. m_ct = loc.m_card_msg.m_sync_num;
  230. auto site_ptr = sit_list::instance()->get(loc.m_site_msg.m_site_id);
  231. if(!site_ptr){
  232. log_warn("[tdoa] 接收到分站的数据:site=%d, card=%d, ct=%d, 但是分站未定义", loc.m_site_msg.m_site_id, m_id, loc.m_card_msg.m_time_stamp);
  233. return;
  234. }
  235. auto area_tool=get_area_tool();
  236. area_tool->set_site(site_ptr);
  237. handle_message(loc.m_card_msg.m_time_stamp, loc.m_card_msg.m_battery_status);
  238. if(site_ptr->is_up_site())
  239. {}
  240. else{
  241. m_message_handle->on_message(loop, loc, is_history);
  242. }
  243. }
  244. /*
  245. * pdoa 调用算法库定位
  246. *
  247. * */
  248. void card_location_base::on_message(zloop<task*>* loop, message_pdoa_locinfo& loc, bool is_history)
  249. {
  250. m_ct = loc.m_card_ct;
  251. m_time = loc.m_time_stamp;
  252. auto site_ptr = sit_list::instance()->get(loc.m_site_id);
  253. if(!site_ptr){
  254. log_warn("[pdoa] 接收到分站的数据:site=%d, card=%d, ct=%d, 但是分站未定义", loc.m_site_id, m_id, loc.m_card_ct);
  255. return;
  256. }
  257. site_ptr->m_loc_time = time(0);
  258. // 基站覆盖距离检测
  259. do_site_coverage(loc);
  260. auto area_tool=get_area_tool();
  261. area_tool->set_site(site_ptr);
  262. m_battery_value = loc.m_batty_status; // 电量值
  263. handle_message(loc.m_card_ct, loc.m_batty_status);
  264. if(site_ptr->is_up_site()){
  265. log_info("card=%d被井上分站[site=%d]收到", m_id, site_ptr->id());
  266. area_tool->on_point(shared_from_this(), point(1,1));
  267. this->site_hover(loc.m_site_id);
  268. m_last_site_id = site_ptr->id();
  269. //m_last_down_stream_idx = site_ptr->m_down_stream_idx;
  270. m_cb_stream_idx.push_back(site_ptr->m_down_stream_idx);
  271. }
  272. else{
  273. char sql[1024] = {0};
  274. snprintf(sql, 1024, "insert into his_distance_reader(card_type, ident, reader_id, dist, dir, cur_time) values(%d, %d, %d, %.2f, %d, '%s')", loc.m_card_type, loc.m_card_id, loc.m_site_id, loc.m_tof*15.65*2.996*1E-4, (tool_other::get_pdoa(loc.m_poa, site_ptr->m_pdoa_offset)>=0?1:-1), tool_time::to_str(time(NULL)).c_str());
  275. db_tool::PushAsync(sql);
  276. log_info("[sql] %s", sql);
  277. do_site_locate_event(loc);
  278. do_card_locate_event(loc);
  279. m_message_handle->on_message(loop, loc, is_history);
  280. }
  281. }
  282. //前端推送位置函数.
  283. void card_location_base::upt_card_pos(sys::_CARD_POS_&cp, point &pt)
  284. {
  285. point _p;
  286. if(pt.empty())
  287. {
  288. _p = *this;
  289. pt = _p;
  290. }
  291. else
  292. _p = pt;
  293. cp.Type = m_type;
  294. cp.ID = m_id;
  295. cp.speed = abs(ceil(m_speed));
  296. cp.x = tool_other::round(_p.x,3);
  297. cp.y = tool_other::round(_p.y,3);
  298. cp.running_stat = m_stat;
  299. cp.dept_id = m_deptid;
  300. cp.display = m_display;
  301. cp.rec_time = m_time;
  302. cp.level_id = m_level_id;
  303. cp.battery_val = m_battery_value;
  304. if(m_pwr_stat > 0){
  305. cp.battery_stat = (m_pwr_stat<3?1:0);
  306. }
  307. cp.m_freq = m_freq;
  308. swsTimerThrd.upt_card_pos(cp);
  309. }
  310. void card_location_base::del_card_pos()
  311. {
  312. sys::_CARD_POS_ cp;
  313. cp.ID = m_id;
  314. cp.Type=m_type;
  315. swsTimerThrd.del_card_pos(cp);
  316. }
  317. int card_location_base::get_stat()
  318. {
  319. //盲区>呼救>呼叫>超时>超速>正常
  320. uint64_t now = time(0)*1000;
  321. uint64_t tlost=now>m_time?now-m_time:m_time-now;
  322. if(tlost>CARD_LOST_TIME_OUT)
  323. {
  324. // 人卡盲区: 当人卡丢失信号大于60s,判定人卡进入盲区
  325. return STATUS_LOST;
  326. }
  327. else if(auto ev_ptr = event_list::instance()->get_event_card(m_id, m_type, ET_CARD_HELP))
  328. {
  329. return (ES_DEAL_HELP == ev_ptr->m_status) ? STATUS_HELP_DEALED : STATUS_HELP;
  330. }
  331. else if(CALL_NONE != get_mine_tool()->m_status_call)
  332. {
  333. return STATUS_CALL;
  334. }
  335. else if(is_person())
  336. {
  337. if(event_list::instance()->get_event_card(m_id, m_type,ET_CARD_AREA_OVER_TIME_PERSON)||
  338. event_list::instance()->get_event_card(m_id, m_type,ET_CARD_OVER_TIME_PERSON))
  339. return STATUS_AREA_OVER_TIME;
  340. }
  341. else if(event_list::instance()->get_event_card(m_id, m_type, ET_CARD_OVER_SPEED))
  342. {
  343. return STATUS_OVER_SPEED;
  344. }
  345. return STATUS_NORMAL;
  346. }
  347. void card_location_base::clear()
  348. {
  349. // uint16_t m_display; //1显示0不显示,往前端推送
  350. m_speed=0; //速度
  351. m_stat=0; //运动静止状态
  352. //m_ct; //ct
  353. m_time=0; //时间戳
  354. //pdoa location info clear
  355. m_buff_size = 0;
  356. m_last_recv_time = 0;
  357. m_last_point = point(0,0);
  358. m_last_site_id = 0;
  359. m_last_site_dir = -1;
  360. m_last_ct = 0;
  361. m_last_dist = 0.0;
  362. m_pdoa_diff = m_last_pdoa_diff = 100.0;
  363. m_last_over_site = false;
  364. m_cache_nums = 0;
  365. m_cb_pdoa.clear();
  366. m_cb_tof.clear();
  367. m_cb_point.clear();
  368. }
  369. void card_location_base::put_three_rates(card_pos & cp)
  370. {
  371. if(!three_rates_flag)
  372. return;
  373. cp.rec_time = m_time;
  374. cp.type = m_type;
  375. cp.id = m_id;
  376. cp.identifier_id= m_cid;
  377. cp.running_stat = m_stat;
  378. cp.final_v = m_speed;
  379. cp.dpt_id = m_deptid;
  380. std::shared_ptr<area_tool> _areatool = get_area_tool();
  381. if(nullptr != _areatool && nullptr != _areatool->m_site)
  382. {
  383. cp.reader_x = _areatool->m_site->x;
  384. cp.reader_y = _areatool->m_site->y;
  385. cp.reader_id = _areatool->m_site->m_id;
  386. }
  387. log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
  388. three_rates::get_instance()->put(cp);
  389. }
  390. void card_location_base::put_traffic_light(card_pos& cp)
  391. {
  392. if(!traffic_light_flag){
  393. return;
  394. }
  395. light_message lm;
  396. lm.m_cmd = cmd_card_data;
  397. lm.m_pos.x = cp.x;
  398. lm.m_pos.y = cp.y;
  399. lm.m_pos.z = cp.z;
  400. lm.m_pos.m_card_id = m_id;
  401. lm.m_pos.m_type = m_type;
  402. lm.m_pos.m_site_id = cp.reader_id;
  403. auto site_ptr = get_area_tool()->m_site;
  404. if(site_ptr){
  405. lm.m_pos.m_area_id = site_ptr->m_area_id;
  406. }
  407. //lm.m_pos.m_bigger = 0;
  408. lm.m_pos.m_speed = m_speed;
  409. log_info("[traffic_light] put locate info into traffic light module, card_id=%d, ctype=%d, x=%.2f, y=%.2f, site_id=%d", m_id, m_type, x, y, cp.reader_id);
  410. traffic_light_manager::instance()->put(lm);
  411. }
  412. bool card_location_base::is_person() const
  413. {
  414. return tool_other::is_person(m_type);
  415. }
  416. bool card_location_base::is_vehicle() const
  417. {
  418. return tool_other::is_vehicle(m_type);
  419. }
  420. void card_location_base::set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id) {
  421. m_cid = cid;
  422. m_type = type;
  423. m_deptid = deptid;
  424. m_level_id = level_id;
  425. m_his_location_card->set_cid(cid);
  426. }
  427. card_location_base::~card_location_base()
  428. {
  429. }
  430. std::shared_ptr<card_location_base> card_location_base::make_person(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,
  431. int32_t deptid,int32_t level_id,uint32_t cid,int wl,const std::string &sname,const std::string & dname,int worktype_id)
  432. {
  433. return std::make_shared<person>(type, cardid, needdisplay, t, deptid, level_id, cid, wl, sname, dname, worktype_id);
  434. }
  435. /*
  436. * @brief 创建车辆对象
  437. * @param const std::string& type
  438. * @param uint32_t cardid 卡id
  439. * @param uint16_t needdisplay 是否需要显示
  440. * @param int16_t t
  441. * @param int32_t deptid 部门id
  442. * @param int32_t categoryid
  443. * @param int type_id 卡类型id
  444. * @param int32_t level_id 职级id
  445. * @param uint32_t cid
  446. * @return 车辆对象
  447. * @note
  448. * @bug
  449. * @warning
  450. * */
  451. std::shared_ptr<card_location_base> card_location_base::make_car(const std::string&type, uint32_t cardid, uint16_t needdisplay, int16_t t,
  452. int32_t deptid, int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
  453. {
  454. return std::make_shared<car>(type, cardid, needdisplay, t, deptid, categoryid, type_id, level_id, cid);
  455. }
  456. /*
  457. * @brief 基站覆盖距离检测
  458. * @param message_pdoa_locinfo& loc 卡数据
  459. * @return 无
  460. * @note
  461. * @bug
  462. * @warning
  463. * */
  464. void card_location_base::do_site_coverage(message_pdoa_locinfo& loc)
  465. {
  466. auto site_ptr = sit_list::instance()->get(loc.m_site_id);
  467. if(!site_ptr){
  468. log_warn("[pdoa] 接收到分站的数据:site=%d, card=%d, ct=%d, 但是分站未定义", loc.m_site_id, m_id, loc.m_card_ct);
  469. return;
  470. }
  471. double pdoa = tool_other::get_pdoa(loc.m_poa, site_ptr->m_pdoa_offset);
  472. double dist = loc.m_tof*15.65*2.996*1e-4;
  473. bool is_update = false;
  474. if(pdoa > 0){
  475. if(dist > site_ptr->m_coverage[0].m_distance){
  476. site_ptr->m_coverage[0].m_distance = dist;
  477. site_ptr->m_coverage[0].m_cid = tool_byte::to_cardid(loc.m_card_type, loc.m_card_id);
  478. site_ptr->m_coverage[0].m_time = time(0);
  479. is_update = true;
  480. }
  481. }else{
  482. if(dist > site_ptr->m_coverage[1].m_distance){
  483. site_ptr->m_coverage[1].m_distance = dist;
  484. site_ptr->m_coverage[1].m_cid = tool_byte::to_cardid(loc.m_card_type, loc.m_card_id);
  485. site_ptr->m_coverage[1].m_time = time(0);
  486. is_update = true;
  487. }
  488. }
  489. if(is_update){
  490. char sql[1024] = {0};
  491. snprintf(sql, 1024, "REPLACE INTO his_reader_coverage(reader_id, plus_dist, plus_card_id, plus_occur_time, minus_dist, minus_card_id, minus_occur_time, last_update) VALUES(%d,%.2f,'%s','%s',%.2f,'%s','%s','%s');", site_ptr->m_id, site_ptr->m_coverage[0].m_distance, site_ptr->m_coverage[0].m_cid.c_str(), tool_time::to_str(site_ptr->m_coverage[0].m_time).c_str(), site_ptr->m_coverage[1].m_distance, site_ptr->m_coverage[1].m_cid.c_str(), tool_time::to_str(site_ptr->m_coverage[1].m_time).c_str(), tool_time::to_str(time(0)).c_str());
  492. db_tool::PushAsync(sql);
  493. logn_info(2, "[sql] %s", sql);
  494. }
  495. }
  496. /*
  497. * @brief 卡定位异常检测
  498. * @param message_pdoa_locinfo& loc 卡数据
  499. * @return 无
  500. * @note
  501. * @bug
  502. * @warning
  503. * */
  504. void card_location_base::do_card_locate_event(const message_pdoa_locinfo& loc)
  505. {
  506. bool status = false;
  507. status = ((loc.m_tof == 0)?true:false);
  508. uint64_t id = tool_other::type_id_to_u64(m_type, m_id);
  509. event_tool::instance()->handle_event(OT_CARD, ET_CARD_LOCATE_ERROR, id, 0, 0, status);
  510. //log_info("[card-locate-event] card_id=%d, ct=%d, tof=%lld", m_id, m_ct, loc.m_tof);
  511. }
  512. /*
  513. * @brief 基站定位异常检测
  514. * @param message_pdoa_locinfo& loc 卡数据
  515. * @return 无
  516. * @note
  517. * @bug
  518. * @warning
  519. * */
  520. void card_location_base::do_site_locate_event(const message_pdoa_locinfo& loc)
  521. {
  522. //log_info("[site-locate-event] cur_ct=%d, ct=%d, m_last_ct=%d, m_last_site_id=%d, loc.m_site_id=%d", loc.m_card_ct, ct, m_last_ct, m_last_site_id, loc.m_site_id);
  523. if(m_last_ct <= 0 || m_last_site_id == 0){
  524. return;
  525. }
  526. if(loc.m_site_id != m_last_site_id){
  527. return;
  528. }
  529. int dt = 0;
  530. if(loc.m_card_ct > m_last_ct){
  531. dt = loc.m_card_ct - m_last_ct;
  532. }else{
  533. dt = 65535 + loc.m_card_ct - m_last_ct;
  534. }
  535. event_tool::instance()->handle_event(OT_DEVICE_READER, ET_READER_LONG_TIME_NO_POSITION, loc.m_site_id, 3, dt, (dt>=3));
  536. log_info("[site-locate-event] site_id=%d, card_id=%d, ct=%d, dt=%d", loc.m_site_id, m_id, loc.m_card_ct, dt);
  537. }