|
@@ -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>
|