Пример #1
0
  /** 初始化时用以生成超高频对象,以后就可以直接用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;
  }