zhuyf 4 anni fa
parent
commit
0a16fcfff0
2 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 8 6
      card_car.cpp
  2. 1 1
      db/db_api/CDBConnect.cpp

+ 8 - 6
card_car.cpp

@@ -65,7 +65,7 @@ void car::handle_anti_coll(const point& pt, const int& sid)
 
     for(auto k : CYaSetting::m_sys_setting.mp_anti_collision){
         log_info("[anti_coll] key=%d, value=%.2f", k.first, k.second);
-        for(auto c : tmp_cards)
+        for(auto& c : tmp_cards)
         {
             if(c.second->m_type == CT_VEHICLE){
                 continue;
@@ -73,17 +73,19 @@ void car::handle_anti_coll(const point& pt, const int& sid)
             bool s = false;
             int d = (c.second->m_timeval >= m_timeval ? (c.second->m_timeval - m_timeval) : (m_timeval - c.second->m_timeval)) / 1000.0;
             s = ((c.second->m_timeval >= m_timeval ? (c.second->m_timeval - m_timeval) : (m_timeval - c.second->m_timeval)) /1000.0 <= 30);
-            log_info("[anti_coll] distance=%.3f, thre_value=%.3f, time_diff=%d", pt.dist(*c.second), k.second, d);
             if(pt.dist(*c.second) < k.second && s){
+                int call_level = 5 - k.first;
+                log_info("[anti_coll] distance=%.3f, level=%d, thre_value=%.3f, time_diff=%d", pt.dist(*c.second), call_level, k.second, d);
+
                 auto it = cards.find(c.second->m_id);
                 if(it != cards.end()){
-                    if(c.second->m_call_level < k.first + 3){
-                        c.second->m_call_level = k.first + 3;
+                    if(c.second->m_call_level > call_level){
+                        c.second->m_call_level = call_level;
                     }
                 }else{
-                    log_info("[anti_coll] card_id=%d, ctype=%d, call_level=%d, call_type_id=%d, site_id=%d",c.second->m_id, c.second->m_type, k.first, CCT_CALL_APOINT, sid);
-                    cards.insert(std::make_pair(c.second->m_id, call_card(c.second->m_id, c.second->m_type, k.first, CCT_CALL_APOINT, sid)));
+                    cards.insert(std::make_pair(c.second->m_id, call_card(c.second->m_id, c.second->m_type, call_level, CCT_CALL_APOINT, sid)));
                 }
+                log_info("[anti_coll] card_id=%d, ctype=%d, call_level=%d, call_type_id=%d, site_id=%d",c.second->m_id, c.second->m_type, call_level, CCT_CALL_APOINT, sid);
             }
         }
     }

+ 1 - 1
db/db_api/CDBConnect.cpp

@@ -40,7 +40,7 @@ namespace YADB
 		}
 
 		//连接数据库
-		if ( !mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), 0, NULL, 0 ) )
+		if ( !mysql_real_connect( __pConn, DBSetting.Host.c_str(), DBSetting.User.c_str(), DBSetting.PWD.c_str(), DBSetting.DBName.c_str(), DBSetting.Port, NULL, 0 ) )
 		{
 			Error = "Failed to connect database,";
 			Error += " LastError=";