Exemple #1
0
  private EpcCache getNewEpcList(String eoj) {

    ArrayList<EPC> epcGetter = new ArrayList<EPC>();
    ArrayList<EPC> epcList = new ArrayList<EPC>();
    EpcCache epcCache = new EpcCache();

    try {
      // System.out.println(eoj);

      epcGetter.add(OBSERVABLE_EPC);
      epcGetter.add(SETABLE_EPC);
      epcGetter.add(GETABLE_EPC);

      //            DataTransactionListenerDelegate delegate = new
      // EpcListTransactionListenerDelegate(epcCache);
      //            DataTransactionListener listener = new DataTransactionListener(delegate);
      EpcListTransactionListener listener = new EpcListTransactionListener(epcCache);
      Transaction epcListTransaction =
          transactionFactory.makeMulticastTransaction(eoj, epcGetter, listener);
      listener.setTransaction(epcListTransaction);

      epcListTransaction.execute();
      epcListTransaction.join();

      // System.out.println(epcCache);

    } catch (SubnetException ex) {
      Logger.getLogger(ValidEpcCache.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InterruptedException ex) {
      Logger.getLogger(ValidEpcCache.class.getName()).log(Level.SEVERE, null, ex);
    }

    return epcCache;
  }
Exemple #2
0
  @Override
  public void receive(Transaction t, Subnet subnet, Frame frame) {
    StandardPayload payload = TransactionListenerUtility.getPayload(frame);
    int propertyNum = TransactionListenerUtility.getPropertyNum(payload);

    for (int propertyIndex = 0; propertyIndex < propertyNum; propertyIndex++) {

      Property property = payload.getFirstPropertyAt(propertyIndex);
      EPC epc = property.getEPC();
      ArrayList<EPC> data = TransactionListenerUtility.explodeEdtToEpcList(property.getEDT());

      if (epc == OBSERVABLE_EPC) {
        epcCache.Observable = data;
      } else if (epc == SETABLE_EPC) {
        epcCache.Setable = data;
      } else if (epc == GETABLE_EPC) {
        epcCache.Getable = data;
      }

      epcCache.AllEPC.addAll(data);
    }

    transaction.finish();
  }