QGCMAVLinkInspector.h 1.93 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

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);
27 28 29
    /** @brief Clear all messages */
    void clearView();
    /** Update view */
lm's avatar
lm committed
30
    void refreshView();
LM's avatar
LM committed
31 32 33 34 35 36
    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
37 38

protected:
LM's avatar
LM committed
39 40
    int selectedSystemID;          ///< Currently selected system
    int selectedComponentID;       ///< Currently selected component
41
    QMap<int, quint64> lastMessageUpdate; ///< Used to switch between highlight and non-highlighting color
42
    QMap<int, float> messagesHz; ///< Used to store update rate in Hz
LM's avatar
LM committed
43
    QMap<int, unsigned int> messageCount; ///< Used to store the message count
lm's avatar
lm committed
44
    mavlink_message_t receivedMessages[256]; ///< Available / known messages
lm's avatar
lm committed
45 46
    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
47 48 49 50
    mavlink_message_info_t messageInfo[256];

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

54 55
    static const unsigned int updateInterval;
    static const float updateHzLowpass;
LM's avatar
LM committed
56

lm's avatar
lm committed
57 58 59 60 61
private:
    Ui::QGCMAVLinkInspector *ui;
};

#endif // QGCMAVLINKINSPECTOR_H