|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.realtime.HighResolutionTime | +--javax.realtime.RelativeTime | +--javax.realtime.RationalTime
An object that represents a time interval millis/1E3+nanos/1E9
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 u niformly spaced as possible,
but clock and scheduling jitter is moderately acceptable.
If the value of any of the millisecond or nanosecond fields is
negative the variable is set to negative value. Although logically
this may represent time before the epoch, invalid results may
occur if an instance of AbsoluteTime
representing
time before the epoch is given as a parameter to a method.
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.
Field Summary | |
private int |
frequency
|
Fields inherited from class javax.realtime.RelativeTime |
ZERO |
Fields inherited from class javax.realtime.HighResolutionTime |
defaultClock |
Constructor Summary | |
RationalTime(int frequency)
Constructs an instance of RationalTime . |
|
RationalTime(int frequency,
long millis,
int nanos)
Constructs an instance of RationalTime . |
|
RationalTime(int frequency,
javax.realtime.RelativeTime interval)
Constructs an instance of RationalTime from the given
RelativeTime . |
Method Summary | |
javax.realtime.AbsoluteTime |
absolute(javax.realtime.Clock clock,
javax.realtime.AbsoluteTime destination)
Convert this time to an absolute time. |
void |
addInterarrivalTo(javax.realtime.AbsoluteTime destination)
Add this time to an AbsoluteTime . |
int |
getFrequency()
Gets the value of frequency . |
javax.realtime.RelativeTime |
getInterarrivalTime()
Gets the interarrival time. |
javax.realtime.RelativeTime |
getInterarrivalTime(javax.realtime.RelativeTime dest)
Gets the interarrival time. |
void |
set(long millis,
int nanos)
Sets the indicated fields to the given values. |
void |
setFrequency(int frequency)
Sets the value of the frequency field. |
Methods inherited from class javax.realtime.RelativeTime |
absolute, add, add, add, add, relative, relative, relative, subtract, subtract, toString |
Methods inherited from class javax.realtime.HighResolutionTime |
compareTo, compareTo, equals, equals, getMilliseconds, getNanoseconds, hashCode, set, set, time, waitForObject |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private int frequency
Constructor Detail |
public RationalTime(int frequency)
RationalTime
. Equivalent to
new RationalTime(frequency, 1000, 0)
-- essentially a
cycle-per-seconds value.
frequency
- The frequency value.public RationalTime(int frequency, long millis, int nanos) throws java.lang.IllegalArgumentException
RationalTime
. All arguments
must be greater than or equal to zero.
frequency
- The frequency value.millis
- The milliseconds value.nanos
- The nanoseconds value.
java.lang.IllegalArgumentException
- If any of the argument values
are less than zero.public RationalTime(int frequency, javax.realtime.RelativeTime interval) throws java.lang.IllegalArgumentException
RationalTime
from the given
RelativeTime
.
frequency
- The frequency value.interval
- The given instance of RelativeTime
.
java.lang.IllegalArgumentException
- If any of the argument values
are less than zero.Method Detail |
public javax.realtime.AbsoluteTime absolute(javax.realtime.Clock clock, javax.realtime.AbsoluteTime destination)
absolute
in class RelativeTime
clock
- The reference clock. If null, Clock.getRealTimeClock()
is used.destination
- A reference to the destination istance.
AbsoluteTime
containing the result.public void addInterarrivalTo(javax.realtime.AbsoluteTime destination)
AbsoluteTime
. It is almost the same as
destination.add(this, destination)
except that it accounts
for (ie. divides by) the frequency.
addInterarrivalTo
in class RelativeTime
destination
- A reference to the given instance of
AbsoluteTime
and the result.public int getFrequency()
frequency
.
frequency
as an integer.public javax.realtime.RelativeTime getInterarrivalTime()
(milliseconds/10^3 + nanoseconds/10^9)/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
.
public javax.realtime.RelativeTime getInterarrivalTime(javax.realtime.RelativeTime dest)
(milliseconds/10^3 + nanoseconds/10^9)/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.
public void set(long millis, int nanos) throws java.lang.IllegalArgumentException
set
in class HighResolutionTime
millis
- The new value for the millisecond field.nanos
- The new value for the nanosecond field.
java.lang.IllegalArgumentException
public void setFrequency(int frequency) throws java.lang.ArithmeticException
frequency
field.
frequency
- The new value for the frequency
.
java.lang.ArithmeticException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |