Browse Source

fix merging

researchman 7 years ago
parent
commit
6f08cc4d4f
4 changed files with 77 additions and 40 deletions
  1. 1 0
      KNN/KNN.cpp
  2. 69 38
      YAServerDlg.cpp
  3. 1 1
      YAServerDlg.h
  4. 6 1
      classdef.cpp

+ 1 - 0
KNN/KNN.cpp

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

+ 69 - 38
YAServerDlg.cpp

@@ -8847,7 +8847,7 @@ void CYAServerDlg::load_his_card_postion()
 			it->second->state = atoi(pRow[7]);
 			it->second->set_speed(atof(pRow[8]));
 			it->second->mileage = atof(pRow[9]);
-			
+
 			enter_time = pRow[10];
 			CFunctions::string2systemtime(enter_time,it->second->enter_area_time);
 			start_time = pRow[11];
@@ -9930,30 +9930,30 @@ int CYAServerDlg::getTunelProperty(std::shared_ptr<Card> pCard)
 	return nProperty;
 }
 
-void CYAServerDlg::AnalysisAlgoFailedData(/*std::shared_ptr<Card> pCard*/)
+void CYAServerDlg::AnalysisAlgoFailedData(int interval  /*=60000*//*std::shared_ptr<Card> pCard*/)
 {
 	std::string strLog = "";
 
 	//单条定位信息状态的输出
 	/*for (int i = 1;i<ALGO_LOC_TOTAL;i++)
 	{
-		if (pCard->m_afmData.nType == i)
-		{
-			char log[100] = {0};
-			sprintf_s(log,100,"algoLocType: %d , cardid:%s , cardstamp: %d ;",pCard->m_afmData.nType,pCard->m_afmData.strCardId.c_str(),pCard->m_afmData.nCardStamp);
-			strLog+=log;
-		}
+	if (pCard->m_afmData.nType == i)
+	{
+	char log[100] = {0};
+	sprintf_s(log,100,"algoLocType: %d , cardid:%s , cardstamp: %d ;",pCard->m_afmData.nType,pCard->m_afmData.strCardId.c_str(),pCard->m_afmData.nCardStamp);
+	strLog+=log;
+	}
 	}
 	if (strLog != "" && m_log_locate_data)
 	{
-		CString cstrLog = _T(""); 
-		cstrLog = strLog.c_str();
-		writeErrorLog(_T("ALGO_F"), cstrLog, false);
+	CString cstrLog = _T(""); 
+	cstrLog = strLog.c_str();
+	writeErrorLog(_T("ALGO_F"), cstrLog, false);
 	}*/
 
 	//存储数据到数据库中
 	ULONGLONG cur_time = ::GetTickCount();
-	if (cur_time - g_ullCurTime > 6000)
+	if (cur_time - g_ullCurTime > interval)
 	{
 		SYSTEMTIME st;
 		GetLocalTime(&st);
@@ -10079,6 +10079,9 @@ void CYAServerDlg::ReadFileTest()
 	char pch[200] = {0};
 	double dMapScale = 2;
 
+	std::shared_ptr<Card> card = std::make_shared<Card>("",0, 0, theApp.z_offset);
+	card->set_reader_path_tdoa(mp_reader_path_list_tdoa);
+
 	while (!in.eof())
 	{
 		in.getline(pch,200);
@@ -10086,27 +10089,35 @@ void CYAServerDlg::ReadFileTest()
 		stringstream sout;
 
 		std::vector<std::string> metaDatas = CFunctions::split(data,",",true);
-		std::shared_ptr<ReceiveData> prd = std::make_shared<ReceiveData>();
+		//std::shared_ptr<ReceiveData> prd = std::make_shared<ReceiveData>();
+
+		std::shared_ptr<_coordinate> dist = std::make_shared<_coordinate>();
 		for (int i=0;i<metaDatas.size();i++)
 		{	
 			std::string meta = metaDatas[i];
 
 			std::vector<std::string> vtMeta = CFunctions::split(meta,":",true);
 			std::vector<std::string> vtReader;
+
 			switch(i){
 			case 0:
-				//分站信息
-				vtReader = CFunctions::split(vtMeta[1],"-",true);
-				prd->reader_id = atoi(vtReader[0].c_str());
-				//设置天线id为1
-				prd->antenna_id = atoi(vtReader[1].c_str());
-				//如果分站号为101,218,is_special为1
-				if (prd->reader_id == 101 || prd->reader_id == 218)
 				{
-					prd->special = 1;
+					int len = vtMeta.size() - 1;
+					//分站信息
+					vtReader = CFunctions::split(vtMeta[len],"-",true);
+					dist->reader_id = atoi(vtReader[0].c_str());
+					//如果分站号为101,218,is_special为1
+					if (dist->reader_id == 108 || dist->reader_id == 218 || dist->reader_id == 107 || dist->reader_id==320)
+					{
+						dist->special = 1;
+					}
+					
+					dist->syncRootId = 0;
+					dist->antenna_id = 1;
 				}
 				break;
 			case 1:
+				dist->sync_num = atoi(vtMeta[1].c_str());
 				break;
 			case 2:
 				break;
@@ -10115,23 +10126,24 @@ void CYAServerDlg::ReadFileTest()
 			case 4:
 				//时间戳值
 				sout<<vtMeta[1];
-				sout>>prd->rec_time_stamp;
+				sout>> dist->tt;
 				break;
 			case 5:
 				break;
 			case 6:
 				//x
-				prd->x = atof(vtMeta[1].c_str())*dMapScale;
+				dist->x = atof(vtMeta[1].c_str())*dMapScale;
 				break;
 			case 7:
 				//y
-				prd->y = atof(vtMeta[1].c_str())*dMapScale;
+				dist->y = atof(vtMeta[1].c_str())*dMapScale;
 				break;
 			case 8:
 				//z
-				prd->z = atof(vtMeta[1].c_str())*dMapScale;
+				dist->z = atof(vtMeta[1].c_str())*dMapScale;
 				break;
 			case 9:
+				dist->t =  atoi(vtMeta[1].c_str());
 				break;
 			case 10:
 				//卡号
@@ -10140,31 +10152,50 @@ void CYAServerDlg::ReadFileTest()
 				break;
 			}
 		}
-		if (prd->rec_time_stamp)
+		dist->acce_state = card->accelerate_state;
+		dist->acce_state_last = card->accelerate_state_last;
+		dist->ins_direction = card->ins_direction;
+
+		card->add_dist(dist);
+
+		if (card->m_afmData.bStatus)
 		{
-			pRdm->insert(ReceiveDataMap::value_type(prd->rec_time_stamp,prd));
+			AnalysisAlgoFailedData(5);
+			card->m_afmData.bStatus = false;
+		}
+
+		if(card->x != card->last_x || card->y != card->last_y){
+			CString strLog = _T("");
+			strLog.Format(_T("cx: %f, cy: %f, cz: %f, clx: %f, cly: %f, v: %f, ct: %d"),
+				card->x/dMapScale, card->y/dMapScale, card->z, card->last_x/dMapScale, card->last_y/dMapScale, card->get_speed(), card->time_stamp_cal);
+			writeErrorLog(_T("DISTXX_S"), strLog, false);
+			strLog.Empty();
+
+			card->last_x = card->x;
+			card->last_y = card->y;
+			card->last_z = card->z;
 		}
-		//pRdm->insert(ReceiveDataMap::value_type(prd->rec_time_stamp,prd));
 	}
 	in.close();
 
-	std::unique_ptr<POS> p;
-	std::unique_ptr<POS> p2;
-	std::shared_ptr<POS> p2d;
+	//std::unique_ptr<POS> p;
+	//std::unique_ptr<POS> p2;
+	//std::shared_ptr<POS> p2d;
 
-	p2d = LocateAlgorithm::TdoaLocate2d(pRdm);
+	//p2d = LocateAlgorithm::TdoaLocate2d(pRdm);
 
-	//p = LocateAlgorithm::LocatePos(pRdm,mp_reader_path_list_tdoa);
+	////p = LocateAlgorithm::LocatePos(pRdm,mp_reader_path_list_tdoa);
 
-	p = LocateAlgorithm::Pos(pRdm,mp_reader_path_list_tdoa);
+	//p = LocateAlgorithm::Pos(pRdm,mp_reader_path_list_tdoa);
 
-	p2 =  LocateAlgorithm::CalcCardPosition(pRdm, mp_reader_path_list_tdoa);
+	//p2 =  LocateAlgorithm::CalcCardPosition(pRdm, mp_reader_path_list_tdoa);
 
 	//ReceiveDataMap* pTestRdm = pRdm.get();
 	//TDOAReaderPathMap* pTestTrpm = mp_reader_path_list_tdoa.get();
 
-	double x = p->posx / dMapScale;	
-	double y = p->posy / dMapScale;
+	//double x = p->posx / dMapScale;	
+	//double y = p->posy / dMapScale;
+
 }
 
 /*
@@ -10419,7 +10450,7 @@ void CYAServerDlg::deal_card_msg( std::shared_ptr<Card> card/*Card* card*/, bool
 
 			/*if (card->card_id != "0020000001047")
 			{
-				return;
+			return;
 			}*/
 
 			unsigned short root_sync_num = dist->syncRootId;

+ 1 - 1
YAServerDlg.h

@@ -480,7 +480,7 @@ public:
 	bool is_has_chamber(int section_id);	//路段内存在可用的硐室
 	bool isInMainTunel(std::shared_ptr<Card> pCard);		//此卡是否在主巷道
 	int getTunelProperty(std::shared_ptr<Card> pCard);		//获得卡的巷道值
-	void AnalysisAlgoFailedData(/*std::shared_ptr<Card> pCard*/);
+	void AnalysisAlgoFailedData(int interval = 60000 /*std::shared_ptr<Card> pCard*/);
 public:
 	//测试函数
 	void Test();

+ 6 - 1
classdef.cpp

@@ -120,6 +120,8 @@ Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12
 		m_event_list[i] = 0;
 	}
 
+	p_reader = nullptr;
+
 	_dists.swap(DistQueMap());
 	vt_his_speed.resize(0);
 
@@ -659,7 +661,10 @@ void Card::algo_tdoa(int cnt)
 		//	}
 		//}
 
-		double interval_time = this->p_reader->reader_interval_time;
+		double interval_time = 0.2; // µ±ReadFileTestʱ£¬Ã»ÓÐset_reader£¬¸øĬÈÏÖµ
+		if(this->p_reader){
+			interval_time =  this->p_reader->reader_interval_time;
+		}
 
 		double deltaT = 0.0;
 		double cvx = 0;