![]() |
VR-Link API Documentation for HLA 4
|
Used to set and maintain time in a simulation. More...
Collaboration diagram for DtClock:Public Types | |
| typedef std::function< DtTime()> | DtSetTimeForTimestampsCallback |
| Callback prototype invoked during setSimTime() to supply the time value to be used for timestamps (myRealTimeAtSimTime). More... | |
Public Member Functions | |
| DtClock () | |
| constructor calls init() More... | |
| DtClock (const DtClock &orig) | |
| copy constructor More... | |
| DtClock & | operator= (const DtClock &orig) |
| assignment operator More... | |
| virtual | ~DtClock () |
| destructor More... | |
| virtual void | init () |
| Initialize all VR-Link time object functionality. More... | |
| virtual DtTime | simTime () const |
| Get the current value of VR-Link's simulation time. More... | |
| virtual void | setSimTime (DtTime NewSimTime) |
| Set the current value of VR-Link simulation time. More... | |
| virtual bool | isSimTimeSet () const |
| Returns false if DtSetSimTime was never called and prints out warning message. More... | |
| virtual DtTime | elapsedRealTime () const |
| Return real seconds elapsed since DtTimeInit was called. More... | |
| virtual DtTime | approximateElapsedRealTime () const |
| Returns the value of getElapsedRealTime at the time that setSimTime was last invoked. More... | |
| virtual bool | useSimTimeForApproxRealTime () const |
| Check whether myUseSimTimeForApproxRealTime is set. More... | |
| virtual void | setUseSimTimeForApproxRealTime () |
| Set/Clear whether simTime should be used to approximate the real time for the method approximateElapsedRealTime(). More... | |
| virtual void | clearUseSimTimeForApproxRealTime () |
| virtual DtTime | absRealTime () const |
| Return current wall-clock time - seconds since Jan 1, 1970. More... | |
| virtual DtTime | realTimeAtLastSimTimeSet () const |
| Return the real time at the point that setSimTime was last invoked. More... | |
| virtual DtTime | initialTime () const |
| Return the initial time that was saved at DtTimeInit. More... | |
| void | setTimeForTimestampsCallback (DtSetTimeForTimestampsCallback callback) |
| Register a callback to be invoked during setSimTime() to obtain the value stored in myRealTimeAtSimTime. More... | |
Static Public Attributes | |
| static const double | hour2sec |
| Clock constants used for time conversions. More... | |
| static const double | sec2hour |
Protected Attributes | |
| DtTime | myInitialTime |
| Save starting time to subtract from current to get elapsed. More... | |
| DtTime | mySimTime |
| This is the internal vr-link simulation clock. More... | |
| DtTime | myApproxElapsedRealTime |
| This is the Elapsed Real Time at the point that SetSimTime() is called. More... | |
| DtTime | myRealTimeAtSimTime |
| This is the real time at the point that SetSimTime() is called. More... | |
| bool | mySimTimeSet |
| bool | myUseSimTimeForApproxRealTime |
| Flag to change meaning of approximate real time. More... | |
| bool | myInitializedTime |
| True after init() has been called. Guards absRealTime() before init runs. More... | |
| std::chrono::steady_clock::time_point | myInitialSteadyTime |
| Monotonic anchor captured at init(), paired with myInitialTime. More... | |
| DtSetTimeForTimestampsCallback | myRealTimeAtSimTimeSetCallback |
| Optional callback that supplies the value for myRealTimeAtSimTime during setSimTime(). More... | |
Used to set and maintain time in a simulation.
| typedef std::function<DtTime()> DtClock::DtSetTimeForTimestampsCallback |
Callback prototype invoked during setSimTime() to supply the time value to be used for timestamps (myRealTimeAtSimTime).
When registered, this callback is called instead of absRealTime(). Return value should always be DtTime in the form of seconds since the epoch.
| DtClock::DtClock | ( | ) |
constructor calls init()
| DtClock::DtClock | ( | const DtClock & | orig | ) |
copy constructor
|
virtual |
destructor
|
virtual |
Return current wall-clock time - seconds since Jan 1, 1970.
|
virtual |
Returns the value of getElapsedRealTime at the time that setSimTime was last invoked.
|
virtual |
|
virtual |
Return real seconds elapsed since DtTimeInit was called.
|
virtual |
Initialize all VR-Link time object functionality.
This must be called before any other time-related functions.
|
inlinevirtual |
Return the initial time that was saved at DtTimeInit.
|
virtual |
Returns false if DtSetSimTime was never called and prints out warning message.
|
inlinevirtual |
Return the real time at the point that setSimTime was last invoked.
|
virtual |
Set the current value of VR-Link simulation time.
Should be called once per simulation frame to let VR-Link know the value of simulation time for the frame. Also sets myRealTimeAtSimTime to the value of absRealTime() for timestamping in Relative Timestamp mode.
| void DtClock::setTimeForTimestampsCallback | ( | DtSetTimeForTimestampsCallback | callback | ) |
Register a callback to be invoked during setSimTime() to obtain the value stored in myRealTimeAtSimTime.
When set, the callback replaces the default absRealTime() call. Pass an empty DtSetTimeForTimestampsCallback (or nullptr) to restore the default behaviour.
|
virtual |
Set/Clear whether simTime should be used to approximate the real time for the method approximateElapsedRealTime().
|
virtual |
Get the current value of VR-Link's simulation time.
|
virtual |
Check whether myUseSimTimeForApproxRealTime is set.
|
static |
Clock constants used for time conversions.
|
protected |
This is the Elapsed Real Time at the point that SetSimTime() is called.
It is good enough for timeouts, and is a LOT cheaper than getting the exact real time, which is overkill.
|
protected |
True after init() has been called. Guards absRealTime() before init runs.
|
protected |
Monotonic anchor captured at init(), paired with myInitialTime.
Used by absRealTime() to compute elapsed ticks without wall-clock drift.
|
protected |
Save starting time to subtract from current to get elapsed.
|
protected |
This is the real time at the point that SetSimTime() is called.
It is used to set the time for timestamping in Relative Timestamp mode.
|
protected |
Optional callback that supplies the value for myRealTimeAtSimTime during setSimTime().
When empty, absRealTime() is used instead.
|
protected |
This is the internal vr-link simulation clock.
|
protected |
|
protected |
Flag to change meaning of approximate real time.
|
static |