Ejemplo n.º 1
0
    /*
     * (non-Javadoc)
     *
     * @see java.lang.Runnable#run()
     */
    @Override
    public void run() {
      SET_READER_CONFIG srchigh = new SET_READER_CONFIG();
      List<GPOWriteData> gpowritehigh = new ArrayList<GPOWriteData>();
      for (Integer port : ports) {
        GPOWriteData write = new GPOWriteData();
        write.setGPOData(new Bit(1));
        write.setGPOPortNumber(new UnsignedShort(port));
        gpowritehigh.add(write);
      }
      srchigh.setGPOWriteDataList(gpowritehigh);
      srchigh.setResetToFactoryDefault(new Bit(0));

      session.send(srchigh);

      // Sleeping for the time given for the flash.
      try {
        Thread.sleep(flashTime * 1000);
      } catch (InterruptedException e) {
      }

      SET_READER_CONFIG srclow = new SET_READER_CONFIG();
      List<GPOWriteData> gpowritelow = new ArrayList<GPOWriteData>();
      for (Integer port : ports) {
        GPOWriteData write = new GPOWriteData();
        write.setGPOData(new Bit(0));
        write.setGPOPortNumber(new UnsignedShort(port));
        gpowritelow.add(write);
      }
      srclow.setGPOWriteDataList(gpowritelow);
      srclow.setResetToFactoryDefault(new Bit(0));

      session.send(srclow);
    }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.rifidi.edge.sensors.AbstractGPIOService#testGPI(java.lang.String,
   * int)
   */
  @Override
  public boolean testGPI(String readerID, int port) throws CannotExecuteException {
    LLRPReaderSession session = super.getSession(readerID);

    GET_READER_CONFIG grc = new GET_READER_CONFIG();
    grc.setGPOPortNum(new UnsignedShort(0));
    grc.setAntennaID(new UnsignedShort(0));
    GetReaderConfigRequestedData requestedData = new GetReaderConfigRequestedData();
    grc.setRequestedData(requestedData);
    grc.setGPIPortNum(new UnsignedShort(0));
    GET_READER_CONFIG_RESPONSE grcr = null;
    try {
      grcr = (GET_READER_CONFIG_RESPONSE) session.transact(grc);
    } catch (Exception e) {
      throw new CannotExecuteException(
          "Exception during transact while trying to " + "obtain GPI information");
    }
    List<GPIPortCurrentState> gpilist = grcr.getGPIPortCurrentStateList();

    for (GPIPortCurrentState gpi : gpilist) {
      if (gpi.getGPIPortNum().intValue() == port) {
        if (gpi.getState().intValue() == 1) {
          return true;
        } else {
          return false;
        }
      }
    }

    throw new CannotExecuteException("No such port found while searching for GPI value: " + port);
  }
Ejemplo n.º 3
0
  /*
   * (non-Javadoc)
   *
   * @see org.rifidi.edge.sensors.AbstractGPIOService#setGPO(java.lang.String,
   * java.util.Collection)
   */
  @Override
  public void setGPO(String readerID, Collection<Integer> ports) throws CannotExecuteException {
    LLRPReaderSession session = super.getSession(readerID);

    GET_READER_CONFIG grc = new GET_READER_CONFIG();
    grc.setGPOPortNum(new UnsignedShort(0));
    grc.setAntennaID(new UnsignedShort(0));
    GetReaderConfigRequestedData requestedData = new GetReaderConfigRequestedData();
    grc.setRequestedData(requestedData);
    grc.setGPIPortNum(new UnsignedShort(0));
    GET_READER_CONFIG_RESPONSE grcr = null;
    try {
      grcr = (GET_READER_CONFIG_RESPONSE) session.transact(grc);
    } catch (Exception e) {
      throw new CannotExecuteException(
          "Exception during transact while trying to " + "obtain GPO information");
    }
    int num_ports = grcr.getGPOWriteDataList().size();

    List<GPOWriteData> writedata = new ArrayList<GPOWriteData>();
    for (int i = 1; i <= num_ports; i++) {
      Bit setbit;
      if (ports.contains(new Integer(i))) {
        setbit = new Bit(1);
      } else {
        setbit = new Bit(0);
      }
      GPOWriteData data = new GPOWriteData();
      data.setGPOData(setbit);
      data.setGPOPortNumber(new UnsignedShort(i));
      writedata.add(data);
    }

    SET_READER_CONFIG src = new SET_READER_CONFIG();
    src.setGPOWriteDataList(writedata);
    src.setResetToFactoryDefault(new Bit(0));

    session.send(src);
  }