QGCMAVLinkInspector.h 1.85 KB
Newer Older
lm's avatar
lm committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#ifndef QGCMAVLINKINSPECTOR_H
#define QGCMAVLINKINSPECTOR_H

#include <QWidget>
#include <QMap>
#include <QTimer>

#include "MAVLinkProtocol.h"

namespace Ui {
    class QGCMAVLinkInspector;
}

class QTreeWidgetItem;
LM's avatar
LM committed
15
class UASInterface;
lm's avatar
lm committed
16 17 18 19 20 21 22 23 24 25 26 27

class QGCMAVLinkInspector : public QWidget
{
    Q_OBJECT

public:
    explicit QGCMAVLinkInspector(MAVLinkProtocol* protocol, QWidget *parent = 0);
    ~QGCMAVLinkInspector();

public slots:
    void receiveMessage(LinkInterface* link,mavlink_message_t message);
    void refreshView();
LM's avatar
LM committed
28 29 30 31 32 33
    void addSystem(UASInterface* uas);
    void addComponent(int uas, int component, const QString& name);
    /** @Brief Select a system through the drop down menu */
    void selectDropDownMenuSystem(int dropdownid);
    /** @Brief Select a component through the drop down menu */
    void selectDropDownMenuComponent(int dropdownid);
lm's avatar
lm committed
34 35

protected:
LM's avatar
LM committed
36 37
    int selectedSystemID;          ///< Currently selected system
    int selectedComponentID;       ///< Currently selected component
38
    QMap<int, quint64> lastMessageUpdate; ///< Used to switch between highlight and non-highlighting color
39
    QMap<int, float> messagesHz; ///< Used to store update rate in Hz
LM's avatar
LM committed
40
    QMap<int, unsigned int> messageCount; ///< Used to store the message count
lm's avatar
lm committed
41
    mavlink_message_t receivedMessages[256]; ///< Available / known messages
lm's avatar
lm committed
42 43
    QMap<int, QTreeWidgetItem*> treeWidgetItems;   ///< Available tree widget items
    QTimer updateTimer; ///< Only update at 1 Hz to not overload the GUI
lm's avatar
lm committed
44 45 46 47
    mavlink_message_info_t messageInfo[256];

    // Update one message field
    void updateField(int msgid, int fieldid, QTreeWidgetItem* item);
LM's avatar
LM committed
48 49
    /** @brief Rebuild the list of components */
    void rebuildComponentList();
lm's avatar
lm committed
50

51 52
    static const unsigned int updateInterval;
    static const float updateHzLowpass;
LM's avatar
LM committed
53

lm's avatar
lm committed
54 55 56 57 58
private:
    Ui::QGCMAVLinkInspector *ui;
};

#endif // QGCMAVLINKINSPECTOR_H