23std::chrono::steady_clock::time_point currentTimeComputer;
45 auto elapsed = std::chrono::steady_clock::now() - currentTimeComputer;
46 return currentTime + elapsed;
52 insTime < currentExactTime)
54 LOG_DATA(
"Not updating current Time [{} {:.6f}] to [{} {:.6f}], because the new time is earlier.",
55 currentExactTime.toGPSweekTow().gpsWeek, currentExactTime.toGPSweekTow().tow,
58 else if (insTime >= currentExactTime)
62 LOG_INFO(
"Updating current Time [{}] to [{} ]", currentExactTime, insTime);
64 currentTimeComputer = std::chrono::steady_clock::now();
65 currentTime = insTime;
66 LOG_DATA(
"Updating current Time [{}] to [{} ]", currentExactTime, insTime);
72 std::time_t t = std::time(
nullptr);
73 std::tm* now = std::gmtime(&t);
75 currentTimeComputer = std::chrono::steady_clock::now();
76 currentTime =
InsTime{
static_cast<uint16_t
>(now->tm_year + 1900),
static_cast<uint16_t
>(now->tm_mon) + 1,
static_cast<uint16_t
>(now->tm_mday),
77 static_cast<uint16_t
>(now->tm_hour),
static_cast<uint16_t
>(now->tm_min),
static_cast<long double>(now->tm_sec),
UTC };
Utility class for logging to console and file.
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
#define LOG_INFO
Info to the user on the state of the program.
Keeps track of the current real/simulation time.
The class is responsible for all time-related tasks.
constexpr InsTime_GPSweekTow toGPSweekTow(TimeSystem timesys=GPST) const
Converts this time object into a different format.
void reset()
Resets the InsTime object.
Mode
Different Modes the Time Base class can work in.
@ POST_PROCESSING
Time will be set by FlowExecutor only.
@ REAL_TIME
Computer clock will be added to last time update.
void ClearCurrentTime()
Clears the current time object.
void SetCurrentTime(const InsTime &insTime)
Set the current time object.
void SetMode(Mode mode)
Set the time mode.
InsTime GetCurrentInsTime()
Get the current time.
void SetCurrentTimeToComputerTime()
Set the current time object to the computer time.
Mode GetMode()
Get the time mode.
@ UTC
Coordinated Universal Time.
int32_t gpsWeek
Contains GPS week in GPS standard time [GPST].
long double tow
Contains GPS time of week in seconds in GPS standard time [GPST].