Ejemplo n.º 1
0
  public void actionPerformed(ActionEvent evt) {
    Object src = evt.getSource();

    try {
      if (src == propDialog) {
        propDialog_actionPerformed(evt);
      } else {
        pdu = new BlockPdu(context);
        if (src == setButton) {
          pdu.setPduType(BlockPdu.SET);
          pdu.addOid(toid.getText(), new AsnOctets(tvalue.getText()));
        } else if (src == getButton) {
          pdu.setPduType(BlockPdu.GET);
          pdu.addOid(toid.getText());
        } else if (src == getNextButton) {
          pdu.setPduType(BlockPdu.GETNEXT);
          pdu.addOid(toid.getText());
        }
        sendRequest(pdu);
      }
    } catch (Exception exc) {
      exc.printStackTrace();
      lmessage.setText("Exception: " + exc.getMessage());
      lmessage.setBackground(Color.red);
    }
  }
Ejemplo n.º 2
0
  private void sendGetRequest() {
    try {
      pdu = new BlockPdu(context);
      pdu.setPduType(BlockPdu.GET);
      pdu.addOid(ifNumber);
      AsnObject res = pdu.getResponseVariable();

      if (res != null) {
        int ifCount = ((AsnInteger) res).getValue();
        System.out.println("ifCount " + ifCount);

        pdu = new BlockPdu(context);
        pdu.setPduType(BlockPdu.GETNEXT);
        for (int no = 0; no < ifCount; no++) {
          for (int i = 1; i <= noIfEntry; i++) {
            String oid = ifEntry + "." + i + "." + no;
            pdu.addOid(oid);
          }
        }
        sendRequest(pdu);
      } else {
        System.out.println("Received no answer");
      }
    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }
Ejemplo n.º 3
0
 private void sendGetRequest(String oid) {
   pdu = new BlockPdu(context);
   pdu.setPduType(BlockPdu.GET);
   pdu.addOid(oid);
   sendRequest(pdu);
 }