Class Command

java.lang.Object
org.networkupstools.jnut.Command

public class Command extends Object
Class representing a command of a device.

It can be used to retrieve description and execute commands. A Command object can be retrieved from Device instance and cannot be constructed directly.

Author:
Emilien Kia
  • Constructor Details

    • Command

      protected Command(String name, Device device)
      Internally create a command.
      Parameters:
      name - Command name.
      device - Device to which the command is attached.
  • Method Details

    • getDevice

      public Device getDevice()
      Return the device to which the command can be executed.
      Returns:
      Attached device.
    • getName

      public String getName()
      Return the command name.
      Returns:
      Command name.
    • getDescription

      public String getDescription() throws IOException, NutException
      Retrieve the command description from UPSD and store it in a cache.
      Returns:
      Command description
      Throws:
      IOException
      NutException
    • execute

      public TrackingID execute() throws IOException, NutException
      Execute the instant command without any optional argument.
      Returns:
      Tracking ID if tracking is enabled, or null.
      Throws:
      IOException
      NutException
    • execute

      public TrackingID execute(String param) throws IOException, NutException
      Execute the instant command with an optional parameter.
      Parameters:
      param - Command parameter (the value may be null to not send it; however, an empty string may be a valid value for server side, so a "" argument would be sent).
      Returns:
      Tracking ID if tracking is enabled, or null.
      Throws:
      IOException
      NutException
    • execute

      public TrackingID execute(String param, int waitIntervalSec, int waitMaxCount) throws IOException, NutException
      Execute the instant command with an optional parameter, and optionally waiting for completion.
      Parameters:
      param - Command parameter (the value may be null to not send it; however, an empty string may be a valid value for server side, so a "" argument would be sent).
      waitIntervalSec - Interval between checks in seconds (if >= 1).
      waitMaxCount - Maximum number of checks (if >= 1).
      Returns:
      Tracking ID if tracking is enabled (and not waiting), or null.
      Throws:
      IOException
      NutException