Browse Source

lost card reset algo param

researchman 7 years ago
parent
commit
5b28251a0e
5 changed files with 113 additions and 44 deletions
  1. 1 1
      CSVparser/CSVparser.cpp
  2. 1 0
      KNN/KNN.cpp
  3. 0 2
      ProcessRemodule.cpp
  4. 56 8
      YAServerDlg.cpp
  5. 55 33
      classdef.cpp

+ 1 - 1
CSVparser/CSVparser.cpp

@@ -267,4 +267,4 @@ namespace csv {
     }
     return os;
   }
-}
+}

+ 1 - 0
KNN/KNN.cpp

@@ -1,3 +1,4 @@
+//#include "stdafx.h"
 #include<iostream>  
 #include<map>  
 #include<vector>  

+ 0 - 2
ProcessRemodule.cpp

@@ -167,7 +167,6 @@ unsigned __stdcall message_process_entry(void *param)
 	return 0;
 }
 
-
 int send_tcp_thread_message(ParseData* data)
 {
 	//send thread message
@@ -183,7 +182,6 @@ int send_tcp_thread_message(ParseData* data)
 	return 0;
 }
 
-
 int sql_process_thread_init()
 {
 	int i = 0;

+ 56 - 8
YAServerDlg.cpp

@@ -570,8 +570,8 @@ HCURSOR CYAServerDlg::OnQueryDragIcon()
 void CYAServerDlg::OnBnStart()
 {
 	//Test();
-	//ReadFileTest();
-	get_json_count_area();
+	ReadFileTest();
+	//get_json_count_area();
 	if(!is_websocket_login){
 		ws_login();
 	}
@@ -819,6 +819,11 @@ int CYAServerDlg::init_staffer(string staff_id /* = "" */, bool is_card /*= fals
 
 	pRes = pConn->Execute(buf, err);
 
+	if (err > 0)
+	{
+		return 1;
+	}
+
 	std::shared_ptr<Card> pCard = nullptr;
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes))	{
@@ -921,6 +926,11 @@ int CYAServerDlg::init_vehicle(string vehicle_id /* = "" */, bool is_card /*= fa
 	}
 	pRes = pConn->Execute(buf, err);
 
+	if (err > 0)
+	{
+		return 1;
+	}
+
 	std::shared_ptr<Card> pCard = nullptr;
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes)){
@@ -1111,6 +1121,12 @@ int CYAServerDlg::init_area(int area_id /* = 0 */)
 	}
 	pRes = pConn->Execute(strsql, err);
 	std::shared_ptr<Area> pArea = nullptr;
+
+	if (err > 0)
+	{
+		return 0;
+	}
+
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes)){
 		AreaMap::iterator it = mp_area_list.find(atoi(pRow[0]));		
@@ -1166,6 +1182,12 @@ int CYAServerDlg::init_special_area_entry(void)
 		end_point_z, special_area_id FROM dat_special_area_entry;");
 	
 	pRes = pConn->Execute(strsql, err);
+
+	if (err > 0)
+	{
+		return 1;
+	}
+
 	std::shared_ptr<SpecialAreaEntry> pSpecialAreaEntry = nullptr;
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes)){
@@ -1218,6 +1240,11 @@ int CYAServerDlg::init_reader(int reader_id /* = 0 */)
 	}
 	pRes = pConn->Execute(strsql, err);
 
+	if (err > 0)
+	{
+		return 1;
+	}
+
 	std::shared_ptr<Reader> pReader = nullptr;
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes))	{
@@ -1295,6 +1322,11 @@ int CYAServerDlg::init_ctrl_reader( int reader_id /*= 0*/ )
 	}
 	pRes = pConn->Execute(strsql, err);
 
+	if (err > 0)
+	{
+		return 1;
+	}
+
 	std::shared_ptr<Reader> pReader = nullptr;
 	int nRow = 0;
 	while(pRow = mysql_fetch_row(pRes))	{
@@ -1599,6 +1631,17 @@ int CYAServerDlg::init_tdoa_all_readers_coverage(int reader_id)
 
 		int nTotal = get_map_path_nums(start_reader_id,end_reader_id);
 
+		ReaderMap::iterator it_reader = mp_reader_list.find(start_reader_id);
+		if (it_reader == mp_reader_list.end())
+		{
+			continue;
+		}
+		it_reader = mp_reader_list.find(end_reader_id);
+		if (it_reader == mp_reader_list.end())
+		{
+			continue;
+		}
+
 		//ºó׺_r¶¼ÎªÈßÓàÐÅÏ¢
 		std::shared_ptr<ReaderPath> prp = nullptr;
 		std::shared_ptr<ReaderPath> prp_r = nullptr;
@@ -6632,6 +6675,11 @@ int CYAServerDlg::init_alarm_type()
 	MYSQL_RES *pRes = NULL;
 	int err = 0;
 	pRes = pConn->Execute("select event_type_id, name from dat_event_type;", err);
+
+	if(err>0){
+		return 1;
+	}
+
 	while(pRow = mysql_fetch_row(pRes))	{
 		AlarmTypeMap::iterator it = mp_alarm_type_list.find(atoi(pRow[0]));		
 		if(it != mp_alarm_type_list.end()){
@@ -6806,8 +6854,6 @@ void CYAServerDlg::OnCallMessage(string const& name, message::ptr const& data, b
 
 void CYAServerDlg::parse_json_data_set_limit_value( const char* sz )
 {
-	//USES_CONVERSION;
-	//CUTF82C strJson(szJson);
 	Json::Value root;
 	Json::Reader reader;
 	CString strlog;
@@ -9592,10 +9638,10 @@ void CYAServerDlg::ReadFileTest()
 
 	p2 =  LocateAlgorithm::CalcCardPosition(pRdm, mp_reader_path_list_tdoa);
 
-	ReceiveDataMap* pTestRdm = pRdm.get();
-	TDOAReaderPathMap* pTestTrpm = mp_reader_path_list_tdoa.get();
+	//ReceiveDataMap* pTestRdm = pRdm.get();
+	//TDOAReaderPathMap* pTestTrpm = mp_reader_path_list_tdoa.get();
 
-	double x = p->posx / dMapScale;
+	double x = p->posx / dMapScale;	
 	double y = p->posy / dMapScale;
 }
 
@@ -11060,7 +11106,9 @@ void CYAServerDlg::deal_card_lost_state()
 							(card->card_id).c_str(), card->area_id, card->get_speed(), card->x, card->y, card->z);
     				}
 				}	    
-        	}		
+        	}	
+
+			card->reset();
 		}
 	}
 }

+ 55 - 33
classdef.cpp

@@ -143,8 +143,30 @@ Card::Card( void )
 
 void Card::reset()
 {
+	//以下参数与算法相关
 	//坐标初始值为0
 	m_nLastLocateT = 0;
+	time_stamp_last = 0;
+	b_long_interval = false;
+	is_first_location = false;
+	last_locate.x = last_locate.y = last_locate.z = 0;
+	last_locate.sync_num = 0;
+
+	if (m_syncNumList.size() > 0)
+	{
+		m_syncNumList.erase(m_syncNumList.begin(),m_syncNumList.end());
+		m_syncNumList.resize(0);
+	}
+
+	if (vt_his_speed.size()>0)
+	{
+		vt_his_speed.erase(vt_his_speed.begin(),vt_his_speed.end());
+		vt_his_speed.resize(0);
+	}
+
+	//卡尔曼参数重置
+	m_pKalmanFilter->m_nCounts = 0;
+	m_pKalmanFilter->Initial(0.2);
 }
 
 void Card::set_reader(std::shared_ptr<Reader> preader) // 设置卡时间
@@ -520,16 +542,16 @@ void Card::algo_tdoa(int cnt)
 		return;
 	}
 
+	//time_stamp_last特指卡的计数序号,非分站的
 	//当卡需要新定位的计数序列号小于上一次成功定位的序列号,则此次不定位,避免定位结果的回退
-	if (this->time_stamp_last != 0 && this->time_stamp_last > this->time_stamp_cal)
+	if (this->time_stamp_last != 0 && this->time_stamp_last > time_stamp_cal)
 	{
 		string str_last = "";
 		string str_cur  = "";
 
 		str_last = CFunctions::int2string(this->time_stamp_last);
-		str_cur  = CFunctions::int2string(this->time_stamp_cal);
+		str_cur  = CFunctions::int2string(time_stamp_cal);
 
-		//if ((this->time_stamp_last + this->time_stamp_cal)%65535 < 2)//120
 		if (str_last.length() == 5 && str_cur.length() <= 2)
 		{
 			//满足此条件,表示标示卡的计数序号走完了65535的周期
@@ -542,7 +564,7 @@ void Card::algo_tdoa(int cnt)
 			this->z = 0;
 			m_afmData.bStatus = true;
 			m_afmData.strCardId = this->card_id;
-			m_afmData.nCardStamp = this->time_stamp_cal;
+			m_afmData.nCardStamp = maxSyncTimes;
 			m_afmData.nType = ALGO_FAILED_CONDITION_4;
 			ALGORITHM_FAILED(ALGO_FAILED_CONDITION_4);
 			//此处需要输出计数
@@ -728,20 +750,20 @@ void Card::algo_tdoa(int cnt)
 						break;
 					case CT_VEHICLE:
 						LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_159);
-						if(av > VECHILE_ACCELERATE_THRESHOLD){
-							LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_160);
-							//保留上次结果
-							this->x = this->last_locate.x;
-							this->y = this->last_locate.y;
-							this->b_long_interval = false;
-							pRdm->clear();
-
-							m_afmData.bStatus = true;
-							m_afmData.strCardId = this->card_id;
-							m_afmData.nType = ALGO_FAILED_CONDITION_6;
-							ALGORITHM_FAILED(ALGO_FAILED_CONDITION_6);
-							return;
-						}
+						//if(av > VECHILE_ACCELERATE_THRESHOLD){
+						//	LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_160);
+						//	//保留上次结果
+						//	this->x = this->last_locate.x;
+						//	this->y = this->last_locate.y;
+						//	this->b_long_interval = false;
+						//	pRdm->clear();
+
+						//	m_afmData.bStatus = true;
+						//	m_afmData.strCardId = this->card_id;
+						//	m_afmData.nType = ALGO_FAILED_CONDITION_6;
+						//	ALGORITHM_FAILED(ALGO_FAILED_CONDITION_6);
+						//	return;
+						//}
 						break;
 					}
 					deltaT = 0;
@@ -837,19 +859,19 @@ void Card::algo_tdoa(int cnt)
 						break;
 					case CT_VEHICLE:
 						LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_170);
-						if(av > VECHILE_ACCELERATE_THRESHOLD){
-							LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_171);
-							//保留上次结果
-							this->x = this->last_locate.x;
-							this->y = this->last_locate.y;
-							pRdm->clear();
-
-							m_afmData.bStatus = true;
-							m_afmData.strCardId = this->card_id;
-							m_afmData.nType = ALGO_FAILED_CONDITION_6;
-							ALGORITHM_FAILED(ALGO_FAILED_CONDITION_6);
-							return;
-						}
+						//if(av > VECHILE_ACCELERATE_THRESHOLD){
+						//	LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_171);
+						//	//保留上次结果
+						//	this->x = this->last_locate.x;
+						//	this->y = this->last_locate.y;
+						//	pRdm->clear();
+
+						//	m_afmData.bStatus = true;
+						//	m_afmData.strCardId = this->card_id;
+						//	m_afmData.nType = ALGO_FAILED_CONDITION_6;
+						//	ALGORITHM_FAILED(ALGO_FAILED_CONDITION_6);
+						//	return;
+						//}
 						break;
 					}
 					this->last_locate.acceleration = av;
@@ -860,7 +882,7 @@ void Card::algo_tdoa(int cnt)
 					//速度的限制
 					if(fabs(cv) > MAX_VECHILE_SPEED){
 						LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_173);
-						this->x = this->last_locate.x;
+						/*this->x = this->last_locate.x;
 						this->y = this->last_locate.y;
 						pRdm->clear();
 
@@ -868,7 +890,7 @@ void Card::algo_tdoa(int cnt)
 						m_afmData.strCardId = this->card_id;
 						m_afmData.nType = ALGO_FAILED_CONDITION_7;
 						ALGORITHM_FAILED(ALGO_FAILED_CONDITION_7);
-						return;
+						return;*/
 					}
 					
 					//删除第一个元素到tmp(含)之间的所有元素