Browse Source

git ssh test

researchman 8 years ago
parent
commit
e7e2584d19
5 changed files with 111 additions and 33 deletions
  1. 1 0
      QueueStrManager.cpp
  2. BIN
      YAServer.rc
  3. 49 27
      YAServerDlg.cpp
  4. 55 6
      classdef.cpp
  5. 6 0
      classdef.h

+ 1 - 0
QueueStrManager.cpp

@@ -47,6 +47,7 @@ void QueueStrManager::AddString(const char * chr)
 		}
 		m_couter++;
 		m_length += strlen(chr);
+		TRACE(_T("sql counts: %d \r\n"),m_couter);
 	}
 	LeaveCriticalSection(&m_csQueueList);
 }

BIN
YAServer.rc


+ 49 - 27
YAServerDlg.cpp

@@ -211,9 +211,15 @@ DWORD WINAPI _exec_sql(LPVOID lparam)
 
 	if(err > 0){
 		TRACE(_T("sql error \n"));
-
 	}
 	mysql_free_result(pRes);
+
+	ofstream out("SQL_S.log");
+	if (out.is_open())
+	{
+		out<<sql;
+		out.close();
+	}
 	//TRACE(_T("passed\n"));
 	delete[] sql;
 	sql = NULL;
@@ -3931,21 +3937,39 @@ void CYAServerDlg::store_data_card( Card* card, int tag )
 				//	card->card_id.c_str(), _time, _time);
 				sprintf_s(sql, LENGTH_SQL,
 					"CALL add_att(%s, '%s', '%s');", card->card_id.c_str(), _time, _time);
+
+				CString str = _T("");
+				//str.Format(_T("%s"),sql);
+				CString strtmp = _T("");
+				strtmp.Format(_T("%d"),RPT_ATTEND_DOWN);
+				str = sql;
+				str += strtmp;
+				writeErrorLog(_T("SQL_S"),str,false);
 			}
 			break;
 		}
 	case RPT_ATTEND_UP:
 		{
 			if(card->map_id != 0 && card->area_id != 0){
-				TRACE(_T(" 6 "));
 				b_exec = true;
-				localtime_s(&local_time_ex, &card->down_time);
-				strftime(_time_ex, 30, "%Y-%m-%d %H:%M:%S", &local_time_ex);
+				//localtime_s(&local_time_ex, &card->down_time);
+				//strftime(_time_ex, 30, "%Y-%m-%d %H:%M:%S", &local_time_ex);
+
+				string str_down_time = CFunctions::time_t2string(card->down_time);
 				//sprintf_s(sql, LENGTH_SQL,
 				//	"UPDATE rpt_attendance SET end_time = '%s' WHERE card_id = %s AND start_time = '%s';",
 				//	_time, card->card_id.c_str(), _time_ex);
+				/*sprintf_s(sql, LENGTH_SQL,
+				"CALL add_att(%s, '%s', '%s');", card->card_id.c_str(), _time, _time_ex);*/
 				sprintf_s(sql, LENGTH_SQL,
-					"CALL add_att(%s, '%s', '%s');", card->card_id.c_str(), _time, _time_ex);
+					"CALL add_att(%s, '%s', '%s');", card->card_id.c_str(), _time, str_down_time.c_str());
+
+				CString str = _T("");
+				CString strtmp = _T("");
+				strtmp.Format(_T("%d"),RPT_ATTEND_UP);
+				str = sql;
+				str += strtmp;
+				writeErrorLog(_T("SQL_S"),str,false);
 			}
 			break;
 		}
@@ -4037,19 +4061,17 @@ void CYAServerDlg::store_data_card( Card* card, int tag )
 	}
 	catch (...)
 	{
-		CString str = _T("");
-		//str.Format(_T("%s\n"), CFunctions::c2wc(sql));
-
-		wchar_t* p = CFunctions::c2wc(sql);
-		str.Format(_T("%s\n"), p);
-		writeErrorLog(_T("SQL_S"), str);
-		//str = _T("");
-		str.Empty();
-
-		if(p){
-			free(p);
-			p = NULL;
-		}
+		//CString str = _T("");
+		//wchar_t* p = CFunctions::c2wc(sql);
+		//str.Format(_T("%s\n"), p);
+		//writeErrorLog(_T("SQL_S"), str);
+		////str = _T("");
+		//str.Empty();
+
+		//if(p){
+		//	free(p);
+		//	p = NULL;
+		//}
 	}
 }
 
@@ -6183,7 +6205,7 @@ EnHandleResult CYAServerDlg::OnSend( ITcpServer* pSender, CONNID dwConnID, const
 }
 EnHandleResult CYAServerDlg::OnReceive( ITcpServer* pSender, CONNID dwConnID, const BYTE* pData, int iLength )
 {
-	TRACE(_T("OnReceive: %d, %d\n"), iLength, dwConnID);
+	//TRACE(_T("OnReceive: %d, %d\n"), iLength, dwConnID);
 
 	DWORD dw = ::GetTickCount();
 
@@ -7404,7 +7426,7 @@ void CYAServerDlg::parse_data_locate_card_his_tof_card( BYTE* DataBuffer, int nL
 	}
 	catch (...)
 	{
-		CString str;
+		/*CString str;
 		wchar_t* p = CFunctions::c2wc(sql);
 		str.Format(_T("%s\n"), p);
 		writeErrorLog(_T("SQL_S"), str);
@@ -7413,7 +7435,7 @@ void CYAServerDlg::parse_data_locate_card_his_tof_card( BYTE* DataBuffer, int nL
 		if(p){
 			free(p);
 			p = NULL;
-		}
+		}*/
 	}
 }
 
@@ -7518,7 +7540,7 @@ void CYAServerDlg::parse_data_locate_card_his_tdoa_card( BYTE* DataBuffer, int n
 	}
 	catch (...)
 	{
-		CString str;
+		/*CString str;
 		wchar_t* p = CFunctions::c2wc(sql);
 		str.Format(_T("%s\n"), p);
 		writeErrorLog(_T("SQL_S"), str);
@@ -7527,7 +7549,7 @@ void CYAServerDlg::parse_data_locate_card_his_tdoa_card( BYTE* DataBuffer, int n
 		if(p){
 			free(p);
 			p = NULL;
-		}
+		}*/
 	}
 }
 
@@ -7595,16 +7617,16 @@ void CYAServerDlg::parse_data_locate_card_his_sync_time( BYTE* DataBuffer, int n
 	}
 	catch (...)
 	{
-		CString str;
+		/*CString str;
 		wchar_t* p = CFunctions::c2wc(sql);
 		str.Format(_T("%s\n"), p);
 		writeErrorLog(_T("SQL_S"), str);
 		str.Empty();
 
 		if(p){
-			free(p);
-			p = NULL;
-		}
+		free(p);
+		p = NULL;
+		}*/
 	}
 }
 

+ 55 - 6
classdef.cpp

@@ -85,6 +85,7 @@ Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12
 	weight = 0;
 	acce_cur_state = 0;
 	acce_last_state = 0;
+	b_long_interval = false;
 
 	time_stamp_last = 0;
 	reader_id_last  = 0;
@@ -381,7 +382,7 @@ void Card::algo_tdoa(int cnt)
 	int i = 0, nCount = 0;
 	POS *p = NULL;
 	bool bOutput = false;
-	//int nSize = 0;
+	this->z = 0;
 
 	if(pTdoaReaderPathMap->size() > 0 && pRdm.size() > 1){
 		this->m_nCalcSyncNum = maxSyncTimes;
@@ -450,6 +451,50 @@ void Card::algo_tdoa(int cnt)
 				this->m_dFirstDiff = p->dFirstDiff;
 				this->m_dSecondDiff = p->dSecondDiff;
 
+				if (this->b_long_interval)
+				{
+					//此段代码用于将上一次定位是根据两个时间差是个很大值而定位出的结果
+					//当后续定位时就和最近的定位结果进行比较
+					//例如:当上一次同步序号是14321,它定位时比较的同步序号是14200,时间差大于20多秒
+					//这时我们就将b_long_interval置为true
+					//当本次定位,同步序号是14326,,这时就需要根据最近的14321进行判断
+					list<sync_data>::reverse_iterator it = m_syncNumList.rbegin();
+					sync_data sdl = *it;
+					deltaT = (maxSyncTimes - sdl.sync_num)*interval_time;
+					//避免同一个同步序号下存在多个不同卡序号
+					if (deltaT < 1E-2)
+					{
+						deltaT = 0.2;
+					}
+					cvx = (cx - sd.x)*this->map_scale/deltaT;
+					cvy = (cy - sd.y)*this->map_scale/deltaT;
+
+					double avx = (cvx - sd.vx) / deltaT;
+					double avy = (cvy - sd.vy) / deltaT;
+					double av = sqrt(pow(avx,2) + pow(avy,2));
+					//车卡的加速度
+					switch(this->card_type){
+					case CT_PERSON:
+						if(av > PERSON_ACCELERATE_THRESHOLD){
+							this->x = this->last_locate.x;
+							this->y = this->last_locate.y;
+							return;
+						}
+						break;
+					case CT_VEHICLE:
+						if(av > VECHILE_ACCELERATE_THRESHOLD){
+							//保留上次结果
+							this->x = this->last_locate.x;
+							this->y = this->last_locate.y;
+							this->b_long_interval = false;
+							return;
+						}
+						break;
+					}
+					deltaT = 0;
+					cvx = cvy = 0;
+				}
+
 				//从队列尾部开始查找,找到第一个同步序号与当前计算卡的同步序号相差5个以上的数据
 				//list<sync_data>::reverse_iterator it = m_syncNumList.rbegin();	
 				list<sync_data>::reverse_iterator it;
@@ -479,6 +524,10 @@ void Card::algo_tdoa(int cnt)
 				}
 				//使用间隔来修正速度
 				if(deltaT - 1.0 >= 0){
+					if (deltaT > 10)
+					{
+						this->b_long_interval = true;
+					}
 					//转为m/s
 					cvx = (cx - sd.x)*this->map_scale/deltaT;
 					cvy = (cy - sd.y)*this->map_scale/deltaT;
@@ -488,9 +537,9 @@ void Card::algo_tdoa(int cnt)
 					//其他情况,则x2 - x1 > 0 为正
 					if(cx == sd.x){
 						if(cy > sd.y){
-							nSign = -1;
-						}else{
 							nSign = 1;
+						}else{
+							nSign = -1;
 						}
 					}else{
 						if(cx > sd.x){
@@ -509,14 +558,14 @@ void Card::algo_tdoa(int cnt)
 					//车卡的加速度
 					switch(this->card_type){
 					case CT_PERSON:
-						if(av > 3){
+						if(av > PERSON_ACCELERATE_THRESHOLD){
 							this->x = this->last_locate.x;
 							this->y = this->last_locate.y;
 							return;
 						}
 						break;
 					case CT_VEHICLE:
-						if(av > 5){
+						if(av > VECHILE_ACCELERATE_THRESHOLD){
 							//保留上次结果
 							this->x = this->last_locate.x;
 							this->y = this->last_locate.y;
@@ -530,7 +579,7 @@ void Card::algo_tdoa(int cnt)
 					cv = cv*3.6;
 
 					//速度的限制
-					if(cv > 30){
+					if(fabs(cv) > MAX_VECHILE_SPEED){
 						this->x = this->last_locate.x;
 						this->y = this->last_locate.y;
 						return;

+ 6 - 0
classdef.h

@@ -49,9 +49,13 @@
 
 using namespace std;
 
+//算法中使用的常量定义
 const int MAX_CALC_POINTS = 30;
 const double INS_WEIGHT = 9.0;	//惯导权重
 const double UWB_WEIGHT = 1.0;  //UWB权重
+const double MAX_VECHILE_SPEED = 25.0;
+const double VECHILE_ACCELERATE_THRESHOLD = 5;
+const double PERSON_ACCELERATE_THRESHOLD = 3;
 
 enum TIMER_ID
 {
@@ -785,6 +789,8 @@ public:
 
 	void EnableFilter(int nType);
 	int FindDistMap(int cardstamp);
+private:
+	bool b_long_interval;	//上一次定位的间隔时间差大于10s
 public: // 采集到的底层数据
 	int reader_tickcount; 
 	int time_stamp; // 定位时间戳