From 21827374c26ea0a38027794ec38cce9fa0f1a792 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 2 Sep 2012 14:39:07 +0200 Subject: [PATCH] Adding vehicle configuration widget, fixed link disconnected logic for serial links --- qgroundcontrol.pro | 9 +- src/comm/SerialLink.cc | 17 ++-- src/uas/UAS.cc | 1 + src/ui/MainWindow.cc | 22 +++-- src/ui/MainWindow.h | 2 + src/ui/QGCVehicleConfig.cc | 14 +++ src/ui/QGCVehicleConfig.h | 22 +++++ src/ui/QGCVehicleConfig.ui | 214 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 287 insertions(+), 14 deletions(-) create mode 100644 src/ui/QGCVehicleConfig.cc create mode 100644 src/ui/QGCVehicleConfig.h create mode 100644 src/ui/QGCVehicleConfig.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 65d367b..82486d0 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -222,7 +222,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/mission/QGCMissionNavTakeoff.ui \ src/ui/mission/QGCMissionNavSweep.ui \ src/ui/mission/QGCMissionDoStartSearch.ui \ - src/ui/mission/QGCMissionDoFinishSearch.ui + src/ui/mission/QGCMissionDoFinishSearch.ui \ + src/ui/QGCVehicleConfig.ui INCLUDEPATH += src \ src/ui \ src/ui/linechart \ @@ -356,7 +357,8 @@ HEADERS += src/MG.h \ src/ui/mission/QGCMissionNavTakeoff.h \ src/ui/mission/QGCMissionNavSweep.h \ src/ui/mission/QGCMissionDoStartSearch.h \ - src/ui/mission/QGCMissionDoFinishSearch.h + src/ui/mission/QGCMissionDoFinishSearch.h \ + src/ui/QGCVehicleConfig.h # Google Earth is only supported on Mac OS and Windows with Visual Studio Compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::HEADERS += src/ui/map3D/QGCGoogleEarthView.h @@ -510,7 +512,8 @@ SOURCES += src/main.cc \ src/ui/mission/QGCMissionNavTakeoff.cc \ src/ui/mission/QGCMissionNavSweep.cc \ src/ui/mission/QGCMissionDoStartSearch.cc \ - src/ui/mission/QGCMissionDoFinishSearch.cc + src/ui/mission/QGCMissionDoFinishSearch.cc \ + src/ui/QGCVehicleConfig.cc # Enable Google Earth only on Mac OS and Windows with Visual Studio compiler macx|macx-g++|macx-g++42|win32-msvc2008|win32-msvc2010::SOURCES += src/ui/map3D/QGCGoogleEarthView.cc diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index 4362d0e..e0ed648 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -436,12 +436,19 @@ void SerialLink::checkForBytes() { readBytes(); } + else if (available < 0) { + /* Error, close port */ + port->close(); + emit disconnected(); + emit connected(false); + emit communicationError(this->getName(), tr("Could not send data - link %1 is disconnected!").arg(this->getName())); + } } - else - { - emit disconnected(); - emit connected(false); - } +// else +// { +// emit disconnected(); +// emit connected(false); +// } } diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index e0152db..1151536 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1151,6 +1151,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) case MAVLINK_MSG_ID_DEBUG: case MAVLINK_MSG_ID_NAMED_VALUE_FLOAT: case MAVLINK_MSG_ID_NAMED_VALUE_INT: + case MAVLINK_MSG_ID_MANUAL_CONTROL: break; default: { diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 9232e72..f8e8361 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -438,10 +438,10 @@ void MainWindow::buildCommonWidgets() if (!parametersDockWidget) { - parametersDockWidget = new QDockWidget(tr("Calibration and Onboard Parameters"), this); + parametersDockWidget = new QDockWidget(tr("Onboard Parameters"), this); parametersDockWidget->setWidget( new ParameterInterface(this) ); parametersDockWidget->setObjectName("PARAMETER_INTERFACE_DOCKWIDGET"); - addTool(parametersDockWidget, tr("Calibration and Parameters"), Qt::RightDockWidgetArea); + addTool(parametersDockWidget, tr("Onboard Parameters"), Qt::RightDockWidgetArea); } if (!hsiDockWidget) @@ -556,25 +556,35 @@ void MainWindow::buildCommonWidgets() addCentralWidget(firmwareUpdateWidget, "Firmware Update"); } - if (!hudWidget) { + if (!hudWidget) + { hudWidget = new HUD(320, 240, this); addCentralWidget(hudWidget, tr("Head Up Display")); } - if (!dataplotWidget) { + if (!configWidget) + { + configWidget = new QGCVehicleConfig(this); + addCentralWidget(configWidget, tr("Vehicle Configuration")); + } + + if (!dataplotWidget) + { dataplotWidget = new QGCDataPlot2D(this); addCentralWidget(dataplotWidget, tr("Logfile Plot")); } #ifdef QGC_OSG_ENABLED - if (!_3DWidget) { + if (!_3DWidget) + { _3DWidget = Q3DWidgetFactory::get("PIXHAWK", this); addCentralWidget(_3DWidget, tr("Local 3D")); } #endif #if (defined _MSC_VER) | (defined Q_OS_MAC) - if (!gEarthWidget) { + if (!gEarthWidget) + { gEarthWidget = new QGCGoogleEarthView(this); addCentralWidget(gEarthWidget, tr("Google Earth")); } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 565d16f..939827c 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -76,6 +76,7 @@ This file is part of the QGROUNDCONTROL project #include "UASControlParameters.h" #include "QGCMAVLinkInspector.h" #include "QGCMAVLinkLogPlayer.h" +#include "QGCVehicleConfig.h" #include "MAVLinkDecoder.h" class QGCMapTool; @@ -313,6 +314,7 @@ protected: // Center widgets QPointer linechartWidget; QPointer hudWidget; + QPointer configWidget; QPointer mapWidget; QPointer protocolWidget; QPointer dataplotWidget; diff --git a/src/ui/QGCVehicleConfig.cc b/src/ui/QGCVehicleConfig.cc new file mode 100644 index 0000000..9ea63a2 --- /dev/null +++ b/src/ui/QGCVehicleConfig.cc @@ -0,0 +1,14 @@ +#include "QGCVehicleConfig.h" +#include "ui_QGCVehicleConfig.h" + +QGCVehicleConfig::QGCVehicleConfig(QWidget *parent) : + QWidget(parent), + ui(new Ui::QGCVehicleConfig) +{ + ui->setupUi(this); +} + +QGCVehicleConfig::~QGCVehicleConfig() +{ + delete ui; +} diff --git a/src/ui/QGCVehicleConfig.h b/src/ui/QGCVehicleConfig.h new file mode 100644 index 0000000..9be86a8 --- /dev/null +++ b/src/ui/QGCVehicleConfig.h @@ -0,0 +1,22 @@ +#ifndef QGCVEHICLECONFIG_H +#define QGCVEHICLECONFIG_H + +#include + +namespace Ui { +class QGCVehicleConfig; +} + +class QGCVehicleConfig : public QWidget +{ + Q_OBJECT + +public: + explicit QGCVehicleConfig(QWidget *parent = 0); + ~QGCVehicleConfig(); + +private: + Ui::QGCVehicleConfig *ui; +}; + +#endif // QGCVEHICLECONFIG_H diff --git a/src/ui/QGCVehicleConfig.ui b/src/ui/QGCVehicleConfig.ui new file mode 100644 index 0000000..13d4117 --- /dev/null +++ b/src/ui/QGCVehicleConfig.ui @@ -0,0 +1,214 @@ + + + QGCVehicleConfig + + + + 0 + 0 + 499 + 451 + + + + Form + + + + 0 + + + + + 0 + + + + Tab 1 + + + + + 10 + 230 + 160 + 22 + + + + Qt::Horizontal + + + + + + 170 + 80 + 22 + 160 + + + + Qt::Vertical + + + + + + 220 + 230 + 160 + 22 + + + + Qt::Horizontal + + + + + + 380 + 80 + 22 + 160 + + + + Qt::Vertical + + + + + + 30 + 300 + 22 + 71 + + + + Qt::Vertical + + + + + + 60 + 300 + 22 + 71 + + + + Qt::Vertical + + + + + + 90 + 300 + 22 + 71 + + + + Qt::Vertical + + + + + + 120 + 300 + 22 + 71 + + + + Qt::Vertical + + + + + + 20 + 70 + 141 + 151 + + + + TextLabel + + + + + + 220 + 70 + 151 + 141 + + + + TextLabel + + + + + + 10 + 20 + 171 + 26 + + + + + Select RC model + + + + + + + 210 + 20 + 191 + 26 + + + + + Select RC mode + + + + + + + 10 + 250 + 171 + 23 + + + + 24 + + + + + + Tab 2 + + + + + + + + +