Package jadex.noplatform.services
Class ClockService
- java.lang.Object
- 
- jadex.noplatform.services.BaseService
- 
- jadex.noplatform.services.ClockService
 
 
- 
- All Implemented Interfaces:
- IInternalService,- IService,- IClockService
 
 public class ClockService extends BaseService implements IClockService 
- 
- 
Field SummaryFields Modifier and Type Field Description protected ClockCreationInfocinfoThe clock type.protected IClockclockThe clock.protected java.util.List<IChangeListener>listenersThe clock listeners.protected IThreadPoolthreadpoolThe threadpool.protected java.util.TimertimerThe realtime timer.- 
Fields inherited from class jadex.noplatform.services.BaseServicecid, sid
 - 
Fields inherited from interface jadex.bridge.service.types.clock.IClockServiceBISIMULATION_CLOCK_FLAG, SIMULATION_CLOCK_FLAG, TYPE
 - 
Fields inherited from interface jadex.bridge.service.IServiceEMPTY_SERVICES
 
- 
 - 
Constructor SummaryConstructors Constructor Description ClockService(IComponentIdentifier cid, ClockCreationInfo cinfo, IThreadPool threadpool)Create a new clock service.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(IChangeListener listener)Add a change listener.booleanadvanceEvent()Advance one event.protected static IClockcreateClock(ClockCreationInfo cinfo, IThreadPool tp)Create a clock based on creation info.java.util.TimerTaskcreateRealtimeTimer(long time, ITimedObject to)Create a new realtime timer.ITimercreateTickTimer(ITimedObject to)Create a new tick timer.ITimercreateTimer(long time, ITimedObject to)Create a new timer.java.lang.StringgetClockType()Get the clock type.longgetDelta()Get the clock delta.doublegetDilation()Get the clocks dilation.ITimergetNextTimer()Get the next timer.longgetStarttime()Get the clocks start time.java.lang.StringgetState()Get the clock state.doublegetTick()Get the current tick.longgetTime()Get the current time.ITimer[]getTimers()Get all active timers.voidremoveChangeListener(IChangeListener listener)Remove a change listener.voidsetClock(ClockCreationInfo cinfo, IThreadPool tp)Create and set a new clock.voidsetClock(java.lang.String type, IThreadPool tp)Change the clock.voidsetDelta(long delta)Set the clock delta.voidsetDilation(double dilation)Set the clocks dilation.voidsetTime(long time)Set the current time.IFuture<java.lang.Void>shutdownService()Shutdown the service.voidstart()Start the clock.IFuture<java.lang.Void>startService()Start the service.voidstop()Stop the clock.- 
Methods inherited from class jadex.noplatform.services.BaseServicegetComponentId, getMethodInfos, getPropertyMap, getServiceId, invokeMethod, isValid, setComponentAccess, setServiceIdentifier
 
- 
 
- 
- 
- 
Field Detail- 
clockprotected IClock clock The clock.
 - 
threadpoolprotected IThreadPool threadpool The threadpool.
 - 
listenersprotected java.util.List<IChangeListener> listeners The clock listeners.
 - 
cinfoprotected ClockCreationInfo cinfo The clock type.
 - 
timerprotected java.util.Timer timer The realtime timer.
 
- 
 - 
Constructor Detail- 
ClockServicepublic ClockService(IComponentIdentifier cid, ClockCreationInfo cinfo, IThreadPool threadpool) Create a new clock service.
 
- 
 - 
Method Detail- 
getTimepublic long getTime() Get the current time.- Specified by:
- getTimein interface- IClockService
- Returns:
- The current time.
 
 - 
setTimepublic void setTime(long time) Set the current time.- Parameters:
- time- The current time.
 
 - 
getTickpublic double getTick() Get the current tick.- Specified by:
- getTickin interface- IClockService
- Returns:
- The current tick.
 
 - 
getStarttimepublic long getStarttime() Get the clocks start time.- Specified by:
- getStarttimein interface- IClockService
- Returns:
- The start time.
 
 - 
getDeltapublic long getDelta() Get the clock delta.- Specified by:
- getDeltain interface- IClockService
- Returns:
- The clock delta.
 
 - 
setDeltapublic void setDelta(long delta) Set the clock delta. param delta The new clock delta.- Specified by:
- setDeltain interface- IClockService
- Parameters:
- delta- The new clock delta.
 
 - 
getStatepublic java.lang.String getState() Get the clock state.- Specified by:
- getStatein interface- IClockService
- Returns:
- The clock state.
 
 - 
getDilationpublic double getDilation() Get the clocks dilation.- Specified by:
- getDilationin interface- IClockService
- Returns:
- The clocks dilation. // Hack!!! only for continuous clock.
 
 - 
setDilationpublic void setDilation(double dilation) Set the clocks dilation.- Specified by:
- setDilationin interface- IClockService
- Parameters:
- dilation- The clocks dilation. // Hack. Remove? only for continuous
 
 - 
getClockTypepublic java.lang.String getClockType() Get the clock type.- Specified by:
- getClockTypein interface- IClockService
- Returns:
- The clock type.
 
 - 
createTimerpublic ITimer createTimer(long time, ITimedObject to) Create a new timer. The unit of the timespan value depends on the clock implementation. For system clocks, the time value should adhere to the time representation as used bySystem.currentTimeMillis().- Specified by:
- createTimerin interface- IClockService
- Parameters:
- timespan- The relative timespan after which the timed object should be notified.
- to- The timed object.
 
 - 
createTickTimerpublic ITimer createTickTimer(ITimedObject to) Create a new tick timer. todo: @param tickcount The number of ticks.- Specified by:
- createTickTimerin interface- IClockService
- Parameters:
- to- The timed object.
 
 - 
createRealtimeTimerpublic java.util.TimerTask createRealtimeTimer(long time, ITimedObject to)Create a new realtime timer.- Specified by:
- createRealtimeTimerin interface- IClockService
- Parameters:
- timespan- The relative timespan after which the timed object should be notified.
- to- The timed object.
 
 - 
getNextTimerpublic ITimer getNextTimer() Get the next timer.- Specified by:
- getNextTimerin interface- IClockService
- Returns:
- The next timer.
 
 - 
getTimerspublic ITimer[] getTimers() Get all active timers.- Specified by:
- getTimersin interface- IClockService
- Returns:
- The active timers.
 
 - 
addChangeListenerpublic void addChangeListener(IChangeListener listener) Add a change listener.- Specified by:
- addChangeListenerin interface- IClockService
- Parameters:
- listener- The change listener.
 
 - 
removeChangeListenerpublic void removeChangeListener(IChangeListener listener) Remove a change listener.- Specified by:
- removeChangeListenerin interface- IClockService
- Parameters:
- listener- The change listener.
 
 - 
advanceEventpublic boolean advanceEvent() Advance one event.- Specified by:
- advanceEventin interface- IClockService
- Returns:
- True, if clock could be advanced.
 
 - 
startpublic void start() Start the clock.- Specified by:
- startin interface- IClockService
 
 - 
stoppublic void stop() Stop the clock.- Specified by:
- stopin interface- IClockService
 
 - 
startServicepublic IFuture<java.lang.Void> startService() Start the service.- Specified by:
- startServicein interface- IInternalService
- Returns:
- A future that is done when the service has completed starting.
 
 - 
shutdownServicepublic IFuture<java.lang.Void> shutdownService() Shutdown the service.- Specified by:
- shutdownServicein interface- IInternalService
- Parameters:
- listener- The listener.
- Returns:
- A future that is done when the service has completed its shutdown.
 
 - 
setClockpublic void setClock(java.lang.String type, IThreadPool tp)Change the clock.- Specified by:
- setClockin interface- IClockService
- Parameters:
- type- The new clock type
 
 - 
setClockpublic void setClock(ClockCreationInfo cinfo, IThreadPool tp) Create and set a new clock.
 - 
createClockprotected static IClock createClock(ClockCreationInfo cinfo, IThreadPool tp) Create a clock based on creation info.
 
- 
 
-