Module: simSynch

The clock synchronization module is used to slave the simulation to realtime. The module is controlled by specifying an acceleration factor which can be adjusted dynamically if the timeInitialized factor is also reset dynamically.


class ClockSynch : public SysModel
#include <simSynch.h>

clock sync model class

Public Functions

ClockSynch()

This is the constructor for the clock synch model. It sets default variable values and initializes the various parts of the model

~ClockSynch()

Destructor. Nothing here.

void Reset(uint64_t currentSimNanos)

Reset the module variables.

Parameters:

currentSimNanos

Returns:

void

void UpdateState(uint64_t currentSimNanos)

This method performs all of the runtime behavior for the clock synch model. It initializes the timers present in the model on the first pass and then ensures that the model stays stuck on the synchronization pulse. Note that we do the init on the first pass instead of the init routines so that we don’t have a big lag between initialization and runtime which messes up our clocking.

Parameters:

currentSimNanos – The clock time associated with the model call

Returns:

void

Public Members

double accelFactor

[-] Factor used to accelerate sim-time relative to clock

SynchClockMsgPayload outputData

[-] Output data for the synch module

Message<SynchClockMsgPayload> clockOutMsg

[-] output message

int64_t accuracyNanos

ns Level of accuracy that we want out of the timer, default is 10ms

bool displayTime

[-] Flag indicating that we want to display the time elapsed in cmd line, default is off

BSKLogger bskLogger

&#8212; BSK Logging

Private Members

bool timeInitialized

[-] Flag that the module has been reset

std::chrono::high_resolution_clock::time_point startTime
uint64_t startSimTimeNano

[-] first time stamp of pass through data

[ns] Previous simulation time observed