Public Member Functions | Static Protected Member Functions | Protected Attributes

CxUtils::Time::Synchronizer Class Reference

A Time Synchronizer acts as either a timer server or a time client. More...

#include <time.h>

List of all members.

Public Member Functions

 Synchronizer ()
 Constructor.
virtual ~Synchronizer ()
 Destructor.
bool Start (const bool server, const unsigned short port, const IP4Address &multicastGroup, const unsigned int udelay=1)
 Creates a time synchronizer in either server mode or client.
void Stop ()
 Stops the synchronizer.

Static Protected Member Functions

static void ServerThread (void *args)
 Thread for sending or receiving synchronized time data.

Protected Attributes

void * mpThreadObject
 Thread data object.
SocketmpSocket
 Socket data.
unsigned int mDelayUs
 Delay in ms. Changes based on hardware capabilities.

Detailed Description

A Time Synchronizer acts as either a timer server or a time client.

If created in server mode, the Synchronizer will continuosly transmit at UTC time at high speed over the network to a multicast address so that clients on other computers can use that value is the system time for applications using this library (CxUtils).

If initialized in client mode, the client attempts to receive time data being transmitted by a Synchronizer server. If data is available, the Time methods in this fill will return the time values received by the server, synchronizing time between multiple computers.

Definition at line 191 of file time.h.


Constructor & Destructor Documentation

Time::Synchronizer::Synchronizer (  )

Constructor.

Definition at line 618 of file time.cpp.

Time::Synchronizer::~Synchronizer (  ) [virtual]

Destructor.

Definition at line 631 of file time.cpp.


Member Function Documentation

void Time::Synchronizer::ServerThread ( void *  args ) [static, protected]

Thread for sending or receiving synchronized time data.

Definition at line 727 of file time.cpp.

bool Time::Synchronizer::Start ( const bool  server,
const unsigned short  port,
const IP4Address multicastGroup,
const unsigned int  udelay = 1 
)

Creates a time synchronizer in either server mode or client.

Parameters:
[in]serverIf true, creates a thread which multicasts UTC time data. If false, thread tries to receive synchronized time being transmitted.
[in]portPort to use.
[in]multicastGroupMulticast group to use.
[in]udelayBy default, there is a minimum of a 1 micro-second delay (Linux only) between reading of system time to prevent over-use of CPU. However, on some systems you may want to turn this off if you don't care or they system is slow and cannot process quickly enough with a delay. To turn off, set to 0.
Returns:
True on success, false on failure.

Definition at line 667 of file time.cpp.

void Time::Synchronizer::Stop (  )

Stops the synchronizer.

Definition at line 710 of file time.cpp.


Member Data Documentation

unsigned int CxUtils::Time::Synchronizer::mDelayUs [protected]

Delay in ms. Changes based on hardware capabilities.

Definition at line 205 of file time.h.

Socket data.

Definition at line 204 of file time.h.

Thread data object.

Definition at line 203 of file time.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines