lihz před 7 roky
rodič
revize
75eb3a952c
3 změnil soubory, kde provedl 32 přidání a 14 odebrání
  1. 22 0
      SyncTime/SyncManager.cpp
  2. 5 0
      SyncTime/SyncManager.h
  3. 5 14
      YAServerDlg.cpp

+ 22 - 0
SyncTime/SyncManager.cpp

@@ -3,6 +3,9 @@
 #include <deque>
 #include <Eigen/Dense>
 
+#include <fstream>  
+#include <iostream>  
+
 #include "../ProcessRemodule.h"
 #include "../log_process_module.h"
 #include "./../system_basic_info/SystemAnalysis.h"
@@ -22,6 +25,7 @@ void HostServer::SyncManager::init()
 	//_syncTimeMsgs.clear();
 	//_historySync.clear();
     _distance.swap(unordered_map<unsigned long long,unordered_map<unsigned long long, double>>());
+	isOutputLog = false;
 }
 
 void HostServer::SyncManager::analyzeSyncMsg(SyncTimeMsg &msg)
@@ -147,8 +151,20 @@ bool HostServer::SyncManager::updateSync(unsigned long long rootIdCode, int idx,
 			timeDelay += TIME_MAX;
 		}
         _historySync[rootIdCode][idx_synctime].HistSync[localIdCode].TimeDelay(timeDelay);
+
+
 		//debug_print_syslog(0, "Delay info, syncnum:%d, station id: 0x%x, timeDelay:%I64u", 
 		//                 SyncNum, localIdCode, timeDelay);
+
+		if(isOutputLog){
+			char filename[10];
+			char temp[200]; 
+			sprintf_s(filename, ".\\0x%x.log", localIdCode);
+			ofstream outfile(filename, ofstream::app);  
+			sprintf_s(temp, "syncnum:%d, id: 0x%x, delay:%I64u", SyncNum, localIdCode, timeDelay); 
+			outfile << temp; 
+		}
+
 		LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_69);
         return true;
     }else{
@@ -229,6 +245,12 @@ unsigned long long HostServer::SyncManager::calTimeByLinar(TagMsg &tag)
 		y2 -=TIME_MAX;
 	}
 
+	// y1 = k*x1 + b;
+	// y2 = k*x2 + b;
+
+	// k = (x1-x2)/(y1-y2);
+	// b = y1 - k*x1; 
+
     Eigen::Matrix3d a;
     a << x1 ,1 , 0,
          x2 ,1 , 0,

+ 5 - 0
SyncTime/SyncManager.h

@@ -29,6 +29,8 @@ namespace HostServer{
 
 		CRITICAL_SECTION m_csSyncTime;
 		CRITICAL_SECTION m_csCalcLiner;
+
+		bool isOutputLog;
     public:
         SyncManager();
 		~SyncManager();
@@ -112,5 +114,8 @@ namespace HostServer{
 		bool updateSync(unsigned long long rootIdCode, int idx, unsigned short SyncNum, unsigned long long localIdCode);
 		int FindSyncTimeMsg(unsigned long long rootIdCode, unsigned short SyncNum);
 		int FindHisSyncTime(unsigned long long rootIdCode, unsigned short SyncNum);
+
+		void SetOutputLog(bool log){	this->isOutputLog = log;}
+		bool IsOutputLog() const {return isOutputLog;}
     };
 }

+ 5 - 14
YAServerDlg.cpp

@@ -467,7 +467,7 @@ BOOL CYAServerDlg::OnInitDialog()
 	m_log_send_package = theApp.log_send_package;
 	m_log_recv_package = theApp.log_recv_package;
 	m_log_locate_data  = theApp.log_locate_data;
-
+	
 	m_reader_interval_time = theApp.reader_interval_time * 1.0 / 1000.0;
 
 	m_nMallocTimes = 0;
@@ -5358,13 +5358,6 @@ void CYAServerDlg::deal_areas()
 		for(;it_card_vehicle != it_Area->second->area_card_list_vehicle->end(); ++it_card_vehicle){
 			// 计数
 			count_total++;
-			// 区域超速,实现
-			if(it_card_vehicle->second->get_speed() > it_Area->second->over_speed_vehicle){
-				is_true = true;
-				it_card_vehicle->second->is_area_over_speed = true;
-				it_card_vehicle->second->time_over_speed = current_time;
-				//deal_alarm_card(it_card_vehicle->second,it_Area->second->area_card_list_vehicle,is_true,AF_CARD_OVER_SPEED);
-			}
 
 			count_vehicle++;
 			// 超时
@@ -9101,12 +9094,6 @@ void CYAServerDlg::load_his_card_postion()
 
 			it->second->pos_state = atoi(pRow[12]);
 			it->second->pos_state_old = it->second->pos_state;
-			//if(PDT_UP == it->second->pos_state ){
-			//	it->second->area_id = 0;
-			//	/*it->second->x = 0;
-			//	it->second->y = 0;
-			//	it->second->z = 0;*/
-			//}
 
 			it->second->last_x = it->second->x;
 			it->second->last_y = it->second->y;
@@ -10064,6 +10051,10 @@ void CYAServerDlg::parse_data_locate_reader_his( BYTE * DataBuffer, int nLen, in
 
 void CYAServerDlg::parse_data_reader_synctime(BYTE *DataBuffer, int nLen, int& nCurPos, WORD wChr)
 {
+	if(syncmanager.IsOutputLog() != m_log_parse_data){
+		syncmanager.SetOutputLog(m_log_parse_data);
+	}
+
 	while(nCurPos < nLen - sizeof(WORD)){
 		LOCATION_SYSTEM_BRANCH(LOCATION_SYSTEM_BRANCH_9);
 		DWORD dwReaderID = 0; // 本机分站号