Browse Source

Z991239-891 #comment feat: 功能集实体睡眠函数Sleep用chrono::Sleep_for代替

翟俊伟80258120 5 years ago
parent
commit
bd9b8178c6
1 changed files with 10 additions and 7 deletions
  1. 10 7
      Module/mod_CustMngrAuth/CustMngrAuthFSM.cpp

+ 10 - 7
Module/mod_CustMngrAuth/CustMngrAuthFSM.cpp

@@ -5,15 +5,13 @@
 #include "CustMngrAuthFSM.h"
 #include <iostream>
 #include <fstream>
-//#include "GetDevInfoHelper.h"
-//#include "EventCode.h"
-//#include "ModuleMix.h"
-//#include <algorithm>
 #include <map>
 #include <iomanip>
 #include <random>
 #include <stdint.h>
 #include <sstream>
+#include <thread>
+#include <chrono>
 
 using namespace std;
 #define _ATL_NO_AUTOMATIC_NAMESPACE
@@ -830,7 +828,8 @@ ErrorCodeEnum CCustMngrAuthFSM::MatchFingerPrint(SpReqAnsContext<CustMngrAuthSer
 			Dbg("m_pFingerPrint is NULL or connection closed.");
 			return Error_Unexpect;
 		}
-		Sleep(100);//如果指纹仪返回及时,这里可以考虑去掉
+		std::this_thread::sleep_for(std::chrono::milliseconds(100));
+		//Sleep(100);//如果指纹仪返回及时,这里可以考虑去掉
 		DWORD startMatch, endMatch;
 		startMatch = GetTickCount();
 		Dbg("begin next invoke match.");
@@ -931,7 +930,8 @@ ErrorCodeEnum CCustMngrAuthFSM::WaitForUkey(ErrorCodeEnum eErr)
 	int status = (eErr == Error_NoTarget) ? 4: 3;//与朱毅约定,4表示本地无指纹数据,3表示指纹仪实体异常,前端给予提示
 	BroadcastGetFinger(status);
 	while(1){
-		Sleep(300);
+		std::this_thread::sleep_for(std::chrono::milliseconds(300));
+		//Sleep(300);
 		if (m_bCancelAuthorize){
 			m_bCancelAuthorize = false;
 			if (m_bAuthorizeTimeout){
@@ -993,7 +993,10 @@ ErrorCodeEnum CCustMngrAuthFSM::CollectFingerPrint(SpReqAnsContext<CustMngrAuthS
 	m_pEntity->GetFunction()->GetPath("Dep", strPath);
 	int getImgNum = 0;
 	for(int i = 0; i < NUM_COLLECT; ++i){
-		if (i) Sleep(2*1000);//internal for 2s between two times(actually finger entity cannot detect finger lift or not)
+		if (i) {
+			std::this_thread::sleep_for(std::chrono::milliseconds(2000));
+			//Sleep(2 * 1000);//internal for 2s between two times(actually finger entity cannot detect finger lift or not)
+		}
 
 		BroadcastPressFinger(i+1, true);//press finger