Explorar el Código

#IQRV #comment [Merge] GPIO

gifur hace 2 años
padre
commit
b21cc9c804
Se han modificado 3 ficheros con 134 adiciones y 99 borrados
  1. 4 0
      Module/mod_gpio/Gpio_def_g.h
  2. 111 31
      Module/mod_gpio/mod_gpio.cpp
  3. 19 68
      Module/mod_gpio/mod_gpio.h

+ 4 - 0
Module/mod_gpio/Gpio_def_g.h

@@ -20,6 +20,10 @@ namespace Gpio {
 #define GpioService_MethodSignature_GetStatus 1783612278
 #define GpioService_MethodSignature_QueryCurrSet -1281718647
 
+#define GpioService_LogCode_Set "QLR040220900"
+#define GpioService_LogCode_GetStatus "QLR040220901"
+#define GpioService_LogCode_QueryCurrSet "QLR040220902"
+
 struct GpioService_Set_Info
 {
 	int devseq;

+ 111 - 31
Module/mod_gpio/mod_gpio.cpp

@@ -115,6 +115,7 @@ static const char* GetLightSeqString(int seq)
 
 void CGpioServiceSession::Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx)
 {
+	DbgToBeidou(ctx->link, __FUNCTION__)();
     GpioService_Set_Info req = ctx->Info;
     DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq=%d", req.devseq);
     DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mode=%d", req.mode);
@@ -124,11 +125,13 @@ void CGpioServiceSession::Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::
 
 void CGpioServiceSession::Handle_GetStatus(SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
 {
+	DbgToBeidou(ctx->link, __FUNCTION__)();
     m_pEntity->GetStatus(ctx->Req.devseq, ctx);
 }
 
 void CGpioServiceSession::Handle_QueryCurrSet(SpReqAnsContext<GpioService_QueryCurrSet_Req, GpioService_QueryCurrSet_Ans>::Pointer ctx)
 {
+	DbgToBeidou(ctx->link, __FUNCTION__)();
     DevOutputInfo output;
     output = m_pEntity->GetCurrDevStatus();
     ctx->Ans.dir = output.dir;
@@ -187,6 +190,54 @@ void CGpioEntity::ToLogRootINIInfo()
     return;
 }
 
+
+struct GpioInitTask : public ITaskSp {
+	CGpioEntity* m_entity;
+	CSmartPointer<ITransactionContext> m_pTransactionContext;
+	GpioInitTask(CGpioEntity* entity, CSmartPointer<ITransactionContext> pTransactionContext) :m_entity(entity), m_pTransactionContext(pTransactionContext) {}
+
+	void Process()
+	{
+		m_entity->InitializeVendorLogSwitch();
+		ErrorCodeEnum err = m_entity->Initial();
+		if (err == Error_Succeed)
+		{
+			LOG_TRACE("Gpio open succeeded.");
+
+			//oiltest 20130118 for audiodg handle
+			m_entity->GetStatus(PHONEPICKUP, NULL);
+
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("subscribelog...");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidHealth, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "HealthManager");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidIDC, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "IDCertificate");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidFP, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "FingerPrint");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidKB, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PinPad");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidCR, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "CardIssuer");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidCA, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "CustomerAware");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidCC, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "ContactlessCard");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidDD, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "DeviceControl");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidCS, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "CardSwiper");
+			m_entity->GetFunction()->SubscribeLog(m_entity->m_uuidHSPscanner, m_entity, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "HSPScanner");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sub ok...");
+
+			m_pTransactionContext->SendAnswer(Error_Succeed);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send Error_Succeed ok...");
+		}
+		else
+		{
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("gpio open failed(%d).", err); 
+			m_pTransactionContext->SendAnswer(Error_Unexpect);
+		}
+	}
+};
+
+void CGpioEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext)
+{
+	LOG_FUNCTION();
+	GpioInitTask* initTask = new GpioInitTask(this, pTransactionContext);
+	GetFunction()->PostThreadPoolTask(initTask);
+}
+
 void CGpioEntity::ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo)
 {
 	LOG_FUNCTION();
@@ -203,10 +254,20 @@ void CGpioEntity::ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo)
     SP::Module::Util::HexBuf2StrBuf(fileHash, &strFileHash, 32);
 
 	//calculate file size
-	struct stat statbuf;
-	ZeroMemory(&statbuf, sizeof(statbuf));
-	stat(m_adapterInfo.adapterFileName.GetData(), &statbuf);
-	int fileSize = statbuf.st_size;
+#if defined(RVC_OS_LINUX)
+    struct stat statbuf;
+    ZeroMemory(&statbuf, sizeof(statbuf));
+    stat(m_adapterInfo.adapterFilePath.GetData(), &statbuf);
+    int fileSize = statbuf.st_size;
+#else
+    int fileSize = 0;
+    HANDLE hFile;
+    hFile = CreateFile(m_adapterInfo.adapterFilePath.GetData(), 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+    if (hFile != INVALID_HANDLE_VALUE) {
+        fileSize = GetFileSize(hFile, NULL);
+        CloseHandle(hFile);
+    }
+#endif //RVC_OS_LINUX
 
 	termInfo["VendorDllName"] = m_adapterInfo.adapterFileName;
 	termInfo["VendorDllFileHash"] = strFileHash;
@@ -278,7 +339,7 @@ ErrorCodeEnum CGpioEntity::Initial()
         DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load up %s failed: %s", dllName.GetData(), SpStrError(eErrDev));
         return Error_DevLoadFileFailed;
     }
-	m_adapterInfo.adapterFileName = dllName;
+	m_adapterInfo.adapterFilePath = dllName;
     int initTries = 0;
     do {
         DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to open device.");
@@ -353,12 +414,15 @@ ErrorCodeEnum CGpioEntity::Initial()
     }
 
     err = m_hDevHelper->WritePort(0, 0x00);
-    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(0) returned: %s)", SpStrError(err));
+	if (err != Error_Succeed)
+    	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(0) returned: %s)", SpStrError(err));
     err = m_hDevHelper->WritePort(1, 0x00);
-    DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(1) returned: %s)", SpStrError(err));
+	if (err != Error_Succeed)
+    	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(1) returned: %s)", SpStrError(err));
     if (m_bNewVersion) {
         err = m_hDevHelper->WritePort(3, 0x00);
-        DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(3) returned: %s)", SpStrError(err));
+		if (err != Error_Succeed)
+        	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("write ports(3) returned: %s)", SpStrError(err));
     }
 
     //oilyang@20170214 
@@ -893,7 +957,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
             if (initCtt == 1) {
                 if (DetectBit(btInput, VIBRATIONSENSOR)) {
-                    if (!m_bVibrationFlag && (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)) {
+                    if (!m_bVibrationFlag && IfHaveMoveDetect()) {
                         LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR,  CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
                     }
                     m_bVibrationFlag = true;
@@ -905,7 +969,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
             if (m_bVibrationRound) {
                 if (DetectBit(btInput, VIBRATIONSENSOR) && !m_bVibrationFlag) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
                     m_bVibrationFlag = true;
                     m_bVibrationRound = false;
@@ -929,12 +993,12 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             if (initCtt == 1) {
                 if (DetectBit(btInput, OPENSENSOR)) {
                     if (!m_bOpenFlag) {
-                        if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                        if (IfHaveMoveDetect())
                             LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
                         m_bOpenFlag = true;
                     }
                 } else if (m_bOpenFlag) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
                     m_bOpenFlag = false;
                 }
@@ -943,13 +1007,13 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
             if (m_bOpenRound) {
                 if (DetectBit(btInput, OPENSENSOR) && !m_bOpenFlag) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
                     m_bOpenFlag = true;
                     m_bOpenRound = false;
                 }
             } else if (!DetectBit(btInput, OPENSENSOR) && m_bOpenFlag) {
-                if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                if (IfHaveMoveDetect())
                     LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
                 m_bOpenFlag = false;
                 m_bOpenRound = true;
@@ -968,7 +1032,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
             if (initCtt == 1) {
 
-                if (m_ePickUpFlag == Unknown) {
+                if (m_ePickUpFlag == UnknownStatus) {
                     if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
                     else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
                     DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
@@ -978,7 +1042,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
                     if (DetectBit(btInput, PICKUPSENSOR)) {
                         if (m_ePickUpFlag == InActive) {
 
-                            if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                            if (IfHaveMoveDetect())
                                 LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
 
                             m_ePickUpFlag = Actived;
@@ -986,7 +1050,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
                     } else if (m_ePickUpFlag == Actived) {
 
-                        if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                        if (IfHaveMoveDetect())
                             LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
 
                         m_ePickUpFlag = InActive;
@@ -1001,13 +1065,13 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
                     if (m_ePickUpFlag == InActive) {
 
-                        if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                        if (IfHaveMoveDetect())
                             LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
 
                         m_ePickUpFlag = Actived;
                         m_bPickUpRound = false;
 
-                    } else if (m_ePickUpFlag == Unknown) {
+                    } else if (m_ePickUpFlag == UnknownStatus) {
                         m_ePickUpFlag = Actived;
                     }
                 }
@@ -1015,13 +1079,13 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
                 if (m_ePickUpFlag == Actived) {
 
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
 
                     m_ePickUpFlag = InActive;
                     m_bPickUpRound = true;
 
-                } else if (m_ePickUpFlag == Unknown) {
+                } else if (m_ePickUpFlag == UnknownStatus) {
                     m_ePickUpFlag = InActive;
                 }
             }
@@ -1038,7 +1102,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
         do {
             if (initCtt == 1) {
                 if (DetectBit(btInput, MOVESENSOR)) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
                 }
                 break;
@@ -1049,12 +1113,20 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
                     m_moveDisappearTimes = 0;
                     if (m_moveHoldTimes < MAX_MOVE_HOLD_TIMES) { // 100ms * 5000
                         if ((m_moveHoldTimes % LOG_TIME_VALUE) == 0) {  //100ms * 25 = 2.5s 但因为厂家接口调用,不进来计数,需要800ms+
-                            if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                            if (IfHaveMoveDetect())
                                 LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
                         }
                     } else if ((m_moveHoldTimes % MAX_MOVE_HOLD_TIMES) == 0) { //难道8分钟一直有人就异常?还有一个 Round 标识
-                        if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
-                            LogWarn(Severity_Middle, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL, "移动次数异常");
+                        if (IfHaveMoveDetect()) {
+								SYSTEMTIME localTime;
+								GetLocalTime(&localTime);
+								if (localTime.wHour > 8 && localTime.wHour < 18)
+									LogWarn(Severity_High, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL_WORKTIME, "Move detect is abnormal(Work time).");
+								else
+									LogWarn(Severity_High, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL_OFFWORK, "Move detect is abnormal(off work).");
+						
+						}
+
                     }
                     m_moveHoldTimes++;
                     m_bMoveRound = false;
@@ -1062,7 +1134,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             } else if (!DetectBit(btInput, MOVESENSOR)) {
                 m_moveHoldTimes = 0;
                 if ((m_moveDisappearTimes % LOG_TIME_VALUE) == 0) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(20), __LINE__));
                 }
                 m_moveDisappearTimes++;
@@ -1083,7 +1155,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
             if (initCtt == 1) {
                 if (DetectBit(btInput, CARDGATESENSOR)) {
                     if (!m_bCardGateFlag) {
-                        if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                        if (IfHaveMoveDetect())
                             LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
                         m_bCardGateFlag = true;
                     }
@@ -1094,7 +1166,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
 
             if (m_bCardGateRound) {
                 if (DetectBit(btInput, CARDGATESENSOR) && !m_bCardGateFlag) {
-                    if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus)
+                    if (IfHaveMoveDetect())
                         LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
                     m_bCardGateFlag = true;
                     m_bCardGateRound = false;
@@ -1154,7 +1226,7 @@ void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
     if (pGci->CttPhone > 1 && !bPhoneOne) {
         do {
 
-            if (m_ePickUpFlag == Unknown) {
+            if (m_ePickUpFlag == UnknownStatus) {
                 if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
                 else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
                 DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
@@ -1378,6 +1450,14 @@ BYTE CGpioEntity::GetOutputStatus(int sn)
         return 0;
 }
 
+bool CGpioEntity::IfHaveMoveDetect()
+{
+	if (m_eMachineType == RVC_Stand2S || m_eMachineType == RVC_Stand1SPlus ||m_eMachineType == RVC_CardPrinter)
+		return true;
+	else
+		return false;
+}
+
 SP_BEGIN_ENTITY_MAP()
-SP_ENTITY(CGpioEntity)
-SP_END_ENTITY_MAP()
+	SP_ENTITY(CGpioEntity)
+SP_END_ENTITY_MAP() 

+ 19 - 68
Module/mod_gpio/mod_gpio.h

@@ -11,7 +11,9 @@
 #include "DevFSMCommBase.hpp"
 #include "CommEntityUtil.hpp"
 
+using namespace std;
 using namespace Gpio;
+
 const int GPIO_INIT_COUNT = 3;
 typedef ErrorCodeEnum (*lpCreateDevCom)(DeviceBaseClass *&baseObj);
 typedef ErrorCodeEnum (*lpReleaseDevCom)(DeviceBaseClass *&pBaseObj);
@@ -45,7 +47,7 @@ enum PinPort{
 /*用于标识等挂机等状态,布尔型不能满足,需要有一个初始状态*/
 enum PinActiveStatus
 {
-	Unknown,
+	UnknownStatus,
 	InActive,
 	Actived
 };
@@ -142,12 +144,12 @@ class CGpioEntity : public CDevAdptEntityBase, public ILogListener
 public:
 	//0000 0000 0000 0010 0110 1111 1100 0000
 	CGpioEntity():m_devEnableStatus(0x1f),m_bPickUpRound(false),m_bVibrationRound(false)
-		,m_bOpenRound(false),m_bMoveRound(false),m_bCardGateRound(false), m_ePickUpFlag(Unknown)
+		,m_bOpenRound(false),m_bMoveRound(false),m_bCardGateRound(false), m_ePickUpFlag(UnknownStatus)
 		,m_bVibrationFlag(false),m_bOpenFlag(false),m_bMoveFlag(false),m_bCardGateFlag(false)
 		, m_pLogListener(NULL), m_bHeadLightFlag(false), m_headlightDevPort(0), m_moveHoldTimes(0)
 		, m_moveDisappearTimes(0),m_eMachineType(SP::Module::Comm::RVC_UNKNOWN)
 		, m_bNewVersion(FALSE), m_FirstStart(true)
-		, m_csDevNo(""), m_port(""), m_portNum(""), m_Baudrate(""), m_InOutDir("")
+		, m_csDevNo(true), m_port(true), m_portNum(true), m_Baudrate(true), m_InOutDir(true)
 	{
 		m_timerID = 1;
 		currDevStatus.dir = 0x3eFC0;
@@ -157,70 +159,18 @@ public:
 		currDevStatus.output = 0x0;
 //		currDir = 0x2007ffff;
 		//m_pPIUT = new PositivePulseUpTimer();
+		HARDWARE_ENTITY_RESET_ENTITYID(m_entCode, 0x209);
 	}
-
-#ifdef RVC_OS_LINUX
-	unsigned long GetTickCount()
-	{
-		struct timespec ts;
-		clock_gettime(CLOCK_MONOTONIC, &ts);
-		return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
-	}
-#endif
-
-	virtual ~CGpioEntity()
-	{
-		LOG_FUNCTION();
-	}
-
+	virtual ~CGpioEntity(){}
 	virtual const char* GetEntityName()const {return "Gpio";}
 	const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
-
-	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
-	{
-		LOG_FUNCTION();
-		InitializeVendorLogSwitch();
-
-		ErrorCodeEnum err = Initial();
-		if (err == Error_Succeed)
-		{
-			LOG_TRACE("Gpio open succeeded.");
-
-			GetStatus(PHONEPICKUP,NULL);
-
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("subscribelog...");
-			GetFunction()->SubscribeLog(m_uuidHealth,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"HealthManager");
-			GetFunction()->SubscribeLog(m_uuidIDC,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"IDCertificate");
-			GetFunction()->SubscribeLog(m_uuidFP, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "FingerPrint");
-			GetFunction()->SubscribeLog(m_uuidKB,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"PinPad");
-			GetFunction()->SubscribeLog(m_uuidCR,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"CardIssuer");
-			GetFunction()->SubscribeLog(m_uuidCA,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"CustomerAware");
-			GetFunction()->SubscribeLog(m_uuidCC,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"ContactlessCard");
-			GetFunction()->SubscribeLog(m_uuidDD,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"DeviceControl");
-			GetFunction()->SubscribeLog(m_uuidCS, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "CardSwiper");
-			GetFunction()->SubscribeLog(m_uuidHSPscanner, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "HSPScanner");
-            GetFunction()->SubscribeLog(m_uuidIE, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "IEBrowser");
-
-#if defined(RVC_OS_WIN)
-			GetFunction()->SubscribeLog(m_uuidPtr, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "Printer");
-            GetFunction()->SubscribeLog(m_uuidPrintSeal, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PrintSeal");
-#endif //RVC_OS_WIN
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("subscribelog ok...");
-
-			pTransactionContext->SendAnswer(Error_Succeed);
-		}
-		else
-		{
-			DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("gpio open failed(%s).",SpStrError(err));
-			pTransactionContext->SendAnswer(Error_Unexpect);
-		}
-	}
-
+	
+	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext);
+	
 	virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
 		CSimpleStringA initDriver = "";
 		int driverPort;
-		ErrorCodeEnum Error;
         initDriver = "CardReaderNormal";
         driverPort = 0;
 		OutDrivingInfo odi;
@@ -281,21 +231,19 @@ public:
 	void ToLogRootINIInfo();
 	void ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo);
 
-private:
+public:
 
-	HMODULE m_hVerdorDll;
-	lpCreateDevCom CreateDevComponent;
-	lpReleaseDevCom ReleaseDevComponent;
+    CUUID m_uuidHealth, m_uuidPtr, m_uuidCR, m_uuidIDC, m_uuidFP, m_uuidKB, m_uuidCA, m_uuidCC, m_uuidDD, m_uuidCS, m_uuidIE;
+    CUUID m_uuidHSPscanner;
 
+private:
 	DevAdptLibHelper<GpioClass> m_hDevHelper;
 	SP::Module::Comm::What m_eMachineType;
 
 	BYTE m_btOutputStatus[MAX_PORT_NUM];
 	DWORD m_dwPortNum,m_dwInOutDir;
 	BOOL m_bNewVersion;
-	CUUID m_uuidHealth,m_uuidPtr,m_uuidCR,m_uuidIDC,m_uuidFP,m_uuidKB,m_uuidCA,m_uuidCC,m_uuidDD,m_uuidCS,m_uuidIE,m_uuidPrinter;
-	CUUID m_uuidHSPscanner;
-	CUUID m_uuidPrintSeal;
+
 	DevOutputInfo currDevStatus;
 	DevCategoryInfo m_devCatInfo;
 	ULONG m_devEnableStatus;
@@ -306,7 +254,10 @@ private:
 	bool m_bHeadLightFlag;
 	int m_headlightDevPort, m_moveHoldTimes, m_moveDisappearTimes;
 	ILogListener *m_pLogListener;
-	CSimpleStringA m_csMachineType;
+	CSimpleStringA m_csMachineType, m_csAlarmMsg;
+	DevEntityErrorCode m_entCode;
+	bool IfHaveMoveDetect();
+	ErrorPackage m_errPkg;
 	AdapterInfo m_adapterInfo;
 	CSimpleStringA m_csDevNo;
 	CSimpleStringA m_port;