Browse Source

add Test button

lihz 7 years ago
parent
commit
4780035ed2
5 changed files with 182 additions and 162 deletions
  1. BIN
      YAServer.rc
  2. 178 161
      YAServerDlg.cpp
  3. 1 0
      YAServerDlg.h
  4. 3 1
      classdef.h
  5. BIN
      resource.h

BIN
YAServer.rc


+ 178 - 161
YAServerDlg.cpp

@@ -168,6 +168,7 @@ BEGIN_MESSAGE_MAP(CYAServerDlg, CDialogEx)
 	ON_MESSAGE(WM_REMOVE_SOCKET, &CYAServerDlg::OnRemoveSocket)
 	ON_EN_UPDATE(IDC_EDIT_READERID, &CYAServerDlg::OnEnUpdateEditReaderid)
 	ON_COMMAND(ID_ABOUT, &CYAServerDlg::OnAbout)
+	ON_BN_CLICKED(IDC_BUTTON1, &CYAServerDlg::OnBnClickedButton1)
 END_MESSAGE_MAP()
 
 // CYAServerDlg 消息处理程序
@@ -514,6 +515,10 @@ BOOL CYAServerDlg::OnInitDialog()
 
 	SetWindowText(_T("永安信通数据采集系统"));
 	OnBnStart();
+	
+#ifndef _DEBUG
+	GetDlgItem(IDC_BUTTON1).ShowWindow(SW_HIDE);
+#endif
 
 	UpdateData(FALSE);
 	debug_print_syslog(0, "Server dialog init success.");
@@ -583,8 +588,10 @@ HCURSOR CYAServerDlg::OnQueryDragIcon()
 */
 void CYAServerDlg::OnBnStart()
 {
-	//Test();
+#ifndef _DEBUG
 	ReadFileTest();
+#endif // !_DEBUG
+
 	//get_json_count_area();
 	if(!is_websocket_login){
 		ws_login();
@@ -10064,119 +10071,6 @@ void CYAServerDlg::Test()
 
 void CYAServerDlg::ReadFileTest()
 {
-	//ifstream in;
-	//in.open("D:/5.log");
-
-	//if (!in.is_open())
-	//{
-	//	return;
-	//}
-
-	//std::shared_ptr<ReceiveDataMap> pRdm = std::make_shared<ReceiveDataMap>();
-	//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);
-	//	string data = pch;
-	//	stringstream sout;
-
-	//	std::vector<std::string> metaDatas = CFunctions::split(data,",",true);
-	//	//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:
-	//			{
-	//				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;
-	//		case 3:
-	//			break;
-	//		case 4:
-	//			//时间戳值
-	//			sout<<vtMeta[1];
-	//			sout>> dist->tt;
-	//			break;
-	//		case 5:
-	//			break;
-	//		case 6:
-	//			//x
-	//			dist->x = atof(vtMeta[1].c_str())*dMapScale;
-	//			break;
-	//		case 7:
-	//			//y
-	//			dist->y = atof(vtMeta[1].c_str())*dMapScale;
-	//			break;
-	//		case 8:
-	//			//z
-	//			dist->z = atof(vtMeta[1].c_str())*dMapScale;
-	//			break;
-	//		case 9:
-	//			dist->t =  atoi(vtMeta[1].c_str());
-	//			break;
-	//		case 10:
-	//			//卡号
-	//			break;
-	//		default:
-	//			break;
-	//		}
-	//	}
-
-	//	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)
-	//	{
-	//		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;
-	//	}
-	//}
-	//in.close();
-
-	//单条
 	ifstream in;
 	in.open("D:/5.log");
 
@@ -10189,6 +10083,11 @@ 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);
+	card->m_nFilterType = FILTER_KALMAN;
+	card->EnableFilter(FILTER_KALMAN);
+
 	while (!in.eof())
 	{
 		in.getline(pch,200);
@@ -10196,27 +10095,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;
@@ -10225,23 +10132,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:
 				//卡号
@@ -10250,50 +10158,153 @@ 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::vector<std::shared_ptr<POS>> udm_pos;
-	udm_pos.resize(0);
-
-	//p2d = LocateAlgorithm::TdoaLocate2d(pRdm);
-	LocateAlgorithm::CalcTdoaPosition(pRdm,mp_reader_path_list_tdoa,udm_pos);
-	//4.定位解有效性判断
-	/*std::shared_ptr<POS> pos = std::make_shared<POS>();
-	ret = ChooseOneSolution(pRdm, udm_pos, pos);
-	if(ret) return ret; 
-	5.唯一解合法性验证
-	ret = CheckSolution(pos);
-	if(ret) {
-		return ret; 
-	}	
-	6.滤波
-	if (FILTER_KALMAN == m_nFilterType)
-	{
-		ret = KalmanFilterProcess(pos);
-	}else{
-		pos->update = true;
-	}*/
+	card->get_coordinate();
 
-	//p = LocateAlgorithm::LocatePos(pRdm,mp_reader_path_list_tdoa);
+	////单条
+	//ifstream in;
+	//in.open("D:/5.log");
 
-	p = LocateAlgorithm::Pos(pRdm,mp_reader_path_list_tdoa);
+	//if (!in.is_open())
+	//{
+	//	return;
+	//}
 
-	p2 =  LocateAlgorithm::CalcCardPosition(pRdm, mp_reader_path_list_tdoa);
+	//std::shared_ptr<ReceiveDataMap> pRdm = std::make_shared<ReceiveDataMap>();
+	//char pch[200] = {0};
+	//double dMapScale = 2;
+
+	//while (!in.eof())
+	//{
+	//	in.getline(pch,200);
+	//	string data = pch;
+	//	stringstream sout;
 
-	//ReceiveDataMap* pTestRdm = pRdm.get();
-	//TDOAReaderPathMap* pTestTrpm = mp_reader_path_list_tdoa.get();
+	//	std::vector<std::string> metaDatas = CFunctions::split(data,",",true);
+	//	std::shared_ptr<ReceiveData> prd = std::make_shared<ReceiveData>();
+	//	for (int i=0;i<metaDatas.size();i++)
+	//	{	
+	//		std::string meta = metaDatas[i];
 
-	double x = p->posx / dMapScale;	
-	double y = p->posy / dMapScale;
+	//		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;
+	//			}
+	//			break;
+	//		case 1:
+	//			break;
+	//		case 2:
+	//			break;
+	//		case 3:
+	//			break;
+	//		case 4:
+	//			//时间戳值
+	//			sout<<vtMeta[1];
+	//			sout>>prd->rec_time_stamp;
+	//			break;
+	//		case 5:
+	//			break;
+	//		case 6:
+	//			//x
+	//			prd->x = atof(vtMeta[1].c_str())*dMapScale;
+	//			break;
+	//		case 7:
+	//			//y
+	//			prd->y = atof(vtMeta[1].c_str())*dMapScale;
+	//			break;
+	//		case 8:
+	//			//z
+	//			prd->z = atof(vtMeta[1].c_str())*dMapScale;
+	//			break;
+	//		case 9:
+	//			break;
+	//		case 10:
+	//			//卡号
+	//			break;
+	//		default:
+	//			break;
+	//		}
+	//	}
+	//	if (prd->rec_time_stamp)
+	//	{
+	//		pRdm->insert(ReceiveDataMap::value_type(prd->rec_time_stamp,prd));
+	//	}
+	//	//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::vector<std::shared_ptr<POS>> udm_pos;
+	//udm_pos.resize(0);
+
+	////p2d = LocateAlgorithm::TdoaLocate2d(pRdm);
+	//LocateAlgorithm::CalcTdoaPosition(pRdm,mp_reader_path_list_tdoa,udm_pos);
+	////4.定位解有效性判断
+	///*std::shared_ptr<POS> pos = std::make_shared<POS>();
+	//ret = ChooseOneSolution(pRdm, udm_pos, pos);
+	//if(ret) return ret; 
+	//5.唯一解合法性验证
+	//ret = CheckSolution(pos);
+	//if(ret) {
+	//	return ret; 
+	//}	
+	//6.滤波
+	//if (FILTER_KALMAN == m_nFilterType)
+	//{
+	//	ret = KalmanFilterProcess(pos);
+	//}else{
+	//	pos->update = true;
+	//}*/
+
+	////p = LocateAlgorithm::LocatePos(pRdm,mp_reader_path_list_tdoa);
+
+	//p = LocateAlgorithm::Pos(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;
 }
 
 /*
@@ -12182,3 +12193,9 @@ bool CYAServerDlg::IsInLine( _point p1, _point p2, _point p3 )
 {
 	return true;
 }
+
+
+void CYAServerDlg::OnBnClickedButton1()
+{
+	ReadFileTest();
+}

+ 1 - 0
YAServerDlg.h

@@ -508,6 +508,7 @@ public:
 	UINT m_reader_id_hist;
 	afx_msg void OnEnUpdateEditReaderid();
 	afx_msg void OnAbout();
+	afx_msg void OnBnClickedButton1();
 };
 
 typedef struct {

+ 3 - 1
classdef.h

@@ -523,12 +523,14 @@ struct POS{
 		posx = 0;
 		posy = 0;
 		posz = 0;
+		pos_radius = 0;	
 		rx = ry = rz = cx = cy = cz = cvx = cvy = cvz = 0.0;
+
 		for (int i=0;i<MAX_READER_TDOA_PATH_NUMS;i++)
 		{
 			dDiff[i] = 0;
 		}
-		pos_radius = 0;	
+		
 		update = false;
 		origin_speed = 0;
 		sumVariance = 0;

BIN
resource.h