Package jadex.base.test.impl
Class SharedClockService
- java.lang.Object
-
- jadex.bridge.service.BasicService
-
- jadex.base.test.impl.SharedService<IClockService>
-
- jadex.base.test.impl.SharedClockService
-
- All Implemented Interfaces:
IInternalService
,IService
,IClockService
public class SharedClockService extends SharedService<IClockService> implements IClockService
Helper class to allow sharing a clock service across platforms in same VM.
-
-
Field Summary
-
Fields inherited from class jadex.base.test.impl.SharedService
factory
-
Fields inherited from class jadex.bridge.service.BasicService
DEFAULT_SYSTEM_SECURITY, idcnt, impltype, internalaccess, providerid, shutdowned, sid, started, type
-
Fields inherited from interface jadex.bridge.service.types.clock.IClockService
SIMULATION_CLOCK_FLAG, TYPE
-
Fields inherited from interface jadex.bridge.service.IService
EMPTY_SERVICES
-
-
Constructor Summary
Constructors Constructor Description SharedClockService(IComponentIdentifier provider, SharedServiceFactory<IClockService> factory)
Get the instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(jadex.commons.IChangeListener listener)
Add a change listener.boolean
advanceEvent()
Advance one event.java.util.TimerTask
createRealtimeTimer(long time, ITimedObject to)
Create a new realtime timer.ITimer
createTickTimer(ITimedObject to)
Create a new tick timer.ITimer
createTimer(long time, ITimedObject to)
Create a new timer.java.lang.String
getClockType()
Get the clock type.long
getDelta()
Get the clock delta.double
getDilation()
Get the clocks dilation.ITimer
getNextTimer()
Get the next timer.long
getStarttime()
Get the clocks start time.java.lang.String
getState()
Get the clock state.double
getTick()
Get the current tick.long
getTime()
Get the current time.ITimer[]
getTimers()
Get all active timers.void
removeChangeListener(jadex.commons.IChangeListener listener)
Remove a change listener.void
setClock(java.lang.String type, jadex.commons.concurrent.IThreadPool tp)
Set the clock.void
setDelta(long delta)
Set the clock delta.void
setDilation(double dilation)
Set the clocks dilation.void
start()
Start the clock.void
stop()
Stop the clock.-
Methods inherited from class jadex.base.test.impl.SharedService
getInstance, shutdownService, startService
-
Methods inherited from class jadex.bridge.service.BasicService
createServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getInvokeMethod, getMethodInfos, getMethodTimeout, getPropertyMap, getProviderId, getSecurityLevel, getServiceId, hashCode, initNFProperties, invokeMethod, isUnrestricted, isValid, setComponentAccess, setPropertyMap, setServiceIdentifier, toString
-
-
-
-
Constructor Detail
-
SharedClockService
public SharedClockService(IComponentIdentifier provider, SharedServiceFactory<IClockService> factory)
Get the instance.
-
-
Method Detail
-
getTime
public long getTime()
Description copied from interface:IClockService
Get the current time.- Specified by:
getTime
in interfaceIClockService
- Returns:
- The current time.
-
getTick
public double getTick()
Description copied from interface:IClockService
Get the current tick.- Specified by:
getTick
in interfaceIClockService
- Returns:
- The current tick.
-
getStarttime
public long getStarttime()
Description copied from interface:IClockService
Get the clocks start time.- Specified by:
getStarttime
in interfaceIClockService
- Returns:
- The start time.
-
getDelta
public long getDelta()
Description copied from interface:IClockService
Get the clock delta.- Specified by:
getDelta
in interfaceIClockService
- Returns:
- The clock delta.
-
getState
public java.lang.String getState()
Description copied from interface:IClockService
Get the clock state.- Specified by:
getState
in interfaceIClockService
- Returns:
- The clock state.
-
setDelta
public void setDelta(long delta)
Description copied from interface:IClockService
Set the clock delta.- Specified by:
setDelta
in interfaceIClockService
- Parameters:
delta
- The new clock delta.
-
getDilation
public double getDilation()
Description copied from interface:IClockService
Get the clocks dilation.- Specified by:
getDilation
in interfaceIClockService
- Returns:
- The clocks dilation. // Hack. Remove? only for continuous
-
setDilation
public void setDilation(double dilation)
Description copied from interface:IClockService
Set the clocks dilation.- Specified by:
setDilation
in interfaceIClockService
- Parameters:
dilation
- The clocks dilation. // Hack. Remove? only for continuous
-
start
public void start()
Description copied from interface:IClockService
Start the clock.- Specified by:
start
in interfaceIClockService
-
stop
public void stop()
Description copied from interface:IClockService
Stop the clock.- Specified by:
stop
in interfaceIClockService
-
createTimer
public ITimer createTimer(long time, ITimedObject to)
Description copied from interface:IClockService
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:
createTimer
in interfaceIClockService
to
- The timed object.
-
createTickTimer
public ITimer createTickTimer(ITimedObject to)
Description copied from interface:IClockService
Create a new tick timer. todo: @param tickcount The number of ticks.- Specified by:
createTickTimer
in interfaceIClockService
- Parameters:
to
- The timed object.
-
createRealtimeTimer
public java.util.TimerTask createRealtimeTimer(long time, ITimedObject to)
Description copied from interface:IClockService
Create a new realtime timer.- Specified by:
createRealtimeTimer
in interfaceIClockService
to
- The timed object.
-
getNextTimer
public ITimer getNextTimer()
Description copied from interface:IClockService
Get the next timer.- Specified by:
getNextTimer
in interfaceIClockService
- Returns:
- The next timer.
-
getTimers
public ITimer[] getTimers()
Description copied from interface:IClockService
Get all active timers.- Specified by:
getTimers
in interfaceIClockService
- Returns:
- The active timers.
-
addChangeListener
public void addChangeListener(jadex.commons.IChangeListener listener)
Description copied from interface:IClockService
Add a change listener.- Specified by:
addChangeListener
in interfaceIClockService
- Parameters:
listener
- The change listener.
-
removeChangeListener
public void removeChangeListener(jadex.commons.IChangeListener listener)
Description copied from interface:IClockService
Remove a change listener.- Specified by:
removeChangeListener
in interfaceIClockService
- Parameters:
listener
- The change listener.
-
getClockType
public java.lang.String getClockType()
Description copied from interface:IClockService
Get the clock type.- Specified by:
getClockType
in interfaceIClockService
- Returns:
- The clock type.
-
advanceEvent
public boolean advanceEvent()
Description copied from interface:IClockService
Advance one event.- Specified by:
advanceEvent
in interfaceIClockService
- Returns:
- True, if clock could be advanced.
-
setClock
public void setClock(java.lang.String type, jadex.commons.concurrent.IThreadPool tp)
Description copied from interface:IClockService
Set the clock.- Specified by:
setClock
in interfaceIClockService
-
-