Commit 1b324cff authored by dogmaphobic's avatar dogmaphobic

Added latest error message to Main Flight Display

parent d70464d8
...@@ -112,40 +112,41 @@ ...@@ -112,40 +112,41 @@
<file alias="FlightDisplay.qml">src/ui/flightdisplay/FlightDisplay.qml</file> <file alias="FlightDisplay.qml">src/ui/flightdisplay/FlightDisplay.qml</file>
<file alias="MapDisplay.qml">src/ui/mapdisplay/MapDisplay.qml</file> <file alias="MapDisplay.qml">src/ui/mapdisplay/MapDisplay.qml</file>
<!-- QML Main UI Components --> <!-- QML Main UI Components -->
<file alias="QGroundControl/FlightControls/qmldir">src/ui/qmlcommon/qmldir</file>
<file alias="QGroundControl/FlightControls/QGCAltitudeWidget.qml">src/ui/qmlcommon/QGCAltitudeWidget.qml</file> <file alias="QGroundControl/FlightControls/QGCAltitudeWidget.qml">src/ui/qmlcommon/QGCAltitudeWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeWidget.qml">src/ui/qmlcommon/QGCAttitudeWidget.qml</file> <file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeInstrument.qml">src/ui/qmlcommon/QGCAttitudeInstrument.qml</file> <file alias="QGroundControl/FlightControls/QGCAttitudeInstrument.qml">src/ui/qmlcommon/QGCAttitudeInstrument.qml</file>
<file alias="QGroundControl/FlightControls/QGCAttitudeWidget.qml">src/ui/qmlcommon/QGCAttitudeWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCCompass.qml">src/ui/qmlcommon/QGCCompass.qml</file> <file alias="QGroundControl/FlightControls/QGCCompass.qml">src/ui/qmlcommon/QGCCompass.qml</file>
<file alias="QGroundControl/FlightControls/QGCCompassInstrument.qml">src/ui/qmlcommon/QGCCompassInstrument.qml</file> <file alias="QGroundControl/FlightControls/QGCCompassInstrument.qml">src/ui/qmlcommon/QGCCompassInstrument.qml</file>
<file alias="QGroundControl/FlightControls/QGCCurrentAltitude.qml">src/ui/qmlcommon/QGCCurrentAltitude.qml</file> <file alias="QGroundControl/FlightControls/QGCCurrentAltitude.qml">src/ui/qmlcommon/QGCCurrentAltitude.qml</file>
<file alias="QGroundControl/FlightControls/QGCCurrentSpeed.qml">src/ui/qmlcommon/QGCCurrentSpeed.qml</file> <file alias="QGroundControl/FlightControls/QGCCurrentSpeed.qml">src/ui/qmlcommon/QGCCurrentSpeed.qml</file>
<file alias="QGroundControl/FlightControls/QGCHudMessage.qml">src/ui/qmlcommon/QGCHudMessage.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapBackground.qml">src/ui/qmlcommon/QGCMapBackground.qml</file> <file alias="QGroundControl/FlightControls/QGCMapBackground.qml">src/ui/qmlcommon/QGCMapBackground.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file>
<file alias="QGroundControl/FlightControls/QGCPitchWidget.qml">src/ui/qmlcommon/QGCPitchWidget.qml</file> <file alias="QGroundControl/FlightControls/QGCPitchWidget.qml">src/ui/qmlcommon/QGCPitchWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCSpeedWidget.qml">src/ui/qmlcommon/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCSlider.qml">src/ui/qmlcommon/QGCSlider.qml</file> <file alias="QGroundControl/FlightControls/QGCSlider.qml">src/ui/qmlcommon/QGCSlider.qml</file>
<file alias="QGroundControl/FlightControls/QGCSpeedWidget.qml">src/ui/qmlcommon/QGCSpeedWidget.qml</file>
<file alias="QGroundControl/FlightControls/QGCWaypointEditor.qml">src/ui/qmlcommon/QGCWaypointEditor.qml</file> <file alias="QGroundControl/FlightControls/QGCWaypointEditor.qml">src/ui/qmlcommon/QGCWaypointEditor.qml</file>
<file alias="QGroundControl/FlightControls/QGCMapToolButton.qml">src/ui/qmlcommon/QGCMapToolButton.qml</file> <file alias="QGroundControl/FlightControls/qmldir">src/ui/qmlcommon/qmldir</file>
<file alias="QGroundControl/FlightControls/QGCArtificialHorizon.qml">src/ui/qmlcommon/QGCArtificialHorizon.qml</file>
<!-- QML Map Resources --> <!-- QML Map Resources -->
<file alias="QGroundControl/FlightControls/QGCWaypoint.qml">src/ui/qmlcommon/QGCWaypoint.qml</file> <file alias="QGroundControl/FlightControls/QGCWaypoint.qml">src/ui/qmlcommon/QGCWaypoint.qml</file>
<!-- QML Main UI Resources --> <!-- QML Main UI Resources -->
<file alias="attitudeDial.svg">src/ui/qmlcommon/attitudeDial.svg</file>
<file alias="attitudeInstrument.svg">src/ui/qmlcommon/attitudeInstrument.svg</file>
<file alias="attitudePointer.svg">src/ui/qmlcommon/attitudePointer.svg</file>
<file alias="buttonHome.svg">src/ui/qmlcommon/buttonHome.svg</file>
<file alias="buttonLeft.svg">src/ui/qmlcommon/buttonLeft.svg</file>
<file alias="buttonMore.svg">src/ui/qmlcommon/buttonMore.svg</file>
<file alias="buttonRight.svg">src/ui/qmlcommon/buttonRight.svg</file>
<file alias="compass.svg">src/ui/qmlcommon/compass.svg</file> <file alias="compass.svg">src/ui/qmlcommon/compass.svg</file>
<file alias="compassInstrumentAirplane.svg">src/ui/qmlcommon/compassInstrumentAirplane.svg</file>
<file alias="compassInstrumentDial.svg">src/ui/qmlcommon/compassInstrumentDial.svg</file>
<file alias="compassNeedle.svg">src/ui/qmlcommon/compassNeedle.svg</file> <file alias="compassNeedle.svg">src/ui/qmlcommon/compassNeedle.svg</file>
<file alias="crossHair.svg">src/ui/qmlcommon/crossHair.svg</file> <file alias="crossHair.svg">src/ui/qmlcommon/crossHair.svg</file>
<file alias="rollDialWhite.svg">src/ui/qmlcommon/rollDialWhite.svg</file> <file alias="rollDialWhite.svg">src/ui/qmlcommon/rollDialWhite.svg</file>
<file alias="rollPointerWhite.svg">src/ui/qmlcommon/rollPointerWhite.svg</file> <file alias="rollPointerWhite.svg">src/ui/qmlcommon/rollPointerWhite.svg</file>
<file alias="scale.png">src/ui/qmlcommon/scale.png</file> <file alias="scale.png">src/ui/qmlcommon/scale.png</file>
<file alias="scale_end.png">src/ui/qmlcommon/scale_end.png</file> <file alias="scale_end.png">src/ui/qmlcommon/scale_end.png</file>
<file alias="buttonLeft.svg">src/ui/qmlcommon/buttonLeft.svg</file>
<file alias="buttonRight.svg">src/ui/qmlcommon/buttonRight.svg</file>
<file alias="buttonHome.svg">src/ui/qmlcommon/buttonHome.svg</file>
<file alias="buttonMore.svg">src/ui/qmlcommon/buttonMore.svg</file>
<file alias="attitudeInstrument.svg">src/ui/qmlcommon/attitudeInstrument.svg</file>
<file alias="attitudeDial.svg">src/ui/qmlcommon/attitudeDial.svg</file>
<file alias="attitudePointer.svg">src/ui/qmlcommon/attitudePointer.svg</file>
<file alias="compassInstrumentAirplane.svg">src/ui/qmlcommon/compassInstrumentAirplane.svg</file>
<file alias="compassInstrumentDial.svg">src/ui/qmlcommon/compassInstrumentDial.svg</file>
</qresource> </qresource>
<qresource prefix="/AutoPilotPlugins/PX4"> <qresource prefix="/AutoPilotPlugins/PX4">
......
...@@ -119,6 +119,7 @@ static QObject* screenToolsSingletonFactory(QQmlEngine*, QJSEngine*) ...@@ -119,6 +119,7 @@ static QObject* screenToolsSingletonFactory(QQmlEngine*, QJSEngine*)
static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*) static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
{ {
MavManager* mavManager = new MavManager; MavManager* mavManager = new MavManager;
qgcApp()->setMavManager(mavManager);
return mavManager; return mavManager;
} }
...@@ -133,10 +134,11 @@ static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*) ...@@ -133,10 +134,11 @@ static QObject* mavManagerSingletonFactory(QQmlEngine*, QJSEngine*)
**/ **/
QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
QApplication(argc, argv), : QApplication(argc, argv)
_runningUnitTests(unitTesting), , _runningUnitTests(unitTesting)
_styleIsDark(true) , _styleIsDark(true)
, _pMavManager(NULL)
{ {
Q_ASSERT(_app == NULL); Q_ASSERT(_app == NULL);
_app = this; _app = this;
...@@ -709,7 +711,19 @@ void QGCApplication::_missingParamsDisplay(void) ...@@ -709,7 +711,19 @@ void QGCApplication::_missingParamsDisplay(void)
} }
_missingParams.clear(); _missingParams.clear();
QGCMessageBox::critical("Missing Parameters", QGCMessageBox::critical(
"Missing Parameters",
QString("Parameters missing from firmware: %1.\n\n" QString("Parameters missing from firmware: %1.\n\n"
"You should quit QGroundControl immediately and update your firmware.").arg(params)); "You should quit QGroundControl immediately and update your firmware.").arg(params));
} }
void QGCApplication::setMavManager(MavManager* pMgr)
{
if(!_pMavManager)
_pMavManager = pMgr;
}
MavManager* QGCApplication::getMavManager()
{
return _pMavManager;
}
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
// Work around circular header includes // Work around circular header includes
class QGCSingleton; class QGCSingleton;
class MainWindow; class MainWindow;
class MavManager;
/** /**
* @brief The main application and management class. * @brief The main application and management class.
...@@ -100,6 +101,12 @@ public: ...@@ -100,6 +101,12 @@ public:
/// multiple times. /// multiple times.
void reportMissingParameter(int componentId, const QString& name); void reportMissingParameter(int componentId, const QString& name);
/// When the singleton is created, it sets a pointer for subsequent use
void setMavManager(MavManager* pMgr);
/// MavManager accessor
MavManager* getMavManager();
public slots: public slots:
/// You can connect to this slot to show an information message box from a different thread. /// You can connect to this slot to show an information message box from a different thread.
void informationMessageBoxOnMainThread(const QString& title, const QString& msg); void informationMessageBoxOnMainThread(const QString& title, const QString& msg);
...@@ -166,6 +173,7 @@ private: ...@@ -166,6 +173,7 @@ private:
static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display static const int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
QStringList _missingParams; ///< List of missing facts to be displayed QStringList _missingParams; ///< List of missing facts to be displayed
MavManager* _pMavManager;
/// Unit Test have access to creating and destroying singletons /// Unit Test have access to creating and destroying singletons
friend class UnitTest; friend class UnitTest;
......
...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,6 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASManager.h" #include "UASManager.h"
#include "Waypoint.h" #include "Waypoint.h"
#include "MavManager.h" #include "MavManager.h"
#include "UASMessageHandler.h"
#define UPDATE_TIMER 50 #define UPDATE_TIMER 50
#define DEFAULT_LAT 38.965767f #define DEFAULT_LAT 38.965767f
...@@ -40,6 +41,12 @@ This file is part of the QGROUNDCONTROL project ...@@ -40,6 +41,12 @@ This file is part of the QGROUNDCONTROL project
MavManager::MavManager(QObject *parent) MavManager::MavManager(QObject *parent)
: QObject(parent) : QObject(parent)
, _mav(NULL) , _mav(NULL)
, _currentMessageCount(0)
, _messageCount(0)
, _currentErrorCount(0)
, _currentWarningCount(0)
, _currentNormalCount(0)
, _currentMessageType(MessageNone)
, _roll(0.0f) , _roll(0.0f)
, _pitch(0.0f) , _pitch(0.0f)
, _heading(0.0f) , _heading(0.0f)
...@@ -99,6 +106,8 @@ QString MavManager::loadSetting(const QString &name, const QString& defaultValue ...@@ -99,6 +106,8 @@ QString MavManager::loadSetting(const QString &name, const QString& defaultValue
void MavManager::_forgetUAS(UASInterface* uas) void MavManager::_forgetUAS(UASInterface* uas)
{ {
if (_mav != NULL && _mav == uas) { if (_mav != NULL && _mav == uas) {
// Stop listening for system messages
disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage);
// Disconnect any previously connected active MAV // Disconnect any previously connected active MAV
disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64))); disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64)));
disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64))); disconnect(_mav, SIGNAL(attitudeChanged (UASInterface*, int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64)));
...@@ -149,6 +158,8 @@ void MavManager::_setActiveUAS(UASInterface* uas) ...@@ -149,6 +158,8 @@ void MavManager::_setActiveUAS(UASInterface* uas)
emit heartbeatTimeoutChanged(); emit heartbeatTimeoutChanged();
// Set new UAS // Set new UAS
_mav = uas; _mav = uas;
// Listen for system messages
connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MavManager::_handleTextMessage);
// Now connect the new UAS // Now connect the new UAS
connect(_mav, SIGNAL(attitudeChanged (UASInterface*,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64))); connect(_mav, SIGNAL(attitudeChanged (UASInterface*,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*, double, double, double, quint64)));
connect(_mav, SIGNAL(attitudeChanged (UASInterface*,int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64))); connect(_mav, SIGNAL(attitudeChanged (UASInterface*,int,double,double,double,quint64)), this, SLOT(_updateAttitude(UASInterface*,int,double, double, double, quint64)));
...@@ -637,3 +648,87 @@ void MavManager::_waypointViewOnlyListChanged() ...@@ -637,3 +648,87 @@ void MavManager::_waypointViewOnlyListChanged()
*/ */
} }
} }
void MavManager::_handleTextMessage(int newCount)
{
// Reset?
if(!newCount) {
_currentMessageCount = 0;
_currentNormalCount = 0;
_currentWarningCount = 0;
_currentErrorCount = 0;
_messageCount = 0;
_currentMessageType = MessageNone;
emit newMessageCountChanged();
emit messageTypeChanged();
emit messageCountChanged();
return;
}
UASMessageHandler* pMh = UASMessageHandler::instance();
Q_ASSERT(pMh);
MessageType_t type = newCount ? _currentMessageType : MessageNone;
int errorCount = _currentErrorCount;
int warnCount = _currentWarningCount;
int normalCount = _currentNormalCount;
//-- Add current message counts
errorCount += pMh->getErrorCount();
warnCount += pMh->getWarningCount();
normalCount += pMh->getNormalCount();
//-- See if we have a higher level
if(errorCount != _currentErrorCount) {
_currentErrorCount = errorCount;
type = MessageError;
}
if(warnCount != _currentWarningCount) {
_currentWarningCount = warnCount;
if(_currentMessageType != MessageError) {
type = MessageWarning;
}
}
if(normalCount != _currentNormalCount) {
_currentNormalCount = normalCount;
if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) {
type = MessageNormal;
}
}
int count = _currentErrorCount + _currentWarningCount + _currentNormalCount;
if(count != _currentMessageCount) {
_currentMessageCount = count;
// Display current total new messages count
emit newMessageCountChanged();
}
if(type != _currentMessageType) {
_currentMessageType = type;
// Update message level
emit messageTypeChanged();
}
// Update message count (all messages)
if(newCount != _messageCount) {
_messageCount = newCount;
emit messageCountChanged();
}
QString errMsg = pMh->getLatestError();
if(errMsg != _latestError) {
_latestError = errMsg;
emit latestErrorChanged();
}
}
void MavManager::resetMessages()
{
// Reset Counts
int count = _currentMessageCount;
MessageType_t type = _currentMessageType;
_currentErrorCount = 0;
_currentWarningCount = 0;
_currentNormalCount = 0;
_currentMessageCount = 0;
_currentMessageType = MessageNone;
if(count != _currentMessageCount) {
emit newMessageCountChanged();
}
if(type != _currentMessageType) {
emit messageTypeChanged();
}
}
...@@ -46,6 +46,13 @@ public: ...@@ -46,6 +46,13 @@ public:
explicit MavManager(QObject *parent = 0); explicit MavManager(QObject *parent = 0);
~MavManager(); ~MavManager();
typedef enum {
MessageNone,
MessageNormal,
MessageWarning,
MessageError
} MessageType_t;
enum { enum {
ROLL_CHANGED, ROLL_CHANGED,
PITCH_CHANGED, PITCH_CHANGED,
...@@ -58,10 +65,19 @@ public: ...@@ -58,10 +65,19 @@ public:
ALTITUDEAMSL_CHANGED ALTITUDEAMSL_CHANGED
}; };
// Called when the message drop-down is invoked to clear current count
void resetMessages();
Q_INVOKABLE QString getMavIconColor(); Q_INVOKABLE QString getMavIconColor();
Q_INVOKABLE void saveSetting (const QString &key, const QString& value); Q_INVOKABLE void saveSetting (const QString &key, const QString& value);
Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue); Q_INVOKABLE QString loadSetting (const QString &key, const QString& defaultValue);
//-- System Messages
Q_PROPERTY(MessageType_t messageType READ messageType NOTIFY messageTypeChanged)
Q_PROPERTY(int newMessageCount READ newMessageCount NOTIFY newMessageCountChanged)
Q_PROPERTY(int messageCount READ messageCount NOTIFY messageCountChanged)
Q_PROPERTY(QString latestError READ latestError NOTIFY latestErrorChanged)
//-- UAV Stats
Q_PROPERTY(float roll READ roll NOTIFY rollChanged) Q_PROPERTY(float roll READ roll NOTIFY rollChanged)
Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged) Q_PROPERTY(float pitch READ pitch NOTIFY pitchChanged)
Q_PROPERTY(float heading READ heading NOTIFY headingChanged) Q_PROPERTY(float heading READ heading NOTIFY headingChanged)
...@@ -87,8 +103,13 @@ public: ...@@ -87,8 +103,13 @@ public:
Q_PROPERTY(double waypointDistance READ waypointDistance NOTIFY waypointDistanceChanged) Q_PROPERTY(double waypointDistance READ waypointDistance NOTIFY waypointDistanceChanged)
Q_PROPERTY(uint16_t currentWaypoint READ currentWaypoint NOTIFY currentWaypointChanged) Q_PROPERTY(uint16_t currentWaypoint READ currentWaypoint NOTIFY currentWaypointChanged)
Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged) Q_PROPERTY(unsigned int heartbeatTimeout READ heartbeatTimeout NOTIFY heartbeatTimeoutChanged)
//-- Waypoint management
Q_PROPERTY(QQmlListProperty<Waypoint> waypoints READ waypoints NOTIFY waypointsChanged) Q_PROPERTY(QQmlListProperty<Waypoint> waypoints READ waypoints NOTIFY waypointsChanged)
MessageType_t messageType () { return _currentMessageType; }
int newMessageCount () { return _currentMessageCount; }
int messageCount () { return _messageCount; }
QString latestError () { return _latestError; }
float roll () { return _roll; } float roll () { return _roll; }
float pitch () { return _pitch; } float pitch () { return _pitch; }
float heading () { return _heading; } float heading () { return _heading; }
...@@ -118,6 +139,10 @@ public: ...@@ -118,6 +139,10 @@ public:
QQmlListProperty<Waypoint> waypoints() {return QQmlListProperty<Waypoint>(this, _waypoints); } QQmlListProperty<Waypoint> waypoints() {return QQmlListProperty<Waypoint>(this, _waypoints); }
signals: signals:
void messageTypeChanged ();
void newMessageCountChanged ();
void messageCountChanged ();
void latestErrorChanged ();
void rollChanged (); void rollChanged ();
void pitchChanged (); void pitchChanged ();
void headingChanged (); void headingChanged ();
...@@ -147,6 +172,7 @@ signals: ...@@ -147,6 +172,7 @@ signals:
void waypointsChanged (); void waypointsChanged ();
private slots: private slots:
void _handleTextMessage (int newCount);
/** @brief Attitude from main autopilot / system state */ /** @brief Attitude from main autopilot / system state */
void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp); void _updateAttitude (UASInterface* uas, double roll, double pitch, double yaw, quint64 timestamp);
/** @brief Attitude from one specific component / redundant autopilot */ /** @brief Attitude from one specific component / redundant autopilot */
...@@ -182,6 +208,13 @@ private: ...@@ -182,6 +208,13 @@ private:
private: private:
UASInterface* _mav; UASInterface* _mav;
int _currentMessageCount;
int _messageCount;
int _currentErrorCount;
int _currentWarningCount;
int _currentNormalCount;
MessageType_t _currentMessageType;
QString _latestError;
float _roll; float _roll;
float _pitch; float _pitch;
float _heading; float _heading;
......
...@@ -163,6 +163,17 @@ void UASMessageHandler::handleTextMessage(int, int compId, int severity, QString ...@@ -163,6 +163,17 @@ 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)
{
case MAV_SEVERITY_EMERGENCY:
case MAV_SEVERITY_ALERT:
case MAV_SEVERITY_CRITICAL:
case MAV_SEVERITY_ERROR:
_latestError = severityText + " " + text;
break;
default:
break;
}
_mutex.unlock(); _mutex.unlock();
emit textMessageReceived(message); emit textMessageReceived(message);
emit textMessageCountChanged(count); emit textMessageCountChanged(count);
......
...@@ -107,6 +107,10 @@ public: ...@@ -107,6 +107,10 @@ public:
* @brief Get normal message count (Resets count once read) * @brief Get normal message count (Resets count once read)
*/ */
int getNormalCount(); int getNormalCount();
/**
* @brief Get latest error message
*/
QString getLatestError() { return _latestError; }
public slots: public slots:
/** /**
* @brief Set currently active UAS * @brief Set currently active UAS
...@@ -140,6 +144,7 @@ private: ...@@ -140,6 +144,7 @@ private:
int _errorCount; int _errorCount;
int _warningCount; int _warningCount;
int _normalCount; int _normalCount;
QString _latestError;
}; };
#endif // QGCMESSAGEHANDLER_H #endif // QGCMESSAGEHANDLER_H
...@@ -487,6 +487,15 @@ Item { ...@@ -487,6 +487,15 @@ Item {
z: 10 z: 10
} }
QGCHudMessage {
id: hudMessage
y: ScreenTools.pixelSizeFactor * (5)
width: (parent.width - 520 > 200) ? parent.width - 520 : 200
height: ScreenTools.pixelSizeFactor * (30)
anchors.horizontalCenter: parent.horizontalCenter
z: mapBackground.z + 1
}
QGCCompassInstrument { QGCCompassInstrument {
id: compassInstrument id: compassInstrument
y: ScreenTools.pixelSizeFactor * (5) y: ScreenTools.pixelSizeFactor * (5)
...@@ -494,7 +503,7 @@ Item { ...@@ -494,7 +503,7 @@ Item {
size: ScreenTools.pixelSizeFactor * (160) size: ScreenTools.pixelSizeFactor * (160)
heading: isNaN(MavManager.heading) ? 0 : MavManager.heading heading: isNaN(MavManager.heading) ? 0 : MavManager.heading
visible: mapBackground.visible && showCompass visible: mapBackground.visible && showCompass
z: mapBackground.z + 1 z: mapBackground.z + 2
onResetRequested: { onResetRequested: {
y = ScreenTools.pixelSizeFactor * (5) y = ScreenTools.pixelSizeFactor * (5)
x = ScreenTools.pixelSizeFactor * (85) x = ScreenTools.pixelSizeFactor * (85)
...@@ -514,7 +523,7 @@ Item { ...@@ -514,7 +523,7 @@ Item {
visible: mapBackground.visible && showAttitudeIndicator visible: mapBackground.visible && showAttitudeIndicator
anchors.right: root.right anchors.right: root.right
anchors.rightMargin: ScreenTools.pixelSizeFactor * (85) anchors.rightMargin: ScreenTools.pixelSizeFactor * (85)
z: mapBackground.z + 1 z: mapBackground.z + 2
onResetRequested: { onResetRequested: {
y = ScreenTools.pixelSizeFactor * (5) y = ScreenTools.pixelSizeFactor * (5)
anchors.right = root.right anchors.right = root.right
...@@ -531,7 +540,6 @@ Item { ...@@ -531,7 +540,6 @@ Item {
rollAngle: roll rollAngle: roll
pitchAngle: pitch pitchAngle: pitch
visible: !mapBackground.visible visible: !mapBackground.visible
z: 10
} }
QGCAttitudeWidget { QGCAttitudeWidget {
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief QGC HUD Message
* @author Gus Grubba <mavlink@grubba.com>
*/
import QtQuick 2.4
import QtQuick.Controls 1.3
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.MavManager 1.0
Item {
id: root
visible: MavManager.latestError !== ''
Rectangle {
anchors.fill: parent
color: Qt.rgba(0,0,0,0.75)
border.color: Qt.rgba(1,1,1,0.75)
radius: 4
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
font.weight: Font.DemiBold
text: MavManager.latestError
color: "#f84444"
}
OpacityAnimator {
id: vanish
target: root;
from: 1;
to: 0;
duration: 2000
running: false
}
}
Timer {
id: vanishTimer
interval: 30000
running: false
repeat: false
onTriggered: {
vanish.start();
}
}
MouseArea {
anchors.fill: parent
z: 1000
acceptedButtons: Qt.LeftButton
onClicked: {
if (mouse.button == Qt.LeftButton)
{
vanishTimer.stop();
vanish.stop();
root.opacity = 0;
}
}
}
Connections {
target: MavManager
onLatestErrorChanged: {
vanishTimer.stop();
vanish.stop();
vanishTimer.start();
root.opacity = 1;
}
}
}
...@@ -15,3 +15,4 @@ QGCAttitudeInstrument 1.0 QGCAttitudeInstrument.qml ...@@ -15,3 +15,4 @@ QGCAttitudeInstrument 1.0 QGCAttitudeInstrument.qml
QGCCompassInstrument 1.0 QGCCompassInstrument.qml QGCCompassInstrument 1.0 QGCCompassInstrument.qml
QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml
QGCWaypoint 1.0 QGCWaypoint.qml QGCWaypoint 1.0 QGCWaypoint.qml
QGCHudMessage 1.0 QGCHudMessage.qml
...@@ -32,9 +32,11 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,9 +32,11 @@ This file is part of the QGROUNDCONTROL project
#include "MainToolBar.h" #include "MainToolBar.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "UASMessageHandler.h"
#include "UASMessageView.h" #include "UASMessageView.h"
#include "UASMessageHandler.h"
#include "FlightDisplay.h" #include "FlightDisplay.h"
#include "QGCApplication.h"
#include "MavManager.h"
MainToolBar::MainToolBar(QWidget* parent) MainToolBar::MainToolBar(QWidget* parent)
: QGCQmlWidgetHolder(parent) : QGCQmlWidgetHolder(parent)
...@@ -42,12 +44,6 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -42,12 +44,6 @@ MainToolBar::MainToolBar(QWidget* parent)
, _toolBar(NULL) , _toolBar(NULL)
, _currentView(ViewNone) , _currentView(ViewNone)
, _connectionCount(0) , _connectionCount(0)
, _currentMessageCount(0)
, _messageCount(0)
, _currentErrorCount(0)
, _currentWarningCount(0)
, _currentNormalCount(0)
, _currentMessageType(MessageNone)
, _showGPS(true) , _showGPS(true)
, _showMav(true) , _showMav(true)
, _showMessages(true) , _showMessages(true)
...@@ -215,20 +211,8 @@ void MainToolBar::onEnterMessageArea(int x, int y) ...@@ -215,20 +211,8 @@ void MainToolBar::onEnterMessageArea(int x, int y)
// If not already there and messages are actually present // If not already there and messages are actually present
if(!_rollDownMessages && UASMessageHandler::instance()->messages().count()) if(!_rollDownMessages && UASMessageHandler::instance()->messages().count())
{ {
// Reset Counts if(qgcApp()->getMavManager())
int count = _currentMessageCount; qgcApp()->getMavManager()->resetMessages();
MessageType_t type = _currentMessageType;
_currentErrorCount = 0;
_currentWarningCount = 0;
_currentNormalCount = 0;
_currentMessageCount = 0;
_currentMessageType = MessageNone;
if(count != _currentMessageCount) {
emit newMessageCountChanged(0);
}
if(type != _currentMessageType) {
emit messageTypeChanged(MessageNone);
}
// Show messages // Show messages
int dialogWidth = 400; int dialogWidth = 400;
x = x - (dialogWidth >> 1); x = x - (dialogWidth >> 1);
...@@ -280,7 +264,6 @@ void MainToolBar::setCurrentView(int currentView) ...@@ -280,7 +264,6 @@ void MainToolBar::setCurrentView(int currentView)
void MainToolBar::_forgetUAS(UASInterface* uas) void MainToolBar::_forgetUAS(UASInterface* uas)
{ {
if (_mav != NULL && _mav == uas) { if (_mav != NULL && _mav == uas) {
disconnect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage);
disconnect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged); disconnect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged);
disconnect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue); disconnect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue);
_mav = NULL; _mav = NULL;
...@@ -300,7 +283,6 @@ void MainToolBar::_setActiveUAS(UASInterface* active) ...@@ -300,7 +283,6 @@ void MainToolBar::_setActiveUAS(UASInterface* active)
_mav = active; _mav = active;
if (_mav) if (_mav)
{ {
connect(UASMessageHandler::instance(), &UASMessageHandler::textMessageCountChanged, this, &MainToolBar::_handleTextMessage);
connect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged); connect(_mav, &UASInterface::remoteControlRSSIChanged, this, &MainToolBar::_remoteControlRSSIChanged);
connect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue); connect(AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_mav).data(), &AutoPilotPlugin::parameterListProgress, this, &MainToolBar::_setProgressBarValue);
} }
...@@ -401,67 +383,6 @@ void MainToolBar::_updateConnection(LinkInterface *disconnectedLink) ...@@ -401,67 +383,6 @@ void MainToolBar::_updateConnection(LinkInterface *disconnectedLink)
} }
} }
void MainToolBar::_handleTextMessage(int newCount)
{
// Reset?
if(!newCount) {
_currentMessageCount = 0;
_currentNormalCount = 0;
_currentWarningCount = 0;
_currentErrorCount = 0;
_messageCount = 0;
_currentMessageType = MessageNone;
emit newMessageCountChanged(0);
emit messageTypeChanged(MessageNone);
emit messageCountChanged(0);
return;
}
UASMessageHandler* pMh = UASMessageHandler::instance();
Q_ASSERT(pMh);
MessageType_t type = newCount ? _currentMessageType : MessageNone;
int errorCount = _currentErrorCount;
int warnCount = _currentWarningCount;
int normalCount = _currentNormalCount;
//-- Add current message counts
errorCount += pMh->getErrorCount();
warnCount += pMh->getWarningCount();
normalCount += pMh->getNormalCount();
//-- See if we have a higher level
if(errorCount != _currentErrorCount) {
_currentErrorCount = errorCount;
type = MessageError;
}
if(warnCount != _currentWarningCount) {
_currentWarningCount = warnCount;
if(_currentMessageType != MessageError) {
type = MessageWarning;
}
}
if(normalCount != _currentNormalCount) {
_currentNormalCount = normalCount;
if(_currentMessageType != MessageError && _currentMessageType != MessageWarning) {
type = MessageNormal;
}
}
int count = _currentErrorCount + _currentWarningCount + _currentNormalCount;
if(count != _currentMessageCount) {
_currentMessageCount = count;
// Display current total new messages count
emit newMessageCountChanged(count);
}
if(type != _currentMessageType) {
_currentMessageType = type;
// Update message level
emit messageTypeChanged(type);
}
// Update message count (all messages)
if(newCount != _messageCount) {
_messageCount = newCount;
emit messageCountChanged(_messageCount);
}
}
void MainToolBar::_setProgressBarValue(float value) void MainToolBar::_setProgressBarValue(float value)
{ {
_progressBarValue = value; _progressBarValue = value;
......
...@@ -47,17 +47,7 @@ class MainToolBar : public QGCQmlWidgetHolder ...@@ -47,17 +47,7 @@ class MainToolBar : public QGCQmlWidgetHolder
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(ViewType_t) Q_ENUMS(ViewType_t)
Q_ENUMS(MessageType_t)
public: public:
MainToolBar(QWidget* parent = NULL);
~MainToolBar();
typedef enum {
MessageNone,
MessageNormal,
MessageWarning,
MessageError
} MessageType_t;
typedef enum { typedef enum {
ViewNone = -1, ViewNone = -1,
...@@ -67,6 +57,9 @@ public: ...@@ -67,6 +57,9 @@ public:
ViewSetup , // MainWindow::VIEW_SETUP ViewSetup , // MainWindow::VIEW_SETUP
} ViewType_t; } ViewType_t;
MainToolBar(QWidget* parent = NULL);
~MainToolBar();
Q_INVOKABLE void onSetupView(); Q_INVOKABLE void onSetupView();
Q_INVOKABLE void onPlanView(); Q_INVOKABLE void onPlanView();
Q_INVOKABLE void onFlyView(); Q_INVOKABLE void onFlyView();
...@@ -78,9 +71,6 @@ public: ...@@ -78,9 +71,6 @@ public:
Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged) Q_PROPERTY(ViewType_t currentView MEMBER _currentView NOTIFY currentViewChanged)
Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged) Q_PROPERTY(QStringList configList MEMBER _linkConfigurations NOTIFY configListChanged)
Q_PROPERTY(MessageType_t messageType MEMBER _currentMessageType NOTIFY messageTypeChanged)
Q_PROPERTY(int newMessageCount MEMBER _currentMessageCount NOTIFY newMessageCountChanged)
Q_PROPERTY(int messageCount MEMBER _messageCount NOTIFY messageCountChanged)
Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged) Q_PROPERTY(int connectionCount READ connectionCount NOTIFY connectionCountChanged)
Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged) Q_PROPERTY(QStringList connectedList MEMBER _connectedList NOTIFY connectedListChanged)
Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged) Q_PROPERTY(bool showGPS MEMBER _showGPS NOTIFY showGPSChanged)
...@@ -104,9 +94,6 @@ signals: ...@@ -104,9 +94,6 @@ signals:
void connectionCountChanged (int count); void connectionCountChanged (int count);
void currentViewChanged (); void currentViewChanged ();
void configListChanged (); void configListChanged ();
void messageTypeChanged (MessageType_t type);
void newMessageCountChanged (int count);
void messageCountChanged (int count);
void connectedListChanged (QStringList connectedList); void connectedListChanged (QStringList connectedList);
void showGPSChanged (bool value); void showGPSChanged (bool value);
void showMavChanged (bool value); void showMavChanged (bool value);
...@@ -124,7 +111,6 @@ private slots: ...@@ -124,7 +111,6 @@ private slots:
void _updateConfigurations (); void _updateConfigurations ();
void _linkConnected (LinkInterface* link); void _linkConnected (LinkInterface* link);
void _linkDisconnected (LinkInterface* link); void _linkDisconnected (LinkInterface* link);
void _handleTextMessage (int newCount);
void _leaveMessageView (); void _leaveMessageView ();
void _setProgressBarValue (float value); void _setProgressBarValue (float value);
void _updatePixelSize (); void _updatePixelSize ();
...@@ -141,12 +127,6 @@ private: ...@@ -141,12 +127,6 @@ private:
ViewType_t _currentView; ViewType_t _currentView;
QStringList _linkConfigurations; QStringList _linkConfigurations;
int _connectionCount; int _connectionCount;
int _currentMessageCount;
int _messageCount;
int _currentErrorCount;
int _currentWarningCount;
int _currentNormalCount;
MessageType_t _currentMessageType;
QStringList _connectedList; QStringList _connectedList;
bool _showGPS; bool _showGPS;
bool _showMav; bool _showMav;
......
...@@ -64,20 +64,20 @@ Rectangle { ...@@ -64,20 +64,20 @@ Rectangle {
} }
function getMessageColor() { function getMessageColor() {
if(mainToolBar.messageType === MainToolBar.MessageNone) if(MavManager.messageType === MavManager.MessageNone)
return qgcPal.button; return qgcPal.button;
if(mainToolBar.messageType === MainToolBar.MessageNormal) if(MavManager.messageType === MavManager.MessageNormal)
return colorBlue; return colorBlue;
if(mainToolBar.messageType === MainToolBar.MessageWarning) if(MavManager.messageType === MavManager.MessageWarning)
return colorOrange; return colorOrange;
if(mainToolBar.messageType === MainToolBar.MessageError) if(MavManager.messageType === MavManager.MessageError)
return colorRed; return colorRed;
// Cannot be so make make it obnoxious to show error // Cannot be so make make it obnoxious to show error
return "purple"; return "purple";
} }
function getMessageIcon() { function getMessageIcon() {
if(mainToolBar.messageType === MainToolBar.MessageNormal || mainToolBar.messageType === MainToolBar.MessageNone) if(MavManager.messageType === MavManager.MessageNormal || MavManager.messageType === MavManager.MessageNone)
return "qrc:/res/Megaphone"; return "qrc:/res/Megaphone";
else else
return "qrc:/res/Yield"; return "qrc:/res/Yield";
...@@ -311,7 +311,7 @@ Rectangle { ...@@ -311,7 +311,7 @@ Rectangle {
Rectangle { Rectangle {
id: messages id: messages
width: (mainToolBar.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60) width: (MavManager.messageCount > 99) ? getProportionalDimmension(65) : getProportionalDimmension(60)
height: cellHeight height: cellHeight
visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages) visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -337,7 +337,7 @@ Rectangle { ...@@ -337,7 +337,7 @@ Rectangle {
width: messages.width - messageIcon.width width: messages.width - messageIcon.width
QGCLabel { QGCLabel {
id: messageText id: messageText
text: (mainToolBar.messageCount > 0) ? mainToolBar.messageCount : '' text: (MavManager.messageCount > 0) ? MavManager.messageCount : ''
font.pointSize: ScreenTools.fontPointFactor * (14); font.pointSize: ScreenTools.fontPointFactor * (14);
font.weight: Font.DemiBold font.weight: Font.DemiBold
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
...@@ -350,7 +350,7 @@ Rectangle { ...@@ -350,7 +350,7 @@ Rectangle {
Image { Image {
id: dropDown id: dropDown
source: "QGroundControl/Controls/arrow-down.png" source: "QGroundControl/Controls/arrow-down.png"
visible: (messages.showTriangle) && (mainToolBar.messageCount > 0) visible: (messages.showTriangle) && (MavManager.messageCount > 0)
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
anchors.bottomMargin: getProportionalDimmension(3) anchors.bottomMargin: getProportionalDimmension(3)
......
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