|
@@ -2,7 +2,6 @@
|
|
|
#include "IDCertFSM.h"
|
|
|
#include "GetDevInfoHelper.h"
|
|
|
#include "EventCode.h"
|
|
|
-//#pragma comment(lib,"IDCerReader.lib")
|
|
|
#include "libimageproc.h"
|
|
|
#include "ModuleMix.h"
|
|
|
#include "IDCertificate_UserErrorCode.h"
|
|
@@ -16,7 +15,6 @@
|
|
|
#include "DevFSMCommBase.hpp"
|
|
|
#include "fileutil.h"
|
|
|
|
|
|
-#pragma comment(lib,"user32.lib")
|
|
|
#define IDCER_INIT_COUNT 3
|
|
|
|
|
|
#define IDCER_READ_TIMEOUT 60000
|
|
@@ -67,12 +65,6 @@ void CIDCertFSM::s0_on_entry()
|
|
|
void CIDCertFSM::s0_on_exit()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- //if (m_hDevHelper != NULL) {
|
|
|
- // if (m_hDevHelper->DevClose() == Error_Succeed)
|
|
|
- // LOG_TRACE("关闭二代证成功!");
|
|
|
- // else
|
|
|
- // LOG_TRACE("关闭二代证失败!");
|
|
|
- //}
|
|
|
}
|
|
|
unsigned int CIDCertFSM::s0_on_event(FSMEvent* pEvt)
|
|
|
{
|
|
@@ -387,7 +379,7 @@ int CIDCertFSM::ReadInfo(SpReqAnsContext<IDCert_Read_Req, IDCert_Read_Ans>::Poin
|
|
|
hr = m_hDevHelper->IDCerGetData(idInfo);
|
|
|
if (hr != Error_Succeed)
|
|
|
{
|
|
|
- LogErrMsg("ReadInfo::IDCerGetData", hr, MEC_DEVAPI_IDCER_IDCerGetData);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(hr, IDCerGetData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -472,7 +464,7 @@ int CIDCertFSM::ReadInfo(SpReqAnsContext<IDCert_Read_Req, IDCert_Read_Ans>::Poin
|
|
|
hr = m_hDevHelper->IDCerRFControl(false);
|
|
|
if (hr != Error_Succeed)
|
|
|
{
|
|
|
- Dbg("rf close failed(%d).",hr);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(hr, IDCerRFControl);
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
@@ -539,10 +531,7 @@ int CIDCertFSM::ReadInfoEx(SpReqAnsContext<IDCert_ReadEx_Req, IDCert_ReadEx_Ans>
|
|
|
eErr = m_hDevHelper->IDCerAuthenticate();//卡认证
|
|
|
if (Error_Succeed != eErr)
|
|
|
{
|
|
|
- //LOG_TRACE("auth failed.");
|
|
|
- DevErrorInfo devErrInfo;
|
|
|
- m_hDevHelper->GetLastErr(devErrInfo);
|
|
|
- Dbg("IDCerAuthenticate failed %d,%s.", eErr, devErrInfo.szErrMsg);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(eErr, IDCerAuthenticate);
|
|
|
dwEnd = GetTickCount();
|
|
|
elapsed = dwEnd - dwStart;
|
|
|
continue;
|
|
@@ -553,7 +542,7 @@ int CIDCertFSM::ReadInfoEx(SpReqAnsContext<IDCert_ReadEx_Req, IDCert_ReadEx_Ans>
|
|
|
eErr = m_hDevHelper->IDCerGetDataEx(idInfo);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
- LogErrMsg("ReadInfoEx::IDCerGetDataEx", eErr, MEC_DEVAPI_IDCER_IDCerGetDataEx,TRUE);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(eErr, IDCerGetDataEx);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -735,9 +724,7 @@ int CIDCertFSM::ReadAndScan(SpReqAnsContext<IDCert_ReadAndScan_Req, IDCert_ReadA
|
|
|
eErr = m_hDevHelper->IDCerAuthenticate();
|
|
|
if (Error_Succeed != eErr)
|
|
|
{
|
|
|
- DevErrorInfo devErrInfo;
|
|
|
- m_hDevHelper->GetLastErr(devErrInfo);
|
|
|
- Dbg("IDCerAuthenticate failed %d,%s.", eErr, devErrInfo.szErrMsg);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(eErr, IDCerAuthenticate);
|
|
|
dwEnd = GetTickCount();
|
|
|
elapsed = dwEnd - dwStart;
|
|
|
continue;
|
|
@@ -752,7 +739,7 @@ int CIDCertFSM::ReadAndScan(SpReqAnsContext<IDCert_ReadAndScan_Req, IDCert_ReadA
|
|
|
eErr = m_hDevHelper->IDCerGetData(idInfoOld);
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
- LogErrMsg("ReadAndScan::IDCerGetData", eErr, MEC_DEVAPI_IDCER_IDCerGetData);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(eErr, IDCerGetData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -811,7 +798,7 @@ int CIDCertFSM::ReadAndScan(SpReqAnsContext<IDCert_ReadAndScan_Req, IDCert_ReadA
|
|
|
{
|
|
|
if (eErr != Error_Succeed)
|
|
|
{
|
|
|
- LogErrMsg("ReadAndScan::IDCerGetDataEx", eErr, MEC_DEVAPI_IDCER_IDCerGetDataEx,TRUE);
|
|
|
+ LOG_IDCER_ERROR_MSG_MACRO(eErr, IDCerGetDataEx);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -948,22 +935,6 @@ int CIDCertFSM::ReadAndScan(SpReqAnsContext<IDCert_ReadAndScan_Req, IDCert_ReadA
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
-#if 0
|
|
|
-ErrorCodeEnum CIDCertFSM::ConvertBmpToPng(CSimpleStringA &strBmpPath, CSimpleStringA &strPngPath)
|
|
|
-{
|
|
|
- CxImage image;
|
|
|
- if (image.Load((LPCSTR)strBmpPath, CXIMAGE_FORMAT_BMP)) {
|
|
|
- if (image.Save((LPCSTR)strPngPath, CXIMAGE_FORMAT_PNG)) {
|
|
|
- return Error_Succeed;
|
|
|
- } else {
|
|
|
- LOG_TRACE("save %s failed!", (LPCSTR)strPngPath);
|
|
|
- }
|
|
|
- } else {
|
|
|
- LOG_TRACE("load %s failed!", (LPCSTR)strBmpPath);
|
|
|
- }
|
|
|
- return Error_IO;
|
|
|
-}
|
|
|
-#endif
|
|
|
|
|
|
ErrorCodeEnum CIDCertFSM::GetPngBlob(CBlob &data, bool bClear)
|
|
|
{
|
|
@@ -1076,7 +1047,7 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName)
|
|
|
{
|
|
|
if(RemoveFileA((LPCTSTR)strAimPath))
|
|
|
{
|
|
|
- Dbg("DeleteFile(%s) suc.", (LPCTSTR)strAimPath);
|
|
|
+ Dbg("RemoveFileA(%s) suc.", (LPCTSTR)strAimPath);
|
|
|
return Error_Succeed;
|
|
|
}
|
|
|
else
|
|
@@ -1324,28 +1295,6 @@ bool CIDCertFSM::GetAttachedTerminal(CSimpleStringA &csTerm)
|
|
|
return (Error_Succeed == GetEntityBase()->GetFunction()->GetSysVar("AttachedTerminal", csTerm));
|
|
|
}
|
|
|
|
|
|
-void CIDCertFSM::LogErrMsg(const char *pMsgHead, ErrorCodeEnum eErrCode,
|
|
|
- DWORD defaultDevCode /*= 0*/, BOOL bAlarm /*= FALSE*/)
|
|
|
-{
|
|
|
- WORD wdErrCode = 0;
|
|
|
- CSimpleStringA csErrMsg(true);
|
|
|
- ErrorCodeEnum ec = CCommDevFSM::GetAndSplitDevErrInfo(csErrMsg, wdErrCode, "");
|
|
|
- if(ec == Error_Succeed && wdErrCode != 0) {
|
|
|
- //oilyang@20200525 if have been set ErrorCode of entity defined (not device),use it directly
|
|
|
- if ((defaultDevCode >> 20) == m_entCode.dwEntityId)
|
|
|
- UpdateDEC(defaultDevCode);
|
|
|
- else
|
|
|
- UpdateDEC(wdErrCode);
|
|
|
- } else if(defaultDevCode != 0) {
|
|
|
- UpdateDEC(defaultDevCode);
|
|
|
- }
|
|
|
- m_csAlarmMsg = CSimpleStringA::Format("%s failed EC= 0x%x : %s", pMsgHead, eErrCode, (LPCTSTR)csErrMsg);
|
|
|
- if(bAlarm) {
|
|
|
- LogWarn(Severity_High, eErrCode, AlarmDECToBusiness(), (LPCTSTR)m_csAlarmMsg);
|
|
|
- }
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
int CIDCertFSM::Initial()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
@@ -1361,19 +1310,18 @@ int CIDCertFSM::Initial()
|
|
|
|
|
|
CSimpleStringA csLibFullName;
|
|
|
auto pEntity = GET_DEV_ENTITY_BASE_POINTER();
|
|
|
-
|
|
|
+ Dbg("To extra vendor lib file path...");
|
|
|
ErrorCodeEnum err = pEntity->ExtractVendorLibFullPath(csLibFullName);
|
|
|
if (err != Error_Succeed)
|
|
|
{
|
|
|
Dbg("Get vendor libname(%s) failed.", (const char*)csLibFullName);
|
|
|
return Error_DevLoadFileFailed;
|
|
|
}
|
|
|
-
|
|
|
+ Dbg("To load up vendor lib...");
|
|
|
err = m_hDevHelper.LoadUp(csLibFullName);
|
|
|
if (err != Error_Succeed)
|
|
|
{
|
|
|
- LOG_IDCER_ERROR_MSG_MACRO(err, DevOpen);
|
|
|
- LogWarn(Severity_Middle, err, AlarmDEC(), "IDCertificate init failed.");
|
|
|
+ LogErrMsg("LoadUp", err, DEC_DEV_OBJECT_CREATE_FAILED, TRUE);
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
@@ -1394,12 +1342,7 @@ int CIDCertFSM::Initial()
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- err = SpGetDevAdaptorPath(m_pEntity, GetEntityBase()->GetEntityName(), dllName);
|
|
|
- if (err != Error_Succeed) {
|
|
|
- Dbg("get vendor dll(%s)name failed.", (LPCTSTR)dllName);
|
|
|
- return 2;
|
|
|
- }
|
|
|
-
|
|
|
+ dllName = pEntity->GetVendorLibName();
|
|
|
CSmartPointer<IConfigInfo> pConfig;
|
|
|
ErrorCodeEnum rc = GetEntityBase()->GetFunction()->OpenConfig(Config_Root, pConfig);
|
|
|
CSimpleStringA strSection = CSimpleStringA("Device.") + GetEntityBase()->GetEntityName();
|
|
@@ -1428,9 +1371,7 @@ int CIDCertFSM::Initial()
|
|
|
err = m_hDevHelper->DevOpen(tmpPort);
|
|
|
if (err != Error_Succeed)
|
|
|
{
|
|
|
- //LogErrMsg("Initial::DevOpen", err, MEC_DEVAPI_IDCER_DevOpen);
|
|
|
LOG_IDCER_ERROR_MSG_MACRO(err, DevOpen);
|
|
|
- LogWarn(Severity_Middle, err, AlarmDEC(), "IDCertificate init failed.");
|
|
|
return 2;
|
|
|
}
|
|
|
} while (!m_hDevHelper && bOpenFlag == false);
|
|
@@ -1459,8 +1400,7 @@ int CIDCertFSM::Initial()
|
|
|
m_devInit = true;
|
|
|
return 0;
|
|
|
}
|
|
|
-
|
|
|
- else
|
|
|
- return 2;
|
|
|
- return 0;
|
|
|
+ else {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
}
|