Commit bfc40123 authored by Lorenz Meier's avatar Lorenz Meier

Message handler: Retain total count

parent 8b7bc4ad
...@@ -57,6 +57,7 @@ UASMessageHandler::UASMessageHandler(QObject *parent) ...@@ -57,6 +57,7 @@ UASMessageHandler::UASMessageHandler(QObject *parent)
: QGCSingleton(parent) : QGCSingleton(parent)
, _activeUAS(NULL) , _activeUAS(NULL)
, _errorCount(0) , _errorCount(0)
, _errorCountTotal(0)
, _warningCount(0) , _warningCount(0)
, _normalCount(0) , _normalCount(0)
{ {
...@@ -125,6 +126,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -125,6 +126,7 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
//Use set RGB values from given color from QGC //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()); style = QString("color: rgb(%1, %2, %3); font-weight:bold").arg(QGC::colorRed.red()).arg(QGC::colorRed.green()).arg(QGC::colorRed.blue());
_errorCount++; _errorCount++;
_errorCountTotal++;
break; break;
case MAV_SEVERITY_NOTICE: case MAV_SEVERITY_NOTICE:
case MAV_SEVERITY_WARNING: case MAV_SEVERITY_WARNING:
...@@ -176,22 +178,21 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -176,22 +178,21 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString
message->_setFormatedText(QString("<p style=\"color:#CCCCCC\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text)); message->_setFormatedText(QString("<p style=\"color:#CCCCCC\">[%2 - COMP:%3]<font style=\"%1\">%4 %5</font></p>").arg(style).arg(dateString).arg(compId).arg(severityText).arg(text));
_messages.append(message); _messages.append(message);
int count = _messages.count(); int count = _messages.count();
switch (severity) if (message->severityIsError()) {
{
case MAV_SEVERITY_EMERGENCY:
case MAV_SEVERITY_ALERT:
case MAV_SEVERITY_CRITICAL:
case MAV_SEVERITY_ERROR:
_latestError = severityText + " " + text; _latestError = severityText + " " + text;
break;
default:
break;
} }
_mutex.unlock(); _mutex.unlock();
emit textMessageReceived(message); emit textMessageReceived(message);
emit textMessageCountChanged(count); emit textMessageCountChanged(count);
} }
int UASMessageHandler::getErrorCountTotal() {
_mutex.lock();
int c = _errorCountTotal;
_mutex.unlock();
return c;
}
int UASMessageHandler::getErrorCount() { int UASMessageHandler::getErrorCount() {
_mutex.lock(); _mutex.lock();
int c = _errorCount; int c = _errorCount;
......
...@@ -104,6 +104,10 @@ public: ...@@ -104,6 +104,10 @@ public:
* @brief Get error message count (Resets count once read) * @brief Get error message count (Resets count once read)
*/ */
int getErrorCount(); int getErrorCount();
/**
* @brief Get error message count (never reset)
*/
int getErrorCountTotal();
/** /**
* @brief Get warning message count (Resets count once read) * @brief Get warning message count (Resets count once read)
*/ */
...@@ -147,6 +151,7 @@ private: ...@@ -147,6 +151,7 @@ private:
QVector<UASMessage*> _messages; QVector<UASMessage*> _messages;
QMutex _mutex; QMutex _mutex;
int _errorCount; int _errorCount;
int _errorCountTotal;
int _warningCount; int _warningCount;
int _normalCount; int _normalCount;
QString _latestError; QString _latestError;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment