From bfc401234ab5306c50de39725619175f69b1e87f Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 6 Aug 2015 22:54:34 +0200 Subject: [PATCH] Message handler: Retain total count --- src/uas/UASMessageHandler.cc | 19 ++++++++++--------- src/uas/UASMessageHandler.h | 5 +++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/uas/UASMessageHandler.cc b/src/uas/UASMessageHandler.cc index 926f5183b..69ddbfa31 100644 --- a/src/uas/UASMessageHandler.cc +++ b/src/uas/UASMessageHandler.cc @@ -57,6 +57,7 @@ UASMessageHandler::UASMessageHandler(QObject *parent) : QGCSingleton(parent) , _activeUAS(NULL) , _errorCount(0) + , _errorCountTotal(0) , _warningCount(0) , _normalCount(0) { @@ -125,6 +126,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString //Use set RGB values from given color from QGC style = QString("color: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorRed.red()).arg(QGC::colorRed.green()).arg(QGC::colorRed.blue()); _errorCount++; + _errorCountTotal++; break; case MAV_SEVERITY_NOTICE: case MAV_SEVERITY_WARNING: @@ -176,22 +178,21 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString message->_setFormatedText(QString("

[%2 - COMP:%3]%4 %5

").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text)); _messages.append(message); int count = _messages.count(); - switch (severity) - { - case MAV_SEVERITY_EMERGENCY: - case MAV_SEVERITY_ALERT: - case MAV_SEVERITY_CRITICAL: - case MAV_SEVERITY_ERROR: + if (message->severityIsError()) { _latestError = severityText + " " + text; - break; - default: - break; } _mutex.unlock(); emit textMessageReceived(message); emit textMessageCountChanged(count); } +int UASMessageHandler::getErrorCountTotal() { + _mutex.lock(); + int c = _errorCountTotal; + _mutex.unlock(); + return c; +} + int UASMessageHandler::getErrorCount() { _mutex.lock(); int c = _errorCount; diff --git a/src/uas/UASMessageHandler.h b/src/uas/UASMessageHandler.h index 00300fc42..082ec07e7 100644 --- a/src/uas/UASMessageHandler.h +++ b/src/uas/UASMessageHandler.h @@ -104,6 +104,10 @@ public: * @brief Get error message count (Resets count once read) */ int getErrorCount(); + /** + * @brief Get error message count (never reset) + */ + int getErrorCountTotal(); /** * @brief Get warning message count (Resets count once read) */ @@ -147,6 +151,7 @@ private: QVector _messages; QMutex _mutex; int _errorCount; + int _errorCountTotal; int _warningCount; int _normalCount; QString _latestError; -- 2.22.0