HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: //opt/OV/OpC/examples/jopcagtapi/JOpcMonValueTest.java
import java.io.*;
import java.util.*;
import com.hp.openview.ib.api.jopc.*;

class JOpcMonValueTest
{
  private static BufferedReader         stdin  = null;
  private static String                 lastID = null;
  private static JOpcMonValue      	msg    = null;

  public static void main(String args[]) throws JOpcException, IOException,
                                                ClassNotFoundException
  {
    stdin = new BufferedReader(new InputStreamReader(System.in));

    try {
      System.out.println("JOpcMonValueTest startup");

      msg = new JOpcMonValue();

      System.out.print("Enter monitor name (i.E. swap_util): ");
      System.out.flush();
      String var = stdin.readLine();
      msg.setMonVar(var);

      System.out.print("Enter monitor value (a double): ");
      System.out.flush();
      String valStr = stdin.readLine();
      if((valStr != null) && (valStr.length() > 0))
      {
        try
        {
          Double v = new Double(valStr);
          msg.setMonValue(v.doubleValue());

          System.out.print("Enter optional parameters (format <var>=<value>): ");
          System.out.flush();
          String option_var = stdin.readLine();
          msg.setOptionVar(option_var);

          System.out.print("Enter message object (a string): ");
          System.out.flush();
          String msg_obj = stdin.readLine();
          msg.setObject(msg_obj);

          // Send the value if the user has entered something numberish
          msg.send();
          System.out.println("Sent monitor value " + var + " = " + valStr);
        }
        catch(NumberFormatException e){
          System.out.println("ERROR> Bad numeric value: " + valStr);
        }
      }

    }
    catch(JOpcException jopce){
      System.out.println("Exception occured!");
      System.out.println("Message: " + jopce.getMessage());
      System.out.println("Stack Trace: " + jopce.getStack());
    }

  } // END main METHOD

} // END CLASS