Class TimeKeeper#

Inheritance Relationships#

Base Type#

Class Documentation#

class TimeKeeper : public Karana::Core::BaseWithVars#

Keeps track of time.

Public Types

using TimePoint = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>#

System-clock time point with microsecond storage.

Public Functions

TimeKeeper()#

TimeKeeper constructor. The constructor is not meant to be called directly. Please use the corresponding create(…) method instead to create an instance.

TimeKeeper(const TimeKeeper &other)#

Copy constructor.

Parameters:

other – The TimeKeeper instance to copy from.

const km::Ktime &getTime() const#

Get the time since the initial ephemeris from TimeKeeper.

This is the time from the initial ephemeris in ET time.

Returns:

The current time in seconds since the initial ephemeris.

double getTime(TimeType time_type) const#

Get the current time in the requested representation.

Parameters:

time_type – Requested output representation.

Returns:

The number of seconds or days since the J2000 epoch. Seconds for second-based types and days for Julian-date-like. types.

TimePoint getDateTime() const#

Get the current time as a UTC-like system clock time.

Returns:

The current time converted to a UTC-like system clock time.

inline double getEphemerisTime() const#

Get the current ephemeris time in ET.

This is equivalent to getTime(TimeType.ET), but does not use an enum, so is more performant. This is mainly for use by SpiceFrameToFrames.

Returns:

The number of seconds since the J2000 epoch in ET.

virtual void setTime(const km::Ktime &time)#

Set the TimeKeeper’s time.

Parameters:

time – The current time.

virtual bool isReady() const override#

Determine if the TimeKeeper is initialized.

Returns:

true if initialized, false otherwise.

void setInitialEphemeris(double initial_ephemeris, TimeType type)#

Set the initial ephemeris.

Parameters:
  • initial_ephemeris – The initial ephemeris. This is in seconds for second-based types, and days for JD and MJD.

  • type – Time representation of initial_ephemeris.

void setInitialEphemeris(const TimePoint &time_point)#

Set the initial ephemeris from a UTC-like time point.

Parameters:

time_point – The UTC time point to use as the initial ephemeris.

void setUT1Offset(double delta_ut1_seconds)#

Set \(\Delta UT1 = UT1 - UTC\).

Parameters:

delta_ut1_seconds – UT1 offset in seconds.

double getUT1Offset() const#

Get the configured \(\Delta UT1 = UT1 - UTC\).

Throws:

std::runtime_error – if the value is still uninitialized.

Returns:

UT1 offset in seconds.

void setRelativisticCorrection(bool enable)#

Enable or disable the periodic relativistic correction.

Parameters:

enable – If true, inputs/outputs include the periodic ET-to-TT correction; if false, ET and TT seconds are treated as equal.

bool getRelativisticCorrection() const#

Check whether the periodic relativistic correction is enabled.

Returns:

True when the relativistic correction is enabled; false otherwise.

void setLeapSecondsFile(const std::filesystem::path &leap_seconds_file)#

Set the leap seconds file.

Parameters:

leap_seconds_file – Filepath to the leap seconds file.

const std::filesystem::path &getLeapSecondsFile() const#

Get the loaded leap-second filepath.

Returns:

Configured path to the leap seconds file.

Public Static Functions

static kc::ks_ptr<TimeKeeper> create()#

Create a new instance of TimeKeeper.

Returns:

A pointer to the newly created instance of TimeKeeper.

Protected Functions

virtual Karana::Core::ks_ptr<Karana::Core::BaseVars> _getVars() const override#

Create the vars for this object.

Returns:

The vars for this object.

Protected Attributes

km::Ktime _time#

The current time.

double _ephemeris_time = km::notReadyNaN#

The ephemeris time.

double _initial_ephemeris = km::notReadyNaN#

Initial ephemeris.