QGCMAVLinkInspector.h 2.51 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 39
    void rateTreeItemChanged(QTreeWidgetItem* paramItem, int column);

lm's avatar
lm committed
40
protected:
41
    MAVLinkProtocol *_protocol;     ///< MAVLink instance
LM's avatar
LM committed
42 43
    int selectedSystemID;          ///< Currently selected system
    int selectedComponentID;       ///< Currently selected component
44 45
    QMap<int, int> systems;     ///< Already observed systems
    QMap<int, int> components; ///< Already observed components
46
    QMap<int, quint64> lastMessageUpdate; ///< Used to switch between highlight and non-highlighting color
47
    QMap<int, float> messagesHz; ///< Used to store update rate in Hz
48
    QMap<int, float> onboardMessageInterval; ///< Stores the onboard selected data rate
LM's avatar
LM committed
49
    QMap<int, unsigned int> messageCount; ///< Used to store the message count
lm's avatar
lm committed
50
    mavlink_message_t receivedMessages[256]; ///< Available / known messages
lm's avatar
lm committed
51
    QMap<int, QTreeWidgetItem*> treeWidgetItems;   ///< Available tree widget items
52
    QMap<int, QTreeWidgetItem*> rateTreeWidgetItems; ///< Available rate tree widget items
lm's avatar
lm committed
53
    QTimer updateTimer; ///< Only update at 1 Hz to not overload the GUI
54
    mavlink_message_info_t messageInfo[256]; // Store the metadata for all available MAVLink messages.
lm's avatar
lm committed
55 56 57

    // Update one message field
    void updateField(int msgid, int fieldid, QTreeWidgetItem* item);
LM's avatar
LM committed
58 59
    /** @brief Rebuild the list of components */
    void rebuildComponentList();
60 61
    /** @brief Change the stream interval */
    void changeStreamInterval(int msgid, int interval);
lm's avatar
lm committed
62

63 64
    static const unsigned int updateInterval;
    static const float updateHzLowpass;
LM's avatar
LM committed
65

lm's avatar
lm committed
66 67 68 69 70
private:
    Ui::QGCMAVLinkInspector *ui;
};

#endif // QGCMAVLINKINSPECTOR_H