Package jadex.platform.service.clock
Class AbstractClock
- java.lang.Object
- 
- jadex.platform.service.clock.AbstractClock
 
- 
- All Implemented Interfaces:
- IClock
 - Direct Known Subclasses:
- ContinuousClock,- SimulationEventClock,- SimulationTickClock
 
 public abstract class AbstractClock extends java.lang.Object implements IClock Abstract base class for all clocks.
- 
- 
Field SummaryFields Modifier and Type Field Description protected longcurrenttimeThe current time (last measurement).static longDEFAULT_DELTAThe default delta (tick time).protected longdeltaThe clock tick delta (relative to base time).protected java.util.ListlistenersThe change listeners.protected java.lang.StringnameThe clock name.protected longstarttimeThe start time (model time).protected java.lang.StringstateThe clock state.protected TimerticktimerThe tick timer.protected java.util.ListticktimersThe tick timers.java.util.SortedSettimersThe timers (entries ordered by timepoint).- 
Fields inherited from interface jadex.bridge.service.types.clock.IClockEVENT_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 SummaryConstructors Constructor Description AbstractClock(java.lang.String name, long starttime, long delta)Create a new clock.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidactivateTickTimer()Activate the tick timer.voidaddChangeListener(IChangeListener listener)Add a change listener.voidaddTickTimer(ITimer timer)Add a tick timer.voidaddTimer(ITimer timer)Add a timer.voidcopyFromClock(IClock oldclock)Transfer state from another clock to this clock.ITimercreateTickTimer(ITimedObject to)Create a new tick timer.ITimercreateTimer(long timespan, ITimedObject to)Create a new timer.voiddispose()Called, when the clock is no longer used.longgetDelta()Get the clock delta.java.lang.StringgetName()Get the current time.ITimergetNextTimer()Get the next timer.longgetStarttime()Get the clocks start time.java.lang.StringgetState()Get the clock state.doublegetTick()Get the current tick.ITimer[]getTickTimers()Get all active tick timers.longgetTime()Get the clocks name.ITimer[]getTimers()Get all active timers.protected booleanhasListeners()Check if the clock has listeners.protected voidnotifyListeners(ChangeEvent ce)Notify the listeners.voidremoveChangeListener(IChangeListener listener)Remove a change listener.voidremoveTickTimer(ITimer timer)Remove a tick timer.voidremoveTimer(ITimer timer)Remove a timer.voidreset()Reset the clock.voidsetDelta(long delta)Set the clock delta.voidsetStarttime(long starttime)Set the clocks start time.voidshutdown(IResultListener listener)Shutdown the service.voidstart()Start the clock.voidstop()Stop the clock.
 
- 
- 
- 
Field Detail- 
DEFAULT_DELTApublic static final long DEFAULT_DELTA The default delta (tick time).- See Also:
- Constant Field Values
 
 - 
nameprotected java.lang.String name The clock name.
 - 
starttimeprotected long starttime The start time (model time).
 - 
currenttimeprotected long currenttime The current time (last measurement).
 - 
deltaprotected long delta The clock tick delta (relative to base time).
 - 
stateprotected java.lang.String state The clock state.
 - 
ticktimersprotected java.util.List ticktimers The tick timers.
 - 
timerspublic java.util.SortedSet timers The timers (entries ordered by timepoint).
 - 
ticktimerprotected Timer ticktimer The tick timer.
 - 
listenersprotected java.util.List listeners The change listeners.
 
- 
 - 
Method Detail- 
copyFromClockpublic void copyFromClock(IClock oldclock) Transfer state from another clock to this clock.
 - 
disposepublic void dispose() Called, when the clock is no longer used.
 - 
getNamepublic java.lang.String getName() Get the current time.
 - 
getStarttimepublic long getStarttime() Get the clocks start time.- Specified by:
- getStarttimein interface- IClock
- Returns:
- The start time.
 
 - 
setStarttimepublic void setStarttime(long starttime) Set the clocks start time.- Specified by:
- setStarttimein interface- IClock
- Parameters:
- starttime- The start time.
 
 - 
getTimepublic long getTime() Get the clocks name.
 - 
getTickpublic double getTick() Get the current tick.
 - 
getDeltapublic long getDelta() Get the clock delta.
 - 
setDeltapublic void setDelta(long delta) Set the clock delta. param delta The new clock delta.
 - 
getNextTimerpublic ITimer getNextTimer() Get the next timer.- Specified by:
- getNextTimerin interface- IClock
- Returns:
- The next timer.
 
 - 
getStatepublic java.lang.String getState() Get the clock state.
 - 
createTimerpublic ITimer createTimer(long timespan, ITimedObject to) Create a new timer.- Specified by:
- createTimerin interface- IClock
- Parameters:
- timespan- The timespan.
- to- The timed object.
 
 - 
createTickTimerpublic ITimer createTickTimer(ITimedObject to) Create a new tick timer.- Specified by:
- createTickTimerin interface- IClock
- Parameters:
- to- The timed object.
- info- Optional info object.
 
 - 
getTimerspublic ITimer[] getTimers() Get all active timers.
 - 
getTickTimerspublic ITimer[] getTickTimers() Get all active tick timers.- Specified by:
- getTickTimersin interface- IClock
- Returns:
- The active tick timers.
 
 - 
addTimerpublic void addTimer(ITimer timer) Add a timer.
 - 
removeTimerpublic void removeTimer(ITimer timer) Remove a timer.- Specified by:
- removeTimerin interface- IClock
- Parameters:
- timer- The timer.
 
 - 
addTickTimerpublic void addTickTimer(ITimer timer) Add a tick timer.- Specified by:
- addTickTimerin interface- IClock
- Parameters:
- timer- The timer.
 
 - 
activateTickTimerprotected void activateTickTimer() Activate the tick timer.
 - 
removeTickTimerpublic void removeTickTimer(ITimer timer) Remove a tick timer.- Specified by:
- removeTickTimerin interface- IClock
- Parameters:
- timer- The timer.
 
 - 
addChangeListenerpublic void addChangeListener(IChangeListener listener) Add a change listener.- Specified by:
- addChangeListenerin interface- IClock
- Parameters:
- listener- The change listener.
 
 - 
removeChangeListenerpublic void removeChangeListener(IChangeListener listener) Remove a change listener.- Specified by:
- removeChangeListenerin interface- IClock
- Parameters:
- listener- The change listener.
 
 - 
notifyListenersprotected void notifyListeners(ChangeEvent ce) Notify the listeners.
 - 
hasListenersprotected boolean hasListeners() Check if the clock has listeners.
 - 
shutdownpublic void shutdown(IResultListener listener) Shutdown the service.- Parameters:
- listener- The listener.
 
 
- 
 
-