Commit a02927bf authored by lm's avatar lm

Working on MAVLink inspector

parent 09d4e8ec
......@@ -208,7 +208,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/mission/QGCMissionDoWidget.ui \
src/ui/mission/QGCMissionConditionWidget.ui \
src/ui/map/QGCMapTool.ui \
src/ui/map/QGCMapToolBar.ui
src/ui/map/QGCMapToolBar.ui \
src/ui/QGCMAVLinkInspector.ui
INCLUDEPATH += src \
src/ui \
src/ui/linechart \
......@@ -320,7 +321,8 @@ HEADERS += src/MG.h \
src/ui/map/QGCMapToolBar.h \
src/libs/qextserialport/qextserialenumerator.h \
src/QGCGeo.h \
src/ui/QGCToolBar.h
src/ui/QGCToolBar.h \
src/ui/QGCMAVLinkInspector.h
# Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler
macx|win32-msvc2008|win32-msvc2010::HEADERS += src/ui/map3D/QGCGoogleEarthView.h
......@@ -444,7 +446,8 @@ SOURCES += src/main.cc \
src/ui/map/Waypoint2DIcon.cc \
src/ui/map/QGCMapTool.cc \
src/ui/map/QGCMapToolBar.cc \
src/ui/QGCToolBar.cc
src/ui/QGCToolBar.cc \
src/ui/QGCMAVLinkInspector.cc
# Enable Google Earth only on Mac OS and Windows with Visual Studio compiler
macx|win32-msvc2008|win32-msvc2010::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc
......
......@@ -376,6 +376,14 @@ void MainWindow::buildCommonWidgets()
addToToolsMenu(logPlayerDockWidget, tr("MAVLink Log Replay"), SLOT(showToolWidget(bool)), MENU_MAVLINK_LOG_PLAYER, Qt::RightDockWidgetArea);
}
if (!mavlinkInspectorWidget)
{
mavlinkInspectorWidget = new QDockWidget(tr("MAVLink Message Inspector"), this);
mavlinkInspectorWidget->setWidget( new QGCMAVLinkInspector(mavlink, this) );
mavlinkInspectorWidget->setObjectName("MAVLINK_INSPECTOR_DOCKWIDGET");
addToToolsMenu(mavlinkInspectorWidget, tr("MAVLink Inspector"), SLOT(showToolWidget(bool)), MENU_MAVLINK_INSPECTOR, Qt::RightDockWidgetArea);
}
// Center widgets
if (!mapWidget)
{
......
......@@ -75,7 +75,7 @@ This file is part of the QGROUNDCONTROL project
#include "SlugsPadCameraControl.h"
#include "UASControlParameters.h"
#include "QGCFlightGearLink.h"
#include "QGCMAVLinkInspector.h"
class QGCMapTool;
......@@ -254,6 +254,7 @@ protected:
MENU_MAVLINK_LOG_PLAYER,
MENU_VIDEO_STREAM_1,
MENU_VIDEO_STREAM_2,
MENU_MAVLINK_INSPECTOR,
CENTRAL_SEPARATOR= 255, // do not change
CENTRAL_LINECHART,
CENTRAL_PROTOCOL,
......@@ -424,6 +425,8 @@ protected:
QPointer<QGCToolBar> toolBar;
QPointer<QDockWidget> mavlinkInspectorWidget;
// Popup widgets
JoystickWidget* joystickWidget;
......
#include <QList>
#include "QGCMAVLinkInspector.h"
#include "ui_QGCMAVLinkInspector.h"
#include <QDebug>
QGCMAVLinkInspector::QGCMAVLinkInspector(MAVLinkProtocol* protocol, QWidget *parent) :
QWidget(parent),
ui(new Ui::QGCMAVLinkInspector)
{
ui->setupUi(this);
connect(protocol, SIGNAL(messageReceived(LinkInterface*,mavlink_message_t)), this, SLOT(receiveMessage(LinkInterface*,mavlink_message_t)));
ui->treeWidget->setColumnCount(3);
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(refreshView()));
updateTimer.start(1000);
}
void QGCMAVLinkInspector::refreshView()
{
foreach (mavlink_message_t msg, receivedMessages.values())
{
// Update the tree view
if (!treeWidgetItems.contains(msg.msgid))
{
QString messageName("MSG (#%1)");
messageName = messageName.arg(msg.msgid);
QStringList fields;
fields << messageName;
fields << "";
fields << "";
QTreeWidgetItem* widget = new QTreeWidgetItem(fields);
treeWidgetItems.insert(msg.msgid, widget);
ui->treeWidget->addTopLevelItem(widget);
}
}
// // List all available MAVLink messages
// QList<QTreeWidgetItem *> items;
// for (int i = 0; i < 256; ++i)
// {
// QStringList stringList;
// stringList << QString("message: %1").arg(i) << QString("") << QString("Not received yet.");
// items.append(new QTreeWidgetItem((QTreeWidget*)0, stringList));
// }
// ui->treeWidget->insertTopLevelItems(0, items);
}
void QGCMAVLinkInspector::receiveMessage(LinkInterface* link,mavlink_message_t message)
{
Q_UNUSED(link);
receivedMessages.insert(message.msgid, message);
// Q_UNUSED(link);
// qDebug() << __FILE__ << __LINE__ << "GOT MAVLINK MESSAGE";
// // Check if children exist
// const QObjectList& fields = ui->treeWidget->children().at(message.msgid)->children();
// if (fields.length() == 0)
// {
// // Create children
// }
// for (int i = 0; i < fields.length(); ++i)
// {
// // Fill in field data
// }
}
QGCMAVLinkInspector::~QGCMAVLinkInspector()
{
delete ui;
}
#ifndef QGCMAVLINKINSPECTOR_H
#define QGCMAVLINKINSPECTOR_H
#include <QWidget>
#include <QMap>
#include <QTimer>
#include "MAVLinkProtocol.h"
namespace Ui {
class QGCMAVLinkInspector;
}
class QTreeWidgetItem;
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();
protected:
QMap<int, quint64> lastFieldUpdate; ///< Used to switch between highlight and non-highlighting color
QMap<int, mavlink_message_t> receivedMessages; ///< Available / known messages
QMap<int, QTreeWidgetItem*> treeWidgetItems; ///< Available tree widget items
QTimer updateTimer; ///< Only update at 1 Hz to not overload the GUI
private:
Ui::QGCMAVLinkInspector *ui;
};
#endif // QGCMAVLINKINSPECTOR_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QGCMAVLinkInspector</class>
<widget class="QWidget" name="QGCMAVLinkInspector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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