DAQ Driver
Time Class Reference

The Time class Is used to sync time between devices. More...

#include <Driver/DriverComponents/Time.h>

Inheritance diagram for Time:
Collaboration diagram for Time:

Public Member Functions

 Time (pMessageProcessor messageProcessor)
 
void sync ()
 sync Synchronizes time between devives through calculating clock difference in ms More...
 
void reset ()
 reset Resets m_timeDifference to 0 More...
 
int64_t timeDifference () const
 timeDifference Gets time difference between this pc and the Voyager in ms More...
 
void addTimeSyncedCallback (const std::function< void()> &newCallback)
 addTimeSyncedCallback Adds a callback that is called when the time is synced More...
 
- Public Member Functions inherited from AbstractDriverComponent
 AbstractDriverComponent (pMessageProcessor messageProcessor)
 

Protected Member Functions

uint64_t mSecSinceEpoch () const
 
void handleTimeRequest (const google::protobuf::Message &message)
 
void handleTimeResponse (const google::protobuf::Message &message)
 

Private Attributes

std::vector< std::function< void(void)> > m_timeSyncedCallbacks
 
std::mutex m_timeSyncedCallbacksMutex
 
std::atomic< int64_t > m_timeDifference
 

Additional Inherited Members

- Protected Attributes inherited from AbstractDriverComponent
pMessageProcessor m_messageProcessor
 

Detailed Description

The Time class Is used to sync time between devices.

Definition at line 19 of file Time.h.

Constructor & Destructor Documentation

◆ Time()

Time::Time ( pMessageProcessor  messageProcessor)

Definition at line 3 of file Time.cpp.

Member Function Documentation

◆ addTimeSyncedCallback()

void Time::addTimeSyncedCallback ( const std::function< void()> &  newCallback)

addTimeSyncedCallback Adds a callback that is called when the time is synced

Parameters
newCallbacknew callbback to call when the time is synced

Definition at line 63 of file Time.cpp.

◆ handleTimeRequest()

void Time::handleTimeRequest ( const google::protobuf::Message &  message)
protected

Definition at line 28 of file Time.cpp.

◆ handleTimeResponse()

void Time::handleTimeResponse ( const google::protobuf::Message &  message)
protected

Definition at line 39 of file Time.cpp.

◆ mSecSinceEpoch()

uint64_t Time::mSecSinceEpoch ( ) const
protected

Definition at line 23 of file Time.cpp.

◆ reset()

void Time::reset ( )
virtual

reset Resets m_timeDifference to 0

Implements AbstractDriverComponent.

Definition at line 18 of file Time.cpp.

◆ sync()

void Time::sync ( )

sync Synchronizes time between devives through calculating clock difference in ms

Definition at line 11 of file Time.cpp.

◆ timeDifference()

int64_t Time::timeDifference ( ) const

timeDifference Gets time difference between this pc and the Voyager in ms

Returns
time difference in ms

Definition at line 59 of file Time.cpp.

Member Data Documentation

◆ m_timeDifference

std::atomic<int64_t> Time::m_timeDifference
private

Definition at line 63 of file Time.h.

◆ m_timeSyncedCallbacks

std::vector<std::function<void(void)> > Time::m_timeSyncedCallbacks
private

Definition at line 61 of file Time.h.

◆ m_timeSyncedCallbacksMutex

std::mutex Time::m_timeSyncedCallbacksMutex
private

Definition at line 62 of file Time.h.