/** 初始化时用以生成超高频对象,以后就可以直接用rfid()来调用了。 */ public static StUhf getRfid() { if (rfid == null) { StUhf rf = null; if (getSavedModel() == null) { rf = StUhf.getUhfInstance(); // InterrogatorModel.InterrogatorModelD2 } else { rf = StUhf.getUhfInstance(getSavedModel()); } if (rf == null) { Log.e(TAG, "Rfid instance is null,exit"); return null; } boolean b = rf.init(); if (b == false) { Log.e(TAG, "cannot init rfid"); return null; } rfid = rf; StUhf.InterrogatorModel model = rfid.getInterrogatorModel(); saveModelName(model); switch (model) { case InterrogatorModelA: case InterrogatorModelB: case InterrogatorModelC: case InterrogatorModelD2: // case InterrogatorModelE: break; default: throw new IllegalStateException( "new rfid model found,please check your code for compatibility."); } } return rfid; }
/** 在这儿最多会执行三次Stop,只所以这样,只是为了方便各Activity不用担心执行一次不成功 */ public static boolean stop() { if (rfid != null) { if (rfid.isFunctionSupported(com.senter.support.openapi.StUhf.Function.StopOperation)) { for (int i = 0; i < 3; i++) { if (rfid().stopOperation()) { Log.i(TAG, "stopOperation 成功"); return true; } } Log.i(TAG, "stopOperation 不成功"); return false; } } return true; }
/** 清除Selection选定 */ public static void clearMaskAndSelection() { if (rfid.isFunctionSupported(StUhf.Function.DisableMaskSettings)) { rfid.disableMaskSettings(); } }