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
bool getDemoFileData(std::string fileName, std::vector< uint32_t > &tickVec, std::vector< uint32_t > &secVec, std::vector< uint32_t > &nanoSecVec)
double dTAvgFeedback
Definition: softwarePLL.h:94
double dClockDiffFeedBack
Definition: softwarePLL.h:95
class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github.com/michael1309/SoftwarePLL/blob/master/README.md for details.
Definition: softwarePLL.h:20
double firstTimeStamp
Definition: softwarePLL.h:96
static SoftwarePLL & instance()
Definition: softwarePLL.h:23
uint32_t extrapolationDivergenceCounter
Definition: softwarePLL.h:109
void AllowedTimeDeviation(double val)
Definition: softwarePLL.h:69
double extraPolateRelativeTimeStamp(uint32_t tick)
Definition: softwarePLL.cpp:90
double mostRecentTimeStamp
Definition: softwarePLL.h:102
void InterpolationSlope(double val)
Definition: softwarePLL.h:63
void FirstTimeStamp(double val)
Definition: softwarePLL.h:57
double allowedTimeDeviation
Definition: softwarePLL.h:97
bool isInitialized
Definition: softwarePLL.h:93
int packeds_droped
Definition: softwarePLL.h:83
bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
bool pushIntoFifo(double curTimeStamp, uint32_t curtick)
Definition: softwarePLL.cpp:69
double clockFifo[fifoSize]
Definition: softwarePLL.h:90
uint32_t ExtrapolationDivergenceCounter() const
Definition: softwarePLL.h:72
uint32_t lastcurtick
Definition: softwarePLL.h:99
uint32_t tickFifo[fifoSize]
Definition: softwarePLL.h:89
void ExtrapolationDivergenceCounter(uint32_t val)
Definition: softwarePLL.h:75
bool IsInitialized() const
Definition: softwarePLL.h:42
uint32_t mostRecentNanoSec
Definition: softwarePLL.h:101
double AllowedTimeDeviation() const
Definition: softwarePLL.h:66
int numberValInFifo
Definition: softwarePLL.h:86
uint32_t mostRecentSec
Definition: softwarePLL.h:100
SoftwarePLL & operator=(const SoftwarePLL &)
static void testbed()
double InterpolationSlope() const
Definition: softwarePLL.h:60
double FirstTimeStamp() const
Definition: softwarePLL.h:54
static const uint32_t MaxExtrapolationCounter
Definition: softwarePLL.h:88
double lastValidTimeStamp
Definition: softwarePLL.h:91
static const double MaxAllowedTimeDeviation
Definition: softwarePLL.h:87
uint32_t lastValidTick
Definition: softwarePLL.h:92
uint64_t firstTick
Definition: softwarePLL.h:98
bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2)
uint64_t FirstTick() const
Definition: softwarePLL.h:48
double interpolationSlope
Definition: softwarePLL.h:103
void FirstTick(uint64_t val)
Definition: softwarePLL.h:51
int findDiffInFifo(double diff, double tol)
Definition: softwarePLL.cpp:99
bool updateInterpolationSlope()
static const int fifoSize
Definition: softwarePLL.h:82
bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick)
Updates PLL internale State should be called only with network send timestamps.
void IsInitialized(bool val)
Definition: softwarePLL.h:45


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48