softwarePLL.h
Go to the documentation of this file.
00001 #ifndef SOFTWARE_PLL_H
00002 #define SOFTWARE_PLL_H
00003 
00004 #ifdef _MSC_VER
00005 #pragma warning(disable : 4996)
00006 #endif
00007 
00008 #include <string>
00009 #include <iostream>
00010 #include <fstream>      // std::ifstream
00011 #include <cstring>
00012 #include <sstream>      // std::stringstream
00013 #include <vector>
00014 #include <cstdlib>
00015 #include <iomanip>
00016 #include <ctime>
00017 #include <boost/cstdint.hpp>
00018 // #include <chrono>
00019 
00020 class SoftwarePLL
00021 {
00022 public:
00023         static SoftwarePLL& instance()
00024         {
00025                 static SoftwarePLL _instance;
00026                 return _instance;
00027         }
00028         ~SoftwarePLL() {}
00029         bool pushIntoFifo(double curTimeStamp, uint32_t curtick);// update tick fifo and update clock (timestamp) fifo;
00030         double extraPolateRelativeTimeStamp(uint32_t tick);
00031         bool getCorrectedTimeStamp(uint32_t& sec, uint32_t& nanoSec, uint32_t tick);
00032         bool getDemoFileData(std::string fileName, std::vector<uint32_t>& tickVec,std::vector<uint32_t>& secVec, std::vector<uint32_t>& nanoSecVec );
00033         static void testbed();
00034 
00035         bool IsInitialized() const { return isInitialized; }
00036         void IsInitialized(bool val) { isInitialized = val; }
00037         uint64_t FirstTick() const { return firstTick; }
00038         void FirstTick(uint64_t val) { firstTick = val; }
00039         double FirstTimeStamp() const { return firstTimeStamp; }
00040         void FirstTimeStamp(double val) { firstTimeStamp = val; }
00041         double InterpolationSlope() const { return interpolationSlope; }
00042         void InterpolationSlope(double val) { interpolationSlope = val; }
00043         double AllowedTimeDeviation() const { return allowedTimeDeviation; }
00044         void AllowedTimeDeviation(double val) { allowedTimeDeviation = val; }
00045         uint32_t ExtrapolationDivergenceCounter() const { return extrapolationDivergenceCounter; }
00046         void ExtrapolationDivergenceCounter(uint32_t val) { extrapolationDivergenceCounter = val; }
00047   bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick);
00048     int findDiffInFifo(double diff, double tol);
00049 
00050 private:
00051         int numberValInFifo;
00052         static const int fifoSize = 7;
00053         static const double MaxAllowedTimeDeviation;
00054         static const uint32_t  MaxExtrapolationCounter;
00055         uint32_t tickFifo[fifoSize]; //  = { 0 };
00056         double clockFifo[fifoSize];
00057         double lastValidTimeStamp;
00058         uint32_t lastValidTick; // = 0;
00059         bool isInitialized; // = false;
00060         double dTAvgFeedback; // = 0.0;
00061         double dClockDiffFeedBack; //  = 0.0;
00062         double firstTimeStamp;
00063         double allowedTimeDeviation;
00064         uint64_t firstTick;
00065         uint32_t mostRecentSec;
00066         uint32_t mostRecentNanoSec;
00067     double mostRecentTimeStamp;
00068         double interpolationSlope;
00069         bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2);
00070         bool updateInterpolationSlope();
00071         uint32_t extrapolationDivergenceCounter;
00072         SoftwarePLL()
00073         {
00074                 AllowedTimeDeviation(SoftwarePLL::MaxAllowedTimeDeviation); // 1 ms
00075                 numberValInFifo = 0;
00076         }
00077         // verhindert, dass ein Objekt von au�erhalb von N erzeugt wird.
00078         // protected, wenn man von der Klasse noch erben m�chte
00079         SoftwarePLL(const SoftwarePLL&); /* verhindert, dass eine weitere Instanz via
00080                                                                    Kopier-Konstruktor erstellt werden kann */
00081         SoftwarePLL & operator = (const SoftwarePLL &); //Verhindert weitere Instanz durch Kopie
00082 };
00083 
00084 
00085 #endif


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