40 std::getline(str, line);
42 std::stringstream lineStream(line);
46 while (std::getline(lineStream, cell,
';'))
51 if (!lineStream && cell.empty())
64 data.readNextRow(str);
72 for (
int i = 0; i <
fifoSize - 1; i++)
93 tempTick = tick - (uint32_t) (0xFFFFFFFF &
FirstTick());
102 double minAllowedDiff = (1.0 - tol) * diff;
103 double maxAllowedDiff = (1.0 + tol) * diff;
108 if ((diffTime >= minAllowedDiff) && (diffTime <= maxAllowedDiff))
130 double start = sec + nanoSec * 1E-9;
151 bool timeStampVerified =
false;
154 timeStampVerified =
true;
160 if (timeStampVerified ==
false)
192 sec = (uint32_t) corrTime;
193 double frac = corrTime - sec;
194 nanoSec = (uint32_t) (1E9 * frac);
200 double dTAbs = fabs(relTimeStamp1 - relTimeStamp2);
218 std::vector<uint64_t> tickFifoUnwrap;
219 std::vector<double> clockFifoUnwrap;
222 uint64_t tickOffset = 0;
223 clockFifoUnwrap[0] = 0.00;
224 tickFifoUnwrap[0] = 0;
228 uint64_t tickDivisor = 0x100000000;
236 tickOffset += tickDivisor;
248 sum_xy += tickFifoUnwrap[i] * clockFifoUnwrap[i];
249 sum_x += tickFifoUnwrap[i];
250 sum_y += clockFifoUnwrap[i];
251 sum_xx += tickFifoUnwrap[i] * tickFifoUnwrap[i];
255 double m = (
fifoSize * sum_xy - sum_x * sum_y) / (
fifoSize * sum_xx - sum_x * sum_x);
260 double yesti = m * tickFifoUnwrap[i];
278 bool SoftwarePLL::getDemoFileData(std::string fileName, std::vector<uint32_t>& tickVec,std::vector<uint32_t>& secVec, std::vector<uint32_t>& nanoSecVec )
280 std::ifstream file(fileName);
287 while (file >> row) {
290 uint32_t tickVal = (uint32_t)std::stoi(row[0]);
291 uint32_t secVal = (uint32_t)std::stoi(row[1]);
292 uint32_t nanoSecVal = (uint32_t)std::stoi(row[2]);
293 tickVec.push_back(tickVal);
294 secVec.push_back(secVal);
295 nanoSecVec.push_back(nanoSecVal);
309 std::cout <<
"Running testbed for SofwarePLL" << std::endl;
310 uint32_t curtick = 0;
315 uint32_t nanoSec = 0;
316 double tickPerSec = 1E6;
317 uint32_t tickInc = 1000;
320 std::vector<uint32_t> tickVec;
321 std::vector<uint32_t> secVec;
322 std::vector<uint32_t> nanoSecVec;
325 bool testWithDataFile =
true;
326 if (testWithDataFile)
329 maxLoop = tickVec.size();
332 for (
int i = 0; i < maxLoop; i++)
334 if (testWithDataFile)
336 curtick = tickVec[i];
338 nanoSec = nanoSecVec[i];
344 double deltaT = tickInc / tickPerSec;
345 nanoSec += (int) (deltaT * 1E9);
356 printf(
"Before correction: %3d.%09d\n", sec, nanoSec);
357 uint32_t org_sec = sec;
358 uint32_t org_nanoSec = nanoSec;
362 bool corrected =
false;
363 if ((nanoSec != org_nanoSec) || (sec != org_sec))
367 printf(
"After correction : %3d.%09d %s %s\n", sec, nanoSec, bRet ?
"OK " :
"DISMISS",
368 corrected ?
"MODI." :
"OK ");
375 #ifdef softwarePLL_MAINTEST
376 int main(
int argc,
char **argv)
378 printf(
"Test for softwarePLL-Class\n");