std::wstring modifiedLDate::debugTree() const { return L"MOD DATEFILTER LESSTHAN " + getDateAsString(date); }
std::wstring accessGDate::debugTree() const { return L"ACCESS DATEFILTER GREATERTHAN " + getDateAsString(date); }
std::wstring headerGDate::debugTree() const { return L"HEADER DATEFILTER GREATERTHAN " + getDateAsString(date); }
std::wstring createdGDate::debugTree() const { return L"CREATED DATEFILTER GREATERTHAN " + getDateAsString(date); }
char *ArduRCT_RealTimeClock::getDateAsString(bool withDayOfWeek) { #ifdef RTC_MCP7941X if (_mcp7941xStatus == RTC_MCP7941X_NOT_STARTED) _getMCP7941xTime(); #endif return getDateAsString(_year, _month, _day, withDayOfWeek, ' '); }
//*********************************************************** bool testTimer( bool printFlag, bool assertFlag ) { //create file to redirect output timerTest.open("TimerTest.log"); double allowedDelay = .005; double timeVariance = (double)2.0 / 1e3; if(printFlag) { // printf("\n\nRegression test for Timer class\n"); timerTest << "\nRegression test for Timer class" << endl; } Timer timer; timer.setFPS(30.0); //Check ObjectId size if( sizeof(uint64_t) != sizeof( ObjectId )) { if(printFlag) { timerTest <<"size uint64_t:"<<sizeof(uint64_t)<<"!= ObjectId:"<<sizeof(ObjectId)<<"!\n" <<"Check variable alignment in ObjectId structure"<<std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } //Check elapsed time timer.start(); double delayTime = 10.0 / 1e3; sleep(delayTime); double result = timer.elapsed(); if (result-delayTime>timeVariance) { if (printFlag) { timerTest << "sleep time1: "<<std::fixed<<delayTime<<" failed: " << result << ">" << delayTime+timeVariance << std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } else if(delayTime-result > timeVariance) { if(printFlag) { timerTest << "sleep time2 failed: "<<std::fixed<<delayTime-result<<" > "<<timeVariance<<std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } //Test a longer sleep timer.start(); delayTime = 1.0; sleep(delayTime); result = timer.elapsed(); if (result-delayTime>timeVariance) { if(printFlag) { timerTest << "sleep time3: "<<std::fixed<<delayTime<<" failed: " << result << ">" << delayTime+timeVariance << std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } else if(delayTime-result > timeVariance) { if(printFlag) { timerTest << "sleep time4 failed("<<std::fixed<<result<<"): "<<delayTime-result<<" > "<<timeVariance<<std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } //Get timestamp int64_t tstamp = convertDoubleToTimeStamp( getTime()); if(printFlag) { timerTest << "Current timestamp: " << tstamp << endl; } timer.start(); result = timer.elapsed(); if(printFlag) { timerTest << "Timer since second start (can be 0 if less than 1 msec): " << result << endl; } double dTime = getTime(); SMPTETime smpte = convertDoubleToSMPTE( dTime, 30 ); if(printFlag) { //freopen("timerTest.log", "a+", stdout); printf( "SMPTETme: %2d:%2d:%2d, frame: %d\n" , smpte.hour , smpte.minute , smpte.second , smpte.frame ); } std::string timeStr = convertTimeValToString( convertDoubleToTimeVal( dTime ), 30 ); if(printFlag) { timerTest << "StringTime: " << timeStr.c_str() << endl; } int64_t timecode = convertTimeValToTimeCode( convertDoubleToTimeVal( dTime ), 30); if(printFlag) { timerTest << "TimeCode: " << timecode << endl; } ObjectId t1; ObjectId t2; t1.m_value = getTimestamp(); sleep(1); t2.m_value = getTimestamp(); ObjectId ref; ref.m_id = 0; ref.m_utc = 123132; for( int i = 0; i < 65535; i++ ) { ref.m_step = i; double r1 = convertObjectIdTimeToDouble(ref); ObjectId ref2 = convertDoubleToObjectIdTime( r1 ); if((ref.m_utc != ref2.m_utc)|| (ref.m_step - ref2.m_step > 1)|| (ref2.m_step - ref.m_step > 1)) { if(printFlag) { timerTest << "Time difference in conversion\n" << " "<<ref.m_step << "!= "<<ref2.m_step <<std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } } double time1 = convertObjectIdTimeToDouble(t1); // double time1 = (double)t1.m_utc + STEP_SIZE * (double)t1.m_step/(double)TIMER_STEP; double time2 = (double)t2.m_utc + STEP_SIZE * (double)t2.m_step/(double)TIMER_STEP; if( time2 - time1 > 1 + allowedDelay ) { if(printFlag) { timerTest << "Time difference is large. Expected 1.0 +/- "<<allowedDelay<<"\n" << " Actual: "<<time2<<"-"<<time1<<" = "<<time2 -time1 <<std::endl; cout << "Timer test failed. See TimerTest.log" << endl; } if (assertFlag) { assert(false); }; return false; } std::cout << "Should be date: "<<getDateAsString() << std::endl; std::system("rm TimerTest.log"); return true; }