org.ros.time
Class NtpTimeProvider

java.lang.Object
  extended by org.ros.time.NtpTimeProvider
All Implemented Interfaces:
TimeProvider

public class NtpTimeProvider
extends java.lang.Object
implements TimeProvider

Provides NTP synchronized wallclock (actual) time.


Constructor Summary
NtpTimeProvider(java.net.InetAddress host, java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
           
 
Method Summary
 Time getCurrentTime()
           
 void startPeriodicUpdates(long period, java.util.concurrent.TimeUnit unit)
          Starts periodically updating the current time offset periodically.
 void stopPeriodicUpdates()
          Stops periodically updating the current time offset.
 void updateTime()
          Update the current time offset from the configured NTP host.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NtpTimeProvider

public NtpTimeProvider(java.net.InetAddress host,
                       java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
Parameters:
host - the NTP host to use
Method Detail

updateTime

public void updateTime()
                throws java.io.IOException
Update the current time offset from the configured NTP host.

Throws:
java.io.IOException

startPeriodicUpdates

public void startPeriodicUpdates(long period,
                                 java.util.concurrent.TimeUnit unit)
Starts periodically updating the current time offset periodically.

The first time update happens immediately.

Note that errors thrown while periodically updating time will be logged but not rethrown.

Parameters:
period - time between updates
unit - unit of period

stopPeriodicUpdates

public void stopPeriodicUpdates()
Stops periodically updating the current time offset.


getCurrentTime

public Time getCurrentTime()
Specified by:
getCurrentTime in interface TimeProvider
Returns:
the current time of the system using rostime