123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356 |
- #include "stdafx.h"
- #include "mod_gpio.h"
- const int MAX_GPIO_INIT_TRIES = 3;
- const int INPUT_PORT_2 = 2;
- const int MAX_MOVE_HOLD_TIMES = 5000;
- const int LOG_TIME_VALUE = 25;
- int positive_pulse_up_count = 0;
- int negative_pulse_down_count = 0;
- int positive_pulse_both_count = 0;
- int negative_pulse_both_count = 0;
- int positive_level_count = 0;
- int negative_level_count = 0;
- #define SETBIT(x,y) x|=(1<<(y))
- #define CLEARBIT(x,y) x&=((1<<(y))^0xffffff)
- using namespace SP::Module::Comm;
- bool DetectBit(ULONG data, int pos)
- {
- ULONG tmp = 0;
- SETBIT(tmp, pos);
- return data & tmp;
- }
- static const char* GetDriverPortString(int pin)
- {
- switch (pin) {
- case 1: return "【驱动】读卡发卡器提示灯";
- case 2: return "【驱动】前端USB通断控制";
- case 3: return "【驱动】身份证阅读器提示灯";
- case 4: return "【驱动】密码键盘提示灯";
- case 5: return "【驱动】脸部照明灯";
- case 6: return "【驱动】故障灯";
- case 7: return "【驱动】读卡发卡器维护提示灯";
- case 8: return "【驱动】前端USB口提示灯";
- case 9: return "【驱动】非接IC读卡器提示灯";
- case 10: return "";
- case 11: return "【驱动】指纹仪提示灯";
- case 12: return "【驱动】凭条打印提示灯";
- case 13: return "【驱动】高拍仪提示灯";
- case 14: return "";
- case 15: return "";
- case 16: return "";
- case 17: return "【接收】震动探测器";
- case 18: return "【接收】机具门感应开关";
- case 19: return "【接收】话机提机感应开关";
- case 20: return "【接收】人体探测感应器";
- case 21: return "【接收】发卡器卡嘴覆盖探测器";
- //case 22: return "";
- //case 23: return "";
- //case 24: return "";
- //case 25: return "";
- case 26: return "【驱动】高拍仪提示灯";
- //case 27: return "";
- //case 28: return "";
- //case 29: return "";
- //case 30: return "";
- //case 31: return "";
- //case 32: return "";
- //case 33: return "";
- //case 34: return "";
- //case 35: return "";
- //case 36: return "";
- //case 37: return "";
- //case 38: return "";
- //case 39: return "";
- //case 40: return "";
- //case 41: return "";
- //case 42: return "";
- default:
- Dbg("Unkown pin sequence: %d", pin);
- return "";
- break;
- }
- }
- #define LIGHT_STRING_CONVERT(str) case str : return #str; break;
- static const char* GetLightSeqString(int seq)
- {
- switch (seq) {
- LIGHT_STRING_CONVERT(UNKNOWN_DEVICE)
- LIGHT_STRING_CONVERT(CARDREADER)
- LIGHT_STRING_CONVERT(CARDREADER_RED)
- LIGHT_STRING_CONVERT(PRINTER)
- LIGHT_STRING_CONVERT(IDCERTIFICATE)
- LIGHT_STRING_CONVERT(PINPAD)
- LIGHT_STRING_CONVERT(PINPADLIGHT)
- LIGHT_STRING_CONVERT(SHAKEDETECT)
- LIGHT_STRING_CONVERT(SWITCHINDUCTOR)
- LIGHT_STRING_CONVERT(PHONEPICKUP)
- LIGHT_STRING_CONVERT(MOVEDETECT)
- LIGHT_STRING_CONVERT(CARDGATEDETECT)
- LIGHT_STRING_CONVERT(HEADLIGHT)
- LIGHT_STRING_CONVERT(HEADLIGHT_RED)
- LIGHT_STRING_CONVERT(CONTACTLESSCARD)
- LIGHT_STRING_CONVERT(USBCONTROL)
- LIGHT_STRING_CONVERT(USBLIGHT)
- LIGHT_STRING_CONVERT(HEADLIGHT_ASSIST)
- LIGHT_STRING_CONVERT(HSPSCANNER)
- LIGHT_STRING_CONVERT(PRINTER_SEAL)
- LIGHT_STRING_CONVERT(FINGERPRINT)
- default:
- Dbg("Unkonwn LightSeq: %d", seq);
- return "UnConver One";
- break;
- }
- }
- #undef LIGHT_STRING_CONVERT
- void CGpioServiceSession::Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx)
- {
- GpioService_Set_Info req = ctx->Info;
- Dbg("devseq=%d", req.devseq);
- Dbg("mode=%d", req.mode);
- Dbg("close=%d", req.close);
- m_pEntity->Set(req);
- }
- void CGpioServiceSession::Handle_GetStatus(SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
- {
- m_pEntity->GetStatus(ctx->Req.devseq, ctx);
- }
- void CGpioServiceSession::Handle_QueryCurrSet(SpReqAnsContext<GpioService_QueryCurrSet_Req, GpioService_QueryCurrSet_Ans>::Pointer ctx)
- {
- DevOutputInfo output;
- output = m_pEntity->GetCurrDevStatus();
- ctx->Ans.dir = output.dir;
- ctx->Ans.output = m_pEntity->GetOutputStatus(0);
- ctx->Answer(Error_Succeed);
- }
- bool isnostr(const char* str)
- {
- int len = strlen(str);
- if (len == 0)
- return true;
- for (int i = 0; i < len; ++i) {
- if (*(str + i) != ' ')
- return false;
- }
- return true;
- }
- ErrorCodeEnum CGpioEntity::Initial()
- {
- ErrorCodeEnum err;
- LOG_FUNCTION();
- ErrorCodeEnum eErrDev;
- CSimpleStringA dllName;
- eErrDev = ExtractVendorLibFullPath(dllName);
- if (eErrDev != Error_Succeed) {
- Dbg("load vendor dll or so(%s)(%s) failed.", dllName.GetData(), SpStrError(eErrDev));
- return Error_DevLoadFileFailed;
- }
- Dbg("library name: %s", dllName.GetData());
- CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- eErrDev = spEntityFunction->OpenConfig(Config_Root, spConfig);
- if (eErrDev != Error_Succeed) {
- Dbg("open cfg file failed!");
- return eErrDev;
- }
- CSimpleStringA devVendor, devVer, devBatch, dllSuffix;
- devVendor = devVer = devBatch = "";
- spConfig->ReadConfigValue("Device.Gpio", "Vendor", devVendor);
- spConfig->ReadConfigValue("Device.Gpio", "Version", devVer);
- spConfig->ReadConfigValue("Device.Gpio", "Batch", devBatch);
- #if defined(RVC_OS_WIN)
- Dbg("[%s],[%s],[%s]", devVendor.GetData(), devVer.GetData(), devBatch.GetData());
- if (!_stricmp(devVendor, "Hyosung") || !_stricmp(devVendor, "Keba") || !_stricmp(devVendor, "Kxd")) {
- if (devVer == "1" && devBatch == "1") {
- m_bNewVersion = FALSE;
- } else {
- m_bNewVersion = TRUE;
- }
- } else {
- m_bNewVersion = TRUE;
- }
- #else
- m_bNewVersion = TRUE;
- #endif
- eErrDev = m_hDevHelper.LoadUp(dllName);
- if (eErrDev != Error_Succeed) {
- Dbg("load up %s failed: %s", dllName.GetData(), SpStrError(eErrDev));
- return Error_DevLoadFileFailed;
- }
- int initTries = 0;
- do {
- Dbg("to open device.");
- int portNum, inOutDir, port, baudRate;
- err = spConfig->ReadConfigValueInt("Device.Gpio", "PortNum", portNum);
- if (err == Error_Succeed)
- m_dwPortNum = portNum;
- else
- return Error_IO;
- err = spConfig->ReadConfigValueInt("Device.Gpio", "InOutDir", inOutDir);
- if (err == Error_Succeed)
- m_dwInOutDir = inOutDir;
- else
- return Error_IO;
- spConfig->ReadConfigValueInt("Device.Gpio", "Port", port);
- spConfig->ReadConfigValueInt("Device.Gpio", "BaudRate", baudRate);
- Dbg("read cfg suc, port(%d), baudrate(%d).", port, baudRate);
- GpioInitParam initParam;
- if (!m_bNewVersion) {
- initParam.dwPortNum = 3;
- initParam.dir[0] = true;
- initParam.dir[1] = true;
- initParam.dir[2] = false;
- } else {
- initParam.dwPortNum = 4;
- initParam.dir[0] = true;
- initParam.dir[1] = true;
- initParam.dir[2] = false;
- initParam.dir[3] = true;
- Dbg("New available 4 port num");
- }
- initParam.dwPort = port;
- initParam.dwBaudRate = baudRate;
- err = m_hDevHelper->DevOpen(initParam);
- if (err == Error_Succeed) {
- initTries = 0;
- break;
- } else {
- Dbg("devopen failed(%d).", err);
- DevErrorInfo devErrInfo;
- m_hDevHelper->GetLastErr(devErrInfo);
- Dbg("err:[%s]", devErrInfo.szErrMsg);
- initTries++;
- continue;
- }
- } while (initTries < MAX_GPIO_INIT_TRIES);
- if (initTries != 0) {
- LOG_TRACE("open gpio failed.");
- err = Error_DevConnFailed;
- }
- err = m_hDevHelper->WritePort(0, 0x00);
- Dbg("write ports(0) returned: %d)", err);
- err = m_hDevHelper->WritePort(1, 0x00);
- Dbg("write ports(1) returned: %d", err);
- if (m_bNewVersion) {
- err = m_hDevHelper->WritePort(3, 0x00);
- Dbg("write ports(3) returned: %d", err);
- }
- //oilyang@20170214
- eErrDev = Error_Unexpect;
- CSmartPointer<IConfigInfo> spConfigRun;
- eErrDev = spEntityFunction->OpenConfig(Config_Run, spConfigRun);
- if (eErrDev == Error_Succeed) {
- int iMoveHoldTimes = 0;
- spConfigRun->ReadConfigValueInt("Init", "MaxMoveHoldTimes", iMoveHoldTimes);
- if (iMoveHoldTimes == 0) {
- spConfigRun->WriteConfigValueInt("Init", "MaxMoveHoldTimes", MAX_MOVE_HOLD_TIMES);
- m_moveHoldTimes = MAX_MOVE_HOLD_TIMES;
- }
- } else {
- m_moveHoldTimes = MAX_MOVE_HOLD_TIMES;//oiltmp about 5000*300ms = 25 minutes
- }
- m_moveDisappearTimes = m_moveHoldTimes;
- m_eMachineType = SP::Module::Comm::GetTerminalMachineInfo(this).type;
- Dbg("machine type: %s", SP::Module::Comm::Type2Str(m_eMachineType));
- return err;
- }
- void CGpioEntity::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)
- {
- Dbg("usercode [%x]", dwUserCode);
- GpioService_Set_Info Req;
- Req.close = 0;
- switch (dwUserCode) {
- case LOG_EVT_CARDREADER_GREEN_ON:
- case LOG_EVT_CARDISSUER_GREEN_ON:
- Req.devseq = CARDREADER;
- Req.mode = 1;
- break;
- case LOG_EVT_CARDREADER_RED_ON:
- case LOG_EVT_CARDISSUER_RED_ON:
- Req.devseq = CARDREADER_RED;
- Req.mode = 1;
- break;
- case LOG_EVT_THERMAL_PRINTER_GREEN_ON:
- Req.devseq = PRINTER;
- Req.mode = 1;
- break;
- case LOG_EVT_IDCERTIFICATE_GREEN_ON:
- Req.devseq = IDCERTIFICATE;
- Req.mode = 1;
- break;
- case LOG_EVT_FINGERPRINT_GREEN_ON:
- Req.devseq = FINGERPRINT;
- Req.mode = 1;
- break;
- case LOG_EVT_PINPAD_GREEN_ON:
- Req.devseq = PINPAD;
- Req.mode = 1;
- break;
- case LOG_EVT_HEADLIGHT_GREEN_ON:
- m_bHeadLightFlag = true;
- Req.devseq = HEADLIGHT;
- Req.mode = 1;
- LOG_TRACE("machine light on");
- break;
- case LOG_EVT_HEADLIGHT_RED_ON:
- Req.devseq = HEADLIGHT_RED;
- Req.mode = 1;
- break;
- case LOG_EVT_CONTACTLESS_CARD_GREEN_ON:
- Req.devseq = CONTACTLESSCARD;
- Req.mode = 1;
- break;
- case LOG_EVT_USB_CONTROL_ON:
- Req.devseq = USBCONTROL;
- Req.mode = 1;
- break;
- case LOG_EVT_USB_LIGHT_ON:
- Req.devseq = USBLIGHT;
- Req.mode = 1;
- break;
- case LOG_EVT_IEBROWSER_LIGHT_ASSISTANT_ON:
- Req.devseq = HEADLIGHT_ASSIST;
- Req.mode = 1;
- break;
- case LOG_EVT_CARDREADER_GREEN_OFF:
- case LOG_EVT_CARDISSUER_GREEN_OFF:
- Req.devseq = CARDREADER;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_CARDREADER_RED_OFF:
- case LOG_EVT_CARDISSUER_RED_OFF:
- Req.devseq = CARDREADER_RED;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_THERMAL_PRINTER_GREEN_OFF:
- Req.devseq = PRINTER;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_IDCERTIFICATE_GREEN_OFF:
- Req.devseq = IDCERTIFICATE;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_FINGERPRINT_GREEN_OFF:
- Req.devseq = FINGERPRINT;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_PINPAD_GREEN_OFF:
- Req.devseq = PINPAD;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_HEADLIGHT_GREEN_OFF:
- m_bHeadLightFlag = false;
- Req.devseq = HEADLIGHT;
- Req.mode = 1;
- Req.close = 1;
- LOG_TRACE("machine light off");
- break;
- case LOG_EVT_HEADLIGHT_RED_OFF:
- Req.devseq = HEADLIGHT_RED;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_CONTACTLESS_CARD_GREEN_OFF:
- Req.devseq = CONTACTLESSCARD;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_USB_CONTROL_OFF:
- Req.devseq = USBCONTROL;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_USB_LIGHT_OFF:
- Req.devseq = USBLIGHT;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_IEBROWSER_LIGHT_ASSISTANT_OFF:
- Req.devseq = HEADLIGHT_ASSIST;
- Req.mode = 1;
- Req.close = 1;
- break;
- case LOG_EVT_HSPS_LIGHT_ON:
- Req.devseq = HSPSCANNER;
- Req.mode = 1;
- LOG_TRACE("hspscanner light on");
- break;
- case LOG_EVT_HSPS_LIGHT_OFF:
- Req.devseq = HSPSCANNER;
- Req.mode = 1;
- Req.close = 1;
- LOG_TRACE("hspscanner light off");
- break;
- case LOG_EVT_PRINTSEAL_LIGHT_GREEN_ON:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PRINTER_LIGHT_GREEN;
- break;
- case LOG_EVT_PRINTSEAL_LIGHT_RED_ON:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PRINTER_LIGHT_RED;
- break;
- case LOG_EVT_PRINTSEAL_LIGHT_OFF:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PRINTER_LIGHT_OFF;
- Req.close = 1;
- break;
- case LOG_EVT_PRINTSEAL_PAPER_LIGHT_GREEN_ON:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PAPER_LIGHT_GREEN;
- break;
- case LOG_EVT_PRINTSEAL_PAPER_LIGHT_RED_ON:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PAPER_LIGHT_RED;
- break;
- case LOG_EVT_PRINTSEAL_PAPER_LIGHT_OFF:
- Req.devseq = PRINTER_SEAL;
- Req.mode = PAPER_LIGHT_OFF;
- Req.close = 1;
- break;
- default:
- Dbg("unkown event: 0x%X", dwUserCode);
- return;
- }
- Dbg("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
- Set(Req);
- }
- void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
- {
- ErrorCodeEnum result(Error_Succeed);
- LOG_TRACE("Write Pin %s with %s !", GetDriverPortString(dwPinSeq + 1), bHighLevel ? "[Active]" : "[Inactive]");
- if (dwPinSeq > 16) {
- if (!m_bNewVersion && dwPinSeq < 24) {
- return;
- }
- if (bHighLevel)
- SETBIT(m_btOutputStatus[3], dwPinSeq - 24);
- else
- CLEARBIT(m_btOutputStatus[3], dwPinSeq - 24);
- result = m_hDevHelper->WritePort(3, m_btOutputStatus[3]);
- Dbg("after write port3, %d returned %s", m_btOutputStatus[3], SpStrError(result));
- return;
- }
- if (dwPinSeq < 8) {
- if (bHighLevel)
- SETBIT(m_btOutputStatus[0], dwPinSeq);
- else
- CLEARBIT(m_btOutputStatus[0], dwPinSeq);
- result = m_hDevHelper->WritePort(0, m_btOutputStatus[0]);
- Dbg("after write port0,%d returned %s", m_btOutputStatus[0], SpStrError(result));
- } else {
- if (bHighLevel)
- SETBIT(m_btOutputStatus[1], dwPinSeq - 8);
- else
- CLEARBIT(m_btOutputStatus[1], dwPinSeq - 8);
- DWORD dwStart, dwEnd;
- dwStart = GetTickCount();
- result = m_hDevHelper->WritePort(1, m_btOutputStatus[1]);
- dwEnd = GetTickCount();
- if ((dwEnd - dwStart) > 3000)
- Dbg("writepin so long.than 3s(%d)", (dwEnd - dwStart));
- else
- Dbg("after write port1,%d returned %s", m_btOutputStatus[1], SpStrError(result));
- }
- }
- void CGpioEntity::Set(GpioService_Set_Info req)
- {
- CSimpleStringA activeModeSecName = "";
- int devicePort;
- BOOL bDone = FALSE;
- const int deviceSeq = req.devseq;
- LOG_TRACE("Set request %s arrived!", GetLightSeqString(deviceSeq));
- OutDrivingInfo odi;
- ErrorCodeEnum err;
- CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- err = spEntityFunction->OpenConfig(Config_Software, spConfig);
- if (err != Error_Succeed) {
- LOG_TRACE("open cfg file failed!");
- return;
- }
- switch (deviceSeq) {
- case CARDREADER:
- {
- err = spConfig->ReadConfigValue("InitDriver", "CardReader", activeModeSecName);
- if (err != Error_Succeed)
- goto Error;
- err = spConfig->ReadConfigValueInt("DriverPort", "CardReader", devicePort);
- if (err != Error_Succeed)
- goto Error;
- break;
- }
- case CARDREADER_RED:
- {
- err = spConfig->ReadConfigValue("InitDriver", "CardReaderRed", activeModeSecName);
- if (err != Error_Succeed)
- goto Error;
- err = spConfig->ReadConfigValueInt("DriverPort", "CardReaderRed", devicePort);
- if (err != Error_Succeed)
- goto Error;
- break;
- }
- case PRINTER:
- {
- spConfig->ReadConfigValue("InitDriver", "Printer", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "Printer", devicePort);
- break;
- }
- case IDCERTIFICATE:
- {
- spConfig->ReadConfigValue("InitDriver", "IDCertificate", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "IDCertificate", devicePort);
- break;
- }
- case FINGERPRINT:
- {
- spConfig->ReadConfigValue("InitDriver", "FingerPrint", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "FingerPrint", devicePort);
- break;
- }
- case PINPAD:
- {
- spConfig->ReadConfigValue("InitDriver", "Pinpad", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "Pinpad", devicePort);
- break;
- }
- case HEADLIGHT:
- {
- spConfig->ReadConfigValue("InitDriver", "HeadLight", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "HeadLight", devicePort);
- m_headlightDevPort = devicePort;
- break;
- }
- case HEADLIGHT_RED:
- {
- spConfig->ReadConfigValue("InitDriver", "HeadLightRed", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "HeadLightRed", devicePort);
- break;
- }
- case CONTACTLESSCARD:
- {
- spConfig->ReadConfigValue("InitDriver", "ContactlessCard", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "ContactlessCard", devicePort);
- break;
- }
- case USBCONTROL:
- {
- spConfig->ReadConfigValue("InitDriver", "USBControl", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "USBControl", devicePort);
- break;
- }
- case USBLIGHT:
- {
- spConfig->ReadConfigValue("InitDriver", "USBLight", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "USBLight", devicePort);
- break;
- }
- case HEADLIGHT_ASSIST:
- {
- spConfig->ReadConfigValue("InitDriver", "HeadLightAssist", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "HeadLightAssist", devicePort);
- break;
- }
- case HSPSCANNER:
- {
- spConfig->ReadConfigValue("InitDriver", "HSPScanner", activeModeSecName);
- spConfig->ReadConfigValueInt("DriverPort", "HSPScanner", devicePort);
- break;
- }
- case PRINTER_SEAL:
- {
- if (!m_bNewVersion) {
- bDone = TRUE;
- break;
- }
- //static int paperLighted = PRINTERSEAL_UNKNOWN;
- //static int printLighted = PRINTERSEAL_UNKNOWN;
- err = Error_Unexpect;
- switch (req.mode) {
- case PRINTER_LIGHT_GREEN:
- LOG_TRACE("printseal green light on");
- err = spConfig->ReadConfigValue("InitDriver", "PrintSeal", activeModeSecName);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintSeal", devicePort);
- break;
- case PRINTER_LIGHT_RED:
- LOG_TRACE("printseal red light on");
- err = spConfig->ReadConfigValue("InitDriver", "PrintSealRed", activeModeSecName);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintSealRed", devicePort);
- break;
- case PAPER_LIGHT_GREEN:
- LOG_TRACE("paper slot green light on");
- err = spConfig->ReadConfigValue("InitDriver", "PrintPaper", activeModeSecName);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaper", devicePort);
- break;
- case PAPER_LIGHT_RED:
- LOG_TRACE("paper slot red light on");
- err = spConfig->ReadConfigValue("InitDriver", "PrintPaperRed", activeModeSecName);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaperRed", devicePort);
- break;
- case PRINTER_LIGHT_OFF:
- LOG_TRACE("printerseal light off");
- err = Error_Pending;
- break;
- case PAPER_LIGHT_OFF:
- LOG_TRACE("paper slot light off");
- err = Error_Pending;
- break;
- default:
- err = Error_Param;
- break;
- }
- if (err == Error_Pending) {
- CSimpleStringA initDriver1 = "", initDriver2 = "";
- int devicePort1, devicePort2;
- if (req.mode == PRINTER_LIGHT_OFF) {
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintSeal", devicePort1);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintSealRed", devicePort2);
- } else {
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaper", devicePort1);
- err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaperRed", devicePort2);
- }
- if (err != Error_Succeed) {
- Dbg("read cfg failed ~.");
- return;
- }
- memset(&odi, 0, sizeof(odi));
- SetOutDriving(req, odi, 0, devicePort1);
- SetOutDriving(req, odi, 0, devicePort2);
- bDone = TRUE;
- }
- break;
- }
- break;
- default:
- return;
- }
- Error:
- if (err != Error_Succeed)
- {
- Dbg("read cfg failed.");
- return;
- }
- if (bDone) {
- return;
- }
- GetOutDrivingModInfo(activeModeSecName, odi);
- SetOutDriving(req, odi, 0, devicePort);
- }
- void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
- {
- /** 注意设备序号是实体内定义的逻辑,不是设备端口号*/
- Dbg("GetStatus with devseq %d", deviceSeq);
- CSimpleStringA initDriver = "";
- int devicePort;
- 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;
- }
- /** 获取指定的模式,以便后续获取输入模式和持续触发模式,见 GetReceivingModInfo*/
- spConfig->ReadConfigValue("InitDriver", "PhoneLift", initDriver);
- /** 获取硬件规格里对应的序号,其实是固定死的*/
- spConfig->ReadConfigValueInt("DriverPort", "PhoneLift", devicePort);
- ReceivingInfo ri;
- GetReceivingModInfo(initDriver, ri);
- ri.Port = devicePort;
- GetReceiving(deviceSeq, ri, PICKUPSENSOR, ctx);
- }
- void CGpioEntity::OnOutputPositiveLevelTimerout(void* pData)
- {
- SetContextInfo* pSCI = (SetContextInfo*)pData;
- GetFunction()->KillTimer(pSCI->timerID);
- ULONG devEnableStatus = GetDevEnableStatus();
- DevOutputInfo doi = GetCurrDevStatus();
- WritePin(pSCI->pinSeq, true);
- delete pSCI;
- SaveCurrDevStatus(doi);
- }
- void CGpioEntity::OnPositiveFlickerSetTimerout(void* pData)
- {
- SetContextInfo* pSCI = (SetContextInfo*)pData;
- GetFunction()->KillTimer(pSCI->timerID);
- ULONG devEnableStatus = GetDevEnableStatus();
- DevOutputInfo doi = GetCurrDevStatus();
- WritePin(pSCI->pinSeq, false);
- pSCI->timerID = pSCI->timerID;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerResetTimerout, pSCI, true);
- GetFunction()->SetTimer(pSCI->timerID, pListener, pSCI->resetTime);
- }
- void CGpioEntity::OnPositiveFlickerResetTimerout(void* pData)
- {
- SetContextInfo* pSCI = (SetContextInfo*)pData;
- GetFunction()->KillTimer(pSCI->timerID);
- ULONG devEnableStatus = GetDevEnableStatus();
- DevOutputInfo doi = GetCurrDevStatus();
- WritePin(pSCI->pinSeq, true);
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerSetTimerout, pSCI, true);
- GetFunction()->SetTimer(pSCI->timerID, pListener, pSCI->setTime);
- }
- bool CGpioEntity::SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULONG iIndex, ULONG pinSeq)
- {
- ULONG devEnableStatus = GetDevEnableStatus();
- DevOutputInfo doi = GetCurrDevStatus();
- if (req.close == 1) {
- GetFunction()->KillTimer(req.devseq);
- //oilyang add 20161222
- //如果关闭照明灯,以感知为准
- if (pinSeq == m_headlightDevPort)
- WritePin(pinSeq, m_bHeadLightFlag);
- else {
- if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
- Dbg("off hspsanner.");
- WritePin(PIN_HSPSCANNER_LIGHT, false);
- }
- WritePin(pinSeq, false);
- }
- return true;
- }
- switch (od.OutputMode) {
- case OM_POSITIVE_LEVEL:
- {
- switch (od.StopMode) {
- case SM_CALLTRIGGER:
- {
- LOG_TRACE("0.0 mode:output[%u], pinSeq=%u", doi.output, pinSeq);
- //if it is hspsanner
- if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
- Dbg("light hspsanner.");
- WritePin(PIN_HSPSCANNER_LIGHT, true);
- }
- WritePin(pinSeq, true);
- break;
- }
- case SM_TIMEOUT:
- {
- WritePin(pinSeq, true);
- SetContextInfo* pSci = new SetContextInfo();;
- pSci->ctx = NULL;
- pSci->timerID = req.devseq;
- pSci->timeout = od.TimeOut;
- pSci->index = iIndex;
- pSci->pinSeq = pinSeq;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnOutputPositiveLevelTimerout, pSci);
- GetFunction()->SetTimer(pSci->timerID, pListener, od.TimeOut);
- break;
- }
- case SM_CYCLE:
- break;
- default:
- break;
- }
- }
- break;
- case OM_POSITIVE_FLICKER:
- switch (od.StopMode) {
- case SM_CALLTRIGGER:
- break;
- case SM_TIMEOUT:
- break;
- case SM_CYCLE:
- {
- SetContextInfo* pSci = new SetContextInfo();
- pSci->ctx = NULL;
- pSci->index = iIndex;
- pSci->pinSeq = pinSeq;
- pSci->timerID = req.devseq;
- pSci->setTime = od.SetTime;
- pSci->resetTime = od.ResetTime;
- pSci->timeout = od.TimeOut;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerSetTimerout, pSci, true);
- WritePin(pinSeq, true);
- GetFunction()->SetTimer(pSci->timerID, pListener, pSci->setTime);
- break;
- }
- default:
- break;
- }
- break;
- case OM_NEGATIVE_FLICKER:
- switch (od.StopMode) {
- case SM_CALLTRIGGER:
- break;
- case SM_TIMEOUT:
- break;
- case SM_CYCLE:
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- return true;
- }
- void CGpioEntity::OnPositivePulseUpTimerout(void* pData)
- {
- GetContextInfo* pGCI = (GetContextInfo*)pData;
- BYTE btInput = 0;
- ErrorCodeEnum err;
- Dbg("port[%d]", INPUT_PORT_2);
- err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
- Dbg("read[%d]", btInput);
- //判断输入
- if (DetectBit(btInput, pGCI->index)) {
- if (pGCI->CttPhone == 0)//oiltest 20130709
- {
- ////触发
- pGCI->ctx->Ans.status = 1;
- pGCI->ctx->Answer(Error_Succeed);
- } else {
- pGCI->CttPhone--;//oiltest 20130709
- GetFunction()->ResetTimer(pGCI->timerID, 1000);
- }
- } else {
- pGCI->CttPhone = pGCI->InitCTT;//oiltest 20130709
- GetFunction()->ResetTimer(pGCI->timerID, 1);
- }
- }
- void CGpioEntity::OnNegativePulseUpTimerout(void* pData)
- {
- int count = 1;//from UserData
- ULONG input = 0;
- if (count == 1) {
- //oiltest GetInput(,&input);
- if (input == 0) {
- //返回给调用,发出触发日志
- } else {
- //不稳定,清空计数,重新来
- }
- } else {
- //oiltest GetInput(,&input);
- if (input == 0) {
- //计数减一,继续采样
- //ITimerListener *pListener = new TimerOutHelper<CGpioEntity>(this, CGpioEntity::OnPositivePulseUpTimerout, );
- //GetFunction()->SetTimer(,)
- } else {
- //不稳定,清空计数,重新来
- }
- }
- }
- void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
- {
- GetContextInfo* pGci = (GetContextInfo*)pData;
- const int count = pGci->InitCTT;
- const int initCtt = pGci->InitCTT;
- const int pos = pGci->Port;
-
- ULONG input = 0;
- BYTE btInput;
- bool bShakeOne, bMoveOne, bSwitchOne, bPhoneOne, bCardOne;
- bShakeOne = bMoveOne = bSwitchOne = bPhoneOne = bCardOne = false;
-
- ErrorCodeEnum err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
- if (err != Error_Succeed) {
- DevErrorInfo devErrInfo;
- ZeroMemory(&devErrInfo, sizeof(DevErrorInfo));
- ErrorCodeEnum erroCode = m_hDevHelper->GetLastErr(devErrInfo);
- Dbg("ReadPort failed: %s, ErrMsg[%s]", SpStrError(err), (LPCTSTR)devErrInfo.szErrMsg);
- return;
- }
- /** 震动感应 */
- if (pGci->CttShake == 1) {
-
- bShakeOne = true;
- do {
- if (initCtt == 1) {
- if (DetectBit(btInput, VIBRATIONSENSOR)) {
- if (!m_bVibrationFlag && m_eMachineType == RVC_Stand2S) {
- LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
- }
- m_bVibrationFlag = true;
- } else
- m_bVibrationFlag = false;
- break;
- }
- if (m_bVibrationRound) {
- if (DetectBit(btInput, VIBRATIONSENSOR) && !m_bVibrationFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
- m_bVibrationFlag = true;
- m_bVibrationRound = false;
- }
- } else if (!DetectBit(btInput, VIBRATIONSENSOR) && m_bVibrationFlag) {
- m_bVibrationFlag = false;
- m_bVibrationRound = true;
- }
- } while (0);
- pGci->CttShake = pGci->InitCTT;
- }
- /** 机箱门开关检测*/
- if (pGci->CttSwitch == 1) {
- bSwitchOne = true;
- do {
- if (initCtt == 1) {
- if (DetectBit(btInput, OPENSENSOR)) {
- if (!m_bOpenFlag) {
- if (m_eMachineType == RVC_Stand2S)
- 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)
- LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
- m_bOpenFlag = false;
- }
- break;
- }
- if (m_bOpenRound) {
- if (DetectBit(btInput, OPENSENSOR) && !m_bOpenFlag) {
- if (m_eMachineType == RVC_Stand2S)
- 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)
- LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
- m_bOpenFlag = false;
- m_bOpenRound = true;
- }
- } while (0);
- pGci->CttSwitch = pGci->InitCTT;
- }
- /**话机检测*/
- if (pGci->CttPhone == 1) {
- bPhoneOne = true;
- do {
- if (initCtt == 1) {
- if (DetectBit(btInput, PICKUPSENSOR)) {
- if (!m_bPickUpFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
- m_bPickUpFlag = true;
- }
-
- } else if (m_bPickUpFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
- m_bPickUpFlag = false;
- }
- break;
- }
- if (m_bPickUpRound) {
- if (DetectBit(btInput, PICKUPSENSOR) && !m_bPickUpFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
- m_bPickUpFlag = true;
- m_bPickUpRound = false;
- }
- } else if (!DetectBit(btInput, PICKUPSENSOR)) {
- if (m_bPickUpFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
- m_bPickUpFlag = false;
- m_bPickUpRound = true;
- }
- }
- } while (0);
- pGci->CttPhone = pGci->InitCTT;
- }
- /*物体靠近感知检测*/
- if (pGci->CttMove == 1) {
- bMoveOne = true;
- do {
- if (initCtt == 1) {
- if (DetectBit(btInput, MOVESENSOR)) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
- }
- break;
- }
- if (m_bMoveRound) {
- if (DetectBit(btInput, MOVESENSOR)) {
- 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)
- 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)
- LogWarn(Severity_Middle, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL, "移动次数异常");
- }
- m_moveHoldTimes++;
- m_bMoveRound = false;
- }
- } else if (!DetectBit(btInput, MOVESENSOR)) {
- m_moveHoldTimes = 0;
- if ((m_moveDisappearTimes % LOG_TIME_VALUE) == 0) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(20), __LINE__));
- }
- m_moveDisappearTimes++;
- m_bMoveRound = true;
- }
- } while (0);
- pGci->CttMove = pGci->InitCTT;
- }
- /*卡嘴异物检测*/
- if (pGci->CttCard == 1) {
- bCardOne = true;
- do {
-
- if (initCtt == 1) {
- if (DetectBit(btInput, CARDGATESENSOR)) {
- if (!m_bCardGateFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
- m_bCardGateFlag = true;
- }
- } else
- m_bCardGateFlag = false;
- break;
- }
- if (m_bCardGateRound) {
- if (DetectBit(btInput, CARDGATESENSOR) && !m_bCardGateFlag) {
- if (m_eMachineType == RVC_Stand2S)
- LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
- m_bCardGateFlag = true;
- m_bCardGateRound = false;
- }
- } else if (!DetectBit(btInput, CARDGATESENSOR) && m_bCardGateFlag) {
- m_bCardGateFlag = false;
- m_bCardGateRound = true;
- }
- } while (0);
- pGci->CttCard = pGci->InitCTT;
- }
- /////////////////////////////////////////////////////////////////////////////////////
- if (pGci->CttShake > 1 && !bShakeOne) {
- do {
- if (m_bVibrationRound) {
- if (DetectBit(btInput, VIBRATIONSENSOR))
- pGci->CttShake--;
- else {
- m_bVibrationRound = false;
- pGci->CttShake = pGci->InitCTT;
- }
- } else {
- if (!DetectBit(btInput, VIBRATIONSENSOR))
- pGci->CttShake--;
- else {
- m_bVibrationRound = true;
- pGci->CttShake = pGci->InitCTT;
- }
- }
- } while (0);
- }
- if (pGci->CttSwitch > 1 && !bSwitchOne) {
- do {
- if (m_bOpenRound) {
- if (DetectBit(btInput, OPENSENSOR))
- pGci->CttSwitch--;
- else {
- m_bOpenRound = false;
- pGci->CttSwitch = pGci->InitCTT;
- }
- } else {
- if (!DetectBit(btInput, OPENSENSOR))
- pGci->CttSwitch--;
- else {
- m_bOpenRound = true;
- pGci->CttSwitch = pGci->InitCTT;
- }
- }
- } while (0);
- }
- if (pGci->CttPhone > 1 && !bPhoneOne) {
- do {
- if (m_bPickUpRound) {
- if (DetectBit(btInput, PICKUPSENSOR)) {
- pGci->CttPhone--;
- } else {
- m_bPickUpRound = false;
- pGci->CttPhone = pGci->InitCTT;
- }
- } else {
- if (!DetectBit(btInput, PICKUPSENSOR))
- pGci->CttPhone--;
- else {
- m_bPickUpRound = true;
- pGci->CttPhone = pGci->InitCTT;
- }
- }
- } while (0);
- }
- if (pGci->CttMove > 1 && !bMoveOne) {
- do {
- //Dbg("before ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
- // pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
- if (m_bMoveRound) {
- if (DetectBit(btInput, MOVESENSOR))
- pGci->CttMove--;
- else {
- m_bMoveRound = false;
- pGci->CttMove = pGci->InitCTT;
- }
- } else {
- if (!DetectBit(btInput, MOVESENSOR))
- pGci->CttMove--;
- else {
- m_bMoveRound = true;
- pGci->CttMove = pGci->InitCTT;
- }
- }
- //Dbg("after ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
- // pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
- } while (0);
- } else {
- //Dbg("===== ccMove: %d, moveOne: %d, moveRound: %d, %d, disppear: %d, holder: %d",
- // pGci->CttMove, bMoveOne, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
- }
- if (pGci->CttCard > 1 && !bCardOne) {
- do {
- if (m_bCardGateRound) {
- if (DetectBit(btInput, CARDGATESENSOR))
- pGci->CttCard--;
- else {
- m_bCardGateRound = false;
- pGci->CttCard = pGci->InitCTT;
- }
- } else {
- if (!DetectBit(btInput, CARDGATESENSOR))
- pGci->CttCard--;
- else {
- m_bCardGateRound = true;
- pGci->CttCard = pGci->InitCTT;
- }
- }
- } while (0);
- }
- GetFunction()->ResetTimer(pGci->timerID, 100);
- }
- void CGpioEntity::OnNegativeLevelTimerOut(void* pData)
- {
- int count = 1;//from UserData
- ULONG input = 0;
- if (count == 1) {
- if (input == 0) {
- //返回给调用
- //取消定时器
- } else {
- //清零
- }
- } else {
- if (input == 0) {
- //返回给调用
- //取消定时器
- } else {
- //清零
- }
- }
- }
- bool CGpioEntity::GetReceiving(int deviceSeq, ReceivingInfo ri, ULONG iIndex,
- SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
- {
- Dbg("inputmode[%d],port[%d],ctt[%d]", ri.InputMode, ri.Port, ri.ContinuousTriggerTime);
- switch (ri.InputMode)
- {
- case IM_POSITIVE_PULSE_UP:
- {
- GetContextInfo* pGci = new GetContextInfo();
- pGci->timerID = ctx->Req.devseq;
- pGci->ctx = ctx;
- pGci->index = iIndex;
- pGci->Port = ri.Port;
- pGci->CttCard = ri.ContinuousTriggerTime;
- pGci->CttMove = ri.ContinuousTriggerTime;
- pGci->CttPhone = ri.ContinuousTriggerTime;
- pGci->CttShake = ri.ContinuousTriggerTime;
- pGci->CttSwitch = ri.ContinuousTriggerTime;
- pGci->InitCTT = ri.ContinuousTriggerTime;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositivePulseUpTimerout, pGci);
- GetFunction()->SetTimer(pGci->timerID, pListener, 1);
- break;
- }
- case IM_POSITIVE_LEVEL:
- {
- GetContextInfo* pGci = new GetContextInfo();
- pGci->timerID = deviceSeq;
- pGci->ctx = ctx;
- pGci->index = iIndex;
- pGci->Port = ri.Port;
- //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
- pGci->CttCard = ri.ContinuousTriggerTime;
- pGci->CttMove = ri.ContinuousTriggerTime;
- pGci->CttPhone = ri.ContinuousTriggerTime;
- pGci->CttShake = ri.ContinuousTriggerTime;
- pGci->CttSwitch = ri.ContinuousTriggerTime;
- pGci->InitCTT = ri.ContinuousTriggerTime;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveLevelTimerOut, pGci);
- GetFunction()->SetTimer(pGci->timerID, pListener, 100);
- break;
- }
- case IM_NEGATIVE_LEVEL:
- {
- GetContextInfo* pGci = new GetContextInfo();
- pGci->timerID = deviceSeq;
- pGci->ctx = ctx;
- pGci->index = iIndex;
- pGci->Port = ri.Port;
- //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
- pGci->InitCTT = ri.ContinuousTriggerTime;
- ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnNegativeLevelTimerOut, pGci);
- GetFunction()->SetTimer(pGci->timerID, pListener, 1);
- break;
- }
- default:
- break;
- }
- return true;
- }
- void CGpioEntity::GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& odi)
- {
- ErrorCodeEnum Error;
- CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
- CSmartPointer<IConfigInfo> spConfig;
- Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
- if (Error != Error_Succeed) {
- Dbg("open cfg file failed!");
- return;
- }
- spConfig->ReadConfigValueInt(modName, "OutputMode", odi.OutputMode);
- spConfig->ReadConfigValueInt(modName, "StopMode", odi.StopMode);
- spConfig->ReadConfigValueInt(modName, "SetTime", odi.SetTime);
- spConfig->ReadConfigValueInt(modName, "ResetTime", odi.ResetTime);
- spConfig->ReadConfigValueInt(modName, "Timeout", odi.TimeOut);
- LOG_TRACE("outputmode.stopmode:[%d].[%d]", odi.OutputMode, odi.StopMode);
- }
- /*从配置文件中获取配置*/
- void CGpioEntity::GetReceivingModInfo(CSimpleStringA modName, ReceivingInfo& ri)
- {
- 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->ReadConfigValueInt(modName, "InputMode", ri.InputMode);
- spConfig->ReadConfigValueInt(modName, "ContinuousTriggerTime", ri.ContinuousTriggerTime);
- }
- BYTE CGpioEntity::GetOutputStatus(int sn)
- {
- if (sn == 0)
- return m_btOutputStatus[0];
- else if (sn == 1)
- return m_btOutputStatus[1];
- else if (sn == 2)
- return m_btOutputStatus[2];
- else
- return 0;
- }
- SP_BEGIN_ENTITY_MAP()
- SP_ENTITY(CGpioEntity)
- SP_END_ENTITY_MAP()
|