Browse Source

“add dupm

lihz 8 years ago
parent
commit
5bf425dd2d
9 changed files with 140 additions and 24 deletions
  1. 5 5
      SyncTime/Common.h
  2. 5 11
      SyncTime/SyncManager.cpp
  3. 3 0
      YAServer.cpp
  4. 2 0
      YAServer.vcxproj
  5. 6 0
      YAServer.vcxproj.filters
  6. 29 8
      YAServerDlg.cpp
  7. 2 0
      classdef.cpp
  8. 84 0
      minidump.cpp
  9. 4 0
      minidupm.h

+ 5 - 5
SyncTime/Common.h

@@ -1,8 +1,8 @@
 #pragma once
 
-#define MAX_TIME_DELAY_NUM	65536
-#define TEN_BILLION			10000000000
-#define ROOT_ANCHOR_NUM		6913
+//#define MAX_TIME_DELAY_NUM	65536
+//#define TEN_BILLION			10000000000
+//#define ROOT_ANCHOR_NUM		6913
 #define MAX_SYNCTIME_NUM	200
-#define MAX_ROOT_DELAY_NUM	5
-#define TIME_MAX			0xFFFFFFFFFF
+//#define MAX_ROOT_DELAY_NUM	5
+#define TIME_MAX			0xFFFFFFFFFF // 0x10000000000 //

+ 5 - 11
SyncTime/SyncManager.cpp

@@ -27,10 +27,6 @@ void HostServer::SyncManager::analyzeSyncMsg(SyncTimeMsg &msg)
     }
 
     // 将msg添加到_historySyncTimeMsg
-	/*unordered_map<unsigned short, unordered_map<unsigned long long, SyncTimeMsg>>::iterator it = _syncTimeMsgs.find(msg.SyncNum);
-	if(it != _syncTimeMsgs.end()){
-		_syncTimeMsgs[msg.SyncNum()][msg.LocalIdCode()] = msg;
-	}*/
     _syncTimeMsgs[msg.SyncNum()][msg.LocalIdCode()] = msg;
 
     // 更新时间同步并计算
@@ -173,13 +169,11 @@ unsigned long long HostServer::SyncManager::calTimeByLinar(TagMsg &tag)
     //ofstream fout("test/linar_513.txt",ios::app);
     int i = 0;
 
-	//for(int j = 0; j < MAX_ROOT_DELAY_NUM; j++){ // 增加判断次数
-		if(_syncTimeMsgs[tag.SyncNum][tag.StationIdCode].SyncLevel() == 0)
-		{
-			//fout << hex <<  tag.SyncNum << ' ' <<  tag.StationIdCode << ' ' << tag.ReceiveTime<< endl;
-			return tag.ReceiveTime;
-		}
-	//}
+	if(_syncTimeMsgs[tag.SyncNum][tag.StationIdCode].SyncLevel() == 0)
+	{
+		//fout << hex <<  tag.SyncNum << ' ' <<  tag.StationIdCode << ' ' << tag.ReceiveTime<< endl;
+		return tag.ReceiveTime;
+	}
 
     while(hisSync.size() < 2 && i < MAX_SYNCTIME_NUM)
     {

+ 3 - 0
YAServer.cpp

@@ -8,6 +8,7 @@
 #include "def.h"
 #include "INIFILE.h"
 #include "Functions/Functions.h"
+#include "minidupm.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -62,6 +63,8 @@ BOOL CYAServerApp::InitInstance()
 	InitCtrls.dwICC = ICC_WIN95_CLASSES;
 	InitCommonControlsEx(&InitCtrls);
 
+	SetUnhandledExceptionFilter(ExceptionFilter);
+
 	CWinApp::InitInstance();
 	
 	AfxEnableControlContainer();

+ 2 - 0
YAServer.vcxproj

@@ -157,6 +157,7 @@ xcopy "$(SolutionDir)..\config.ini" "D:\0a-share\$(Configuration)\" /Y /C /D /S<
     <ClInclude Include="Filter\KalmanFilter.h" />
     <ClInclude Include="LogSetting.h" />
     <ClInclude Include="log_def.h" />
+    <ClInclude Include="minidupm.h" />
     <ClInclude Include="MysqlConnPool.h" />
     <ClInclude Include="Resource.h" />
     <ClInclude Include="stdafx.h" />
@@ -224,6 +225,7 @@ xcopy "$(SolutionDir)..\config.ini" "D:\0a-share\$(Configuration)\" /Y /C /D /S<
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="LogSetting.cpp" />
+    <ClCompile Include="minidump.cpp" />
     <ClCompile Include="MysqlConnPool.cpp" />
     <ClCompile Include="stdafx.cpp">
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

+ 6 - 0
YAServer.vcxproj.filters

@@ -76,6 +76,9 @@
     <ClCompile Include="..\thirdparty\include\iocp\Global\FuncHelper.cpp">
       <Filter>hp-socket\global</Filter>
     </ClCompile>
+    <ClCompile Include="minidump.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\common\matrix\BaseMatrix.h">
@@ -201,6 +204,9 @@
     <ClInclude Include="..\thirdparty\include\iocp\Src\HPSocket.h">
       <Filter>hp-socket\socket</Filter>
     </ClInclude>
+    <ClInclude Include="minidupm.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\config.ini" />

+ 29 - 8
YAServerDlg.cpp

@@ -2566,7 +2566,7 @@ std::string CYAServerDlg::get_json_postion()
 
 			pos_card[JSON_KEY_AREA_ID] = it->second->area_id;
 			pos_card[JSON_KEY_STATE_DESC] = it->second->get_state_text(); 
-			pos_card[JSON_KEY_STATE] = it->second->state;
+			pos_card[JSON_KEY_STATE] = it->second->state; //
 			pos_card[JSON_KEY_MOVING_STATE] = it->second->get_acc_text();
 
 			//ctime_s(_time, 30, &(it->second->rev_time));
@@ -5848,11 +5848,6 @@ void CYAServerDlg::parse_data_reader_synctime(BYTE *DataBuffer, int nLen, int& n
 		/*CString strLog;
 		strLog.Format(_T("id1:%d, id2:%d, syncnum:%d, level:%d, send:%I64u, rec:%I64u"), dwReaderID, dwRootReaderID, wSyncNum, wSyncLevel, lTime1, lTime2);
 		writeErrorLog(_T("SYNC_S"), strLog, true);*/
-		if(m_log_parse_data){
-			CString strLog;
-			strLog.Format(_T("id1:%d, id2:%d, syncnum:%d, level:%d, send:%I64u, rec:%I64u"), dwReaderID, dwRootReaderID, wSyncNum, wSyncLevel, lTime1, lTime2);
-			writeErrorLog(_T("SYNC_S"), strLog, true);
-		}
 
 		HostServer::SyncTimeMsg msg;
 		msg.LocalIdCode(dwReaderID);
@@ -5868,6 +5863,32 @@ void CYAServerDlg::parse_data_reader_synctime(BYTE *DataBuffer, int nLen, int& n
 		syncmanager.analyzeSyncMsg(msg);
 		LeaveCriticalSection(&m_csSyncTime);
 
+		if(m_log_parse_data){
+			CString strLog;
+			strLog.Format(_T("id1:%d, id2:%d, syncnum:%d, level:%d, send:%I64u, rec:%I64u"), dwReaderID, dwRootReaderID, wSyncNum, wSyncLevel, lTime1, lTime2);
+			writeErrorLog(_T("SYNC_S"), strLog, true);
+
+			//CString strItSync;
+			//strLog = _T("");
+
+			//if(syncmanager._historySync.count(msg.SyncNum()) > 0 && syncmanager._historySync[msg.SyncNum()].count(msg.LocalIdCode()) > 0){
+			//HostServer::SyncTimeMsg m = syncmanager._historySync[msg.SyncNum()][msg.LocalIdCode()];
+			//}
+			//if(syncmanager._historySync.count(msg.SyncNum())> 0){
+			//for(auto itSync :syncmanager._historySync[msg.SyncNum()])
+			//{
+			//	strItSync.Format(_T("syncnum: %d, readerid: %d, rec_time: %I64u, diff: %I64u\r"), 
+			//		wSyncNum, dwReaderID, itSync.second.ReceiveTime(), itSync.second.TimeDelay());
+			//	strLog += strItSync;
+			//}
+			//}
+			//if(_T("") == strLog){
+			//	strLog.Format(_T("%d, %d"), wSyncNum, dwReaderID);
+			//}
+			//strLog += _T("\n");
+			//writeErrorLog(_T("SYNC_S_A"), strLog, false);
+		}
+
 		//::PostMessage(this->GetSafeHwnd(), WM_SYNC_TIME, NULL, (LPARAM)&msg);
 
 		//CString strItSync;
@@ -5875,8 +5896,8 @@ void CYAServerDlg::parse_data_reader_synctime(BYTE *DataBuffer, int nLen, int& n
 		////if(syncmanager._historySync.count(msg.SyncNum())> 0){
 		//	for(auto itSync :syncmanager._historySync[msg.SyncNum()])
 		//	{
-		//		strItSync.Format(_T("%d, %d, %I64u, %I64u, %I64u\r"), 
-		//			wSyncNum, dwReaderID, itSync.first, itSync.second.ReceiveTime(), itSync.second.TimeDelay());
+		//		strItSync.Format(_T("syncnum: %d, readerid: %d, rec_time: %I64u, diff: %I64u\r"), 
+		//			wSyncNum, dwReaderID, itSync.second.ReceiveTime(), itSync.second.TimeDelay());
 		//		strLog += strItSync;
 		//	}
 		////}

+ 2 - 0
classdef.cpp

@@ -64,6 +64,8 @@ Card::Card( string cardid, int cardtype, double z_offset, double offset_x /*= 12
 	m_bUseFilter = false;
 	m_nFilterType = NO_FILTER;
 	m_pKalmanFilter = NULL;
+	_dists.swap(DistQueMap());
+	//_dists.swap(unordered_map<DWORD, unordered_map<string, _coordinate*>>()); // unordered_map<unsigned short, unordered_map<unsigned long long, SyncTime>>()
 	//m_pKalmanFilter = new CKalmanFilter();
 	//m_pKalmanFilter->Initial(1);
 	//m_pKalmanFilter->m_bFlag = false;

+ 84 - 0
minidump.cpp

@@ -0,0 +1,84 @@
+#include "stdafx.h"
+#include <strsafe.h>
+#include "minidupm.h"
+
+int GenerateMiniDump(HANDLE hFile, PEXCEPTION_POINTERS pExceptionPointers, PWCHAR pwAppName)  
+{  
+	BOOL bOwnDumpFile = FALSE;  
+	HANDLE hDumpFile = hFile;  
+	MINIDUMP_EXCEPTION_INFORMATION ExpParam;  
+
+	typedef BOOL(WINAPI * MiniDumpWriteDumpT)(  
+		HANDLE,  
+		DWORD,  
+		HANDLE,  
+		MINIDUMP_TYPE,  
+		PMINIDUMP_EXCEPTION_INFORMATION,  
+		PMINIDUMP_USER_STREAM_INFORMATION,  
+		PMINIDUMP_CALLBACK_INFORMATION  
+		);  
+
+	MiniDumpWriteDumpT pfnMiniDumpWriteDump = NULL;  
+	HMODULE hDbgHelp = LoadLibrary(L"DbgHelp.dll");  
+	if (hDbgHelp)  
+		pfnMiniDumpWriteDump = (MiniDumpWriteDumpT)GetProcAddress(hDbgHelp, "MiniDumpWriteDump");  
+
+	if (pfnMiniDumpWriteDump)  
+	{  
+		if (hDumpFile == NULL || hDumpFile == INVALID_HANDLE_VALUE)  
+		{  
+			TCHAR szPath[MAX_PATH] = { 0 };  
+			TCHAR szFileName[MAX_PATH] = { 0 };  
+			TCHAR* szAppName = pwAppName;  
+			TCHAR* szVersion = L"v1.0";  
+			TCHAR dwBufferSize = MAX_PATH;  
+			SYSTEMTIME stLocalTime;  
+
+			GetLocalTime(&stLocalTime);  
+			GetTempPath(dwBufferSize, szPath);  
+
+			StringCchPrintf(szFileName, MAX_PATH, L"%s%s", szPath, szAppName);  
+			CreateDirectory(szFileName, NULL);  
+
+			StringCchPrintf(szFileName, MAX_PATH, L"%s%s//%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp",  
+				szPath, szAppName, szVersion,  
+				stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay,  
+				stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond,  
+				GetCurrentProcessId(), GetCurrentThreadId());  
+			hDumpFile = CreateFile(szFileName, GENERIC_READ | GENERIC_WRITE,  
+				FILE_SHARE_WRITE | FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0);  
+
+			bOwnDumpFile = TRUE;  
+			OutputDebugString(szFileName);  
+		}  
+
+		if (hDumpFile != INVALID_HANDLE_VALUE)  
+		{  
+			ExpParam.ThreadId = GetCurrentThreadId();  
+			ExpParam.ExceptionPointers = pExceptionPointers;  
+			ExpParam.ClientPointers = FALSE;  
+
+			pfnMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),  
+				hDumpFile, MiniDumpWithDataSegs, (pExceptionPointers ? &ExpParam : NULL), NULL, NULL);  
+
+			if (bOwnDumpFile)  
+				CloseHandle(hDumpFile);  
+		}  
+	}  
+
+	if (hDbgHelp != NULL)  
+		FreeLibrary(hDbgHelp);  
+
+	return EXCEPTION_EXECUTE_HANDLER;  
+}  
+
+
+LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS lpExceptionInfo)  
+{  
+	if (IsDebuggerPresent())  
+	{  
+		return EXCEPTION_CONTINUE_SEARCH;  
+	}  
+
+	return GenerateMiniDump(NULL, lpExceptionInfo, L"YAServer");  
+}

+ 4 - 0
minidupm.h

@@ -0,0 +1,4 @@
+#include <DbgHelp.h>
+
+int GenerateMiniDump(HANDLE hFile, PEXCEPTION_POINTERS pExceptionPointers, PWCHAR pwAppName);
+LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS lpExceptionInfo);