Class Timeout

java.lang.Object
com.quanser.common.Timeout

public class Timeout extends Object
Represents an absolute or relative time. The Timeout class represents an absolute time or a relative time interval down to nanosecond resolution. It is used throughout the Quanser Java classes for methods that require a timeout. Because the Timeout class contains a flag denoting whether the time is absolute or relative, methods using this class do not require any extra arguments to differentiate between absolute and relative timeouts. The timeout is considered relative by default since that is the most common usage.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a zero relative timeout.
    Timeout(double seconds)
    Construct a relative timeout of the given seconds.
    Timeout(Timeout timeout)
    Construct a copy of the given timeout.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the total number of milliseconds in the timeout.
    int
    Get the number of nanoseconds in the timeout.
    long
    Get the number of seconds in the timeout.
    boolean
    Returns true if the timeout is absolute.
    boolean
    Returns true if the timeout is negative.
    boolean
    Returns true if the timeout is equal to zero.
    Get a string representation of the timeout.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Timeout

      public Timeout()
      Construct a zero relative timeout.
    • Timeout

      public Timeout(Timeout timeout)
      Construct a copy of the given timeout.
      Parameters:
      timeout - The Timeout object to copy.
    • Timeout

      public Timeout(double seconds)
      Construct a relative timeout of the given seconds. It has nanosecond resolution.
      Parameters:
      seconds - A double scalar indicating the number of seconds in the timeout. The timeout will be relative.
  • Method Details

    • getSeconds

      public long getSeconds()
      Get the number of seconds in the timeout. This is only the integral part of the timeout.
      Returns:
      Returns the number of seconds in the timeout as a long.
    • getNanoseconds

      public int getNanoseconds()
      Get the number of nanoseconds in the timeout. This is only the fractional part of the timeout.
      Returns:
      Returns the number of nanoseconds in the timeout as a int.
    • isAbsolute

      public boolean isAbsolute()
      Returns true if the timeout is absolute.
      Returns:
      Returns true if the timeout is absolute and false if it is relative.
    • isNegative

      public boolean isNegative()
      Returns true if the timeout is negative.
      Returns:
      Returns true if the timeout is negative and false if it is non-strictly positive.
    • isZero

      public boolean isZero()
      Returns true if the timeout is equal to zero.
      Returns:
      Returns true if the timeout is zero and false otherwise.
    • getMilliseconds

      public int getMilliseconds()
      Get the total number of milliseconds in the timeout. This combines both the seconds and nanoseconds.
      Returns:
      Returns the total number of milliseconds in the timeout as an int.
    • toString

      public String toString()
      Get a string representation of the timeout.
      Overrides:
      toString in class Object
      Returns:
      Returns a String representation of the timeout.