public class ClockService
extends jadex.bridge.service.BasicService
implements jadex.bridge.service.types.clock.IClockService, jadex.commons.IPropertiesProvider
Modifier and Type | Field and Description |
---|---|
protected ClockCreationInfo |
cinfo
The clock type.
|
protected jadex.bridge.service.types.clock.IClock |
clock
The clock.
|
protected jadex.bridge.IInternalAccess |
component
The component.
|
protected java.util.List |
listeners
The clock listeners.
|
protected java.lang.Boolean |
simulation
Was simulation set via argument?
|
protected jadex.bridge.service.types.threadpool.IThreadPoolService |
threadpool
The threadpool.
|
protected java.util.Timer |
timer
The realtime timer.
|
Constructor and Description |
---|
ClockService(ClockCreationInfo cinfo,
jadex.bridge.IInternalAccess component,
java.lang.Boolean simulation)
Create a new clock service.
|
ClockService(ClockCreationInfo cinfo,
jadex.bridge.IInternalAccess component,
java.util.Map properties,
java.lang.Boolean simulation)
Create a new clock service.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(jadex.commons.IChangeListener listener)
Add a change listener.
|
boolean |
advanceEvent()
Advance one event.
|
static jadex.bridge.service.types.clock.IClock |
createClock(ClockCreationInfo cinfo,
jadex.commons.concurrent.IThreadPool tp)
Create a clock.
|
java.util.TimerTask |
createRealtimeTimer(long time,
jadex.bridge.service.types.clock.ITimedObject to)
Create a new realtime timer.
|
jadex.bridge.service.types.clock.ITimer |
createTickTimer(jadex.bridge.service.types.clock.ITimedObject to)
Create a new tick timer.
|
jadex.bridge.service.types.clock.ITimer |
createTimer(long time,
jadex.bridge.service.types.clock.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.
|
jadex.bridge.service.types.clock.ITimer |
getNextTimer()
Get the next timer.
|
jadex.commons.future.IFuture<jadex.commons.Properties> |
getProperties()
Write current state into properties.
|
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.
|
jadex.bridge.service.types.clock.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.
|
jadex.commons.future.IFuture<java.lang.Void> |
setProperties(jadex.commons.Properties props)
Update from given properties.
|
void |
setTime(long time)
Set the current time.
|
jadex.commons.future.IFuture<java.lang.Void> |
shutdownService()
Shutdown the service.
|
void |
start()
Start the clock.
|
jadex.commons.future.IFuture<java.lang.Void> |
startService()
Start the service.
|
void |
stop()
Stop the clock.
|
createServiceIdentifier, createServiceIdentifier, equals, generateServiceName, getInterfaceType, getInternalAccess, getMethodTimeout, getPropertyMap, getProviderId, getServiceIdentifier, hashCode, initNFProperties, isValid, setComponentAccess, setPropertyMap, toString
protected jadex.bridge.service.types.clock.IClock clock
protected jadex.bridge.service.types.threadpool.IThreadPoolService threadpool
protected java.util.List listeners
protected jadex.bridge.IInternalAccess component
protected ClockCreationInfo cinfo
protected java.lang.Boolean simulation
protected java.util.Timer timer
public ClockService(ClockCreationInfo cinfo, jadex.bridge.IInternalAccess component, java.lang.Boolean simulation)
public ClockService(ClockCreationInfo cinfo, jadex.bridge.IInternalAccess component, java.util.Map properties, java.lang.Boolean simulation)
public long getTime()
getTime
in interface jadex.bridge.service.types.clock.IClockService
public void setTime(long time)
time
- The current time.public double getTick()
getTick
in interface jadex.bridge.service.types.clock.IClockService
public long getStarttime()
getStarttime
in interface jadex.bridge.service.types.clock.IClockService
public long getDelta()
getDelta
in interface jadex.bridge.service.types.clock.IClockService
public void setDelta(long delta)
setDelta
in interface jadex.bridge.service.types.clock.IClockService
public java.lang.String getState()
getState
in interface jadex.bridge.service.types.clock.IClockService
public double getDilation()
getDilation
in interface jadex.bridge.service.types.clock.IClockService
public void setDilation(double dilation)
setDilation
in interface jadex.bridge.service.types.clock.IClockService
dilation
- The clocks dilation.
// Hack. Remove? only for continuouspublic java.lang.String getClockType()
getClockType
in interface jadex.bridge.service.types.clock.IClockService
public jadex.bridge.service.types.clock.ITimer createTimer(long time, jadex.bridge.service.types.clock.ITimedObject to)
System.currentTimeMillis()
.createTimer
in interface jadex.bridge.service.types.clock.IClockService
timespan
- The relative timespan after which the timed object should be notified.to
- The timed object.public jadex.bridge.service.types.clock.ITimer createTickTimer(jadex.bridge.service.types.clock.ITimedObject to)
createTickTimer
in interface jadex.bridge.service.types.clock.IClockService
to
- The timed object.public java.util.TimerTask createRealtimeTimer(long time, jadex.bridge.service.types.clock.ITimedObject to)
createRealtimeTimer
in interface jadex.bridge.service.types.clock.IClockService
timespan
- The relative timespan after which the timed object should be notified.to
- The timed object.public jadex.bridge.service.types.clock.ITimer getNextTimer()
getNextTimer
in interface jadex.bridge.service.types.clock.IClockService
public jadex.bridge.service.types.clock.ITimer[] getTimers()
getTimers
in interface jadex.bridge.service.types.clock.IClockService
public void addChangeListener(jadex.commons.IChangeListener listener)
addChangeListener
in interface jadex.bridge.service.types.clock.IClockService
listener
- The change listener.public void removeChangeListener(jadex.commons.IChangeListener listener)
removeChangeListener
in interface jadex.bridge.service.types.clock.IClockService
listener
- The change listener.public boolean advanceEvent()
advanceEvent
in interface jadex.bridge.service.types.clock.IClockService
public void start()
start
in interface jadex.bridge.service.types.clock.IClockService
public void stop()
stop
in interface jadex.bridge.service.types.clock.IClockService
public jadex.commons.future.IFuture<java.lang.Void> startService()
startService
in interface jadex.bridge.service.IInternalService
startService
in class jadex.bridge.service.BasicService
public jadex.commons.future.IFuture<java.lang.Void> shutdownService()
shutdownService
in interface jadex.bridge.service.IInternalService
shutdownService
in class jadex.bridge.service.BasicService
listener
- The listener.public void setClock(java.lang.String type, jadex.commons.concurrent.IThreadPool tp)
setClock
in interface jadex.bridge.service.types.clock.IClockService
clock
- The new clock.public static jadex.bridge.service.types.clock.IClock createClock(ClockCreationInfo cinfo, jadex.commons.concurrent.IThreadPool tp)
public jadex.commons.future.IFuture<java.lang.Void> setProperties(jadex.commons.Properties props)
setProperties
in interface jadex.commons.IPropertiesProvider
public jadex.commons.future.IFuture<jadex.commons.Properties> getProperties()
getProperties
in interface jadex.commons.IPropertiesProvider