io.sarl.sre.janus.services.time
Interface TimeService
All Superinterfaces:
org.arakhne.afc.services.IService
All Known Implementing Classes:
AbstractTimeService, JreTimeService
interface TimeService
implements org.arakhne.afc.services.IService
This class enables to have access to the time manager of the platform.
Maven Group Identifier:
io.sarl.sre.janus
Maven Artifact Identifier:
janus.kernel
Since:
0.6.0
Property Summary
Modifier and type Property and description
long oSCurrentTime
Replies the OS current time.
double oSTimeFactor
Replies the scaling factor between the agent time and the operating system time.
java.util.concurrent.TimeUnit timePrecision
Replies the precision of the time that is assumed by this manager.
Action Summary
Modifier and type Action and description
abstract void addTimeListener(TimeListener)
Add listener on time changes.
abstract boolean evolveTimeIfPossible([double])
Do a time evolution if the underlying service allows this action.
abstract double fromOSDuration(double)
Convert the given duration from the operating system time scale to the agent system time scale.
abstract double fromOSTime(double)
Convert the given time from the operating system time scale to the agent system time scale.
abstract long getOSCurrentTime
Replies the OS current time.
abstract double getOSTimeFactor
Replies the scaling factor between the agent time and the operating system time.
abstract double getTime(TimeUnit)
Replies the current time.
abstract java.util.concurrent.TimeUnit getTimePrecision
Replies the precision of the time that is assumed by this manager.
abstract void removeTimeListener(TimeListener)
Remove listener on time changes.
abstract boolean setTimeIfPossible(double)
Change the time.
abstract double toOSDuration(double)
Convert the given duration from the agent system time scale to the operating system time scale.
abstract double toOSTime(double)
Convert the given time from the agent system time scale to the operating system time scale.
Property Details
oSCurrentTime
val oSCurrentTime : long
Replies the OS current time.

This property is an alias for the action: getOSCurrentTime

Returns:
the OS current time in ms.
oSTimeFactor
val oSTimeFactor : double
Replies the scaling factor between the agent time and the operating system time.

Consider time in the agent application. It may evolves at a different rate than the operating system time. The value that is replied by this function permits to determine the proportionally between the agent application time and the operating system time. A typical equation for representing this relation is: os time = OSTimeFactor * agent time.

This property is an alias for the action: getOSTimeFactor

Returns:
the factor between agent time and operating system time.
timePrecision
val timePrecision : java.util.concurrent.TimeUnit
Replies the precision of the time that is assumed by this manager.

Any duration that is below the time precision is ignored.

This property is an alias for the action: getTimePrecision

Returns:
the time precision, never null .
Action Details
addTimeListener(TimeListener)
def addTimeListener(TimeListener)
Add listener on time changes.
Parameters:
listener - the listener.
evolveTimeIfPossible([double])
def evolveTimeIfPossible([double]) : boolean
Do a time evolution if the underlying service allows this action.
Parameters:
timeDelta - is the amount of time to consider for the evolution. If it is negative or zero, a default amount will be selected by the time service.
Returns:
true if time has evolved. Otherwise false .
fromOSDuration(double)
def fromOSDuration(double) : double
Convert the given duration from the operating system time scale to the agent system time scale. This function uses getOSTimeFactor() for converting the duration.
Parameters:
timeDuration - the duration for the operating system.
Returns:
the duration for the agent system.
Since:
0.9
fromOSTime(double)
def fromOSTime(double) : double
Convert the given time from the operating system time scale to the agent system time scale. This function uses getOSTimeFactor() for converting the duration.
Parameters:
timeValue - the time for the operating system.
Returns:
the time for the agent system.
Since:
0.9
getOSCurrentTime
def getOSCurrentTime : long
Replies the OS current time.
Returns:
the OS current time in ms.
getOSTimeFactor
def getOSTimeFactor : double
Replies the scaling factor between the agent time and the operating system time.

Consider time in the agent application. It may evolves at a different rate than the operating system time. The value that is replied by this function permits to determine the proportionally between the agent application time and the operating system time. A typical equation for representing this relation is: os time = OSTimeFactor * agent time.
Returns:
the factor between agent time and operating system time.
getTime(TimeUnit)
def getTime(TimeUnit) : double
Replies the current time.
Parameters:
timeUnit - if present, specifies the time unit of the value to reply. By default is it seconds.
Returns:
the current time.
getTimePrecision
def getTimePrecision : java.util.concurrent.TimeUnit
Replies the precision of the time that is assumed by this manager.

Any duration that is below the time precision is ignored.
Returns:
the time precision, never null .
removeTimeListener(TimeListener)
def removeTimeListener(TimeListener)
Remove listener on time changes.
Parameters:
listener - the listener.
setTimeIfPossible(double)
def setTimeIfPossible(double) : boolean
Change the time.
Parameters:
time - the new time.
Returns:
true if time has evolved. Otherwise false .
toOSDuration(double)
def toOSDuration(double) : double
Convert the given duration from the agent system time scale to the operating system time scale. This function uses getOSTimeFactor() for converting the duration.
Parameters:
timeDuration - the duration for the agent system.
Returns:
the duration for the operating system.
Since:
0.9
toOSTime(double)
def toOSTime(double) : double
Convert the given time from the agent system time scale to the operating system time scale. This function uses getOSTimeFactor() for converting the time.
Parameters:
timeValue - the time for the agent system.
Returns:
the time for the operating system.
Since:
0.9