|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.EventObject | +--se.lth.cs.realtime.event.RTEvent
The base class of real-time, i.e. time-stamped, events.
Every RTEvent
comes from a source object referred to
in the EventObject
base class. Additional IDs, such as
sequential numbers or the kind of event within a certain type, are
expected to be defined in subclasses together with other user
attributes. The time stamp is, however, fundamental to real-time
systems as a mean to denote the freshness of the data. It is
therefore an attribute here and the motivation for this class.
The source object, often run in another thread, is not supposed to keep any reference to the event after posting it, thus methods of this class should not need to be synchronized.
There is a ticker
attribute referring to a time-base,
which can be given to the constructor. This is for special computers
or special applications; if you do not know that you need it, simply
ignore it and the default System.currentTimeMillis()
will be used as the actual ticker. However, obtaining the time via
getMillis
or getSeconds
will make your code
portable to such special applications.
Field Summary | |
protected Timebase |
ticker
The time-base relating number of ticks to real time. |
protected long |
timestamp
The time stamp of this event, in number of (system dependent) ticks. |
Fields inherited from class java.util.EventObject |
source |
Constructor Summary | |
RTEvent()
Constructs an RTEvent object with the current
thread as source and a timestamp from the current system time. |
|
RTEvent(long ts)
Constructs an RTEvent object with the current
thread as source and with the specified time stamp. |
|
RTEvent(java.lang.Object source)
Constructs an RTEvent object with the specified
source object and a timestamp from the current system time. |
|
RTEvent(java.lang.Object source,
long ts)
Constructs an RTEvent object with the specified
source object and time stamp. |
|
RTEvent(java.lang.Object source,
long ts,
Timebase timebase)
Constructs an RTEvent object with the specified
source object and time-stamp with respect to the specified time-base. |
Method Summary | |
long |
getMillis()
Returns the event's time stamp in number of milli-seconds. |
long |
getNanos()
Return the sub-milli part of the time-stamp, if any. |
double |
getSeconds()
Returns the creation-time (or supplied time-stamp= of this event. |
long |
getTicks()
Returns the event's time stamp. |
Timebase |
getTimebase()
Obtains the time-base relating (possibly locally counted) ticks or seconds to real time. |
protected java.lang.String |
paramString()
Return a string representation of the attributes/state of this object. |
java.lang.String |
toString()
Gives a string representation of the event object. |
Methods inherited from class java.util.EventObject |
getSource |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected long timestamp
protected Timebase ticker
Constructor Detail |
public RTEvent()
RTEvent
object with the current
thread as source and a timestamp from the current system time.public RTEvent(java.lang.Object source)
RTEvent
object with the specified
source object and a timestamp from the current system time.source
- The object where the event originated.public RTEvent(long ts)
RTEvent
object with the current
thread as source and with the specified time stamp.ts
- The time from which the event originates.public RTEvent(java.lang.Object source, long ts)
RTEvent
object with the specified
source object and time stamp.source
- The object where the event originated.ts
- The time from which the event originates.public RTEvent(java.lang.Object source, long ts, Timebase timebase)
RTEvent
object with the specified
source object and time-stamp with respect to the specified time-base.source
- The object where the event originated.ts
- The time from which the event originates.Method Detail |
public long getTicks()
getSeconds()
.public double getSeconds()
public long getMillis()
System.currentTimeMillis()
.public long getNanos()
getSeconds
usually is a better alternative when working with times that contain
fractions of milli-seconds.public Timebase getTimebase()
null
if
System.currentTimeMillis
is used.public java.lang.String toString()
The string is of the form:
ClassName[paramString]
where ClassName is the name of the event class,
paramString is the string returned by paramString
.
toString
in class java.util.EventObject
protected java.lang.String paramString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |