maslab.data
Class Clock

java.lang.Object
  extended by maslab.data.Clock

public class Clock
extends java.lang.Object

A Clock allows applications to seamlessly interchange live runs with simulated data.


Constructor Summary
Clock()
          Produce a started realtime clock.
Clock(double timeDialation)
          How fast should time travel? Set to <0 for "fast as possible", 1.0 for real time.
 
Method Summary
 void addEventSource(ClockEventSource source)
           
 void forceRealtime()
          Can be called to force timeDialation=1.0 (e.g., realtime).
 java.lang.Thread getEventThread()
           
 double getTime()
          Returns zero if the clock has not yet been started.
 double getWallTime()
           
 void sleep(double ms)
          must NOT be called from our EventThread
 void sleepUntilTime(double time)
           
 void start()
          Starts the clock.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Clock

public Clock()
Produce a started realtime clock.


Clock

public Clock(double timeDialation)
How fast should time travel? Set to <0 for "fast as possible", 1.0 for real time. 2.0 would be twice real time.

Method Detail

getEventThread

public java.lang.Thread getEventThread()

start

public void start()
Starts the clock.


addEventSource

public void addEventSource(ClockEventSource source)

forceRealtime

public void forceRealtime()
Can be called to force timeDialation=1.0 (e.g., realtime). Useful for real-time event sources.


getTime

public double getTime()
Returns zero if the clock has not yet been started.


getWallTime

public double getWallTime()

sleepUntilTime

public void sleepUntilTime(double time)

sleep

public void sleep(double ms)
must NOT be called from our EventThread