mod_gpio.cpp 51 KB

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