private void sendRequest(BlockPdu pdu) {
   setButton.setEnabled(false);
   getButton.setEnabled(false);
   getNextButton.setEnabled(false);
   lmessage.setText("Sending request ..");
   lmessage.setBackground(Color.white);
   try {
     varbind var = pdu.getResponseVariableBinding();
     AsnObjectId oid = var.getOid();
     AsnObject res = var.getValue();
     if (res != null) {
       toid.setText(oid.toString());
       tvalue.setText(res.toString());
       lmessage.setText("Received aswer ");
       lmessage.setBackground(Color.white);
     } else {
       lmessage.setText("Received no aswer ");
       lmessage.setBackground(Color.red);
     }
   } catch (PduException exc) {
     lmessage.setText("PduException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   } catch (java.io.IOException exc) {
     lmessage.setText("IOException: " + exc.getMessage());
     lmessage.setBackground(Color.red);
     exc.printStackTrace();
   }
   setButton.setEnabled(true);
   getButton.setEnabled(true);
   getNextButton.setEnabled(true);
 }
 private void sendRequest(BlockPdu pdu) throws PduException, IOException {
   varbind[] var = pdu.getResponseVariableBindings();
   if (var != null) {
     int sz = var.length;
     System.out.println("Received answer " + sz);
     for (int i = 0; i < sz; i++) {
       AsnObjectId oid = var[i].getOid();
       AsnObject res = var[i].getValue();
       System.out.println(oid.toString() + ": " + res.toString());
     }
   } else {
     System.out.println("Received no answer");
   }
 }
Beispiel #3
0
 /**
  * Prints the oid, but checks first if it is one of the usmStats error messages. If so, it
  * translates it to the usmStats string.
  */
 public static String printOid(AsnObjectId oid) {
   String msg = "";
   boolean found = false;
   int i = 0;
   while (i < usmStatsConstants.usmStatsOids.length && found == false) {
     AsnObjectId usmOid = new AsnObjectId(usmStatsConstants.usmStatsOids[i]);
     found = (oid.startsWith(usmOid) == true);
     i++;
   }
   if (found == true) {
     i--;
     msg = usmStatsConstants.usmStatsStrings[i];
   } else {
     msg = oid.toString();
   }
   return msg;
 }