Browse Source

防碰撞系统坐标定位

zengminguo 2 years ago
parent
commit
faff51a518
1 changed files with 37 additions and 8 deletions
  1. 37 8
      card_message_handle.cpp

+ 37 - 8
card_message_handle.cpp

@@ -206,10 +206,11 @@ struct one_ct_message_handle
 
        	//std::string s = concat(loc.m_site_id, loc.m_ant_id);
         //find_msg(loc.m_card_ct);
-        std::shared_ptr<loc_message> _msg = trans_pdoa_msg(loc);
-        if(nullptr != _msg){
+
+        std::shared_ptr<loc_message> _msg_v = trans_pdoa_msg_v(loc);
+        if(nullptr != _msg_v){
             //add_msg(_msg, s, idx);
-            m_msg_list.push_back(*_msg);
+            m_msg_list.push_back(*_msg_v);
             m_min_timeout_pdoa = true;
         }
         
@@ -217,9 +218,25 @@ struct one_ct_message_handle
         // 默认处理
         if(m_min_timeout_pdoa && m_msg_list.size() > 0)
         {
-            calc_pdoa_location();
+            calc_pdoa_location(true);
             m_pdoa_max_timer.stop();
         }
+		m_msg_list.clear();
+
+		std::shared_ptr<loc_message> _msg = trans_pdoa_msg(loc);
+		if (nullptr != _msg) {
+			//add_msg(_msg, s, idx);
+			m_msg_list.push_back(*_msg);
+			m_min_timeout_pdoa = true;
+		}
+
+		log_info("[pdoa] size=%d, m_min_timeout_pdoa=%d", m_msg_list.size(), m_min_timeout_pdoa);
+		// 默认处理
+		if (m_min_timeout_pdoa && m_msg_list.size() > 0)
+		{
+			calc_pdoa_location();
+			m_pdoa_max_timer.stop();
+		}
     }
 
     /* tdoa
@@ -299,7 +316,7 @@ struct one_ct_message_handle
 	}
 
     // pdoa定位,将定位结果传给主服务程序
-    void calc_pdoa_location()
+	void calc_pdoa_location(bool is_v_map = false)
     {
         auto v = m_msg_list;
         if(v.empty()){
@@ -311,7 +328,7 @@ struct one_ct_message_handle
         logn_info(3, "[pdoa] calc_location_pdoa: card_id=%d, size=%d", m_card->m_id, rc.size());
 
         if(!rc.empty()){
-            m_card->on_location(std::move(rc), v);
+			m_card->on_location(std::move(rc), v, is_v_map);
         }
 
         reset();
@@ -497,6 +514,18 @@ struct one_ct_message_handle
         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]));
     }
 
+	// pdoa定位数据,用于车辆定位系统
+	std::shared_ptr<loc_message> trans_pdoa_msg_v(const message_pdoa_locinfo& loc)
+	{
+		// 分站
+		auto s = sit_list_v::instance()->get(loc.m_site_id);
+		if (nullptr == s) {
+			log_info("[pdoa] trans_pdoa_msg_v: 分站信息缺失,site_id=%d", loc.m_site_id);
+			return nullptr;
+		}
+		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]));
+	}
+
     // tdoa 定位数据
     std::shared_ptr<loc_message> trans_tdoa_msg(const message_tdoa_locinfo& loc)
     {
@@ -566,10 +595,10 @@ void card_message_handle::on_message(zloop<task*> * loop,const message_locinfo&l
 		log_warn("%s","当前代码没有处理历史消息记录。");
 		return;
 	}
-	int c_status = STATUS_POWER_NOMARL;
+	int c_status = STATUS_POWER_NORMAL;
 	if(loc.m_batty_status == 2)
 	{
-		c_status ^= STATUS_POWER_NOMARL;
+		c_status ^= STATUS_POWER_NORMAL;
 		c_status  = STATUS_POWER_LOWER_SERIOUS;
 	}