softwarePLL.h
Go to the documentation of this file.
1 #ifndef SOFTWARE_PLL_H
2 #define SOFTWARE_PLL_H
3 
4 #ifdef _MSC_VER
5 #pragma warning(disable : 4996)
6 #endif
7 
8 #include <string>
9 #include <iostream>
10 #include <fstream> // std::ifstream
11 #include <cstring>
12 #include <sstream> // std::stringstream
13 #include <vector>
14 #include <cstdlib>
15 #include <iomanip>
16 #include <ctime>
17 #include <boost/cstdint.hpp>
18 // #include <chrono>
19 
21 {
22 public:
24  {
25  static SoftwarePLL _instance;
26  return _instance;
27  }
28 
30  {}
31 
32  bool pushIntoFifo(double curTimeStamp, uint32_t curtick);// update tick fifo and update clock (timestamp) fifo;
33  double extraPolateRelativeTimeStamp(uint32_t tick);
34 
35  bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick);
36 
37  bool getDemoFileData(std::string fileName, std::vector<uint32_t> &tickVec, std::vector<uint32_t> &secVec,
38  std::vector<uint32_t> &nanoSecVec);
39 
40  static void testbed();
41 
42  bool IsInitialized() const
43  { return isInitialized; }
44 
45  void IsInitialized(bool val)
46  { isInitialized = val; }
47 
48  uint64_t FirstTick() const
49  { return firstTick; }
50 
51  void FirstTick(uint64_t val)
52  { firstTick = val; }
53 
54  double FirstTimeStamp() const
55  { return firstTimeStamp; }
56 
57  void FirstTimeStamp(double val)
58  { firstTimeStamp = val; }
59 
60  double InterpolationSlope() const
61  { return interpolationSlope; }
62 
63  void InterpolationSlope(double val)
64  { interpolationSlope = val; }
65 
66  double AllowedTimeDeviation() const
67  { return allowedTimeDeviation; }
68 
69  void AllowedTimeDeviation(double val)
70  { allowedTimeDeviation = val; }
71 
74 
75  void ExtrapolationDivergenceCounter(uint32_t val)
77 
78  bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick);
79 
80  int findDiffInFifo(double diff, double tol);
81 
82  static const int fifoSize = 7;
83  int packeds_droped = 0;//just for printing statusmessages when dropping packets
84 
85 private:
87  static const double MaxAllowedTimeDeviation;
88  static const uint32_t MaxExtrapolationCounter;
89  uint32_t tickFifo[fifoSize]; // = { 0 };
92  uint32_t lastValidTick; // = 0;
93  bool isInitialized; // = false;
94  double dTAvgFeedback; // = 0.0;
95  double dClockDiffFeedBack; // = 0.0;
98  uint64_t firstTick;
99  uint32_t lastcurtick = 0;
100  uint32_t mostRecentSec;
104 
105  bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2);
106 
108 
110 
112  {
114  numberValInFifo = 0;
115  }
116 
117  // verhindert, dass ein Objekt von au�erhalb von N erzeugt wird.
118  // protected, wenn man von der Klasse noch erben m�chte
119  SoftwarePLL(const SoftwarePLL &); /* verhindert, dass eine weitere Instanz via
120  Kopier-Konstruktor erstellt werden kann */
121  SoftwarePLL &operator=(const SoftwarePLL &); //Verhindert weitere Instanz durch Kopie
122 };
123 
124 
125 #endif
SoftwarePLL::extrapolationDivergenceCounter
uint32_t extrapolationDivergenceCounter
Definition: softwarePLL.h:109
SoftwarePLL
class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github....
Definition: softwarePLL.h:20
SoftwarePLL::AllowedTimeDeviation
double AllowedTimeDeviation() const
Definition: softwarePLL.h:66
SoftwarePLL::SoftwarePLL
SoftwarePLL()
Definition: softwarePLL.h:111
SoftwarePLL::getDemoFileData
bool getDemoFileData(std::string fileName, std::vector< uint32_t > &tickVec, std::vector< uint32_t > &secVec, std::vector< uint32_t > &nanoSecVec)
SoftwarePLL::~SoftwarePLL
~SoftwarePLL()
Definition: softwarePLL.h:29
SoftwarePLL::updatePLL
bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick)
Updates PLL internale State should be called only with network send timestamps.
Definition: softwarePLL.cpp:125
SoftwarePLL::extraPolateRelativeTimeStamp
double extraPolateRelativeTimeStamp(uint32_t tick)
Definition: softwarePLL.cpp:90
SoftwarePLL::firstTimeStamp
double firstTimeStamp
Definition: softwarePLL.h:96
SoftwarePLL::instance
static SoftwarePLL & instance()
Definition: softwarePLL.h:23
SoftwarePLL::FirstTick
uint64_t FirstTick() const
Definition: softwarePLL.h:48
SoftwarePLL::getCorrectedTimeStamp
bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
Definition: softwarePLL.cpp:183
SoftwarePLL::AllowedTimeDeviation
void AllowedTimeDeviation(double val)
Definition: softwarePLL.h:69
SoftwarePLL::dClockDiffFeedBack
double dClockDiffFeedBack
Definition: softwarePLL.h:95
SoftwarePLL::InterpolationSlope
void InterpolationSlope(double val)
Definition: softwarePLL.h:63
SoftwarePLL::packeds_droped
int packeds_droped
Definition: softwarePLL.h:83
SoftwarePLL::lastcurtick
uint32_t lastcurtick
Definition: softwarePLL.h:99
SoftwarePLL::pushIntoFifo
bool pushIntoFifo(double curTimeStamp, uint32_t curtick)
Definition: softwarePLL.cpp:69
SoftwarePLL::mostRecentTimeStamp
double mostRecentTimeStamp
Definition: softwarePLL.h:102
SoftwarePLL::isInitialized
bool isInitialized
Definition: softwarePLL.h:93
SoftwarePLL::ExtrapolationDivergenceCounter
void ExtrapolationDivergenceCounter(uint32_t val)
Definition: softwarePLL.h:75
SoftwarePLL::numberValInFifo
int numberValInFifo
Definition: softwarePLL.h:86
SoftwarePLL::MaxExtrapolationCounter
static const uint32_t MaxExtrapolationCounter
Definition: softwarePLL.h:88
SoftwarePLL::mostRecentNanoSec
uint32_t mostRecentNanoSec
Definition: softwarePLL.h:101
SoftwarePLL::operator=
SoftwarePLL & operator=(const SoftwarePLL &)
SoftwarePLL::FirstTimeStamp
void FirstTimeStamp(double val)
Definition: softwarePLL.h:57
SoftwarePLL::lastValidTimeStamp
double lastValidTimeStamp
Definition: softwarePLL.h:91
SoftwarePLL::allowedTimeDeviation
double allowedTimeDeviation
Definition: softwarePLL.h:97
SoftwarePLL::ExtrapolationDivergenceCounter
uint32_t ExtrapolationDivergenceCounter() const
Definition: softwarePLL.h:72
SoftwarePLL::tickFifo
uint32_t tickFifo[fifoSize]
Definition: softwarePLL.h:89
SoftwarePLL::testbed
static void testbed()
Definition: softwarePLL.cpp:307
SoftwarePLL::clockFifo
double clockFifo[fifoSize]
Definition: softwarePLL.h:90
SoftwarePLL::mostRecentSec
uint32_t mostRecentSec
Definition: softwarePLL.h:100
SoftwarePLL::FirstTimeStamp
double FirstTimeStamp() const
Definition: softwarePLL.h:54
SoftwarePLL::MaxAllowedTimeDeviation
static const double MaxAllowedTimeDeviation
Definition: softwarePLL.h:87
SoftwarePLL::lastValidTick
uint32_t lastValidTick
Definition: softwarePLL.h:92
SoftwarePLL::FirstTick
void FirstTick(uint64_t val)
Definition: softwarePLL.h:51
SoftwarePLL::nearSameTimeStamp
bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2)
Definition: softwarePLL.cpp:198
SoftwarePLL::IsInitialized
bool IsInitialized() const
Definition: softwarePLL.h:42
SoftwarePLL::firstTick
uint64_t firstTick
Definition: softwarePLL.h:98
SoftwarePLL::updateInterpolationSlope
bool updateInterpolationSlope()
Definition: softwarePLL.cpp:211
SoftwarePLL::interpolationSlope
double interpolationSlope
Definition: softwarePLL.h:103
SoftwarePLL::dTAvgFeedback
double dTAvgFeedback
Definition: softwarePLL.h:94
SoftwarePLL::findDiffInFifo
int findDiffInFifo(double diff, double tol)
Definition: softwarePLL.cpp:99
SoftwarePLL::fifoSize
static const int fifoSize
Definition: softwarePLL.h:82
SoftwarePLL::IsInitialized
void IsInitialized(bool val)
Definition: softwarePLL.h:45
SoftwarePLL::InterpolationSlope
double InterpolationSlope() const
Definition: softwarePLL.h:60


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Thu Sep 8 2022 02:30:19