[Positioner] Timestamp: *current_time() use "replay"
Timestamp::get_current_time() now returns the current time if the replay mode is unactivated, or the most recent request's time in replay mode.
This commit is contained in:
parent
692571e382
commit
d44680751c
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "timestamp.hh"
|
#include "timestamp.hh"
|
||||||
|
#include "configuration.hh"
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
|
@ -92,6 +93,8 @@ inline void Timestamp::set(const uint64_t source_ms)
|
||||||
|
|
||||||
Timestamp Timestamp::get_current_time()
|
Timestamp Timestamp::get_current_time()
|
||||||
{
|
{
|
||||||
|
if (! Configuration::is_configured("replay"))
|
||||||
|
current_time.now() ;
|
||||||
return current_time ;
|
return current_time ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,12 +103,14 @@ Timestamp Timestamp::get_current_time()
|
||||||
* @source A pointer to the new time. If NULL, #current_time is updated
|
* @source A pointer to the new time. If NULL, #current_time is updated
|
||||||
* to the current time.
|
* to the current time.
|
||||||
*/
|
*/
|
||||||
void Timestamp::set_current_time(const Timestamp *const source)
|
void Timestamp::update_current_time(const Timestamp &source)
|
||||||
{
|
{
|
||||||
if (source)
|
// We should never call this function if we are in replay mode:
|
||||||
current_time = *source ;
|
assert(Configuration::is_configured("replay")) ;
|
||||||
else
|
|
||||||
current_time.now() ;
|
// According to human perception, time generally goes only forward:
|
||||||
|
if (current_time < source)
|
||||||
|
current_time = source ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public:
|
||||||
/// Returns a Timestamp containing the current time
|
/// Returns a Timestamp containing the current time
|
||||||
static Timestamp get_current_time(void) ;
|
static Timestamp get_current_time(void) ;
|
||||||
/// Sets #current_time to a new timestamp
|
/// Sets #current_time to a new timestamp
|
||||||
static void set_current_time(const Timestamp *const source = NULL) ;
|
static void update_current_time(const Timestamp &source) ;
|
||||||
/// \brief Initialises #timestamp at the current time whith a
|
/// \brief Initialises #timestamp at the current time whith a
|
||||||
/// nanosecond precision
|
/// nanosecond precision
|
||||||
bool now(void) ;
|
bool now(void) ;
|
||||||
|
|
Loading…
Reference in New Issue