javax.realtime
Class RationalTime

java.lang.Object
  extended by javax.realtime.HighResolutionTime
      extended by javax.realtime.RelativeTime
          extended by javax.realtime.RationalTime
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

Deprecated. As of RTSJ 1.0.1

public class RationalTime
extends RelativeTime

An object that represents a time interval milliseconds/103 + nanoseconds/109 seconds long that is divided into subintervals by some frequency. This is generally used in periodic events, threads, and feasibility analysis to specify periods where there is a basic period that must be adhered to strictly (the interval), but within that interval the periodic events are supposed to happen frequency times, as uniformly spaced as possible, but clock and scheduling jitter is moderately acceptable.

Caution: This class is explicitly unsafe in multithreaded situations when it is being changed. No synchronization is done. It is assumed that users of this class who are mutating instances will be doing their own synchronization at a higher level. All Implemented Interfaces: java.lang.Comparable


Constructor Summary
RationalTime(int frequency)
          Deprecated. 1.0.1
RationalTime(int frequency, long millis, int nanos)
          Deprecated. 1.0.1
RationalTime(int frequency, RelativeTime interval)
          Deprecated. 1.0.1
 
Method Summary
 AbsoluteTime absolute(Clock clock, AbsoluteTime destination)
          Deprecated. 1.0.1
 void addInterarrivalTo(AbsoluteTime destination)
          Deprecated. 1.0.1
 int getFrequency()
          Deprecated. 1.0.1
 RelativeTime getInterarrivalTime()
          Deprecated. 1.0.1
 RelativeTime getInterarrivalTime(RelativeTime dest)
          Deprecated. 1.0.1
 void set(long millis, int nanos)
          Deprecated. 1.0.1
 void setFrequency(int frequency)
          Deprecated. 1.0.1
 java.lang.String toString()
          Deprecated. 1.0.1
 
Methods inherited from class javax.realtime.RelativeTime
absolute, add, add, add, add, relative, relative, subtract, subtract
 
Methods inherited from class javax.realtime.HighResolutionTime
clone, compareTo, compareTo, equals, equals, getClock, getMilliseconds, getNanoseconds, hashCode, set, set, waitForObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RationalTime

public RationalTime(int frequency)
Deprecated. 1.0.1

Construct an instance of RationalTime. Equivalent to new RationalTime(1000, 0, frequency)—essentially a cycles-per-second value.

Throws:
java.lang.IllegalArgumentException - Thrown if frequency is less than or equal to zero.

RationalTime

public RationalTime(int frequency,
                    long millis,
                    int nanos)
Deprecated. 1.0.1

Construct an instance of RationalTime. All arguments must be greater than or equal to zero.

Parameters:
frequency - The frequency value.
millis - The milliseconds value.
nanos - The nanoseconds value.
Throws:
java.lang.IllegalArgumentException - If any of the argument values are less than zero, or if frequency is equal to zero.

RationalTime

public RationalTime(int frequency,
                    RelativeTime interval)
Deprecated. 1.0.1

Construct an instance of RationalTime from the given RelativeTime.

Parameters:
frequency - The frequency value.
interval - The given instance of RelativeTime.
Throws:
java.lang.IllegalArgumentException - If either of the argument values are less than zero, or if frequency is equal to zero.
Method Detail

absolute

public AbsoluteTime absolute(Clock clock,
                             AbsoluteTime destination)
Deprecated. 1.0.1

Convert time of this to an absolute time.

Overrides:
absolute in class RelativeTime
Parameters:
clock - The reference clock. If null, Clock.getRealTimeClock() is used.
destination - A reference to the destination instance.
Returns:
The AbsoluteTime conversion in dest if dest is not null, otherwise the result is returned in a newly allocated object. It is associated with the clock parameter.

addInterarrivalTo

public void addInterarrivalTo(AbsoluteTime destination)
Deprecated. 1.0.1

Add the time of this to an AbsoluteTime It is almost the same dest.add(this, dest) except that it accounts for (i.e. divides by) the frequency.

Overrides:
addInterarrivalTo in class RelativeTime
Parameters:
destination - A reference to the destination instance.

getFrequency

public int getFrequency()
Deprecated. 1.0.1

Gets the value of frequency.

Returns:
The value of frequency as an integer.

getInterarrivalTime

public RelativeTime getInterarrivalTime()
Deprecated. 1.0.1

Gets the interarrival time. This time is (milliseconds/103 + nanoseconds/109)/frequency rounded down to the nearest expressible value of the fields and their types of RelativeTime.

Overrides:
getInterarrivalTime in class RelativeTime
Returns:
A reference to a new instance of RelativeTime with the same interval as this.

getInterarrivalTime

public RelativeTime getInterarrivalTime(RelativeTime dest)
Deprecated. 1.0.1

Gets the interarrival time. This time is (milliseconds/103 + nanoseconds/109)/frequency rounded down to the nearest expressible value of the fields and their types of RelativeTime.

Overrides:
getInterarrivalTime in class RelativeTime
Parameters:
dest - Result is stored in dest and returned, if null, a new object is returned.
Returns:
A reference to an object holding the result.

set

public void set(long millis,
                int nanos)
Deprecated. 1.0.1

Sets the indicated fields to the given values.

Overrides:
set in class HighResolutionTime
Parameters:
millis - The new value for the millisecond field.
nanos - The new value for the nanosecond field.

setFrequency

public void setFrequency(int frequency)
Deprecated. 1.0.1

Sets the value of the frequency field.

Parameters:
frequency - The new value for the frequency.
Throws:
java.lang.IllegalArgumentException - Thrown if frequency is less than or equal to zero.

toString

public java.lang.String toString()
Deprecated. 1.0.1

Create a printable string of the time given by this.

The string shall be a decimal representation of the frequency, milliseconds and nanosecond values; formatted as follows "(100, 2251 ms, 750000 ns)"

Overrides:
toString in class RelativeTime
Returns:
String object converted from the time given by this.