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 double
dilation
The dilation.protected long
elapsed
The elapsed time.protected Executor
executor
The active timer watcher.protected long
laststart
The last starting real time measurement point.protected IThreadPool
threadpool
The 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 void
addChangeListener(IChangeListener listener)
Add a change listener.void
addTimer(ITimer timer)
Add a timer.protected void
computeNextTimepoint()
Compute the next timepoint.void
copyFromClock(IClock oldclock)
Transfer state from another clock to this clock.protected Executor
createExecutor()
Create new executor.void
dispose()
Called, when the clock is no longer used.double
getDilation()
Get the clocks dilation.long
getTime()
Get the clocks name.java.lang.String
getType()
Get the clock type.void
removeTimer(ITimer timer)
Remove a timer.void
reset()
Reset the clock.void
setDilation(double dilation)
Set the clocks dilation.void
start()
Start the clock.void
stop()
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:
copyFromClock
in classAbstractClock
-
dispose
public void dispose()
Called, when the clock is no longer used.- Specified by:
dispose
in interfaceIClock
- Overrides:
dispose
in classAbstractClock
-
getTime
public long getTime()
Get the clocks name.- Specified by:
getTime
in interfaceIClock
- Overrides:
getTime
in classAbstractClock
- Returns:
- The name.
-
getDilation
public double getDilation()
Get the clocks dilation.- Specified by:
getDilation
in interfaceIContinuousClock
- Returns:
- The clocks dilation.
-
setDilation
public void setDilation(double dilation)
Set the clocks dilation.- Specified by:
setDilation
in 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:
start
in interfaceIClock
- Overrides:
start
in classAbstractClock
-
stop
public void stop()
Stop the clock.- Specified by:
stop
in interfaceIClock
- Overrides:
stop
in classAbstractClock
-
reset
public void reset()
Reset the clock.- Specified by:
reset
in interfaceIClock
- Overrides:
reset
in classAbstractClock
-
computeNextTimepoint
protected void computeNextTimepoint()
Compute the next timepoint.
-
addTimer
public void addTimer(ITimer timer)
Add a timer.- Specified by:
addTimer
in interfaceIClock
- Overrides:
addTimer
in classAbstractClock
- Parameters:
timer
- The timer.
-
removeTimer
public void removeTimer(ITimer timer)
Remove a timer.- Specified by:
removeTimer
in interfaceIClock
- Overrides:
removeTimer
in classAbstractClock
- Parameters:
timer
- The timer.
-
addChangeListener
public void addChangeListener(IChangeListener listener)
Add a change listener.- Specified by:
addChangeListener
in interfaceIClock
- Overrides:
addChangeListener
in classAbstractClock
- Parameters:
listener
- The change listener.
-
createExecutor
protected Executor createExecutor()
Create new executor.
-
-