Index: sources/canbus/MessageDispatcher.h =================================================================== diff -u -r38ae7b93679d05a54fc460dac68891562d7da72d -r630c0a7fe305de7fc1911df4022036c4b10e473e --- sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 38ae7b93679d05a54fc460dac68891562d7da72d) +++ sources/canbus/MessageDispatcher.h (.../MessageDispatcher.h) (revision 630c0a7fe305de7fc1911df4022036c4b10e473e) @@ -94,6 +94,16 @@ friend class ::tst_acknow; friend class ::tst_messaging; + /// throw away a + /// look for A5 in next which is b + // a + // b + // d + // 1 + // 2 + // 3 + + QHash _messageList; Sequence _txSequence = 0; Index: sources/storage/Logger.cpp =================================================================== diff -u -re6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09 -r630c0a7fe305de7fc1911df4022036c4b10e473e --- sources/storage/Logger.cpp (.../Logger.cpp) (revision e6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision 630c0a7fe305de7fc1911df4022036c4b10e473e) @@ -159,6 +159,8 @@ this , SLOT(onFlushLogsA())); connect(&_flushLogsWatcherD, SIGNAL(finished ()), this , SLOT(onFlushLogsD())); + connect(&_flushLogsWatcherT, SIGNAL(finished ()), + this , SLOT(onFlushLogsT())); connect(&_DeviceController, SIGNAL( didSDCardStateChange(bool, bool)), this , SLOT( onSDCardStateChange(bool, bool))); @@ -320,26 +322,26 @@ void Logger::logTimeout() { if( _cacheCounter ) { - _cacheCounter --; + _cacheCounter -- ; } else { - _cacheIndex = logSwitch(); // switch the index for caching while the flush is working - concurrentFlushLogA(); - concurrentFlushLogD(); - _cacheCounter = _cachetimeout; + _cacheIndexA = logSwitch(_cacheIndexA); // switch the index for caching while the flush is working + _cacheIndexD = logSwitch(_cacheIndexD); // switch the index for caching while the flush is working + concurrentFlushLogT(); + _cacheCounter = _cacheTimeout; } } bool Logger::logOverflow(LogType vLogType) { switch ( vLogType ) { - case eLogAppED : return _cacheA[_cacheIndex].count() >= _cacheCount; - case eLogDebug : return _cacheD[_cacheIndex].count() >= _cacheCount; - default : return _cacheD[_cacheIndex].count() >= _cacheCount; + case eLogAppED : return _cacheA[_cacheIndexA].count() >= _cacheCount; + case eLogDebug : return _cacheD[_cacheIndexD].count() >= _cacheCount; + default : return _cacheD[_cacheIndexD].count() >= _cacheCount; } } -int Logger::logSwitch() { - return _cacheIndex == eCache1 ? eCache2 : eCache1;; +int Logger::logSwitch(int vCacheIndex) { + return vCacheIndex == eCache1 ? eCache2 : eCache1;; } /*! @@ -366,18 +368,17 @@ // Add the recieved message switch ( vLogType ) { - case eLogAppED : _cacheA[_cacheIndex] += mContent; break; - case eLogDebug : _cacheD[_cacheIndex] += mContent; break; - default : _cacheD[_cacheIndex] += QString("Incorrect type of logging %1").arg(vLogType); - _cacheD[_cacheIndex] += mContent; break; + case eLogAppED : _cacheA[_cacheIndexA] += mContent; break; + case eLogDebug : _cacheD[_cacheIndexD] += mContent; break; + default : _cacheD[_cacheIndexD] += QString("Incorrect type of logging %1").arg(vLogType); + _cacheD[_cacheIndexD] += mContent; break; } if ( logOverflow(vLogType) ) { - _cacheIndex = logSwitch(); // switch the index for caching while the flush is working switch ( vLogType ) { - case eLogAppED : concurrentFlushLogA(); break; - case eLogDebug : concurrentFlushLogD(); break; - default : concurrentFlushLogD(); break; + case eLogAppED : _cacheIndexA = logSwitch(_cacheIndexA); concurrentFlushLogA(); break; + case eLogDebug : _cacheIndexD = logSwitch(_cacheIndexD); concurrentFlushLogD(); break; + default : _cacheIndexD = logSwitch(_cacheIndexD); concurrentFlushLogD(); break; } } @@ -402,7 +403,6 @@ //NOTE: the _cacheIndex has been (has to be) switched for the log to continue while we are in the temp thread to flush the log - QAtomicInt cacheIndex = logSwitch(); QString mContent; QDateTime datetime = QDateTime::currentDateTime(); int count = 0; @@ -423,9 +423,9 @@ // - Add content switch ( vLogType ) { - case eLogAppED : count = _cacheA[cacheIndex].count(); mContent += _cacheA[cacheIndex].join(_sepLines); _cacheA[cacheIndex].clear(); break; - case eLogDebug : count = _cacheD[cacheIndex].count(); mContent += _cacheD[cacheIndex].join(_sepLines); _cacheD[cacheIndex].clear(); break; - default : break; //TODO create another cacheType enum + case eLogAppED : { QAtomicInt cacheIndex = logSwitch(_cacheIndexA); count = _cacheA[cacheIndex].count(); mContent += _cacheA[cacheIndex].join(_sepLines); _cacheA[cacheIndex].clear(); } break; + case eLogDebug : { QAtomicInt cacheIndex = logSwitch(_cacheIndexD); count = _cacheD[cacheIndex].count(); mContent += _cacheD[cacheIndex].join(_sepLines); _cacheD[cacheIndex].clear(); } break; + default : { } break; //TODO create another cacheType enum } // - Make log file name @@ -498,6 +498,13 @@ return count; } +int Logger::flushTimeout() { + int count = 0; + count += flush(LogType::eLogAppED); + count += flush(LogType::eLogDebug); + return count; +} + /*! * \brief Logger::concurrentFlushLogs * \details Flushes the log buffer to the file in a separate thread @@ -506,9 +513,10 @@ */ bool Logger::concurrentFlushLogA() { + qDebug() << " - " << LogType::eLogAppED << " - " << _cacheIndexA; emit didFlushLogsA(true); _flushElapsedA.start(); - LOG_DEBUG("Flush app Logs Starting"); + log("Flush app Logs Starting",LogType::eLogDebug); QFuture mFuture = QtConcurrent::run(this, &Logger::flush, LogType::eLogAppED); _flushLogsWatcherA.setFuture(mFuture); return true; @@ -522,21 +530,33 @@ */ bool Logger::concurrentFlushLogD() { + qDebug() << " - " << LogType::eLogDebug << " - " << _cacheIndexD; emit didFlushLogsD(true); _flushElapsedD.start(); - LOG_DEBUG("Flush err Logs Starting"); + log("Flush err Logs Starting",LogType::eLogDebug); QFuture mFuture = QtConcurrent::run(this, &Logger::flush, LogType::eLogDebug); _flushLogsWatcherD.setFuture(mFuture); return true; } +bool Logger::concurrentFlushLogT() +{ + qDebug() << " - " << "Timeout" << " - " << _cacheIndexA << " - " << _cacheIndexD;; + emit didFlushLogsT(true); + _flushElapsedT.start(); + log("Flush Logs Timeout Starting",LogType::eLogDebug); + QFuture mFuture = QtConcurrent::run(this, &Logger::flushTimeout); + _flushLogsWatcherT.setFuture(mFuture); + return true; +} + /*! * \brief Logger::onRemoveLogs * \details Remove old logs notification slot which logs result of remove. */ void Logger::onFlushLogsA() { - LOG_DEBUG(tr("Flush app Logs Ended: %1,%2").arg(_flushLogsWatcherA.result()).arg(_flushElapsedA.elapsed())); + log(tr("Flush app Logs Ended: %1,%2").arg(_flushLogsWatcherA.result()).arg(_flushElapsedA.elapsed()),LogType::eLogDebug); emit didFlushLogsA(false); } @@ -546,11 +566,21 @@ */ void Logger::onFlushLogsD() { - LOG_DEBUG(tr("Flush err Logs Ended: %1,%2").arg(_flushLogsWatcherD.result()).arg(_flushElapsedD.elapsed())); + log(tr("Flush err Logs Ended: %1,%2").arg(_flushLogsWatcherD.result()).arg(_flushElapsedD.elapsed()),LogType::eLogDebug); emit didFlushLogsD(false); } /*! + * \brief Logger::onRemoveLogs + * \details Remove old logs notification slot which logs result of remove. + */ +void Logger::onFlushLogsT() +{ + log(tr("Flush Logs Timeout Ended: %1,%2").arg(_flushLogsWatcherT.result()).arg(_flushElapsedT.elapsed()),LogType::eLogDebug); + emit didFlushLogsT(false); +} + +/*! * \brief Logger::exportLogs * \details Exports the log files from log folder (Storage::Log_Base_Path_Name_Location) * into USB drive folder (Storage::USB_Mount_Point) Index: sources/storage/Logger.h =================================================================== diff -u -re6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09 -r630c0a7fe305de7fc1911df4022036c4b10e473e --- sources/storage/Logger.h (.../Logger.h) (revision e6ddf6840cdd5a09deaac1dcdcd7d70064dc6a09) +++ sources/storage/Logger.h (.../Logger.h) (revision 630c0a7fe305de7fc1911df4022036c4b10e473e) @@ -122,15 +122,16 @@ const char *_headerA = "TimeStamp,ID,SubSys,Name,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40"; const char *_headerD = "TimeStamp,Description"; - const quint16 _cachetimeout = 5 ; // seconds timeout until flushes, for slow traffics - quint16 _cacheCounter = _cachetimeout ; // seconds timeout counter - quint16 _cacheCount = 3000 ; // K message count - QAtomicInt _cacheIndex = eCache1; + const quint16 _cacheTimeout = 5 ; // seconds timeout until flushes, for slow traffics + quint16 _cacheCounter = _cacheTimeout ; // seconds timeout counter + quint16 _cacheCount = 2000 ; // K message count + QAtomicInt _cacheIndexA = eCache1; + QAtomicInt _cacheIndexD = eCache1; QStringList _cacheA[eCacheIndexCount]; QStringList _cacheD[eCacheIndexCount]; QElapsedTimer _flushElapsedA; QElapsedTimer _flushElapsedD; - + QElapsedTimer _flushElapsedT; QDir _dir; // The HSSerial is going to be the HD Serial always, @@ -211,6 +212,7 @@ QFutureWatcher _removeLogsWatcher; QFutureWatcher _flushLogsWatcherA; QFutureWatcher _flushLogsWatcherD; + QFutureWatcher _flushLogsWatcherT; QThread *_thread = nullptr; bool _init = false; @@ -333,6 +335,7 @@ */ void didFlushLogsA(bool vInProgress); void didFlushLogsD(bool vInProgress); + void didFlushLogsT(bool vInProgress); // ----- Available space is low private slots: @@ -346,14 +349,17 @@ void onLog (const QString &vContent, LogType vLogType, bool vTimestamp); bool concurrentFlushLogA(); bool concurrentFlushLogD(); + bool concurrentFlushLogT(); void onFlushLogsA(); void onFlushLogsD(); + void onFlushLogsT(); private: bool logOverflow (LogType vLogType); - int logSwitch (); + int logSwitch (int vCacheIndex); void logTimeout (); void log (const QString &vContent, LogType vLogType); int flush ( LogType vLogType); + int flushTimeout(); signals: /*!