Răsfoiți Sursa

#IQRV #comment [Module] 修改GPIO,并添加GPIO的生成和启动,一期添加GPIO模块

gifur 4 ani în urmă
părinte
comite
215abe600c

+ 3 - 0
ChangeLog

@@ -1,4 +1,7 @@
 ## 更新记录
+* 健康实体添加GPIO的启动,并修改Demo适配器保证接口调用成功(廖桂发,2020年12月8日)
+* 整合厂商的代码到码云和Conan,修改CMake脚本,做适应性改造(廖桂发,2020年12月8日)
+* 跟恒银要了GPIO的代码,因一期礼鹏的实体严重依赖GPIO,同时打开GPIO的编译(廖桂发,2020年12月8日)
 
 ## V0.0.2-dev1
 

+ 1 - 1
DevAdapter/cmbsz/gpio.1.1/gpio_impl.h

@@ -36,7 +36,7 @@ public:
     //
     virtual ErrorCodeEnum WritePort(DWORD dwPort, BYTE btData)
     {
-        return Error_NotImpl;
+        return Error_Succeed;
     }
     //
     //	Get port input.

+ 1 - 1
Module/CMakeLists.txt

@@ -182,7 +182,7 @@ add_subdirectory(mod_ups)
 add_subdirectory(mod_ScannerSet)
 add_subdirectory(mod_HSPScanner)
 add_subdirectory(mod_ContactlessCard)
-#add_subdirectory(mod_gpio)
+add_subdirectory(mod_gpio)
 add_subdirectory(mod_watchdog)
 add_subdirectory(mod_DeviceControl)
 #add_subdirectory(mod_ThermalPrint)

+ 0 - 48
Module/mod_gpio/ReadMe.txt

@@ -1,48 +0,0 @@
-========================================================================
-    DYNAMIC LINK LIBRARY : mod_gpio Project Overview
-========================================================================
-
-AppWizard has created this mod_gpio DLL for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your mod_gpio application.
-
-
-mod_gpio.vcxproj
-    This is the main project file for VC++ projects generated using an Application Wizard.
-    It contains information about the version of Visual C++ that generated the file, and
-    information about the platforms, configurations, and project features selected with the
-    Application Wizard.
-
-mod_gpio.vcxproj.filters
-    This is the filters file for VC++ projects generated using an Application Wizard. 
-    It contains information about the association between the files in your project 
-    and the filters. This association is used in the IDE to show grouping of files with
-    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
-    "Source Files" filter).
-
-mod_gpio.cpp
-    This is the main DLL source file.
-
-	When created, this DLL does not export any symbols. As a result, it
-	will not produce a .lib file when it is built. If you wish this project
-	to be a project dependency of some other project, you will either need to
-	add code to export some symbols from the DLL so that an export library
-	will be produced, or you can set the Ignore Input Library property to Yes
-	on the General propert page of the Linker folder in the project's Property
-	Pages dialog box.
-
-/////////////////////////////////////////////////////////////////////////////
-Other standard files:
-
-StdAfx.h, StdAfx.cpp
-    These files are used to build a precompiled header (PCH) file
-    named mod_gpio.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////

Fișier diff suprimat deoarece este prea mare
+ 102 - 383
Module/mod_gpio/mod_gpio.cpp


+ 36 - 42
Module/mod_gpio/mod_gpio.h

@@ -1,12 +1,15 @@
 #ifndef __MOD_GPIO_H
 #define __MOD_GPIO_H
 
+#include "modVer.h"
 #include "SpBase.h"
 #include "GpioClass.h"
 #include "Gpio_server_g.h"
 #include "EventCode.h"
 #include "GetDevInfoHelper.h"
 #include "DevFSMCommBase.hpp"
+#include "CommEntityUtil.hpp"
+
 using namespace Gpio;
 const int GPIO_INIT_COUNT = 3;
 typedef ErrorCodeEnum (*lpCreateDevCom)(DeviceBaseClass *&baseObj);
@@ -99,7 +102,7 @@ struct GetContextInfo
 	int CttPhone,CttMove,CttShake,CttSwitch,CttCard;
 	int InitCTT;//ContinuousTriggerTime get from configure file
 };
-class CGpioEntity : public CEntityBase,public ILogListener
+class CGpioEntity : public CDevAdptEntityBase, public ILogListener
 {
 public:
 	//0000 0000 0000 0010 0110 1111 1100 0000
@@ -107,8 +110,8 @@ public:
 		,m_bOpenRound(false),m_bMoveRound(false),m_bCardGateRound(false),m_bPickUpFlag(false)
 		,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_bNewVersion(FALSE), m_csMachineType("")
+		, m_moveDisappearTimes(0),m_eMachineType(SP::Module::Comm::RVC_UNKNOWN)
+		, m_bNewVersion(FALSE)
 	{
 		m_timerID = 1;
 		currDevStatus.dir = 0x3eFC0;
@@ -119,8 +122,8 @@ public:
 //		currDir = 0x2007ffff;
 		//m_pPIUT = new PositivePulseUpTimer();
 	}
-#ifdef RVC_OS_WIN
-#else
+
+#ifdef RVC_OS_LINUX
 	unsigned long GetTickCount()
 	{
 		struct timespec ts;
@@ -128,37 +131,24 @@ public:
 		return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
 	}
 #endif
-	virtual ~CGpioEntity(){}
+
+	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();
-		/*------2020-02-27------*/
-		//modify by LZM
-		VendorLogControlerEx(this,"Gpio");
-		/*---------------------*/
-		//MessageBoxA(0,0,0,0);
+		InitializeVendorLogSwitch();
+
 		ErrorCodeEnum err = Initial();
 		if (err == Error_Succeed)
 		{
 			LOG_TRACE("Gpio open succeeded.");
-			//err = m_pGpio->SetPortsDirection(m_dwPinMask,m_dwInOutDir);
-			
-			//oiltest 20130118 for audiodg handle
 			GetStatus(PHONEPICKUP,NULL);
-			//GetStatus(SWITCHINDUCTOR,NULL);
-			//GetStatus(PHONEPICKUP,NULL);
-			//GetStatus(MOVEDETECT,NULL);
-			//GetStatus(CARDGATEDETECT,NULL);
-
-			//m_pLogListener = new CLogListener(this);
-			//m_pLogListener->Subscribe(true, this);
-			//m_pLogListener->AddFilter(Log_Event, "Printer", Severity_Middle, Error_IgnoreAll, -1); // only accept event from printer
-			//m_pLogListener->AddFilter(Log_Event, "IDCertificate", Severity_Middle, Error_IgnoreAll, -1); // only accept event from IDCertificate
-			//m_pLogListener->AddFilter(Log_Event, "Keyboard", Severity_Middle, Error_IgnoreAll, -1); // only accept event from Keyboard
-			//m_pLogListener->AddFilter(Log_Event, "CardReader", Severity_Middle, Error_IgnoreAll, -1); // only accept event from CardReader
-			//m_pLogListener->AddFilter(Log_Event, "CustomerSensor", Severity_Middle, Error_IgnoreAll, -1); // only accept event from CustomerSensor
-			//m_pLogListener = new ILogListener;
 			Dbg("subscribelog...");
 			GetFunction()->SubscribeLog(m_uuidHealth,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"HealthManager");
 			GetFunction()->SubscribeLog(m_uuidPtr,this,Log_Event,Severity_Middle,Error_IgnoreAll,-1,"Printer");
@@ -174,37 +164,30 @@ public:
 			GetFunction()->SubscribeLog(m_uuidHSPscanner, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "HSPScanner");
 			GetFunction()->SubscribeLog(m_uuidPrinter, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "ThermalPrint");
 			GetFunction()->SubscribeLog(m_uuidPrintSeal, this, Log_Event, Severity_Middle, Error_IgnoreAll, -1, "PrintSeal");
-			Dbg("sub ok...");
+			Dbg("subscribelog ok...");
 			pTransactionContext->SendAnswer(Error_Succeed);
-			Dbg("send Error_Succeed ok...");
 		}
 		else
 		{
-			Dbg("gpio open failed(%d).",err);
+			Dbg("gpio open failed(%s).",SpStrError(err));
 			pTransactionContext->SendAnswer(Error_Unexpect);
 		}
 	}
+
 	virtual void OnPrePause(CSmartPointer<ITransactionContext> pTransactionContext)
 	{
-		//LOG_FUNCTION();
 		CSimpleStringA initDriver = "";
 		int driverPort;
 		ErrorCodeEnum Error;
 		CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
 		CSmartPointer<IConfigInfo> spConfig;
 		Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
-		if (Error != Error_Succeed) {
-			LOG_TRACE("open cfg file failed!");
-			return;
-		}
 		spConfig->ReadConfigValue("InitDriver","CardReader",initDriver);
 		spConfig->ReadConfigValueInt("DriverPort","CardReader",driverPort);
 		OutDrivingInfo odi;
 		GetOutDrivingModInfo(initDriver,odi);
 		bool bSetFlag = true;
 		Dbg("read port[%u]",(ULONG)driverPort);
-		//MessageBoxA(0,0,0,0);
-		//SetOutDriving(odi,0,bSetFlag,(ULONG)driverPort,NULL);
 		pTransactionContext->SendAnswer(Error_Succeed);
 	}
 
@@ -214,20 +197,26 @@ public:
 		m_pGpio->DevClose();
 		pTransactionContext->SendAnswer(Error_Succeed);
 	}
+
 	virtual CServerSessionBase *OnNewSession(const char* /*pszRemoteEntityName*/, const char * pszClass)
 	{
-		//LOG_FUNCTION();
 		return new CGpioServiceSession(this);
 	}
+
 	bool SetOutDriving(GpioService_Set_Info req,OutDrivingInfo od, ULONG iIndex,ULONG devSeq);
-	//bool GetReceiving(ReceivingInfo ri, ULONG iIndex, PULONG pReceiving);
+
 	bool GetReceiving(int deviceSeq,ReceivingInfo ri, ULONG iIndex, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx);
+
 	DevOutputInfo GetCurrDevStatus()const {return currDevStatus;}
+
 	void SaveCurrDevStatus(DevOutputInfo devOutputInfo) {currDevStatus = devOutputInfo;}
-	//void GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& odi);
+
 	ULONG GetDevEnableStatus(){return m_devEnableStatus;}
+
 	void SetDevEnableStatus(ULONG devEnableStatus){m_devEnableStatus = devEnableStatus;}
+
 	ULONG GetNewTimerID(){return m_timerID++;}
+
 	BYTE GetOutputStatus(int sn=0);
 
 	virtual bool IsService()const{return true;}
@@ -245,15 +234,21 @@ public:
 	void GetStatus(int deviceSeq,SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx);
 	void Set(GpioService_Set_Info info);
 	void WritePin(DWORD dwPinSeq,bool bHighLow);
-	void SetDeviceDirOutput(GpioService_Set_Info req,ULONG pinSeq);
+
 	virtual void OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
 		const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID, 
 		const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage);
+
 private:
+
 	HMODULE m_hVerdorDll;
 	lpCreateDevCom CreateDevComponent;
 	lpReleaseDevCom ReleaseDevComponent;
 	GpioClass *m_pGpio;
+
+	DevAdptLibHelper<GpioClass> m_hDevHelper;
+	SP::Module::Comm::What m_eMachineType;
+
 	BYTE m_btOutputStatus[MAX_PORT_NUM];
 	DWORD m_dwPortNum,m_dwInOutDir;
 	BOOL m_bNewVersion;
@@ -270,7 +265,6 @@ private:
 	ILogListener *m_pLogListener;
 	CSimpleStringA m_csMachineType;
 
-	//PositivePulseUpTimer* m_pPIUT;
 };
 
 template<class T>

+ 1 - 1
addin/cfg/HealthManager.ini

@@ -59,7 +59,7 @@ PinPad=2
 ;PinPad=2
 CardIssuer=2
 IDCertificate=2
-;Gpio=2
+Gpio=2
 ;ScannerSet=0
 ;ContactlessCard=0
 ;print=0

+ 1 - 1
addin/cfg/shell.ini.in

@@ -29,7 +29,7 @@ FingerPrint=0,@LIB_PREFIX@mod_FingerPrint@LIB_SUFFIX@,0x204
 ;Printer=0,@LIB_PREFIX@mod_printer@LIB_SUFFIX@,0x205
 PinPad=0,@LIB_PREFIX@mod_PinPad@LIB_SUFFIX@,0x206
 MediaController=0,@LIB_PREFIX@mod_mediacontroller@LIB_SUFFIX@,0x208
-Gpio=0,@LIB_PREFIX@mod_gpio@LIB_SUFFIX@,0x209
+Gpio=0,@LIB_PREFIX@mod_Gpio@LIB_SUFFIX@,0x209
 WatchDog=0,@LIB_PREFIX@mod_WatchDog@LIB_SUFFIX@,0x20D
 Ups=0,@LIB_PREFIX@mod_Ups@LIB_SUFFIX@,0x20E
 MaintainWatcher=0,@LIB_PREFIX@mod_MaintainWatcher@LIB_SUFFIX@,0x210

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff