Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SoftwarePLL Class Reference

class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github.com/michael1309/SoftwarePLL/blob/master/README.md for details. More...

#include <softwarePLL.h>

Public Member Functions

double AllowedTimeDeviation () const
 
void AllowedTimeDeviation (double val)
 
double extraPolateRelativeTimeStamp (uint32_t tick)
 
uint32_t ExtrapolationDivergenceCounter () const
 
void ExtrapolationDivergenceCounter (uint32_t val)
 
int findDiffInFifo (double diff, double tol)
 
uint64_t FirstTick () const
 
void FirstTick (uint64_t val)
 
double FirstTimeStamp () const
 
void FirstTimeStamp (double val)
 
bool getCorrectedTimeStamp (uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
 
bool GetCorrectedTimeStamp (uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
 Computes the timestamp of a measurement from sensor ticks. More...
 
bool getDemoFileData (std::string fileName, std::vector< uint32_t > &tickVec, std::vector< uint32_t > &secVec, std::vector< uint32_t > &nanoSecVec)
 
double InterpolationSlope () const
 
void InterpolationSlope (double val)
 
bool IsInitialized () const
 
void IsInitialized (bool val)
 
bool IsInitialized () const
 Returns the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer) More...
 
bool pushIntoFifo (double curTimeStamp, uint32_t curtick)
 
bool UpdatePLL (uint32_t sec, uint32_t nanoSec, uint32_t curtick)
 Updates PLL internale State should be called only with network send timestamps. More...
 
bool updatePLL (uint32_t sec, uint32_t nanoSec, uint32_t curtick)
 Updates PLL internale State should be called only with network send timestamps. More...
 
 ~SoftwarePLL ()
 
 ~SoftwarePLL ()
 Destructor of class SoftwarePLL. More...
 

Static Public Member Functions

static SoftwarePLLinstance ()
 
static SoftwarePLLInstance (const std::string &id="", int fifo_length=7)
 Creates an instance of SoftwarePLL or returns an existing one, given its id. More...
 
static void testbed ()
 

Public Attributes

int packeds_droped = 0
 

Static Public Attributes

static const int fifoSize = 7
 

Protected Member Functions

double AllowedTimeDeviation () const
 Returns the max. allowed time difference between estimated and measured timestamp time in seconds. More...
 
void AllowedTimeDeviation (double val)
 Set the max. allowed time difference between estimated and measured receive timestamp in seconds. More...
 
double ExtraPolateRelativeTimeStamp (uint32_t tick)
 Extrapolates and returns the measurement timestamp in seconds relative to FirstTimeStamp. The timestamp of a measurement in seconds can be estimated from sensor ticks by ExtraPolateRelativeTimeStamp(tick) + FirstTimeStamp(). More...
 
uint32_t ExtrapolationDivergenceCounter () const
 Returns the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation. More...
 
void ExtrapolationDivergenceCounter (uint32_t val)
 Sets the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation. More...
 
uint64_t FirstTick () const
 Returns the first sensor tick in the fifo buffer. More...
 
void FirstTick (uint64_t val)
 Sets the first sensor tick in the fifo buffer. More...
 
double FirstTimeStamp () const
 Returns the first timestamp in the fifo buffer in seconds. More...
 
void FirstTimeStamp (double val)
 Sets the first timestamp in the fifo buffer in seconds. More...
 
double InterpolationSlope () const
 Returns the interpolated slope (gradient of the regression line) More...
 
void InterpolationSlope (double val)
 Sets the interpolated slope (gradient of the regression line) More...
 
void IsInitialized (bool val)
 Sets the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer) More...
 
bool PushIntoFifo (double curTimeStamp, uint32_t curtick)
 Pushes measurement timestamp and sensor ticks to the fifo, updates tick fifo and clock (timestamp) fifo. More...
 

Private Member Functions

bool nearSameTimeStamp (double relTimeStamp1, double relTimeStamp2)
 
bool NearSameTimeStamp (double relTimeStamp1, double relTimeStamp2)
 
SoftwarePLLoperator= (const SoftwarePLL &)
 
SoftwarePLLoperator= (const SoftwarePLL &)
 
 SoftwarePLL ()
 
 SoftwarePLL (const SoftwarePLL &)
 
 SoftwarePLL (int fifo_length=7)
 
 SoftwarePLL (const SoftwarePLL &)
 
bool updateInterpolationSlope ()
 
bool UpdateInterpolationSlope ()
 

Private Attributes

double allowedTimeDeviation
 
double AllowedTimeDeviation_
 
double clockFifo [fifoSize]
 
std::vector< double > ClockFifo_
 
double dClockDiffFeedBack
 
double dTAvgFeedback
 
uint32_t extrapolationDivergenceCounter
 
uint32_t ExtrapolationDivergenceCounter_
 
const int FifoSize_
 
uint64_t firstTick
 
uint64_t FirstTick_
 
double firstTimeStamp
 
double FirstTimeStamp_
 
double interpolationSlope
 
double InterpolationSlope_
 
bool isInitialized
 
bool IsInitialized_
 
uint32_t lastcurtick = 0
 
uint32_t Lastcurtick_ = 0
 
uint32_t lastValidTick
 
double lastValidTimeStamp
 
uint32_t mostRecentNanoSec
 
uint32_t mostRecentSec
 
double mostRecentTimeStamp
 
int numberValInFifo
 
int NumberValInFifo_
 
uint32_t tickFifo [fifoSize]
 
std::vector< uint32_t > TickFifo_
 

Static Private Attributes

static std::map< std::string, SoftwarePLL * > _instances
 
static const double MaxAllowedTimeDeviation = 0.1
 
static const double MaxAllowedTimeDeviation_ = 0.1
 
static const uint32_t MaxExtrapolationCounter = 20
 
static const uint32_t MaxExtrapolationCounter_ = 20
 

Detailed Description

class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github.com/michael1309/SoftwarePLL/blob/master/README.md for details.

Definition at line 20 of file softwarePLL.h.

Constructor & Destructor Documentation

◆ ~SoftwarePLL() [1/2]

SoftwarePLL::~SoftwarePLL ( )
inline

Definition at line 29 of file softwarePLL.h.

◆ SoftwarePLL() [1/4]

SoftwarePLL::SoftwarePLL ( )
inlineprivate

Definition at line 111 of file softwarePLL.h.

◆ SoftwarePLL() [2/4]

SoftwarePLL::SoftwarePLL ( const SoftwarePLL )
private

◆ ~SoftwarePLL() [2/2]

SoftwarePLL::~SoftwarePLL ( )

Destructor of class SoftwarePLL.

◆ SoftwarePLL() [3/4]

SoftwarePLL::SoftwarePLL ( int  fifo_length = 7)
inlineprivate

Definition at line 186 of file SoftwarePLL.h.

◆ SoftwarePLL() [4/4]

SoftwarePLL::SoftwarePLL ( const SoftwarePLL )
private

Member Function Documentation

◆ AllowedTimeDeviation() [1/4]

double SoftwarePLL::AllowedTimeDeviation ( ) const
inline

Definition at line 66 of file softwarePLL.h.

◆ AllowedTimeDeviation() [2/4]

void SoftwarePLL::AllowedTimeDeviation ( double  val)
inline

Definition at line 69 of file softwarePLL.h.

◆ AllowedTimeDeviation() [3/4]

double SoftwarePLL::AllowedTimeDeviation ( ) const
inlineprotected

Returns the max. allowed time difference between estimated and measured timestamp time in seconds.

Returns
allowed time difference between estimated and measured timestamp

Definition at line 125 of file SoftwarePLL.h.

◆ AllowedTimeDeviation() [4/4]

void SoftwarePLL::AllowedTimeDeviation ( double  val)
inlineprotected

Set the max. allowed time difference between estimated and measured receive timestamp in seconds.

Parameters
[in]valallowed time difference between estimated and measured timestamp

Definition at line 132 of file SoftwarePLL.h.

◆ extraPolateRelativeTimeStamp()

double SoftwarePLL::extraPolateRelativeTimeStamp ( uint32_t  tick)

Definition at line 90 of file softwarePLL.cpp.

◆ ExtraPolateRelativeTimeStamp()

double SoftwarePLL::ExtraPolateRelativeTimeStamp ( uint32_t  tick)
protected

Extrapolates and returns the measurement timestamp in seconds relative to FirstTimeStamp. The timestamp of a measurement in seconds can be estimated from sensor ticks by ExtraPolateRelativeTimeStamp(tick) + FirstTimeStamp().

Parameters
ticksensor ticks
Returns
measurement timestamp in seconds relative to FirstTimeStamp

Definition at line 72 of file SoftwarePLL.cpp.

◆ ExtrapolationDivergenceCounter() [1/4]

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter ( ) const
inline

Definition at line 72 of file softwarePLL.h.

◆ ExtrapolationDivergenceCounter() [2/4]

void SoftwarePLL::ExtrapolationDivergenceCounter ( uint32_t  val)
inline

Definition at line 75 of file softwarePLL.h.

◆ ExtrapolationDivergenceCounter() [3/4]

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter ( ) const
inlineprotected

Returns the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation.

Returns
counter of extrapolated divergences

Definition at line 139 of file SoftwarePLL.h.

◆ ExtrapolationDivergenceCounter() [4/4]

void SoftwarePLL::ExtrapolationDivergenceCounter ( uint32_t  val)
inlineprotected

Sets the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation.

Parameters
[in]valcounter of extrapolated divergences

Definition at line 146 of file SoftwarePLL.h.

◆ findDiffInFifo()

int SoftwarePLL::findDiffInFifo ( double  diff,
double  tol 
)

Definition at line 99 of file softwarePLL.cpp.

◆ FirstTick() [1/4]

uint64_t SoftwarePLL::FirstTick ( ) const
inline

Definition at line 48 of file softwarePLL.h.

◆ FirstTick() [2/4]

void SoftwarePLL::FirstTick ( uint64_t  val)
inline

Definition at line 51 of file softwarePLL.h.

◆ FirstTick() [3/4]

uint64_t SoftwarePLL::FirstTick ( ) const
inlineprotected

Returns the first sensor tick in the fifo buffer.

Returns
first sensor tick

Definition at line 83 of file SoftwarePLL.h.

◆ FirstTick() [4/4]

void SoftwarePLL::FirstTick ( uint64_t  val)
inlineprotected

Sets the first sensor tick in the fifo buffer.

Parameters
[in]valfirst sensor tick

Definition at line 90 of file SoftwarePLL.h.

◆ FirstTimeStamp() [1/4]

double SoftwarePLL::FirstTimeStamp ( ) const
inline

Definition at line 54 of file softwarePLL.h.

◆ FirstTimeStamp() [2/4]

void SoftwarePLL::FirstTimeStamp ( double  val)
inline

Definition at line 57 of file softwarePLL.h.

◆ FirstTimeStamp() [3/4]

double SoftwarePLL::FirstTimeStamp ( ) const
inlineprotected

Returns the first timestamp in the fifo buffer in seconds.

Returns
first timestamp

Definition at line 97 of file SoftwarePLL.h.

◆ FirstTimeStamp() [4/4]

void SoftwarePLL::FirstTimeStamp ( double  val)
inlineprotected

Sets the first timestamp in the fifo buffer in seconds.

Parameters
[in]valfirst timestamp

Definition at line 104 of file SoftwarePLL.h.

◆ getCorrectedTimeStamp()

bool SoftwarePLL::getCorrectedTimeStamp ( uint32_t &  sec,
uint32_t &  nanoSec,
uint32_t  tick 
)

Definition at line 183 of file softwarePLL.cpp.

◆ GetCorrectedTimeStamp()

bool SoftwarePLL::GetCorrectedTimeStamp ( uint32_t &  sec,
uint32_t &  nanoSec,
uint32_t  tick 
)

Computes the timestamp of a measurement from sensor ticks.

Parameters
[out]secEstimated system Timetamp (seconds)
[out]nanoSecEstimated system Timetamp (nanoseconds)
[in]ticksensor ticks
Returns
true if timestamp is computed, false otherwise (SoftwarePLL not initialized)

Definition at line 138 of file SoftwarePLL.cpp.

◆ getDemoFileData()

bool SoftwarePLL::getDemoFileData ( std::string  fileName,
std::vector< uint32_t > &  tickVec,
std::vector< uint32_t > &  secVec,
std::vector< uint32_t > &  nanoSecVec 
)

◆ instance()

static SoftwarePLL& SoftwarePLL::instance ( )
inlinestatic

Definition at line 23 of file softwarePLL.h.

◆ Instance()

SoftwarePLL & SoftwarePLL::Instance ( const std::string &  id = "",
int  fifo_length = 7 
)
static

Creates an instance of SoftwarePLL or returns an existing one, given its id.

Parameters
ididentifier of the instance, f.e. "Sensor1", "TIM571".
fifo_lengthlength of fifo (buffer size, i.e. number of ticks in fifo). Applied only for new instances of SoftwarePLL, existing instance will keep their buffer size.
Returns
instance of a SoftwarePLL

Definition at line 28 of file SoftwarePLL.cpp.

◆ InterpolationSlope() [1/4]

double SoftwarePLL::InterpolationSlope ( ) const
inline

Definition at line 60 of file softwarePLL.h.

◆ InterpolationSlope() [2/4]

void SoftwarePLL::InterpolationSlope ( double  val)
inline

Definition at line 63 of file softwarePLL.h.

◆ InterpolationSlope() [3/4]

double SoftwarePLL::InterpolationSlope ( ) const
inlineprotected

Returns the interpolated slope (gradient of the regression line)

Returns
interpolated slope

Definition at line 111 of file SoftwarePLL.h.

◆ InterpolationSlope() [4/4]

void SoftwarePLL::InterpolationSlope ( double  val)
inlineprotected

Sets the interpolated slope (gradient of the regression line)

Parameters
[in]valinterpolated slope

Definition at line 118 of file SoftwarePLL.h.

◆ IsInitialized() [1/4]

bool SoftwarePLL::IsInitialized ( ) const
inline

Definition at line 42 of file softwarePLL.h.

◆ IsInitialized() [2/4]

void SoftwarePLL::IsInitialized ( bool  val)
inline

Definition at line 45 of file softwarePLL.h.

◆ IsInitialized() [3/4]

bool SoftwarePLL::IsInitialized ( ) const
inline

Returns the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer)

Returns
initialization status

Definition at line 67 of file SoftwarePLL.h.

◆ IsInitialized() [4/4]

void SoftwarePLL::IsInitialized ( bool  val)
inlineprotected

Sets the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer)

Parameters
[in]valinitialization status

Definition at line 76 of file SoftwarePLL.h.

◆ nearSameTimeStamp()

bool SoftwarePLL::nearSameTimeStamp ( double  relTimeStamp1,
double  relTimeStamp2 
)
private

Definition at line 198 of file softwarePLL.cpp.

◆ NearSameTimeStamp()

bool SoftwarePLL::NearSameTimeStamp ( double  relTimeStamp1,
double  relTimeStamp2 
)
private

Definition at line 153 of file SoftwarePLL.cpp.

◆ operator=() [1/2]

SoftwarePLL& SoftwarePLL::operator= ( const SoftwarePLL )
private

◆ operator=() [2/2]

SoftwarePLL& SoftwarePLL::operator= ( const SoftwarePLL )
private

◆ pushIntoFifo()

bool SoftwarePLL::pushIntoFifo ( double  curTimeStamp,
uint32_t  curtick 
)

Definition at line 69 of file softwarePLL.cpp.

◆ PushIntoFifo()

bool SoftwarePLL::PushIntoFifo ( double  curTimeStamp,
uint32_t  curtick 
)
protected

Pushes measurement timestamp and sensor ticks to the fifo, updates tick fifo and clock (timestamp) fifo.

Parameters
curTimeStampmeasurement timestamp in seconds (receive time)
curticksensor ticks
Returns
always true

Definition at line 51 of file SoftwarePLL.cpp.

◆ testbed()

void SoftwarePLL::testbed ( )
static

Definition at line 307 of file softwarePLL.cpp.

◆ updateInterpolationSlope()

bool SoftwarePLL::updateInterpolationSlope ( )
private

Definition at line 211 of file softwarePLL.cpp.

◆ UpdateInterpolationSlope()

bool SoftwarePLL::UpdateInterpolationSlope ( )
private

Definition at line 166 of file SoftwarePLL.cpp.

◆ UpdatePLL()

bool SoftwarePLL::UpdatePLL ( uint32_t  sec,
uint32_t  nanoSec,
uint32_t  curtick 
)

Updates PLL internale State should be called only with network send timestamps.

Parameters
[in]secSystem Timetamp from received network packed
[in]nanoSecSystem Timestamp from received network packed
[in]curticksensor ticks
Returns
PLL is in valid state (true)

Definition at line 81 of file SoftwarePLL.cpp.

◆ updatePLL()

bool SoftwarePLL::updatePLL ( uint32_t  sec,
uint32_t  nanoSec,
uint32_t  curtick 
)

Updates PLL internale State should be called only with network send timestamps.

Parameters
secSystem Timetamp from received network packed
nsecSystem Timestamp from received network packed
curtickmicro Seconds since scanner start from SOPAS Datagram
Returns
PLL is in valid state (true)

Definition at line 125 of file softwarePLL.cpp.

Member Data Documentation

◆ _instances

std::map< std::string, SoftwarePLL * > SoftwarePLL::_instances
staticprivate

Definition at line 197 of file SoftwarePLL.h.

◆ allowedTimeDeviation

double SoftwarePLL::allowedTimeDeviation
private

Definition at line 97 of file softwarePLL.h.

◆ AllowedTimeDeviation_

double SoftwarePLL::AllowedTimeDeviation_
private

Definition at line 179 of file SoftwarePLL.h.

◆ clockFifo

double SoftwarePLL::clockFifo[fifoSize]
private

Definition at line 90 of file softwarePLL.h.

◆ ClockFifo_

std::vector<double> SoftwarePLL::ClockFifo_
private

Definition at line 176 of file SoftwarePLL.h.

◆ dClockDiffFeedBack

double SoftwarePLL::dClockDiffFeedBack
private

Definition at line 95 of file softwarePLL.h.

◆ dTAvgFeedback

double SoftwarePLL::dTAvgFeedback
private

Definition at line 94 of file softwarePLL.h.

◆ extrapolationDivergenceCounter

uint32_t SoftwarePLL::extrapolationDivergenceCounter
private

Definition at line 109 of file softwarePLL.h.

◆ ExtrapolationDivergenceCounter_

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter_
private

Definition at line 185 of file SoftwarePLL.h.

◆ fifoSize

const int SoftwarePLL::fifoSize = 7
static

Definition at line 82 of file softwarePLL.h.

◆ FifoSize_

const int SoftwarePLL::FifoSize_
private

Definition at line 172 of file SoftwarePLL.h.

◆ firstTick

uint64_t SoftwarePLL::firstTick
private

Definition at line 98 of file softwarePLL.h.

◆ FirstTick_

uint64_t SoftwarePLL::FirstTick_
private

Definition at line 180 of file SoftwarePLL.h.

◆ firstTimeStamp

double SoftwarePLL::firstTimeStamp
private

Definition at line 96 of file softwarePLL.h.

◆ FirstTimeStamp_

double SoftwarePLL::FirstTimeStamp_
private

Definition at line 178 of file SoftwarePLL.h.

◆ interpolationSlope

double SoftwarePLL::interpolationSlope
private

Definition at line 103 of file softwarePLL.h.

◆ InterpolationSlope_

double SoftwarePLL::InterpolationSlope_
private

Definition at line 182 of file SoftwarePLL.h.

◆ isInitialized

bool SoftwarePLL::isInitialized
private

Definition at line 93 of file softwarePLL.h.

◆ IsInitialized_

bool SoftwarePLL::IsInitialized_
private

Definition at line 177 of file SoftwarePLL.h.

◆ lastcurtick

uint32_t SoftwarePLL::lastcurtick = 0
private

Definition at line 99 of file softwarePLL.h.

◆ Lastcurtick_

uint32_t SoftwarePLL::Lastcurtick_ = 0
private

Definition at line 181 of file SoftwarePLL.h.

◆ lastValidTick

uint32_t SoftwarePLL::lastValidTick
private

Definition at line 92 of file softwarePLL.h.

◆ lastValidTimeStamp

double SoftwarePLL::lastValidTimeStamp
private

Definition at line 91 of file softwarePLL.h.

◆ MaxAllowedTimeDeviation

const double SoftwarePLL::MaxAllowedTimeDeviation = 0.1
staticprivate

Definition at line 87 of file softwarePLL.h.

◆ MaxAllowedTimeDeviation_

const double SoftwarePLL::MaxAllowedTimeDeviation_ = 0.1
staticprivate

Definition at line 173 of file SoftwarePLL.h.

◆ MaxExtrapolationCounter

const uint32_t SoftwarePLL::MaxExtrapolationCounter = 20
staticprivate

Definition at line 88 of file softwarePLL.h.

◆ MaxExtrapolationCounter_

const uint32_t SoftwarePLL::MaxExtrapolationCounter_ = 20
staticprivate

Definition at line 174 of file SoftwarePLL.h.

◆ mostRecentNanoSec

uint32_t SoftwarePLL::mostRecentNanoSec
private

Definition at line 101 of file softwarePLL.h.

◆ mostRecentSec

uint32_t SoftwarePLL::mostRecentSec
private

Definition at line 100 of file softwarePLL.h.

◆ mostRecentTimeStamp

double SoftwarePLL::mostRecentTimeStamp
private

Definition at line 102 of file softwarePLL.h.

◆ numberValInFifo

int SoftwarePLL::numberValInFifo
private

Definition at line 86 of file softwarePLL.h.

◆ NumberValInFifo_

int SoftwarePLL::NumberValInFifo_
private

Definition at line 171 of file SoftwarePLL.h.

◆ packeds_droped

int SoftwarePLL::packeds_droped = 0

Definition at line 83 of file softwarePLL.h.

◆ tickFifo

uint32_t SoftwarePLL::tickFifo[fifoSize]
private

Definition at line 89 of file softwarePLL.h.

◆ TickFifo_

std::vector<uint32_t> SoftwarePLL::TickFifo_
private

Definition at line 175 of file SoftwarePLL.h.


The documentation for this class was generated from the following files:


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed Sep 7 2022 02:25:06