card_message_handle.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. #include <vector>
  2. #include <ev++.h>
  3. #include "card_base.h"
  4. #include "loc_tool.h"
  5. #include "message.h"
  6. #include "zloop.h"
  7. #include "card_message_handle.h"
  8. #include "loc_common.h"
  9. //一张卡一个ct的所有不同天线的信息,包括tof,tdoa,pdoa等数据处理
  10. struct one_ct_message_handle
  11. {
  12. static loc_tool_main m_loc_tool;
  13. ev::timer m_min_timer, m_max_timer; // 开启两个定时器
  14. ev::timer m_pdoa_min_timer, m_pdoa_max_timer;
  15. ev::timer m_tdoa_min_timer, m_tdoa_max_timer;
  16. std::vector<loc_message> m_msg_list; // 定位消息缓存区,用于tof,pdoa
  17. msg_deque m_msg_deque; // 定位消息缓存区,用于tdoa, pdoa(主要是存在一个数据包内多个ct的卡数据)
  18. card_location_base* m_card;
  19. const algo_config* m_ac = nullptr; // 配置文件参数
  20. int m_ct;
  21. bool m_min_timeout = false;
  22. bool m_min_timeout_pdoa = false;
  23. bool m_min_timeout_tdoa = false;
  24. ev::dynamic_loop * m_loop = nullptr;
  25. one_ct_message_handle(card_location_base* card)
  26. {
  27. m_card = card;
  28. m_ct = -1;
  29. }
  30. void reset()
  31. {
  32. m_ct = -1;
  33. m_min_timeout = false;
  34. m_min_timeout_pdoa = false;
  35. m_min_timeout_tdoa = false;
  36. m_msg_list.clear();
  37. }
  38. void on_min_timer()
  39. {
  40. m_min_timer.stop();
  41. if((int)m_msg_list.size()>=m_ac->best_msg_cnt)
  42. {
  43. m_max_timer.stop();
  44. calc_location();
  45. return;
  46. }
  47. m_min_timeout=true;
  48. }
  49. void on_max_timer()
  50. {
  51. m_max_timer.stop();
  52. calc_location();
  53. }
  54. void on_pdoa_min_timer()
  55. {
  56. m_pdoa_min_timer.stop();
  57. if((int)(m_msg_list.size()) >= 2){
  58. m_pdoa_max_timer.stop();
  59. calc_pdoa_location();
  60. return;
  61. }
  62. m_min_timeout_pdoa = true;
  63. }
  64. void on_pdoa_max_timer()
  65. {
  66. m_pdoa_max_timer.stop();
  67. calc_pdoa_location();
  68. }
  69. void on_tdoa_min_timer()
  70. {
  71. m_tdoa_min_timer.stop();
  72. if((int)(m_msg_list.size()) >= 2){
  73. m_tdoa_max_timer.stop();
  74. calc_tdoa_location();
  75. return;
  76. }
  77. m_min_timeout_tdoa = true;
  78. }
  79. void on_tdoa_max_timer()
  80. {
  81. m_tdoa_max_timer.stop();
  82. calc_tdoa_location();
  83. }
  84. void set(ev::dynamic_loop * loop)
  85. {
  86. m_loop = loop;
  87. // tof
  88. m_min_timer.set(*m_loop);
  89. m_min_timer.set<one_ct_message_handle,&one_ct_message_handle::on_min_timer>(this);
  90. m_max_timer.set(*m_loop);
  91. m_max_timer.set<one_ct_message_handle,&one_ct_message_handle::on_max_timer>(this);
  92. // pdoa
  93. m_pdoa_min_timer.set(*m_loop);
  94. m_pdoa_min_timer.set<one_ct_message_handle, &one_ct_message_handle::on_pdoa_min_timer>(this);
  95. m_pdoa_max_timer.set(*m_loop);
  96. m_pdoa_max_timer.set<one_ct_message_handle, &one_ct_message_handle::on_pdoa_max_timer>(this);
  97. // tdoa
  98. m_tdoa_min_timer.set(*m_loop);
  99. m_tdoa_min_timer.set<one_ct_message_handle, &one_ct_message_handle::on_tdoa_min_timer>(this);
  100. m_tdoa_max_timer.set(*m_loop);
  101. m_tdoa_max_timer.set<one_ct_message_handle, &one_ct_message_handle::on_tdoa_max_timer>(this);
  102. }
  103. void on_message(ev::dynamic_loop *loop,const message_locinfo&loc)
  104. {
  105. if(m_loop == nullptr && loop!=nullptr)
  106. set(loop);
  107. else if(loop == nullptr)
  108. return;
  109. // 如果消息队列非空,且ct切换,清空消息队列
  110. if(!m_msg_list.empty()&& m_ct!=loc.m_card_ct)
  111. {
  112. m_msg_list.clear();
  113. }
  114. auto s = sit_list::instance()->get(loc.m_site_id);
  115. if(nullptr == s)
  116. {
  117. log_warn("分站信息缺失, site_id=%d", loc.m_site_id);
  118. return;
  119. }
  120. // 如果定位数据缓存区为空,则保存定位数据
  121. if(m_msg_list.empty())
  122. {
  123. m_ct=loc.m_card_ct;
  124. m_ac=&s->config();
  125. m_min_timeout=false;
  126. //这里构造loc_message 保存数据
  127. m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
  128. loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
  129. loc.m_sync_ct,loc.m_rssi,loc.m_batty_status));
  130. //启动本CT的最小、最大两个定时器
  131. m_min_timer.start(m_ac->min_wait_time);
  132. m_max_timer.start(m_ac->max_wait_time);
  133. return;
  134. }
  135. m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
  136. loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
  137. loc.m_sync_ct,loc.m_rssi,loc.m_batty_status));
  138. // 满足数据条数,计算定位坐标
  139. if(m_min_timeout && (int)m_msg_list.size() >= m_ac->best_msg_cnt)
  140. {
  141. calc_location();
  142. m_max_timer.stop();
  143. }
  144. }
  145. /* pdoa
  146. * 主要实现两功能:
  147. * 1.将数据放入数据缓冲区;
  148. * 2.根据条件判断是否取出数据进行定位
  149. * */
  150. void on_message(ev::dynamic_loop* loop, const message_pdoa_locinfo& loc)
  151. {
  152. if(nullptr == m_loop && loop != nullptr)
  153. {
  154. set(loop);
  155. }
  156. else if(nullptr == loop)
  157. {
  158. return;
  159. }
  160. // 如果消息队列非空,且ct切换,清空消息队列
  161. auto site_ptr = sit_list::instance()->get(loc.m_site_id);
  162. if(nullptr == site_ptr)
  163. {
  164. log_warn("[pdoa] 分站信息缺失,site_id=%d", loc.m_site_id);
  165. return;
  166. }
  167. if(m_ct == loc.m_card_ct){
  168. return;
  169. }
  170. if(m_msg_list.empty()){
  171. m_ac = &site_ptr->config();
  172. m_min_timeout_pdoa = false;
  173. m_ct = loc.m_card_ct;
  174. //启动本CT的最小、最大两个定时器
  175. m_pdoa_min_timer.start(m_ac->min_wait_time);
  176. m_pdoa_max_timer.start(m_ac->max_wait_time);
  177. }
  178. //std::string s = concat(loc.m_site_id, loc.m_ant_id);
  179. //find_msg(loc.m_card_ct);
  180. std::shared_ptr<loc_message> _msg_v = trans_pdoa_msg_v(loc);
  181. if(nullptr != _msg_v){
  182. //add_msg(_msg, s, idx);
  183. m_msg_list.push_back(*_msg_v);
  184. m_min_timeout_pdoa = true;
  185. }
  186. log_info("[pdoa] size=%d, m_min_timeout_pdoa=%d", m_msg_list.size(), m_min_timeout_pdoa);
  187. // 默认处理
  188. if(m_min_timeout_pdoa && m_msg_list.size() > 0)
  189. {
  190. calc_pdoa_location(true);
  191. m_pdoa_max_timer.stop();
  192. }
  193. m_msg_list.clear();
  194. std::shared_ptr<loc_message> _msg = trans_pdoa_msg(loc);
  195. if (nullptr != _msg) {
  196. //add_msg(_msg, s, idx);
  197. m_msg_list.push_back(*_msg);
  198. m_min_timeout_pdoa = true;
  199. }
  200. log_info("[pdoa] size=%d, m_min_timeout_pdoa=%d", m_msg_list.size(), m_min_timeout_pdoa);
  201. // 默认处理
  202. if (m_min_timeout_pdoa && m_msg_list.size() > 0)
  203. {
  204. calc_pdoa_location();
  205. m_pdoa_max_timer.stop();
  206. }
  207. }
  208. /* tdoa
  209. * 主要实现两个功能:
  210. * 1.将数据放入数据缓冲区;
  211. * 2.根据条件判断是否取出数据进行定位;
  212. * */
  213. void on_message(ev::dynamic_loop* loop, const message_tdoa_locinfo& loc)
  214. {
  215. if(nullptr == m_loop && loop != nullptr)
  216. {
  217. set(loop);
  218. }
  219. else if(nullptr == loop)
  220. {
  221. return;
  222. }
  223. // 如果消息队列非空,且ct切换,清空消息队列
  224. auto site_ptr = sit_list::instance()->get(loc.m_site_msg.m_site_id);
  225. if(nullptr == site_ptr)
  226. {
  227. log_warn("[tdoa] 分站信息缺失,site_id=%d", loc.m_site_msg.m_site_id);
  228. return;
  229. }
  230. if(m_msg_list.empty()){
  231. m_ac = &site_ptr->config();
  232. m_min_timeout_tdoa = false;
  233. //启动本CT的最小、最大两个定时器
  234. m_tdoa_min_timer.start(m_ac->min_wait_time);
  235. m_tdoa_max_timer.start(m_ac->max_wait_time);
  236. }
  237. std::string s = concat(loc.m_site_msg.m_site_id, loc.m_card_msg.m_ant_id);
  238. //把信息放入定位的缓冲区,否则放入队列内
  239. int idx = find_msg(loc.m_card_msg.m_time_stamp);
  240. std::shared_ptr<loc_message> _msg = trans_tdoa_msg(loc);
  241. if(nullptr != _msg){
  242. add_msg(_msg, s, idx);
  243. }
  244. // tdoa默认处理2维
  245. if(m_min_timeout_tdoa && m_msg_list.size() >= 3){
  246. calc_tdoa_location();
  247. m_tdoa_max_timer.stop();
  248. }
  249. }
  250. // tof定位
  251. void calc_location()
  252. {
  253. auto v = m_msg_list;
  254. if(v.empty())
  255. {
  256. return;
  257. }
  258. log_info("calc_location_begin:card_id=%d,ct=%d,m_ct=%d", m_card->m_id, v[0].m_card_ct, m_ct);
  259. std::vector<point> rc = std::move(m_loc_tool.calc_location(v));
  260. log_info("calc_location:%d size:%d",m_card->m_id,rc.size());
  261. #if 0
  262. for(const auto &_p:rc)
  263. log_info("calc_location:%d (%.2f,%.2f)",m_card->m_id,_p.x,_p.y);
  264. #endif
  265. if(!rc.empty())
  266. {
  267. m_card->on_location(std::move(rc), v);
  268. }
  269. reset();
  270. log_info("calc_location_end:card_id=%d",m_card->m_id);
  271. }
  272. // pdoa定位,将定位结果传给主服务程序
  273. void calc_pdoa_location(bool is_v_map = false)
  274. {
  275. auto v = m_msg_list;
  276. if(v.empty()){
  277. return;
  278. }
  279. logn_info(3, "[pdoa] calc_location_pdoa_begin: card_id=%d, ct=%d, m_ct=%d", m_card->m_id, v[0].m_card_ct, m_ct);
  280. std::vector<point> rc = std::move(m_loc_tool.calc_location(v));
  281. logn_info(3, "[pdoa] calc_location_pdoa: card_id=%d, size=%d", m_card->m_id, rc.size());
  282. if(!rc.empty()){
  283. m_card->on_location(std::move(rc), v, is_v_map);
  284. }
  285. reset();
  286. }
  287. void calc_location_extend()
  288. {
  289. /*int dim = get_dimension();
  290. switch(dim){
  291. case _1D:
  292. break;
  293. case _2D:
  294. {
  295. if(LDT_TDOA == m_card->m_loc_type){
  296. }else if(LDT_PDOA == m_card->m_loc_type)
  297. {
  298. //m_loc_tool.set_tool()
  299. }else if(LDT_TOF == m_card->m_loc_type)
  300. {
  301. }
  302. }
  303. break;
  304. case _3D:
  305. {
  306. if(LDT_TDOA == m_card->m_loc_type){
  307. }else if(LDT_PDOA == m_card->m_loc_type)
  308. {
  309. }else if(LDT_TOF == m_card->m_loc_type)
  310. {
  311. }
  312. }
  313. break;
  314. }*/
  315. }
  316. int get_dimension()
  317. {
  318. split_data();
  319. /*if(vt_msg_3d.size() > _3D){
  320. // 构造
  321. return _3D;
  322. }else if(vt_msg_2d.size() > _2D){
  323. return _2D;
  324. }else if(vt_msg_1d.size() > _1D){
  325. return _1D;
  326. }*/
  327. return 0;
  328. }
  329. int split_data()
  330. {
  331. /*if(mp_msg_3d.size() > 0){
  332. mp_msg_3d.erase(mp_msg_3d.begin(), mp_msg_3d.end());
  333. }
  334. if(mp_msg_2d.size() > 0){
  335. mp_msg_2d.erase(mp_msg_2d.begin(), mp_msg_2d.end());
  336. }
  337. if(mp_msg_1d.size() > 0){
  338. mp_msg_1d.erase(mp_msg_1d.begin(), mp_msg_1d.end());
  339. }
  340. for(auto it : mp_msg_.front().m_msg_map)
  341. {
  342. switch(it.second->m_loc_dimension){
  343. case _1D:
  344. mp_msg_1d.insert(std::make_pair(it.first, it.second));
  345. break;
  346. case _2D:
  347. mp_msg_2d.insert(std::make_pair(it.first, it.second));
  348. break;
  349. case _3D:
  350. mp_msg_3d.insert(std::make_pair(it.first, it.second));
  351. break;
  352. }
  353. }*/
  354. return 0;
  355. }
  356. // tdoa定位
  357. void calc_tdoa_location()
  358. {
  359. auto v = m_msg_list;
  360. if(v.empty()){
  361. return;
  362. }
  363. log_info("[tdoa] calc_location_tdoa_begin: card_id=%d, ct=%d, m_ct=%d", m_card->m_id, v[0].m_card_ct, m_ct);
  364. std::vector<point> rc = std::move(m_loc_tool.calc_location(v));
  365. log_info("[tdoa] calc_location_tdoa: card_id=%d, size=%d", m_card->m_id, rc.size());
  366. if(!rc.empty()){
  367. m_card->on_location(std::move(rc), v);
  368. }
  369. reset();
  370. log_info("[tdoa] calc_location_tdoa_end: card_id=%d", m_card->m_id);
  371. }
  372. /*
  373. * 将数据放入队列中
  374. * */
  375. void add_msg(const std::shared_ptr<loc_message>& msg, const std::string& s, const int& idx)
  376. {
  377. if(-1 != idx){
  378. m_msg_deque[idx].m_msg_map[s] = msg;
  379. }else{
  380. int ct_delay = ceil(3 / (10*m_card->m_freq));
  381. ct_delay = (ct_delay > 1)?ct_delay:1;
  382. uint8_t _count_del = 0;
  383. while(true){
  384. bool tag = false;
  385. for(auto it = m_msg_deque.begin(); it != m_msg_deque.end();){
  386. bool is_over = false;
  387. if(1000 > msg->m_card_ct && 64536 < (*it).m_card_stamp){
  388. // 说明it为历史数据,需丢弃
  389. is_over = true;
  390. }
  391. if((!is_over && ((*it).m_card_stamp < msg->m_card_ct - ct_delay)) || (is_over && ((*it).m_card_stamp < 65536 + msg->m_card_ct - ct_delay)))
  392. {
  393. if((*it).m_msg_map.size() < 3){
  394. it = m_msg_deque.erase(it);
  395. }else{
  396. tag = true;
  397. break;
  398. }
  399. }else if((!is_over && ((*it).m_card_stamp > msg->m_card_ct + ct_delay)) || (is_over && ((*it).m_card_stamp > (65536 + msg->m_card_ct - ct_delay))))
  400. {
  401. if(is_over){
  402. if((*it).m_msg_map.size() < 3){
  403. it = m_msg_deque.erase(it);
  404. }else{
  405. tag = true;
  406. break;
  407. }
  408. }else{
  409. if(20 < ++_count_del){
  410. it = m_msg_deque.erase(it);
  411. }else{
  412. break;
  413. }
  414. }
  415. }else{
  416. ++it;
  417. }
  418. }
  419. if(tag){
  420. //1.计算
  421. for(auto item : m_msg_deque.front().m_msg_map){
  422. m_msg_list.push_back(*(item.second));
  423. }
  424. //2.删除数据
  425. m_msg_deque.pop_front();
  426. m_msg_list.erase(m_msg_list.begin(), m_msg_list.end());
  427. tag = false;
  428. }else{
  429. break;
  430. }
  431. }
  432. message_item mi;
  433. mi.m_card_stamp = msg->m_card_ct;
  434. mi.m_msg_map[s] = msg;
  435. m_msg_deque.push_back(mi);
  436. }
  437. }
  438. // pdoa定位数据
  439. std::shared_ptr<loc_message> trans_pdoa_msg(const message_pdoa_locinfo& loc)
  440. {
  441. // 分站
  442. auto s = sit_list::instance()->get(loc.m_site_id);
  443. if(nullptr == s){
  444. log_info("[pdoa] trans_pdoa_msg: 分站信息缺失,site_id=%d", loc.m_site_id);
  445. return nullptr;
  446. }
  447. return std::move(std::make_shared<loc_message>(s, loc.m_tof, loc.m_time_stamp, loc.m_card_id, loc.m_card_ct, loc.m_card_type, loc.m_ant_id, loc.m_rav, loc.m_acc, 0, loc.m_rssi, loc.m_batty_status, loc.m_loc_type, loc.m_loc_dimension, loc.m_poa[0], loc.m_poa[1], loc.m_poa[2]));
  448. }
  449. // pdoa定位数据,用于车辆定位系统
  450. std::shared_ptr<loc_message> trans_pdoa_msg_v(const message_pdoa_locinfo& loc)
  451. {
  452. // 分站
  453. auto s = sit_list_v::instance()->get(loc.m_site_id);
  454. if (nullptr == s) {
  455. log_info("[pdoa] trans_pdoa_msg_v: 分站信息缺失,site_id=%d", loc.m_site_id);
  456. return nullptr;
  457. }
  458. return std::move(std::make_shared<loc_message>(s, loc.m_tof, loc.m_time_stamp, loc.m_card_id, loc.m_card_ct, loc.m_card_type, loc.m_ant_id, loc.m_rav, loc.m_acc, 0, loc.m_rssi, loc.m_batty_status, loc.m_loc_type, loc.m_loc_dimension, loc.m_poa[0], loc.m_poa[1], loc.m_poa[2]));
  459. }
  460. // tdoa 定位数据
  461. std::shared_ptr<loc_message> trans_tdoa_msg(const message_tdoa_locinfo& loc)
  462. {
  463. // 分站
  464. auto s = sit_list::instance()->get(loc.m_site_msg.m_site_id);
  465. if(nullptr == s){
  466. log_info("[pdoa] trans_tdoa_msg: 分站信息缺失,site_id=%d", loc.m_site_msg.m_site_id);
  467. return nullptr;
  468. }
  469. return std::move(std::make_shared<loc_message>(s, loc.m_card_msg.m_loc_stamp, loc.m_card_msg.m_time_stamp, loc.m_card_msg.m_id, loc.m_card_msg.m_time_stamp, loc.m_card_msg.m_type, loc.m_card_msg.m_ant_id, loc.m_card_msg.m_rav, loc.m_card_msg.m_acc, loc.m_card_msg.m_sync_num, loc.m_card_msg.m_rssi, loc.m_card_msg.m_battery_status, loc.m_interpolation, loc.m_loc_type, loc.m_loc_dimension, m_card->m_freq));
  470. }
  471. // 分站+天线
  472. std::string concat(const int& lhs, const int& rhs)
  473. {
  474. char msg[10] = {0};
  475. snprintf(msg, 10, "%d-%d", lhs, rhs);
  476. return std::move(std::string(msg));
  477. }
  478. /*
  479. * 根据卡的ct号查找数据
  480. *
  481. * 参数
  482. * stamp 卡的ct号
  483. *
  484. * */
  485. int find_msg(const uint16_t& stamp)
  486. {
  487. int idx = -1;
  488. for(int i = m_msg_deque.size() - 1; i > 0; --i){
  489. if(m_msg_deque[i].m_card_stamp == stamp){
  490. idx = i;
  491. break;
  492. }
  493. }
  494. return idx;
  495. }
  496. };
  497. loc_tool_main one_ct_message_handle::m_loc_tool;
  498. card_message_handle::card_message_handle(card_location_base*card)
  499. {
  500. m_card = card;
  501. for(size_t i = 0;i < m_ct_list.size();i++)
  502. {
  503. m_ct_list[i] = new one_ct_message_handle(card);
  504. }
  505. }
  506. card_message_handle::~card_message_handle()
  507. {
  508. for(auto&it:m_ct_list)
  509. {
  510. delete it;
  511. }
  512. }
  513. void card_message_handle::on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
  514. {
  515. if(is_history)
  516. {
  517. log_warn("%s","当前代码没有处理历史消息记录。");
  518. return;
  519. }
  520. int c_status = STATUS_POWER_NORMAL;
  521. if(loc.m_batty_status == 2)
  522. {
  523. c_status ^= STATUS_POWER_NORMAL;
  524. c_status = STATUS_POWER_LOWER_SERIOUS;
  525. }
  526. if(loc.m_callinfo & 0x80)
  527. {
  528. c_status |= STATUS_HELP;
  529. }
  530. if((loc.m_callinfo & 0x01) || (loc.m_callinfo & 0x02))
  531. {
  532. c_status |= STATUS_CALL;
  533. }
  534. m_card->do_status(c_status);
  535. m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loop,loc);
  536. }
  537. /*
  538. * 算法模块
  539. * 1.第一步处理;
  540. * 2.根据主服务程序传入的数据使用算法模块进行tdoa定位
  541. * */
  542. void card_message_handle::on_message(zloop<task*>* loop, const message_tdoa_locinfo& loc, bool is_history)
  543. {
  544. if(is_history)
  545. {
  546. log_warn("%s","当前代码没有处理历史数据!");
  547. return;
  548. }
  549. int c_status = STATUS_POWER_LOWER_SERIOUS;
  550. if(loc.m_card_msg.m_call_info & 0x80)
  551. {
  552. c_status |= STATUS_HELP;
  553. }
  554. if((loc.m_card_msg.m_call_info & 0x01) || (loc.m_card_msg.m_call_info& 0x02))
  555. {
  556. c_status |= STATUS_CALL;
  557. }
  558. //处理卡呼叫/呼救业务
  559. m_card->do_status(c_status);
  560. m_ct_list[loc.m_card_msg.m_sync_num & (m_ct_list.size()-1)]->on_message(loop, loc);
  561. }
  562. /*
  563. * 算法模块
  564. * 1.第一步处理;
  565. * 2.根据主服务程序传入的数据使用算法模块进行pdoa定位
  566. * */
  567. void card_message_handle::on_message(zloop<task*>* loop, const message_pdoa_locinfo& loc, bool is_history)
  568. {
  569. if(is_history)
  570. {
  571. log_warn("%s","当前代码没有处理历史数据!");
  572. return;
  573. }
  574. int c_status = STATUS_POWER_LOWER_SERIOUS;
  575. if(loc.m_callinfo & 0x80)
  576. {
  577. c_status |= STATUS_HELP;
  578. }
  579. if((loc.m_callinfo & 0x01) || (loc.m_callinfo& 0x02))
  580. {
  581. c_status |= STATUS_CALL;
  582. }
  583. //处理卡呼叫/呼救业务
  584. m_card->do_status(c_status);
  585. //根据取模结果调用响应的子模块处理
  586. m_ct_list[loc.m_card_ct & (m_ct_list.size()-1)]->on_message(loop, loc);
  587. }