Package jadex.platform.service.clock
Class ContinuousClock
- java.lang.Object
-
- jadex.platform.service.clock.AbstractClock
-
- jadex.platform.service.clock.ContinuousClock
-
- All Implemented Interfaces:
IClock,IContinuousClock
- Direct Known Subclasses:
SystemClock
public class ContinuousClock extends AbstractClock implements IContinuousClock
A continuous clock represents a real time clock that is based on the hardware clock. Can be made faster or slower and also has an adjustable start time.
-
-
Field Summary
Fields Modifier and Type Field Description protected doubledilationThe dilation.protected longelapsedThe elapsed time.protected ExecutorexecutorThe active timer watcher.protected longlaststartThe last starting real time measurement point.protected IThreadPoolthreadpoolThe threadpool.-
Fields inherited from class jadex.platform.service.clock.AbstractClock
currenttime, DEFAULT_DELTA, delta, listeners, name, starttime, state, ticktimer, ticktimers, timers
-
Fields inherited from interface jadex.bridge.service.types.clock.IClock
EVENT_TYPE_NEW_DELTA, EVENT_TYPE_NEW_DILATION, EVENT_TYPE_NEXT_TIMEPOINT, EVENT_TYPE_RESET, EVENT_TYPE_STARTED, EVENT_TYPE_STOPPED, EVENT_TYPE_TIMER_ADDED, EVENT_TYPE_TIMER_REMOVED, STATE_RUNNING, STATE_SUSPENDED, TYPE_CONTINUOUS, TYPE_EVENT_DRIVEN, TYPE_SYSTEM, TYPE_TIME_DRIVEN
-
-
Constructor Summary
Constructors Constructor Description ContinuousClock(IClock oldclock, IThreadPool threadpool)Create a new clock.ContinuousClock(java.lang.String name, long starttime, double dilation, long delta, IThreadPool threadpool)Create a new clock.ContinuousClock(java.lang.String name, long starttime, double dilation, IThreadPool threadpool)Create a new clock.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(IChangeListener listener)Add a change listener.voidaddTimer(ITimer timer)Add a timer.protected voidcomputeNextTimepoint()Compute the next timepoint.voidcopyFromClock(IClock oldclock)Transfer state from another clock to this clock.protected ExecutorcreateExecutor()Create new executor.voiddispose()Called, when the clock is no longer used.doublegetDilation()Get the clocks dilation.longgetTime()Get the clocks name.java.lang.StringgetType()Get the clock type.voidremoveTimer(ITimer timer)Remove a timer.voidreset()Reset the clock.voidsetDilation(double dilation)Set the clocks dilation.voidstart()Start the clock.voidstop()Stop the clock.-
Methods inherited from class jadex.platform.service.clock.AbstractClock
activateTickTimer, addTickTimer, createTickTimer, createTimer, getDelta, getName, getNextTimer, getStarttime, getState, getTick, getTickTimers, getTimers, hasListeners, notifyListeners, removeChangeListener, removeTickTimer, setDelta, setStarttime, shutdown
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jadex.bridge.service.types.clock.IClock
addTickTimer, createTickTimer, createTimer, getDelta, getName, getNextTimer, getStarttime, getState, getTick, getTickTimers, getTimers, removeChangeListener, removeTickTimer, setDelta, setStarttime
-
-
-
-
Field Detail
-
dilation
protected double dilation
The dilation.
-
laststart
protected long laststart
The last starting real time measurement point.
-
elapsed
protected long elapsed
The elapsed time.
-
executor
protected Executor executor
The active timer watcher.
-
threadpool
protected IThreadPool threadpool
The threadpool.
-
-
Constructor Detail
-
ContinuousClock
public ContinuousClock(java.lang.String name, long starttime, double dilation, IThreadPool threadpool)Create a new clock. Delta (tick size) is default (see AbstractClock).- Parameters:
name- The clock name.starttime- The start time.dilation- The dilation.
-
ContinuousClock
public ContinuousClock(java.lang.String name, long starttime, double dilation, long delta, IThreadPool threadpool)Create a new clock.- Parameters:
name- The clock name.starttime- The start time.dilation- The dilation.delta- The tick size (in millis).
-
ContinuousClock
public ContinuousClock(IClock oldclock, IThreadPool threadpool)
Create a new clock.- Parameters:
oldclock- The old clock.
-
-
Method Detail
-
copyFromClock
public void copyFromClock(IClock oldclock)
Transfer state from another clock to this clock.- Overrides:
copyFromClockin classAbstractClock
-
dispose
public void dispose()
Called, when the clock is no longer used.- Specified by:
disposein interfaceIClock- Overrides:
disposein classAbstractClock
-
getTime
public long getTime()
Get the clocks name.- Specified by:
getTimein interfaceIClock- Overrides:
getTimein classAbstractClock- Returns:
- The name.
-
getDilation
public double getDilation()
Get the clocks dilation.- Specified by:
getDilationin interfaceIContinuousClock- Returns:
- The clocks dilation.
-
setDilation
public void setDilation(double dilation)
Set the clocks dilation.- Specified by:
setDilationin interfaceIContinuousClock- Parameters:
dilation- The clocks dilation.
-
getType
public java.lang.String getType()
Get the clock type.
-
start
public void start()
Start the clock.- Specified by:
startin interfaceIClock- Overrides:
startin classAbstractClock
-
stop
public void stop()
Stop the clock.- Specified by:
stopin interfaceIClock- Overrides:
stopin classAbstractClock
-
reset
public void reset()
Reset the clock.- Specified by:
resetin interfaceIClock- Overrides:
resetin classAbstractClock
-
computeNextTimepoint
protected void computeNextTimepoint()
Compute the next timepoint.
-
addTimer
public void addTimer(ITimer timer)
Add a timer.- Specified by:
addTimerin interfaceIClock- Overrides:
addTimerin classAbstractClock- Parameters:
timer- The timer.
-
removeTimer
public void removeTimer(ITimer timer)
Remove a timer.- Specified by:
removeTimerin interfaceIClock- Overrides:
removeTimerin classAbstractClock- Parameters:
timer- The timer.
-
addChangeListener
public void addChangeListener(IChangeListener listener)
Add a change listener.- Specified by:
addChangeListenerin interfaceIClock- Overrides:
addChangeListenerin classAbstractClock- Parameters:
listener- The change listener.
-
createExecutor
protected Executor createExecutor()
Create new executor.
-
-