|
|
@@ -3,7 +3,7 @@
|
|
|
#include "FingerPrint_UserErrorCode.h"
|
|
|
#include "GetDevInfoHelper.h"
|
|
|
|
|
|
-#include <stdio.h>
|
|
|
+#include <cstdio>
|
|
|
#include <thread>
|
|
|
#include <chrono>
|
|
|
#include <fstream>
|
|
|
@@ -16,6 +16,10 @@
|
|
|
using namespace SP::Module::Comm;
|
|
|
|
|
|
#define SLEEP(interval) std::this_thread::sleep_for(std::chrono::milliseconds(interval))
|
|
|
+#define FINGERPRINT_SCAN_TIMEOUT 15000
|
|
|
+#define FINGERPRINT_SCAN_INTERNAL 100
|
|
|
+#define FINGERPRINT_MATCH_TIMEOUT 15000
|
|
|
+#define MAX_FEATURE_LEN 1024
|
|
|
|
|
|
#pragma region event response
|
|
|
|
|
|
@@ -486,30 +490,30 @@ ErrorCodeEnum CFingerPrintFSM::InitParamBeforeScan(ScanParam* initParam, int sca
|
|
|
case 1:
|
|
|
initParam->m_BmpFileName = "finger1.bmp";
|
|
|
m_BmpFileFullPath1 = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
|
|
|
- , (const char*)initParam->m_DepPath
|
|
|
- , (const char*)initParam->m_BmpFileName);
|
|
|
+ , initParam->m_DepPath.GetData()
|
|
|
+ , initParam->m_BmpFileName.GetData());
|
|
|
break;
|
|
|
case 2:
|
|
|
initParam->m_BmpFileName = "finger2.bmp";
|
|
|
m_BmpFileFullPath2 = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
|
|
|
- , (const char*)initParam->m_DepPath
|
|
|
- , (const char*)initParam->m_BmpFileName);
|
|
|
+ , initParam->m_DepPath.GetData()
|
|
|
+ , initParam->m_BmpFileName.GetData());
|
|
|
break;
|
|
|
case 3:
|
|
|
initParam->m_BmpFileName = "finger3.bmp";
|
|
|
m_BmpFileFullPath3 = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
|
|
|
- , (const char*)initParam->m_DepPath
|
|
|
- , (const char*)initParam->m_BmpFileName);
|
|
|
+ , initParam->m_DepPath.GetData()
|
|
|
+ , initParam->m_BmpFileName.GetData());
|
|
|
break;
|
|
|
default:
|
|
|
initParam->m_BmpFileName = "finger.bmp";
|
|
|
break;
|
|
|
}
|
|
|
initParam->m_FullFilePath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
|
|
|
- , (const char*)initParam->m_DepPath
|
|
|
- , (const char*)initParam->m_BmpFileName);
|
|
|
+ , initParam->m_DepPath.GetData()
|
|
|
+ , initParam->m_BmpFileName.GetData());
|
|
|
|
|
|
- Dbg("get imageName success: %s", initParam->m_FullFilePath);
|
|
|
+ Dbg("get imageName success: %s", initParam->m_FullFilePath.GetData());
|
|
|
|
|
|
return errCode;
|
|
|
}
|
|
|
@@ -560,13 +564,12 @@ void CFingerPrintFSM::ScanProcess(ScanParam* pScanParam, SpReqAnsContext<FingerP
|
|
|
{
|
|
|
Dbg("Invoke routine 'Image2Template' success");
|
|
|
|
|
|
- if (pScanParam->m_Template != NULL && pScanParam->m_FeatureLen > 0)
|
|
|
+ if (pScanParam->m_Template != NULL && pScanParam->m_FeatureLen == 684)
|
|
|
{
|
|
|
- Dbg("template length is %d", pScanParam->m_FeatureLen);
|
|
|
ctx->Ans.feature = (CSimpleStringA)(pScanParam->m_Template);
|
|
|
}
|
|
|
else {
|
|
|
- Dbg("template is NULL");
|
|
|
+ Dbg("template len is: %d, or template is NULL", pScanParam->m_FeatureLen);
|
|
|
pScanParam->m_GetTemplateSuc = false;
|
|
|
break;
|
|
|
}
|
|
|
@@ -599,7 +602,7 @@ void CFingerPrintFSM::ScanProcess(ScanParam* pScanParam, SpReqAnsContext<FingerP
|
|
|
Dbg("Invoke routine 'Image2Feature' failed which returned %s(%s) while register."
|
|
|
, SpStrError(errCode), devErrInfo.szErrMsg);
|
|
|
}
|
|
|
- pScanParam->m_TimeEnd = clock();
|
|
|
+ pScanParam->m_TimeEnd = RVCGetTickCount();
|
|
|
pScanParam->m_TimeLeft = pScanParam->m_TimeEnd - pScanParam->m_TimeStart;
|
|
|
}
|
|
|
|
|
|
@@ -746,7 +749,7 @@ void CFingerPrintFSM::ScanBeforeMatch(ScanParam* initParam)
|
|
|
Dbg("Invoke routine 'Image2Feature' failed which returned %s(%s)"
|
|
|
, SpStrError(errCode), devErrInfo.szErrMsg);
|
|
|
}
|
|
|
- initParam->m_TimeEnd = clock();
|
|
|
+ initParam->m_TimeEnd = RVCGetTickCount();
|
|
|
initParam->m_TimeLeft = initParam->m_TimeEnd - initParam->m_TimeStart;
|
|
|
}
|
|
|
LogEvent(Severity_Middle, LOG_EVT_FINGERPRINT_GREEN_OFF, "FingerPrint warning off");
|
|
|
@@ -776,11 +779,11 @@ ErrorCodeEnum CFingerPrintFSM::MatchProcess(ScanParam* initParam, SpReqAnsContex
|
|
|
lpbTemplateLen[i] = ctx->Req.templateLen[i];
|
|
|
}
|
|
|
|
|
|
- clock_t startMatch = clock();
|
|
|
+ ULLINT startMatch = RVCGetTickCount();
|
|
|
errCode = m_hDevHelper->Match(lpbTemplates, lpbTemplateLen, templateNum,
|
|
|
initParam->m_Feature, initParam->m_FeatureLen);
|
|
|
- clock_t endMatch = clock();
|
|
|
- int duration = (endMatch - startMatch) * 1000 / CLOCKS_PER_SEC;
|
|
|
+ ULLINT endMatch = RVCGetTickCount();
|
|
|
+ int duration = endMatch - startMatch;
|
|
|
LogWarn(Severity_High, Error_Debug, LOG_ERR_FINGERPRINT_MATCH_TIME,
|
|
|
GenerateAlarmJson("FingerPrint", duration).GetData());
|
|
|
|
|
|
@@ -881,8 +884,8 @@ ErrorCodeEnum CFingerPrintFSM::InitCommParam(ScanParam* initParam, int operateTy
|
|
|
return errCode;
|
|
|
}
|
|
|
|
|
|
- initParam->m_TimeStart = clock();
|
|
|
- initParam->m_TimeEnd = clock();
|
|
|
+ initParam->m_TimeStart = RVCGetTickCount();
|
|
|
+ initParam->m_TimeEnd = RVCGetTickCount();
|
|
|
initParam->m_TimeLeft = 0;
|
|
|
|
|
|
initParam->m_Feature = new BYTE[MAX_FEATURE_LEN];
|
|
|
@@ -950,9 +953,9 @@ ErrorCodeEnum CFingerPrintFSM::InitCommParam(ScanParam* initParam, int operateTy
|
|
|
|
|
|
ErrorCodeEnum CFingerPrintFSM::GetDevCatInfo(DevCategoryInfo& devInfo)
|
|
|
{
|
|
|
- Dbg("DevCatgoryInfo len:%d, %d, %d", strlen(m_devCatInfo.szModel)
|
|
|
- , strlen(m_devCatInfo.szType)
|
|
|
- , strlen(m_devCatInfo.szVendor));
|
|
|
+ Dbg("m_devCatInfo.szModel:%s, len:%d", m_devCatInfo.szModel, strlen(m_devCatInfo.szModel));
|
|
|
+ Dbg("m_devCatInfo.szType:%s, len:%d", m_devCatInfo.szModel, strlen(m_devCatInfo.szType));
|
|
|
+ Dbg("m_devCatInfo.szVendor:%s, len:%d", m_devCatInfo.szModel, strlen(m_devCatInfo.szVendor));
|
|
|
|
|
|
#ifdef RVC_OS_WIN
|
|
|
strncpy_s(devInfo.szModel, MAX_DEV_MODEL_LEN, m_devCatInfo.szModel, strlen(m_devCatInfo.szModel));
|
|
|
@@ -1104,4 +1107,17 @@ ErrorCodeEnum CFingerPrintFSM::DeleteFileIfExisted(const char* fileName)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ULLINT CFingerPrintFSM::RVCGetTickCount()
|
|
|
+{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ return GetTickCount64();
|
|
|
+#else
|
|
|
+ struct timespec ts;
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
+
|
|
|
+ return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
|
|
|
+#endif // RVC_OS_WIN
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
#pragma endregion
|