mod_gpio.cpp 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. #include "stdafx.h"
  2. #include "mod_gpio.h"
  3. #include "publicFunExport.h"
  4. const int MAX_GPIO_INIT_TRIES = 3;
  5. const int INPUT_PORT_2 = 2;
  6. const int MAX_MOVE_HOLD_TIMES = 5000;
  7. const int LOG_TIME_VALUE = 25;
  8. int positive_pulse_up_count = 0;
  9. int negative_pulse_down_count = 0;
  10. int positive_pulse_both_count = 0;
  11. int negative_pulse_both_count = 0;
  12. int positive_level_count = 0;
  13. int negative_level_count = 0;
  14. #define SETBIT(x,y) x|=(1<<(y))
  15. #define CLEARBIT(x,y) x&=((1<<(y))^0xffffff)
  16. using namespace SP::Module::Comm;
  17. bool DetectBit(ULONG data, int pos)
  18. {
  19. ULONG tmp = 0;
  20. SETBIT(tmp, pos);
  21. return data & tmp;
  22. }
  23. static const char* GetDriverPortString(int pin)
  24. {
  25. switch (pin) {
  26. case 1: return "【驱动】读卡发卡器提示灯";
  27. case 2: return "【驱动】前端USB通断控制";
  28. case 3: return "【驱动】身份证阅读器提示灯";
  29. case 4: return "【驱动】密码键盘提示灯";
  30. case 5: return "【驱动】脸部照明灯";
  31. case 6: return "【驱动】故障灯";
  32. case 7: return "【驱动】读卡发卡器维护提示灯";
  33. case 8: return "【驱动】前端USB口提示灯";
  34. case 9: return "【驱动】非接IC读卡器提示灯";
  35. case 10: return "";
  36. case 11: return "【驱动】指纹仪提示灯";
  37. case 12: return "【驱动】凭条打印提示灯";
  38. case 13: return "【驱动】高拍仪提示灯";
  39. case 14: return "";
  40. case 15: return "";
  41. case 16: return "";
  42. case 17: return "【接收】震动探测器";
  43. case 18: return "【接收】机具门感应开关";
  44. case 19: return "【接收】话机提机感应开关";
  45. case 20: return "【接收】人体探测感应器";
  46. case 21: return "【接收】发卡器卡嘴覆盖探测器";
  47. //case 22: return "";
  48. //case 23: return "";
  49. //case 24: return "";
  50. //case 25: return "";
  51. case 26: return "【驱动】高拍仪提示灯";
  52. //case 27: return "";
  53. //case 28: return "";
  54. //case 29: return "";
  55. //case 30: return "";
  56. //case 31: return "";
  57. //case 32: return "";
  58. //case 33: return "";
  59. //case 34: return "";
  60. //case 35: return "";
  61. //case 36: return "";
  62. //case 37: return "";
  63. //case 38: return "";
  64. //case 39: return "";
  65. //case 40: return "";
  66. //case 41: return "";
  67. //case 42: return "";
  68. default:
  69. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Unkown pin sequence: %d", pin);
  70. return "";
  71. break;
  72. }
  73. }
  74. #define LIGHT_STRING_CONVERT(str) case str : return #str; break;
  75. static const char* GetLightSeqString(int seq)
  76. {
  77. switch (seq) {
  78. LIGHT_STRING_CONVERT(UNKNOWN_DEVICE)
  79. LIGHT_STRING_CONVERT(CARDREADER)
  80. LIGHT_STRING_CONVERT(CARDREADER_RED)
  81. LIGHT_STRING_CONVERT(PRINTER)
  82. LIGHT_STRING_CONVERT(IDCERTIFICATE)
  83. LIGHT_STRING_CONVERT(PINPAD)
  84. LIGHT_STRING_CONVERT(PINPADLIGHT)
  85. LIGHT_STRING_CONVERT(SHAKEDETECT)
  86. LIGHT_STRING_CONVERT(SWITCHINDUCTOR)
  87. LIGHT_STRING_CONVERT(PHONEPICKUP)
  88. LIGHT_STRING_CONVERT(MOVEDETECT)
  89. LIGHT_STRING_CONVERT(CARDGATEDETECT)
  90. LIGHT_STRING_CONVERT(HEADLIGHT)
  91. LIGHT_STRING_CONVERT(HEADLIGHT_RED)
  92. LIGHT_STRING_CONVERT(CONTACTLESSCARD)
  93. LIGHT_STRING_CONVERT(USBCONTROL)
  94. LIGHT_STRING_CONVERT(USBLIGHT)
  95. LIGHT_STRING_CONVERT(HEADLIGHT_ASSIST)
  96. LIGHT_STRING_CONVERT(HSPSCANNER)
  97. LIGHT_STRING_CONVERT(PRINTER_SEAL)
  98. LIGHT_STRING_CONVERT(FINGERPRINT)
  99. default:
  100. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Unkonwn LightSeq: %d", seq);
  101. return "UnConver One";
  102. break;
  103. }
  104. }
  105. #undef LIGHT_STRING_CONVERT
  106. void CGpioServiceSession::Handle_Set(SpOnewayCallContext<GpioService_Set_Info>::Pointer ctx)
  107. {
  108. GpioService_Set_Info req = ctx->Info;
  109. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq=%d", req.devseq);
  110. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mode=%d", req.mode);
  111. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("close=%d", req.close);
  112. m_pEntity->Set(req);
  113. }
  114. void CGpioServiceSession::Handle_GetStatus(SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
  115. {
  116. m_pEntity->GetStatus(ctx->Req.devseq, ctx);
  117. }
  118. void CGpioServiceSession::Handle_QueryCurrSet(SpReqAnsContext<GpioService_QueryCurrSet_Req, GpioService_QueryCurrSet_Ans>::Pointer ctx)
  119. {
  120. DevOutputInfo output;
  121. output = m_pEntity->GetCurrDevStatus();
  122. ctx->Ans.dir = output.dir;
  123. ctx->Ans.output = m_pEntity->GetOutputStatus(0);
  124. ctx->Answer(Error_Succeed);
  125. }
  126. bool isnostr(const char* str)
  127. {
  128. int len = strlen(str);
  129. if (len == 0)
  130. return true;
  131. for (int i = 0; i < len; ++i) {
  132. if (*(str + i) != ' ')
  133. return false;
  134. }
  135. return true;
  136. }
  137. int HexBuf2StrBuf(PBYTE hexBuf, char** strBuf, DWORD len)
  138. {
  139. char* tmpStr = *strBuf;
  140. int count = 0;
  141. for (int i = 0; i < len; ++i)
  142. {
  143. sprintf(tmpStr + count, "%0.2x", hexBuf[i]);
  144. count += 2;
  145. }
  146. return 0;
  147. }
  148. void CGpioEntity::ToLogRootINIInfo()
  149. {
  150. CSmartPointer<IConfigInfo> spConfigRoot;
  151. GetFunction()->OpenConfig(Config_Root, spConfigRoot);
  152. CSimpleStringA entityName(GetEntityName());
  153. CSimpleStringA sectionName = CSimpleStringA::Format("Device.%s", entityName.GetData());
  154. CSimpleStringA csVendor(true), csVersion(true), csBatch(true), csPort(true), csBaudrate(true);
  155. spConfigRoot->ReadConfigValue(sectionName.GetData(), "Vendor", csVendor);
  156. spConfigRoot->ReadConfigValue(sectionName.GetData(), "Version", csVersion);
  157. spConfigRoot->ReadConfigValue(sectionName.GetData(), "Batch", csBatch);
  158. spConfigRoot->ReadConfigValue(sectionName.GetData(), "Port", csPort);
  159. spConfigRoot->ReadConfigValue(sectionName.GetData(), "Baudrate", csBaudrate);
  160. std::map<std::string, std::string> rootInfo;
  161. CSimpleStringA csPortNum(true), csCheckData(true), csKeySN(true), csInOutDir(true);
  162. rootInfo["Vendor"] = csVendor;
  163. rootInfo["Version"] = csVersion;
  164. rootInfo["Batch"] = csBatch;
  165. rootInfo["Port"] = csPort;
  166. rootInfo["Baudrate"] = csBaudrate;
  167. spConfigRoot->ReadConfigValue(sectionName.GetData(), "PortNum", csPortNum);
  168. spConfigRoot->ReadConfigValue(sectionName.GetData(), "InOutDir", csInOutDir);
  169. rootInfo["PortNum"] = csPortNum;
  170. rootInfo["InOutDir"] = csInOutDir;
  171. std::pair<bool, std::string> strResult;
  172. strResult = generateJsonStr(rootInfo);
  173. strResult.second.c_str();
  174. if (!entityName.IsNullOrEmpty()) {
  175. LogWarn(Severity_Low, Error_Debug, GPIO_UserErrorCode_Real_Root_Config, strResult.second.c_str());
  176. } else {
  177. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Entity Name is empty, please check!!!");
  178. }
  179. return;
  180. }
  181. void CGpioEntity::ToLogWarnInfoAboutTerm(const AdapterInfo& m_adapterInfo)
  182. {
  183. LOG_FUNCTION();
  184. CSmartPointer<IConfigInfo> spConfigRoot;
  185. GetFunction()->OpenConfig(Config_Root, spConfigRoot);
  186. CSimpleStringA csEnvCamera(""), csOptCamera, csOSVerion, csWarnMsg("");
  187. //calculate file hash value
  188. std::map<std::string, std::string> termInfo;
  189. char* strFileHash = new char[128];
  190. ZeroMemory(strFileHash, 128);
  191. BYTE fileHash[32];
  192. SM3File(const_cast<char*>(m_adapterInfo.adapterFileName.GetData()), fileHash);
  193. HexBuf2StrBuf(fileHash, &strFileHash, 32);
  194. //calculate file size
  195. struct stat statbuf;
  196. ZeroMemory(&statbuf, sizeof(statbuf));
  197. stat(m_adapterInfo.adapterFileName.GetData(), &statbuf);
  198. int fileSize = statbuf.st_size;
  199. termInfo["VendorDllName"] = m_adapterInfo.adapterFileName;
  200. termInfo["VendorDllFileHash"] = strFileHash;
  201. ZeroMemory(strFileHash, 128);
  202. termInfo["VendorDllFileSize"] = _itoa(fileSize, strFileHash, 10);
  203. termInfo["szModel"] = m_adapterInfo.devCatInfo.szModel;
  204. termInfo["szType"] = m_adapterInfo.devCatInfo.szType;
  205. termInfo["Port"] = m_port;
  206. termInfo["PortNum"] = m_portNum;
  207. termInfo["Baudrate"] = m_Baudrate;
  208. termInfo["InOutDir"] = m_InOutDir;
  209. if (strFileHash != nullptr) {
  210. delete[] strFileHash;
  211. strFileHash = nullptr;
  212. }
  213. std::pair<bool, std::string> strResult;
  214. strResult = generateJsonStr(termInfo);
  215. LogWarn(Severity_Low, Error_Unexpect, GPIO_UserErrorCode_LogInfoAboutTerm, strResult.second.c_str());
  216. return;
  217. }
  218. ErrorCodeEnum CGpioEntity::Initial()
  219. {
  220. ErrorCodeEnum err;
  221. LOG_FUNCTION();
  222. ErrorCodeEnum eErrDev;
  223. CSimpleStringA dllName;
  224. eErrDev = ExtractVendorLibFullPath(dllName);
  225. if (eErrDev != Error_Succeed) {
  226. DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM)("load vendor dll or so(%s)(%s) failed.", dllName.GetData(), SpStrError(eErrDev));
  227. return Error_DevLoadFileFailed;
  228. }
  229. LogWarn(Severity_Low, Error_Unexpect, GPIO_UserErrorCode_RootInfo, dllName.GetData());
  230. CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
  231. CSmartPointer<IConfigInfo> spConfig;
  232. eErrDev = spEntityFunction->OpenConfig(Config_Root, spConfig);
  233. if (eErrDev != Error_Succeed) {
  234. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("open cfg file failed!");
  235. return eErrDev;
  236. }
  237. CSimpleStringA devVendor, devVer, devBatch, dllSuffix;
  238. devVendor = devVer = devBatch = "";
  239. spConfig->ReadConfigValue("Device.Gpio", "Vendor", devVendor);
  240. spConfig->ReadConfigValue("Device.Gpio", "Version", devVer);
  241. spConfig->ReadConfigValue("Device.Gpio", "Batch", devBatch);
  242. #if defined(RVC_OS_WIN)
  243. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[%s],[%s],[%s]", devVendor.GetData(), devVer.GetData(), devBatch.GetData());
  244. if (!_stricmp(devVendor, "Hyosung") || !_stricmp(devVendor, "Keba") || !_stricmp(devVendor, "Kxd")) {
  245. if (devVer == "1" && devBatch == "1") {
  246. m_bNewVersion = FALSE;
  247. } else {
  248. m_bNewVersion = TRUE;
  249. }
  250. } else {
  251. m_bNewVersion = TRUE;
  252. }
  253. #else
  254. m_bNewVersion = TRUE;
  255. #endif
  256. eErrDev = m_hDevHelper.LoadUp(dllName);
  257. if (eErrDev != Error_Succeed) {
  258. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("load up %s failed: %s", dllName.GetData(), SpStrError(eErrDev));
  259. return Error_DevLoadFileFailed;
  260. }
  261. m_adapterInfo.adapterFileName = dllName;
  262. int initTries = 0;
  263. do {
  264. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("to open device.");
  265. int portNum, inOutDir, port, baudRate;
  266. err = spConfig->ReadConfigValueInt("Device.Gpio", "PortNum", portNum);
  267. if (err == Error_Succeed)
  268. m_dwPortNum = portNum;
  269. else
  270. return Error_IO;
  271. err = spConfig->ReadConfigValueInt("Device.Gpio", "InOutDir", inOutDir);
  272. if (err == Error_Succeed)
  273. m_dwInOutDir = inOutDir;
  274. else
  275. return Error_IO;
  276. spConfig->ReadConfigValueInt("Device.Gpio", "Port", port);
  277. spConfig->ReadConfigValueInt("Device.Gpio", "BaudRate", baudRate);
  278. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("read cfg suc, port(%d), baudrate(%d).", port, baudRate);
  279. m_port = CSimpleStringA::Format("%d", port);
  280. m_Baudrate = CSimpleStringA::Format("%d", baudRate);
  281. m_portNum = CSimpleStringA::Format("%d", portNum);
  282. m_InOutDir = CSimpleStringA::Format("%d", inOutDir);
  283. GpioInitParam initParam;
  284. if (!m_bNewVersion) {
  285. initParam.dwPortNum = 3;
  286. initParam.dir[0] = true;
  287. initParam.dir[1] = true;
  288. initParam.dir[2] = false;
  289. } else {
  290. initParam.dwPortNum = 4;
  291. initParam.dir[0] = true;
  292. initParam.dir[1] = true;
  293. initParam.dir[2] = false;
  294. initParam.dir[3] = true;
  295. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("New available 4 port num");
  296. }
  297. CSimpleStringA errMsg("");
  298. initParam.dwPort = port;
  299. initParam.dwBaudRate = baudRate;
  300. err = m_hDevHelper->DevOpen(initParam);
  301. if (err == Error_Succeed) {
  302. ZeroMemory(m_devCatInfo.szModel, sizeof(m_devCatInfo.szModel));
  303. ZeroMemory(m_devCatInfo.szType, sizeof(m_devCatInfo.szType));
  304. ZeroMemory(m_devCatInfo.szVendor, sizeof(m_devCatInfo.szVendor));
  305. err = m_hDevHelper->GetDevCategory(m_devCatInfo);
  306. if (err == Error_Succeed)
  307. {
  308. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("szVendor:%s, szType:%s, szModel:%s", m_devCatInfo.szVendor, m_devCatInfo.szType, m_devCatInfo.szModel);
  309. m_adapterInfo.devCatInfo = m_devCatInfo;
  310. }
  311. else
  312. {
  313. DevErrorInfo devErrInfo;
  314. ZeroMemory(&devErrInfo, sizeof(devErrInfo));
  315. m_hDevHelper->GetLastErr(devErrInfo);
  316. errMsg = CSimpleStringA::Format("GetDevCategory failed:%d(s)", err, devErrInfo.szErrMsg);
  317. LogWarn(Severity_Middle, Error_Unexpect, GPIO_UserErrorCode_GetDevCategory_Failed, errMsg.GetData());
  318. }
  319. initTries = 0;
  320. break;
  321. } else {
  322. DevErrorInfo devErrInfo;
  323. ZeroMemory(&devErrInfo, sizeof(devErrInfo));
  324. m_hDevHelper->GetLastErr(devErrInfo);
  325. errMsg = CSimpleStringA::Format("DevOpen failed:%d(%s)", err, devErrInfo.szErrMsg);
  326. LogWarn(Severity_Middle, Error_Unexpect, GPIO_UserErrorCode_DevOpen_Failed, errMsg.GetData());
  327. Sleep(300);
  328. initTries++;
  329. continue;
  330. }
  331. } while (initTries < MAX_GPIO_INIT_TRIES);
  332. if (initTries != 0) {
  333. LOG_TRACE("open gpio failed.");
  334. err = Error_DevConnFailed;
  335. }
  336. err = m_hDevHelper->WritePort(0, 0x00);
  337. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(0) returned: %d)", err);
  338. err = m_hDevHelper->WritePort(1, 0x00);
  339. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(1) returned: %d", err);
  340. if (m_bNewVersion) {
  341. err = m_hDevHelper->WritePort(3, 0x00);
  342. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("write ports(3) returned: %d", err);
  343. }
  344. //oilyang@20170214
  345. eErrDev = Error_Unexpect;
  346. CSmartPointer<IConfigInfo> spConfigRun;
  347. eErrDev = spEntityFunction->OpenConfig(Config_Run, spConfigRun);
  348. if (eErrDev == Error_Succeed) {
  349. int iMoveHoldTimes = 0;
  350. spConfigRun->ReadConfigValueInt("Init", "MaxMoveHoldTimes", iMoveHoldTimes);
  351. if (iMoveHoldTimes == 0) {
  352. spConfigRun->WriteConfigValueInt("Init", "MaxMoveHoldTimes", MAX_MOVE_HOLD_TIMES);
  353. m_moveHoldTimes = MAX_MOVE_HOLD_TIMES;
  354. }
  355. } else {
  356. m_moveHoldTimes = MAX_MOVE_HOLD_TIMES;//oiltmp about 5000*300ms = 25 minutes
  357. }
  358. m_moveDisappearTimes = m_moveHoldTimes;
  359. m_eMachineType = SP::Module::Comm::GetTerminalMachineInfo(this).type;
  360. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("machine type: %s", SP::Module::Comm::Type2Str(m_eMachineType));
  361. if (m_FirstStart) {
  362. m_FirstStart = FALSE;
  363. ToLogRootINIInfo();
  364. ToLogWarnInfoAboutTerm(m_adapterInfo);
  365. }
  366. return err;
  367. }
  368. void CGpioEntity::OnLog(const CAutoArray<CUUID>& SubIDs, const CUUID nLogID, const LogTypeEnum eLogType, const SeverityLevelEnum eLevel,
  369. const DWORD dwSysError, const DWORD dwUserCode, const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
  370. const CAutoArray<DWORD>& Param, const char* pszEntityName, const char* pszModuleName, const char* pszMessage, const linkContext& pLinkInfo)
  371. {
  372. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("usercode [%x]", dwUserCode);
  373. GpioService_Set_Info Req;
  374. Req.close = 0;
  375. switch (dwUserCode) {
  376. case LOG_EVT_CARDREADER_GREEN_ON:
  377. case LOG_EVT_CARDISSUER_GREEN_ON:
  378. Req.devseq = CARDREADER;
  379. Req.mode = 1;
  380. break;
  381. case LOG_EVT_CARDREADER_RED_ON:
  382. case LOG_EVT_CARDISSUER_RED_ON:
  383. Req.devseq = CARDREADER_RED;
  384. Req.mode = 1;
  385. break;
  386. case LOG_EVT_THERMAL_PRINTER_GREEN_ON:
  387. Req.devseq = PRINTER;
  388. Req.mode = 1;
  389. break;
  390. case LOG_EVT_IDCERTIFICATE_GREEN_ON:
  391. Req.devseq = IDCERTIFICATE;
  392. Req.mode = 1;
  393. break;
  394. case LOG_EVT_FINGERPRINT_GREEN_ON:
  395. Req.devseq = FINGERPRINT;
  396. Req.mode = 1;
  397. break;
  398. case LOG_EVT_PINPAD_GREEN_ON:
  399. Req.devseq = PINPAD;
  400. Req.mode = 1;
  401. break;
  402. case LOG_EVT_HEADLIGHT_GREEN_ON:
  403. m_bHeadLightFlag = true;
  404. Req.devseq = HEADLIGHT;
  405. Req.mode = 1;
  406. LOG_TRACE("machine light on");
  407. break;
  408. case LOG_EVT_HEADLIGHT_RED_ON:
  409. Req.devseq = HEADLIGHT_RED;
  410. Req.mode = 1;
  411. break;
  412. case LOG_EVT_CONTACTLESS_CARD_GREEN_ON:
  413. Req.devseq = CONTACTLESSCARD;
  414. Req.mode = 1;
  415. break;
  416. case LOG_EVT_USB_CONTROL_ON:
  417. Req.devseq = USBCONTROL;
  418. Req.mode = 1;
  419. break;
  420. case LOG_EVT_USB_LIGHT_ON:
  421. Req.devseq = USBLIGHT;
  422. Req.mode = 1;
  423. break;
  424. case LOG_EVT_IEBROWSER_LIGHT_ASSISTANT_ON:
  425. Req.devseq = HEADLIGHT_ASSIST;
  426. Req.mode = 1;
  427. break;
  428. case LOG_EVT_CARDREADER_GREEN_OFF:
  429. case LOG_EVT_CARDISSUER_GREEN_OFF:
  430. Req.devseq = CARDREADER;
  431. Req.mode = 1;
  432. Req.close = 1;
  433. break;
  434. case LOG_EVT_CARDREADER_RED_OFF:
  435. case LOG_EVT_CARDISSUER_RED_OFF:
  436. Req.devseq = CARDREADER_RED;
  437. Req.mode = 1;
  438. Req.close = 1;
  439. break;
  440. case LOG_EVT_THERMAL_PRINTER_GREEN_OFF:
  441. Req.devseq = PRINTER;
  442. Req.mode = 1;
  443. Req.close = 1;
  444. break;
  445. case LOG_EVT_IDCERTIFICATE_GREEN_OFF:
  446. Req.devseq = IDCERTIFICATE;
  447. Req.mode = 1;
  448. Req.close = 1;
  449. break;
  450. case LOG_EVT_FINGERPRINT_GREEN_OFF:
  451. Req.devseq = FINGERPRINT;
  452. Req.mode = 1;
  453. Req.close = 1;
  454. break;
  455. case LOG_EVT_PINPAD_GREEN_OFF:
  456. Req.devseq = PINPAD;
  457. Req.mode = 1;
  458. Req.close = 1;
  459. break;
  460. case LOG_EVT_HEADLIGHT_GREEN_OFF:
  461. m_bHeadLightFlag = false;
  462. Req.devseq = HEADLIGHT;
  463. Req.mode = 1;
  464. Req.close = 1;
  465. LOG_TRACE("machine light off");
  466. break;
  467. case LOG_EVT_HEADLIGHT_RED_OFF:
  468. Req.devseq = HEADLIGHT_RED;
  469. Req.mode = 1;
  470. Req.close = 1;
  471. break;
  472. case LOG_EVT_CONTACTLESS_CARD_GREEN_OFF:
  473. Req.devseq = CONTACTLESSCARD;
  474. Req.mode = 1;
  475. Req.close = 1;
  476. break;
  477. case LOG_EVT_USB_CONTROL_OFF:
  478. Req.devseq = USBCONTROL;
  479. Req.mode = 1;
  480. Req.close = 1;
  481. break;
  482. case LOG_EVT_USB_LIGHT_OFF:
  483. Req.devseq = USBLIGHT;
  484. Req.mode = 1;
  485. Req.close = 1;
  486. break;
  487. case LOG_EVT_IEBROWSER_LIGHT_ASSISTANT_OFF:
  488. Req.devseq = HEADLIGHT_ASSIST;
  489. Req.mode = 1;
  490. Req.close = 1;
  491. break;
  492. case LOG_EVT_HSPS_LIGHT_ON:
  493. Req.devseq = HSPSCANNER;
  494. Req.mode = 1;
  495. LOG_TRACE("hspscanner light on");
  496. break;
  497. case LOG_EVT_HSPS_LIGHT_OFF:
  498. Req.devseq = HSPSCANNER;
  499. Req.mode = 1;
  500. Req.close = 1;
  501. LOG_TRACE("hspscanner light off");
  502. break;
  503. case LOG_EVT_PRINTSEAL_LIGHT_GREEN_ON:
  504. Req.devseq = PRINTER_SEAL;
  505. Req.mode = PRINTER_LIGHT_GREEN;
  506. break;
  507. case LOG_EVT_PRINTSEAL_LIGHT_RED_ON:
  508. Req.devseq = PRINTER_SEAL;
  509. Req.mode = PRINTER_LIGHT_RED;
  510. break;
  511. case LOG_EVT_PRINTSEAL_LIGHT_OFF:
  512. Req.devseq = PRINTER_SEAL;
  513. Req.mode = PRINTER_LIGHT_OFF;
  514. Req.close = 1;
  515. break;
  516. case LOG_EVT_PRINTSEAL_PAPER_LIGHT_GREEN_ON:
  517. Req.devseq = PRINTER_SEAL;
  518. Req.mode = PAPER_LIGHT_GREEN;
  519. break;
  520. case LOG_EVT_PRINTSEAL_PAPER_LIGHT_RED_ON:
  521. Req.devseq = PRINTER_SEAL;
  522. Req.mode = PAPER_LIGHT_RED;
  523. break;
  524. case LOG_EVT_PRINTSEAL_PAPER_LIGHT_OFF:
  525. Req.devseq = PRINTER_SEAL;
  526. Req.mode = PAPER_LIGHT_OFF;
  527. Req.close = 1;
  528. break;
  529. default:
  530. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("unkown event: 0x%X", dwUserCode);
  531. return;
  532. }
  533. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("devseq[%d],mode[%d]close[%d]", Req.devseq, Req.mode, Req.close);
  534. Set(Req);
  535. }
  536. void CGpioEntity::WritePin(DWORD dwPinSeq, bool bHighLevel)
  537. {
  538. ErrorCodeEnum result(Error_Succeed);
  539. LOG_TRACE("Write Pin %s with %s !", GetDriverPortString(dwPinSeq + 1), bHighLevel ? "[Active]" : "[Inactive]");
  540. if (dwPinSeq > 16) {
  541. if (!m_bNewVersion && dwPinSeq < 24) {
  542. return;
  543. }
  544. if (bHighLevel)
  545. SETBIT(m_btOutputStatus[3], dwPinSeq - 24);
  546. else
  547. CLEARBIT(m_btOutputStatus[3], dwPinSeq - 24);
  548. result = m_hDevHelper->WritePort(3, m_btOutputStatus[3]);
  549. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port3, %d returned %s", m_btOutputStatus[3], SpStrError(result));
  550. return;
  551. }
  552. if (dwPinSeq < 8) {
  553. if (bHighLevel)
  554. SETBIT(m_btOutputStatus[0], dwPinSeq);
  555. else
  556. CLEARBIT(m_btOutputStatus[0], dwPinSeq);
  557. result = m_hDevHelper->WritePort(0, m_btOutputStatus[0]);
  558. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port0,%d returned %s", m_btOutputStatus[0], SpStrError(result));
  559. } else {
  560. if (bHighLevel)
  561. SETBIT(m_btOutputStatus[1], dwPinSeq - 8);
  562. else
  563. CLEARBIT(m_btOutputStatus[1], dwPinSeq - 8);
  564. DWORD dwStart, dwEnd;
  565. dwStart = GetTickCount();
  566. result = m_hDevHelper->WritePort(1, m_btOutputStatus[1]);
  567. dwEnd = GetTickCount();
  568. if ((dwEnd - dwStart) > 3000)
  569. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("writepin so long.than 3s(%d)", (dwEnd - dwStart));
  570. else
  571. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after write port1,%d returned %s", m_btOutputStatus[1], SpStrError(result));
  572. }
  573. }
  574. void CGpioEntity::Set(GpioService_Set_Info req)
  575. {
  576. CSimpleStringA activeModeSecName = "";
  577. int devicePort;
  578. BOOL bDone = FALSE;
  579. const int deviceSeq = req.devseq;
  580. LOG_TRACE("Set request %s arrived!", GetLightSeqString(deviceSeq));
  581. OutDrivingInfo odi;
  582. ErrorCodeEnum err;
  583. CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
  584. CSmartPointer<IConfigInfo> spConfig;
  585. err = spEntityFunction->OpenConfig(Config_Software, spConfig);
  586. if (err != Error_Succeed) {
  587. LOG_TRACE("open cfg file failed!");
  588. return;
  589. }
  590. switch (deviceSeq) {
  591. case CARDREADER:
  592. {
  593. err = spConfig->ReadConfigValue("InitDriver", "CardReader", activeModeSecName);
  594. if (err != Error_Succeed)
  595. goto Error;
  596. err = spConfig->ReadConfigValueInt("DriverPort", "CardReader", devicePort);
  597. if (err != Error_Succeed)
  598. goto Error;
  599. break;
  600. }
  601. case CARDREADER_RED:
  602. {
  603. err = spConfig->ReadConfigValue("InitDriver", "CardReaderRed", activeModeSecName);
  604. if (err != Error_Succeed)
  605. goto Error;
  606. err = spConfig->ReadConfigValueInt("DriverPort", "CardReaderRed", devicePort);
  607. if (err != Error_Succeed)
  608. goto Error;
  609. break;
  610. }
  611. case PRINTER:
  612. {
  613. spConfig->ReadConfigValue("InitDriver", "Printer", activeModeSecName);
  614. spConfig->ReadConfigValueInt("DriverPort", "Printer", devicePort);
  615. break;
  616. }
  617. case IDCERTIFICATE:
  618. {
  619. spConfig->ReadConfigValue("InitDriver", "IDCertificate", activeModeSecName);
  620. spConfig->ReadConfigValueInt("DriverPort", "IDCertificate", devicePort);
  621. break;
  622. }
  623. case FINGERPRINT:
  624. {
  625. spConfig->ReadConfigValue("InitDriver", "FingerPrint", activeModeSecName);
  626. spConfig->ReadConfigValueInt("DriverPort", "FingerPrint", devicePort);
  627. break;
  628. }
  629. case PINPAD:
  630. {
  631. spConfig->ReadConfigValue("InitDriver", "Pinpad", activeModeSecName);
  632. spConfig->ReadConfigValueInt("DriverPort", "Pinpad", devicePort);
  633. break;
  634. }
  635. case HEADLIGHT:
  636. {
  637. spConfig->ReadConfigValue("InitDriver", "HeadLight", activeModeSecName);
  638. spConfig->ReadConfigValueInt("DriverPort", "HeadLight", devicePort);
  639. m_headlightDevPort = devicePort;
  640. break;
  641. }
  642. case HEADLIGHT_RED:
  643. {
  644. spConfig->ReadConfigValue("InitDriver", "HeadLightRed", activeModeSecName);
  645. spConfig->ReadConfigValueInt("DriverPort", "HeadLightRed", devicePort);
  646. break;
  647. }
  648. case CONTACTLESSCARD:
  649. {
  650. spConfig->ReadConfigValue("InitDriver", "ContactlessCard", activeModeSecName);
  651. spConfig->ReadConfigValueInt("DriverPort", "ContactlessCard", devicePort);
  652. break;
  653. }
  654. case USBCONTROL:
  655. {
  656. spConfig->ReadConfigValue("InitDriver", "USBControl", activeModeSecName);
  657. spConfig->ReadConfigValueInt("DriverPort", "USBControl", devicePort);
  658. break;
  659. }
  660. case USBLIGHT:
  661. {
  662. spConfig->ReadConfigValue("InitDriver", "USBLight", activeModeSecName);
  663. spConfig->ReadConfigValueInt("DriverPort", "USBLight", devicePort);
  664. break;
  665. }
  666. case HEADLIGHT_ASSIST:
  667. {
  668. spConfig->ReadConfigValue("InitDriver", "HeadLightAssist", activeModeSecName);
  669. spConfig->ReadConfigValueInt("DriverPort", "HeadLightAssist", devicePort);
  670. break;
  671. }
  672. case HSPSCANNER:
  673. {
  674. spConfig->ReadConfigValue("InitDriver", "HSPScanner", activeModeSecName);
  675. spConfig->ReadConfigValueInt("DriverPort", "HSPScanner", devicePort);
  676. break;
  677. }
  678. case PRINTER_SEAL:
  679. {
  680. if (!m_bNewVersion) {
  681. bDone = TRUE;
  682. break;
  683. }
  684. //static int paperLighted = PRINTERSEAL_UNKNOWN;
  685. //static int printLighted = PRINTERSEAL_UNKNOWN;
  686. err = Error_Unexpect;
  687. switch (req.mode) {
  688. case PRINTER_LIGHT_GREEN:
  689. LOG_TRACE("printseal green light on");
  690. err = spConfig->ReadConfigValue("InitDriver", "PrintSeal", activeModeSecName);
  691. err = spConfig->ReadConfigValueInt("DriverPort", "PrintSeal", devicePort);
  692. break;
  693. case PRINTER_LIGHT_RED:
  694. LOG_TRACE("printseal red light on");
  695. err = spConfig->ReadConfigValue("InitDriver", "PrintSealRed", activeModeSecName);
  696. err = spConfig->ReadConfigValueInt("DriverPort", "PrintSealRed", devicePort);
  697. break;
  698. case PAPER_LIGHT_GREEN:
  699. LOG_TRACE("paper slot green light on");
  700. err = spConfig->ReadConfigValue("InitDriver", "PrintPaper", activeModeSecName);
  701. err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaper", devicePort);
  702. break;
  703. case PAPER_LIGHT_RED:
  704. LOG_TRACE("paper slot red light on");
  705. err = spConfig->ReadConfigValue("InitDriver", "PrintPaperRed", activeModeSecName);
  706. err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaperRed", devicePort);
  707. break;
  708. case PRINTER_LIGHT_OFF:
  709. LOG_TRACE("printerseal light off");
  710. err = Error_Pending;
  711. break;
  712. case PAPER_LIGHT_OFF:
  713. LOG_TRACE("paper slot light off");
  714. err = Error_Pending;
  715. break;
  716. default:
  717. err = Error_Param;
  718. break;
  719. }
  720. if (err == Error_Pending) {
  721. CSimpleStringA initDriver1 = "", initDriver2 = "";
  722. int devicePort1, devicePort2;
  723. if (req.mode == PRINTER_LIGHT_OFF) {
  724. err = spConfig->ReadConfigValueInt("DriverPort", "PrintSeal", devicePort1);
  725. err = spConfig->ReadConfigValueInt("DriverPort", "PrintSealRed", devicePort2);
  726. } else {
  727. err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaper", devicePort1);
  728. err = spConfig->ReadConfigValueInt("DriverPort", "PrintPaperRed", devicePort2);
  729. }
  730. if (err != Error_Succeed) {
  731. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("read cfg failed ~.");
  732. return;
  733. }
  734. memset(&odi, 0, sizeof(odi));
  735. SetOutDriving(req, odi, 0, devicePort1);
  736. SetOutDriving(req, odi, 0, devicePort2);
  737. bDone = TRUE;
  738. }
  739. break;
  740. }
  741. break;
  742. default:
  743. return;
  744. }
  745. Error:
  746. if (err != Error_Succeed)
  747. {
  748. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("read cfg failed.");
  749. return;
  750. }
  751. if (bDone) {
  752. return;
  753. }
  754. GetOutDrivingModInfo(activeModeSecName, odi);
  755. SetOutDriving(req, odi, 0, devicePort);
  756. }
  757. void CGpioEntity::GetStatus(int deviceSeq, SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
  758. {
  759. /** 注意设备序号是实体内定义的逻辑,不是设备端口号*/
  760. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetStatus with devseq %d", deviceSeq);
  761. CSimpleStringA initDriver = "";
  762. int devicePort;
  763. ErrorCodeEnum Error;
  764. CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
  765. CSmartPointer<IConfigInfo> spConfig;
  766. Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
  767. if (Error != Error_Succeed) {
  768. LOG_TRACE("open cfg file failed!");
  769. return;
  770. }
  771. /** 获取指定的模式,以便后续获取输入模式和持续触发模式,见 GetReceivingModInfo*/
  772. spConfig->ReadConfigValue("InitDriver", "PhoneLift", initDriver);
  773. /** 获取硬件规格里对应的序号,其实是固定死的*/
  774. spConfig->ReadConfigValueInt("DriverPort", "PhoneLift", devicePort);
  775. ReceivingInfo ri;
  776. GetReceivingModInfo(initDriver, ri);
  777. ri.Port = devicePort;
  778. GetReceiving(deviceSeq, ri, PICKUPSENSOR, ctx);
  779. }
  780. void CGpioEntity::OnOutputPositiveLevelTimerout(void* pData)
  781. {
  782. SetContextInfo* pSCI = (SetContextInfo*)pData;
  783. GetFunction()->KillTimer(pSCI->timerID);
  784. ULONG devEnableStatus = GetDevEnableStatus();
  785. DevOutputInfo doi = GetCurrDevStatus();
  786. WritePin(pSCI->pinSeq, true);
  787. delete pSCI;
  788. SaveCurrDevStatus(doi);
  789. }
  790. void CGpioEntity::OnPositiveFlickerSetTimerout(void* pData)
  791. {
  792. SetContextInfo* pSCI = (SetContextInfo*)pData;
  793. GetFunction()->KillTimer(pSCI->timerID);
  794. ULONG devEnableStatus = GetDevEnableStatus();
  795. DevOutputInfo doi = GetCurrDevStatus();
  796. WritePin(pSCI->pinSeq, false);
  797. pSCI->timerID = pSCI->timerID;
  798. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerResetTimerout, pSCI, true);
  799. GetFunction()->SetTimer(pSCI->timerID, pListener, pSCI->resetTime);
  800. }
  801. void CGpioEntity::OnPositiveFlickerResetTimerout(void* pData)
  802. {
  803. SetContextInfo* pSCI = (SetContextInfo*)pData;
  804. GetFunction()->KillTimer(pSCI->timerID);
  805. ULONG devEnableStatus = GetDevEnableStatus();
  806. DevOutputInfo doi = GetCurrDevStatus();
  807. WritePin(pSCI->pinSeq, true);
  808. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerSetTimerout, pSCI, true);
  809. GetFunction()->SetTimer(pSCI->timerID, pListener, pSCI->setTime);
  810. }
  811. bool CGpioEntity::SetOutDriving(GpioService_Set_Info req, OutDrivingInfo od, ULONG iIndex, ULONG pinSeq)
  812. {
  813. ULONG devEnableStatus = GetDevEnableStatus();
  814. DevOutputInfo doi = GetCurrDevStatus();
  815. if (req.close == 1) {
  816. GetFunction()->KillTimer(req.devseq);
  817. //oilyang add 20161222
  818. //如果关闭照明灯,以感知为准
  819. if (pinSeq == m_headlightDevPort)
  820. WritePin(pinSeq, m_bHeadLightFlag);
  821. else {
  822. if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
  823. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("off hspsanner.");
  824. WritePin(PIN_HSPSCANNER_LIGHT, false);
  825. }
  826. WritePin(pinSeq, false);
  827. }
  828. return true;
  829. }
  830. switch (od.OutputMode) {
  831. case OM_POSITIVE_LEVEL:
  832. {
  833. switch (od.StopMode) {
  834. case SM_CALLTRIGGER:
  835. {
  836. LOG_TRACE("0.0 mode:output[%u], pinSeq=%u", doi.output, pinSeq);
  837. //if it is hspsanner
  838. if (pinSeq == PIN_HSPSCANNER_PREVIEW_LIGHT) {
  839. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("light hspsanner.");
  840. WritePin(PIN_HSPSCANNER_LIGHT, true);
  841. }
  842. WritePin(pinSeq, true);
  843. break;
  844. }
  845. case SM_TIMEOUT:
  846. {
  847. WritePin(pinSeq, true);
  848. SetContextInfo* pSci = new SetContextInfo();;
  849. pSci->ctx = NULL;
  850. pSci->timerID = req.devseq;
  851. pSci->timeout = od.TimeOut;
  852. pSci->index = iIndex;
  853. pSci->pinSeq = pinSeq;
  854. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnOutputPositiveLevelTimerout, pSci);
  855. GetFunction()->SetTimer(pSci->timerID, pListener, od.TimeOut);
  856. break;
  857. }
  858. case SM_CYCLE:
  859. break;
  860. default:
  861. break;
  862. }
  863. }
  864. break;
  865. case OM_POSITIVE_FLICKER:
  866. switch (od.StopMode) {
  867. case SM_CALLTRIGGER:
  868. break;
  869. case SM_TIMEOUT:
  870. break;
  871. case SM_CYCLE:
  872. {
  873. SetContextInfo* pSci = new SetContextInfo();
  874. pSci->ctx = NULL;
  875. pSci->index = iIndex;
  876. pSci->pinSeq = pinSeq;
  877. pSci->timerID = req.devseq;
  878. pSci->setTime = od.SetTime;
  879. pSci->resetTime = od.ResetTime;
  880. pSci->timeout = od.TimeOut;
  881. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveFlickerSetTimerout, pSci, true);
  882. WritePin(pinSeq, true);
  883. GetFunction()->SetTimer(pSci->timerID, pListener, pSci->setTime);
  884. break;
  885. }
  886. default:
  887. break;
  888. }
  889. break;
  890. case OM_NEGATIVE_FLICKER:
  891. switch (od.StopMode) {
  892. case SM_CALLTRIGGER:
  893. break;
  894. case SM_TIMEOUT:
  895. break;
  896. case SM_CYCLE:
  897. break;
  898. default:
  899. break;
  900. }
  901. break;
  902. default:
  903. break;
  904. }
  905. return true;
  906. }
  907. void CGpioEntity::OnPositivePulseUpTimerout(void* pData)
  908. {
  909. GetContextInfo* pGCI = (GetContextInfo*)pData;
  910. BYTE btInput = 0;
  911. ErrorCodeEnum err;
  912. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("port[%d]", INPUT_PORT_2);
  913. err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
  914. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("read[%d]", btInput);
  915. //判断输入
  916. if (DetectBit(btInput, pGCI->index)) {
  917. if (pGCI->CttPhone == 0)//oiltest 20130709
  918. {
  919. ////触发
  920. pGCI->ctx->Ans.status = 1;
  921. pGCI->ctx->Answer(Error_Succeed);
  922. } else {
  923. pGCI->CttPhone--;//oiltest 20130709
  924. GetFunction()->ResetTimer(pGCI->timerID, 1000);
  925. }
  926. } else {
  927. pGCI->CttPhone = pGCI->InitCTT;//oiltest 20130709
  928. GetFunction()->ResetTimer(pGCI->timerID, 1);
  929. }
  930. }
  931. void CGpioEntity::OnNegativePulseUpTimerout(void* pData)
  932. {
  933. int count = 1;//from UserData
  934. ULONG input = 0;
  935. if (count == 1) {
  936. //oiltest GetInput(,&input);
  937. if (input == 0) {
  938. //返回给调用,发出触发日志
  939. } else {
  940. //不稳定,清空计数,重新来
  941. }
  942. } else {
  943. //oiltest GetInput(,&input);
  944. if (input == 0) {
  945. //计数减一,继续采样
  946. //ITimerListener *pListener = new TimerOutHelper<CGpioEntity>(this, CGpioEntity::OnPositivePulseUpTimerout, );
  947. //GetFunction()->SetTimer(,)
  948. } else {
  949. //不稳定,清空计数,重新来
  950. }
  951. }
  952. }
  953. void CGpioEntity::OnPositiveLevelTimerOut(void* pData)
  954. {
  955. GetContextInfo* pGci = (GetContextInfo*)pData;
  956. const int count = pGci->InitCTT;
  957. const int initCtt = pGci->InitCTT;
  958. const int pos = pGci->Port;
  959. ULONG input = 0;
  960. BYTE btInput;
  961. bool bShakeOne, bMoveOne, bSwitchOne, bPhoneOne, bCardOne;
  962. bShakeOne = bMoveOne = bSwitchOne = bPhoneOne = bCardOne = false;
  963. ErrorCodeEnum err = m_hDevHelper->ReadPort(INPUT_PORT_2, btInput);
  964. if (err != Error_Succeed) {
  965. DevErrorInfo devErrInfo;
  966. ZeroMemory(&devErrInfo, sizeof(DevErrorInfo));
  967. ErrorCodeEnum erroCode = m_hDevHelper->GetLastErr(devErrInfo);
  968. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ReadPort failed: %s, ErrMsg[%s]", SpStrError(err), (LPCTSTR)devErrInfo.szErrMsg);
  969. return;
  970. }
  971. /** 震动感应 */
  972. if (pGci->CttShake == 1) {
  973. bShakeOne = true;
  974. do {
  975. if (initCtt == 1) {
  976. if (DetectBit(btInput, VIBRATIONSENSOR)) {
  977. if (!m_bVibrationFlag && m_eMachineType == RVC_Stand2S) {
  978. LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
  979. }
  980. m_bVibrationFlag = true;
  981. } else
  982. m_bVibrationFlag = false;
  983. break;
  984. }
  985. if (m_bVibrationRound) {
  986. if (DetectBit(btInput, VIBRATIONSENSOR) && !m_bVibrationFlag) {
  987. if (m_eMachineType == RVC_Stand2S)
  988. LogEvent(Severity_Middle, LOG_EVT_VIBRATIONSENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(17), __LINE__));
  989. m_bVibrationFlag = true;
  990. m_bVibrationRound = false;
  991. }
  992. } else if (!DetectBit(btInput, VIBRATIONSENSOR) && m_bVibrationFlag) {
  993. m_bVibrationFlag = false;
  994. m_bVibrationRound = true;
  995. }
  996. } while (0);
  997. pGci->CttShake = pGci->InitCTT;
  998. }
  999. /** 机箱门开关检测*/
  1000. if (pGci->CttSwitch == 1) {
  1001. bSwitchOne = true;
  1002. do {
  1003. if (initCtt == 1) {
  1004. if (DetectBit(btInput, OPENSENSOR)) {
  1005. if (!m_bOpenFlag) {
  1006. if (m_eMachineType == RVC_Stand2S)
  1007. LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
  1008. m_bOpenFlag = true;
  1009. }
  1010. } else if (m_bOpenFlag) {
  1011. if (m_eMachineType == RVC_Stand2S)
  1012. LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
  1013. m_bOpenFlag = false;
  1014. }
  1015. break;
  1016. }
  1017. if (m_bOpenRound) {
  1018. if (DetectBit(btInput, OPENSENSOR) && !m_bOpenFlag) {
  1019. if (m_eMachineType == RVC_Stand2S)
  1020. LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(18), __LINE__));
  1021. m_bOpenFlag = true;
  1022. m_bOpenRound = false;
  1023. }
  1024. } else if (!DetectBit(btInput, OPENSENSOR) && m_bOpenFlag) {
  1025. if (m_eMachineType == RVC_Stand2S)
  1026. LogEvent(Severity_Middle, LOG_EVT_OPENSENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(18), __LINE__));
  1027. m_bOpenFlag = false;
  1028. m_bOpenRound = true;
  1029. }
  1030. } while (0);
  1031. pGci->CttSwitch = pGci->InitCTT;
  1032. }
  1033. /**话机检测*/
  1034. if (pGci->CttPhone == 1) {
  1035. bPhoneOne = true;
  1036. do {
  1037. if (initCtt == 1) {
  1038. if (m_ePickUpFlag == Unknown) {
  1039. if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
  1040. else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
  1041. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
  1042. } else {
  1043. if (DetectBit(btInput, PICKUPSENSOR)) {
  1044. if (m_ePickUpFlag == InActive) {
  1045. if (m_eMachineType == RVC_Stand2S)
  1046. LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
  1047. m_ePickUpFlag = Actived;
  1048. }
  1049. } else if (m_ePickUpFlag == Actived) {
  1050. if (m_eMachineType == RVC_Stand2S)
  1051. LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
  1052. m_ePickUpFlag = InActive;
  1053. }
  1054. }
  1055. break;
  1056. }
  1057. if (m_bPickUpRound) {
  1058. if (DetectBit(btInput, PICKUPSENSOR)) {
  1059. if (m_ePickUpFlag == InActive) {
  1060. if (m_eMachineType == RVC_Stand2S)
  1061. LogEvent(Severity_Middle, LOG_EVT_PICKUP, "话机提起");
  1062. m_ePickUpFlag = Actived;
  1063. m_bPickUpRound = false;
  1064. } else if (m_ePickUpFlag == Unknown) {
  1065. m_ePickUpFlag = Actived;
  1066. }
  1067. }
  1068. } else if (!DetectBit(btInput, PICKUPSENSOR)) {
  1069. if (m_ePickUpFlag == Actived) {
  1070. if (m_eMachineType == RVC_Stand2S)
  1071. LogEvent(Severity_Middle, LOG_EVT_ONHOOK, "话机放下");
  1072. m_ePickUpFlag = InActive;
  1073. m_bPickUpRound = true;
  1074. } else if (m_ePickUpFlag == Unknown) {
  1075. m_ePickUpFlag = InActive;
  1076. }
  1077. }
  1078. } while (0);
  1079. pGci->CttPhone = pGci->InitCTT;
  1080. }
  1081. /*物体靠近感知检测*/
  1082. if (pGci->CttMove == 1) {
  1083. bMoveOne = true;
  1084. do {
  1085. if (initCtt == 1) {
  1086. if (DetectBit(btInput, MOVESENSOR)) {
  1087. if (m_eMachineType == RVC_Stand2S)
  1088. LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
  1089. }
  1090. break;
  1091. }
  1092. if (m_bMoveRound) {
  1093. if (DetectBit(btInput, MOVESENSOR)) {
  1094. m_moveDisappearTimes = 0;
  1095. if (m_moveHoldTimes < MAX_MOVE_HOLD_TIMES) { // 100ms * 5000
  1096. if ((m_moveHoldTimes % LOG_TIME_VALUE) == 0) { //100ms * 25 = 2.5s 但因为厂家接口调用,不进来计数,需要800ms+
  1097. if (m_eMachineType == RVC_Stand2S)
  1098. LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_ON, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(20), __LINE__));
  1099. }
  1100. } else if ((m_moveHoldTimes % MAX_MOVE_HOLD_TIMES) == 0) { //难道8分钟一直有人就异常?还有一个 Round 标识
  1101. if (m_eMachineType == RVC_Stand2S)
  1102. LogWarn(Severity_Middle, Error_Unexpect, LOG_EVT_MOVEDETECT_ABNORMAL, "移动次数异常");
  1103. }
  1104. m_moveHoldTimes++;
  1105. m_bMoveRound = false;
  1106. }
  1107. } else if (!DetectBit(btInput, MOVESENSOR)) {
  1108. m_moveHoldTimes = 0;
  1109. if ((m_moveDisappearTimes % LOG_TIME_VALUE) == 0) {
  1110. if (m_eMachineType == RVC_Stand2S)
  1111. LogEvent(Severity_Middle, LOG_EVT_MOVESENSOR_OFF, CSimpleStringA::Format("%s [InActive] line: %d", GetDriverPortString(20), __LINE__));
  1112. }
  1113. m_moveDisappearTimes++;
  1114. m_bMoveRound = true;
  1115. }
  1116. } while (0);
  1117. pGci->CttMove = pGci->InitCTT;
  1118. }
  1119. /*卡嘴异物检测*/
  1120. if (pGci->CttCard == 1) {
  1121. bCardOne = true;
  1122. do {
  1123. if (initCtt == 1) {
  1124. if (DetectBit(btInput, CARDGATESENSOR)) {
  1125. if (!m_bCardGateFlag) {
  1126. if (m_eMachineType == RVC_Stand2S)
  1127. LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
  1128. m_bCardGateFlag = true;
  1129. }
  1130. } else
  1131. m_bCardGateFlag = false;
  1132. break;
  1133. }
  1134. if (m_bCardGateRound) {
  1135. if (DetectBit(btInput, CARDGATESENSOR) && !m_bCardGateFlag) {
  1136. if (m_eMachineType == RVC_Stand2S)
  1137. LogEvent(Severity_Middle, LOG_EVT_CARDGATESENSOR, CSimpleStringA::Format("%s [Active] line: %d", GetDriverPortString(21), __LINE__));
  1138. m_bCardGateFlag = true;
  1139. m_bCardGateRound = false;
  1140. }
  1141. } else if (!DetectBit(btInput, CARDGATESENSOR) && m_bCardGateFlag) {
  1142. m_bCardGateFlag = false;
  1143. m_bCardGateRound = true;
  1144. }
  1145. } while (0);
  1146. pGci->CttCard = pGci->InitCTT;
  1147. }
  1148. /////////////////////////////////////////////////////////////////////////////////////
  1149. if (pGci->CttShake > 1 && !bShakeOne) {
  1150. do {
  1151. if (m_bVibrationRound) {
  1152. if (DetectBit(btInput, VIBRATIONSENSOR))
  1153. pGci->CttShake--;
  1154. else {
  1155. m_bVibrationRound = false;
  1156. pGci->CttShake = pGci->InitCTT;
  1157. }
  1158. } else {
  1159. if (!DetectBit(btInput, VIBRATIONSENSOR))
  1160. pGci->CttShake--;
  1161. else {
  1162. m_bVibrationRound = true;
  1163. pGci->CttShake = pGci->InitCTT;
  1164. }
  1165. }
  1166. } while (0);
  1167. }
  1168. if (pGci->CttSwitch > 1 && !bSwitchOne) {
  1169. do {
  1170. if (m_bOpenRound) {
  1171. if (DetectBit(btInput, OPENSENSOR))
  1172. pGci->CttSwitch--;
  1173. else {
  1174. m_bOpenRound = false;
  1175. pGci->CttSwitch = pGci->InitCTT;
  1176. }
  1177. } else {
  1178. if (!DetectBit(btInput, OPENSENSOR))
  1179. pGci->CttSwitch--;
  1180. else {
  1181. m_bOpenRound = true;
  1182. pGci->CttSwitch = pGci->InitCTT;
  1183. }
  1184. }
  1185. } while (0);
  1186. }
  1187. if (pGci->CttPhone > 1 && !bPhoneOne) {
  1188. do {
  1189. if (m_ePickUpFlag == Unknown) {
  1190. if (DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = Actived;
  1191. else if (!DetectBit(btInput, PICKUPSENSOR)) m_ePickUpFlag = InActive;
  1192. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Set initial value: %d", (int)m_ePickUpFlag);
  1193. break;
  1194. }
  1195. if (m_bPickUpRound) { /** 该参数的作用貌似是用于记录当前是否是提机的累计次数中,状态切换时会重置次数 [Gifur@2022527]*/
  1196. if (DetectBit(btInput, PICKUPSENSOR)) {
  1197. pGci->CttPhone--;
  1198. } else {
  1199. m_bPickUpRound = false;
  1200. pGci->CttPhone = pGci->InitCTT;
  1201. }
  1202. } else {
  1203. if (!DetectBit(btInput, PICKUPSENSOR))
  1204. pGci->CttPhone--;
  1205. else {
  1206. m_bPickUpRound = true;
  1207. pGci->CttPhone = pGci->InitCTT;
  1208. }
  1209. }
  1210. } while (0);
  1211. }
  1212. if (pGci->CttMove > 1 && !bMoveOne) {
  1213. do {
  1214. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("before ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
  1215. // pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
  1216. if (m_bMoveRound) {
  1217. if (DetectBit(btInput, MOVESENSOR))
  1218. pGci->CttMove--;
  1219. else {
  1220. m_bMoveRound = false;
  1221. pGci->CttMove = pGci->InitCTT;
  1222. }
  1223. } else {
  1224. if (!DetectBit(btInput, MOVESENSOR))
  1225. pGci->CttMove--;
  1226. else {
  1227. m_bMoveRound = true;
  1228. pGci->CttMove = pGci->InitCTT;
  1229. }
  1230. }
  1231. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("after ccMove: %d, ccInit: %d, moveRound: %d, %d, disppear: %d, holder: %d",
  1232. // pGci->CttMove, pGci->InitCTT, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
  1233. } while (0);
  1234. } else {
  1235. //DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("===== ccMove: %d, moveOne: %d, moveRound: %d, %d, disppear: %d, holder: %d",
  1236. // pGci->CttMove, bMoveOne, m_bMoveRound, DetectBit(btInput, MOVESENSOR), m_moveDisappearTimes, m_moveHoldTimes);
  1237. }
  1238. if (pGci->CttCard > 1 && !bCardOne) {
  1239. do {
  1240. if (m_bCardGateRound) {
  1241. if (DetectBit(btInput, CARDGATESENSOR))
  1242. pGci->CttCard--;
  1243. else {
  1244. m_bCardGateRound = false;
  1245. pGci->CttCard = pGci->InitCTT;
  1246. }
  1247. } else {
  1248. if (!DetectBit(btInput, CARDGATESENSOR))
  1249. pGci->CttCard--;
  1250. else {
  1251. m_bCardGateRound = true;
  1252. pGci->CttCard = pGci->InitCTT;
  1253. }
  1254. }
  1255. } while (0);
  1256. }
  1257. GetFunction()->ResetTimer(pGci->timerID, 100);
  1258. }
  1259. void CGpioEntity::OnNegativeLevelTimerOut(void* pData)
  1260. {
  1261. int count = 1;//from UserData
  1262. ULONG input = 0;
  1263. if (count == 1) {
  1264. if (input == 0) {
  1265. //返回给调用
  1266. //取消定时器
  1267. } else {
  1268. //清零
  1269. }
  1270. } else {
  1271. if (input == 0) {
  1272. //返回给调用
  1273. //取消定时器
  1274. } else {
  1275. //清零
  1276. }
  1277. }
  1278. }
  1279. bool CGpioEntity::GetReceiving(int deviceSeq, ReceivingInfo ri, ULONG iIndex,
  1280. SpReqAnsContext<GpioService_GetStatus_Req, GpioService_GetStatus_Ans>::Pointer ctx)
  1281. {
  1282. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("inputmode[%d],port[%d],ctt[%d]", ri.InputMode, ri.Port, ri.ContinuousTriggerTime);
  1283. switch (ri.InputMode)
  1284. {
  1285. case IM_POSITIVE_PULSE_UP:
  1286. {
  1287. GetContextInfo* pGci = new GetContextInfo();
  1288. pGci->timerID = ctx->Req.devseq;
  1289. pGci->ctx = ctx;
  1290. pGci->index = iIndex;
  1291. pGci->Port = ri.Port;
  1292. pGci->CttCard = ri.ContinuousTriggerTime;
  1293. pGci->CttMove = ri.ContinuousTriggerTime;
  1294. pGci->CttPhone = ri.ContinuousTriggerTime;
  1295. pGci->CttShake = ri.ContinuousTriggerTime;
  1296. pGci->CttSwitch = ri.ContinuousTriggerTime;
  1297. pGci->InitCTT = ri.ContinuousTriggerTime;
  1298. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositivePulseUpTimerout, pGci);
  1299. GetFunction()->SetTimer(pGci->timerID, pListener, 1);
  1300. break;
  1301. }
  1302. case IM_POSITIVE_LEVEL:
  1303. {
  1304. GetContextInfo* pGci = new GetContextInfo();
  1305. pGci->timerID = deviceSeq;
  1306. pGci->ctx = ctx;
  1307. pGci->index = iIndex;
  1308. pGci->Port = ri.Port;
  1309. //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
  1310. pGci->CttCard = ri.ContinuousTriggerTime;
  1311. pGci->CttMove = ri.ContinuousTriggerTime;
  1312. pGci->CttPhone = ri.ContinuousTriggerTime;
  1313. pGci->CttShake = ri.ContinuousTriggerTime;
  1314. pGci->CttSwitch = ri.ContinuousTriggerTime;
  1315. pGci->InitCTT = ri.ContinuousTriggerTime;
  1316. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnPositiveLevelTimerOut, pGci);
  1317. GetFunction()->SetTimer(pGci->timerID, pListener, 100);
  1318. break;
  1319. }
  1320. case IM_NEGATIVE_LEVEL:
  1321. {
  1322. GetContextInfo* pGci = new GetContextInfo();
  1323. pGci->timerID = deviceSeq;
  1324. pGci->ctx = ctx;
  1325. pGci->index = iIndex;
  1326. pGci->Port = ri.Port;
  1327. //pGci->ContinuousTriggerTime = ri.ContinuousTriggerTime;//oiltest 20130709
  1328. pGci->InitCTT = ri.ContinuousTriggerTime;
  1329. ITimerListener* pListener = new TimerOutHelper<CGpioEntity>(this, &CGpioEntity::OnNegativeLevelTimerOut, pGci);
  1330. GetFunction()->SetTimer(pGci->timerID, pListener, 1);
  1331. break;
  1332. }
  1333. default:
  1334. break;
  1335. }
  1336. return true;
  1337. }
  1338. void CGpioEntity::GetOutDrivingModInfo(CSimpleStringA modName, OutDrivingInfo& odi)
  1339. {
  1340. ErrorCodeEnum Error;
  1341. CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
  1342. CSmartPointer<IConfigInfo> spConfig;
  1343. Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
  1344. if (Error != Error_Succeed) {
  1345. DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("open cfg file failed!");
  1346. return;
  1347. }
  1348. spConfig->ReadConfigValueInt(modName, "OutputMode", odi.OutputMode);
  1349. spConfig->ReadConfigValueInt(modName, "StopMode", odi.StopMode);
  1350. spConfig->ReadConfigValueInt(modName, "SetTime", odi.SetTime);
  1351. spConfig->ReadConfigValueInt(modName, "ResetTime", odi.ResetTime);
  1352. spConfig->ReadConfigValueInt(modName, "Timeout", odi.TimeOut);
  1353. LOG_TRACE("outputmode.stopmode:[%d].[%d]", odi.OutputMode, odi.StopMode);
  1354. }
  1355. /*从配置文件中获取配置*/
  1356. void CGpioEntity::GetReceivingModInfo(CSimpleStringA modName, ReceivingInfo& ri)
  1357. {
  1358. ErrorCodeEnum Error;
  1359. CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
  1360. CSmartPointer<IConfigInfo> spConfig;
  1361. Error = spEntityFunction->OpenConfig(Config_Software, spConfig);
  1362. if (Error != Error_Succeed) {
  1363. LOG_TRACE("open cfg file failed!");
  1364. return;
  1365. }
  1366. spConfig->ReadConfigValueInt(modName, "InputMode", ri.InputMode);
  1367. spConfig->ReadConfigValueInt(modName, "ContinuousTriggerTime", ri.ContinuousTriggerTime);
  1368. }
  1369. BYTE CGpioEntity::GetOutputStatus(int sn)
  1370. {
  1371. if (sn == 0)
  1372. return m_btOutputStatus[0];
  1373. else if (sn == 1)
  1374. return m_btOutputStatus[1];
  1375. else if (sn == 2)
  1376. return m_btOutputStatus[2];
  1377. else
  1378. return 0;
  1379. }
  1380. SP_BEGIN_ENTITY_MAP()
  1381. SP_ENTITY(CGpioEntity)
  1382. SP_END_ENTITY_MAP()