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  }
29  bool pushIntoFifo(double curTimeStamp, uint32_t curtick);// update tick fifo and update clock (timestamp) fifo;
30  double extraPolateRelativeTimeStamp(uint32_t tick);
31  bool getCorrectedTimeStamp(uint32_t& sec, uint32_t& nanoSec, uint32_t tick);
32  bool getDemoFileData(std::string fileName, std::vector<uint32_t>& tickVec,std::vector<uint32_t>& secVec, std::vector<uint32_t>& nanoSecVec );
33  static void testbed();
34 
35  bool IsInitialized() const { return isInitialized; }
36  void IsInitialized(bool val) { isInitialized = val; }
37  uint64_t FirstTick() const { return firstTick; }
38  void FirstTick(uint64_t val) { firstTick = val; }
39  double FirstTimeStamp() const { return firstTimeStamp; }
40  void FirstTimeStamp(double val) { firstTimeStamp = val; }
41  double InterpolationSlope() const { return interpolationSlope; }
42  void InterpolationSlope(double val) { interpolationSlope = val; }
43  double AllowedTimeDeviation() const { return allowedTimeDeviation; }
44  void AllowedTimeDeviation(double val) { allowedTimeDeviation = val; }
47  bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick);
48  int findDiffInFifo(double diff, double tol);
49 
50 private:
52  static const int fifoSize = 7;
53  static const double MaxAllowedTimeDeviation;
54  static const uint32_t MaxExtrapolationCounter;
55  uint32_t tickFifo[fifoSize]; // = { 0 };
58  uint32_t lastValidTick; // = 0;
59  bool isInitialized; // = false;
60  double dTAvgFeedback; // = 0.0;
61  double dClockDiffFeedBack; // = 0.0;
64  uint64_t firstTick;
65  uint32_t mostRecentSec;
69  bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2);
73  {
75  numberValInFifo = 0;
76  }
77  // verhindert, dass ein Objekt von au�erhalb von N erzeugt wird.
78  // protected, wenn man von der Klasse noch erben m�chte
79  SoftwarePLL(const SoftwarePLL&); /* verhindert, dass eine weitere Instanz via
80  Kopier-Konstruktor erstellt werden kann */
81  SoftwarePLL & operator = (const SoftwarePLL &); //Verhindert weitere Instanz durch Kopie
82 };
83 
84 
85 #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:60
double dClockDiffFeedBack
Definition: softwarePLL.h:61
double firstTimeStamp
Definition: softwarePLL.h:62
static SoftwarePLL & instance()
Definition: softwarePLL.h:23
uint32_t extrapolationDivergenceCounter
Definition: softwarePLL.h:71
void AllowedTimeDeviation(double val)
Definition: softwarePLL.h:44
double extraPolateRelativeTimeStamp(uint32_t tick)
Definition: softwarePLL.cpp:89
double mostRecentTimeStamp
Definition: softwarePLL.h:67
void InterpolationSlope(double val)
Definition: softwarePLL.h:42
void FirstTimeStamp(double val)
Definition: softwarePLL.h:40
double allowedTimeDeviation
Definition: softwarePLL.h:63
bool isInitialized
Definition: softwarePLL.h:59
bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
bool pushIntoFifo(double curTimeStamp, uint32_t curtick)
Definition: softwarePLL.cpp:68
double clockFifo[fifoSize]
Definition: softwarePLL.h:56
uint32_t ExtrapolationDivergenceCounter() const
Definition: softwarePLL.h:45
uint32_t tickFifo[fifoSize]
Definition: softwarePLL.h:55
void ExtrapolationDivergenceCounter(uint32_t val)
Definition: softwarePLL.h:46
bool IsInitialized() const
Definition: softwarePLL.h:35
uint32_t mostRecentNanoSec
Definition: softwarePLL.h:66
double AllowedTimeDeviation() const
Definition: softwarePLL.h:43
int numberValInFifo
Definition: softwarePLL.h:51
uint32_t mostRecentSec
Definition: softwarePLL.h:65
SoftwarePLL & operator=(const SoftwarePLL &)
static void testbed()
double InterpolationSlope() const
Definition: softwarePLL.h:41
double FirstTimeStamp() const
Definition: softwarePLL.h:39
static const uint32_t MaxExtrapolationCounter
Definition: softwarePLL.h:54
double lastValidTimeStamp
Definition: softwarePLL.h:57
static const double MaxAllowedTimeDeviation
Definition: softwarePLL.h:53
uint32_t lastValidTick
Definition: softwarePLL.h:58
uint64_t firstTick
Definition: softwarePLL.h:64
bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2)
uint64_t FirstTick() const
Definition: softwarePLL.h:37
double interpolationSlope
Definition: softwarePLL.h:68
void FirstTick(uint64_t val)
Definition: softwarePLL.h:38
int findDiffInFifo(double diff, double tol)
Definition: softwarePLL.cpp:98
bool updateInterpolationSlope()
static const int fifoSize
Definition: softwarePLL.h:52
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:36


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Tue Jul 9 2019 04:55:32