Commit c51c5688 authored by Don Gagne's avatar Don Gagne

Merge pull request #1234 from dogmaphobic/linkManager

Link Configuration Management
parents 24bf2218 e0d94b4d
...@@ -271,7 +271,6 @@ INCLUDEPATH += \ ...@@ -271,7 +271,6 @@ INCLUDEPATH += \
FORMS += \ FORMS += \
src/ui/MainWindow.ui \ src/ui/MainWindow.ui \
src/ui/CommSettings.ui \
src/ui/SerialSettings.ui \ src/ui/SerialSettings.ui \
src/ui/UASControl.ui \ src/ui/UASControl.ui \
src/ui/UASList.ui \ src/ui/UASList.ui \
...@@ -300,7 +299,6 @@ FORMS += \ ...@@ -300,7 +299,6 @@ FORMS += \
src/ui/QGCMAVLinkLogPlayer.ui \ src/ui/QGCMAVLinkLogPlayer.ui \
src/ui/QGCWaypointListMulti.ui \ src/ui/QGCWaypointListMulti.ui \
src/ui/QGCUASFileViewMulti.ui \ src/ui/QGCUASFileViewMulti.ui \
src/ui/QGCUDPLinkConfiguration.ui \
src/ui/QGCTCPLinkConfiguration.ui \ src/ui/QGCTCPLinkConfiguration.ui \
src/ui/SettingsDialog.ui \ src/ui/SettingsDialog.ui \
src/ui/map/QGCMapTool.ui \ src/ui/map/QGCMapTool.ui \
...@@ -344,6 +342,9 @@ FORMS += \ ...@@ -344,6 +342,9 @@ FORMS += \
src/ui/QGCUASFileView.ui \ src/ui/QGCUASFileView.ui \
src/QGCQmlWidgetHolder.ui \ src/QGCQmlWidgetHolder.ui \
src/ui/QGCMapRCToParamDialog.ui \ src/ui/QGCMapRCToParamDialog.ui \
src/ui/QGCLinkConfiguration.ui \
src/ui/QGCCommConfiguration.ui \
src/ui/QGCUDPLinkConfiguration.ui
HEADERS += \ HEADERS += \
src/MG.h \ src/MG.h \
...@@ -354,14 +355,12 @@ HEADERS += \ ...@@ -354,14 +355,12 @@ HEADERS += \
src/uas/UASManager.h \ src/uas/UASManager.h \
src/comm/LinkManager.h \ src/comm/LinkManager.h \
src/comm/LinkInterface.h \ src/comm/LinkInterface.h \
src/comm/SerialLinkInterface.h \
src/comm/SerialLink.h \ src/comm/SerialLink.h \
src/comm/ProtocolInterface.h \ src/comm/ProtocolInterface.h \
src/comm/MAVLinkProtocol.h \ src/comm/MAVLinkProtocol.h \
src/comm/QGCFlightGearLink.h \ src/comm/QGCFlightGearLink.h \
src/comm/QGCJSBSimLink.h \ src/comm/QGCJSBSimLink.h \
src/comm/QGCXPlaneLink.h \ src/comm/QGCXPlaneLink.h \
src/ui/CommConfigurationWindow.h \
src/ui/SerialConfigurationWindow.h \ src/ui/SerialConfigurationWindow.h \
src/ui/MainWindow.h \ src/ui/MainWindow.h \
src/ui/uas/UASControlWidget.h \ src/ui/uas/UASControlWidget.h \
...@@ -416,7 +415,6 @@ HEADERS += \ ...@@ -416,7 +415,6 @@ HEADERS += \
src/uas/QGCMAVLinkUASFactory.h \ src/uas/QGCMAVLinkUASFactory.h \
src/ui/QGCWaypointListMulti.h \ src/ui/QGCWaypointListMulti.h \
src/ui/QGCUASFileViewMulti.h \ src/ui/QGCUASFileViewMulti.h \
src/ui/QGCUDPLinkConfiguration.h \
src/ui/QGCTCPLinkConfiguration.h \ src/ui/QGCTCPLinkConfiguration.h \
src/ui/SettingsDialog.h \ src/ui/SettingsDialog.h \
src/uas/QGCUASParamManager.h \ src/uas/QGCUASParamManager.h \
...@@ -497,6 +495,10 @@ HEADERS += \ ...@@ -497,6 +495,10 @@ HEADERS += \
src/ui/QGCParamTreeWidget.h \ src/ui/QGCParamTreeWidget.h \
src/ui/QGCMapRCToParamDialog.h \ src/ui/QGCMapRCToParamDialog.h \
src/QGCDockWidget.h \ src/QGCDockWidget.h \
src/ui/QGCLinkConfiguration.h \
src/comm/LinkConfiguration.h \
src/ui/QGCCommConfiguration.h \
src/ui/QGCUDPLinkConfiguration.h
SOURCES += \ SOURCES += \
src/main.cc \ src/main.cc \
...@@ -510,7 +512,6 @@ SOURCES += \ ...@@ -510,7 +512,6 @@ SOURCES += \
src/comm/QGCFlightGearLink.cc \ src/comm/QGCFlightGearLink.cc \
src/comm/QGCJSBSimLink.cc \ src/comm/QGCJSBSimLink.cc \
src/comm/QGCXPlaneLink.cc \ src/comm/QGCXPlaneLink.cc \
src/ui/CommConfigurationWindow.cc \
src/ui/SerialConfigurationWindow.cc \ src/ui/SerialConfigurationWindow.cc \
src/ui/MainWindow.cc \ src/ui/MainWindow.cc \
src/ui/uas/UASControlWidget.cc \ src/ui/uas/UASControlWidget.cc \
...@@ -563,7 +564,6 @@ SOURCES += \ ...@@ -563,7 +564,6 @@ SOURCES += \
src/uas/QGCMAVLinkUASFactory.cc \ src/uas/QGCMAVLinkUASFactory.cc \
src/ui/QGCWaypointListMulti.cc \ src/ui/QGCWaypointListMulti.cc \
src/ui/QGCUASFileViewMulti.cc \ src/ui/QGCUASFileViewMulti.cc \
src/ui/QGCUDPLinkConfiguration.cc \
src/ui/QGCTCPLinkConfiguration.cc \ src/ui/QGCTCPLinkConfiguration.cc \
src/ui/SettingsDialog.cc \ src/ui/SettingsDialog.cc \
src/uas/QGCUASParamManager.cc \ src/uas/QGCUASParamManager.cc \
...@@ -639,6 +639,10 @@ SOURCES += \ ...@@ -639,6 +639,10 @@ SOURCES += \
src/ui/QGCParamTreeWidget.cpp \ src/ui/QGCParamTreeWidget.cpp \
src/ui/QGCMapRCToParamDialog.cpp \ src/ui/QGCMapRCToParamDialog.cpp \
src/QGCDockWidget.cc \ src/QGCDockWidget.cc \
src/ui/QGCLinkConfiguration.cc \
src/comm/LinkConfiguration.cc \
src/ui/QGCCommConfiguration.cc \
src/ui/QGCUDPLinkConfiguration.cc
# #
# Unit Test specific configuration goes here # Unit Test specific configuration goes here
......
This diff is collapsed.
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#ifndef QGCMESSAGEBOX_H #ifndef QGCMESSAGEBOX_H
...@@ -40,34 +40,34 @@ ...@@ -40,34 +40,34 @@
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
class QGCMessageBox : public QMessageBox { class QGCMessageBox : public QMessageBox {
public: public:
static StandardButton critical(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL) static StandardButton critical(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Critical, title, text, buttons, defaultButton, parent); } { return _messageBox(QMessageBox::Critical, title, text, buttons, defaultButton, parent); }
static StandardButton information(const QString & title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL) static StandardButton information(const QString & title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Information, title, text, buttons, defaultButton, parent); } { return _messageBox(QMessageBox::Information, title, text, buttons, defaultButton, parent); }
static StandardButton question(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL) static StandardButton question(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Question, title, text, buttons, defaultButton, parent); } { return _messageBox(QMessageBox::Question, title, text, buttons, defaultButton, parent); }
static StandardButton warning(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL) static StandardButton warning(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Warning, title, text, buttons, defaultButton, parent); } { return _messageBox(QMessageBox::Warning, title, text, buttons, defaultButton, parent); }
private slots: private slots:
/// @brief The exec slot is private becasue when only want QGCMessageBox users to use the static methods. Otherwise it will break /// @brief The exec slot is private becasue when only want QGCMessageBox users to use the static methods. Otherwise it will break
/// unit testing. /// unit testing.
int exec(void) { return QMessageBox::exec(); } int exec(void) { return QMessageBox::exec(); }
private: private:
static QWidget* _validateParameters(StandardButtons buttons, StandardButton* defaultButton, QWidget* parent) static QWidget* _validateParameters(StandardButtons buttons, StandardButton* defaultButton, QWidget* parent)
{ {
// This is an obsolete bit which unit tests use for signalling. It should not be used in regular code. // This is an obsolete bit which unit tests use for signalling. It should not be used in regular code.
Q_ASSERT(!(buttons & QMessageBox::Escape)); Q_ASSERT(!(buttons & QMessageBox::Escape));
// If there is more than one button displayed, make sure a default button is set. Without this unit test code // If there is more than one button displayed, make sure a default button is set. Without this unit test code
// will not be able to respond to unexpected message boxes. // will not be able to respond to unexpected message boxes.
unsigned int bits = static_cast<unsigned int>(buttons); unsigned int bits = static_cast<unsigned int>(buttons);
int buttonCount = 0; int buttonCount = 0;
for (size_t i=0; i<sizeof(bits)*8; i++) { for (size_t i=0; i<sizeof(bits)*8; i++) {
...@@ -76,14 +76,14 @@ private: ...@@ -76,14 +76,14 @@ private:
} }
} }
Q_ASSERT(buttonCount != 0); Q_ASSERT(buttonCount != 0);
if (buttonCount > 1) { if (buttonCount > 1) {
Q_ASSERT(buttons & *defaultButton); Q_ASSERT(buttons & *defaultButton);
} else { } else {
// Force default button to be set correctly for single button case to make unit test code simpler // Force default button to be set correctly for single button case to make unit test code simpler
*defaultButton = static_cast<QMessageBox::StandardButton>(static_cast<int>(buttons)); *defaultButton = static_cast<QMessageBox::StandardButton>(static_cast<int>(buttons));
} }
return (parent == NULL) ? MainWindow::instance() : parent; return (parent == NULL) ? MainWindow::instance() : parent;
} }
...@@ -91,9 +91,9 @@ private: ...@@ -91,9 +91,9 @@ private:
{ {
// You can't use QGCMessageBox if QGCApplication is not created yet. // You can't use QGCMessageBox if QGCApplication is not created yet.
Q_ASSERT(qgcApp()); Q_ASSERT(qgcApp());
Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCMessageBox can only be called from main thread"); Q_ASSERT_X(QThread::currentThread() == qgcApp()->thread(), "Threading issue", "QGCMessageBox can only be called from main thread");
parent = _validateParameters(buttons, &defaultButton, parent); parent = _validateParameters(buttons, &defaultButton, parent);
if (MainWindow::instance()) { if (MainWindow::instance()) {
...@@ -102,7 +102,7 @@ private: ...@@ -102,7 +102,7 @@ private:
parent = MainWindow::instance(); parent = MainWindow::instance();
} }
} }
#ifdef QT_DEBUG #ifdef QT_DEBUG
if (qgcApp()->runningUnitTests()) { if (qgcApp()->runningUnitTests()) {
qDebug() << "QGCMessageBox (unit testing)" << title << text; qDebug() << "QGCMessageBox (unit testing)" << title << text;
...@@ -115,6 +115,10 @@ private: ...@@ -115,6 +115,10 @@ private:
QMessageBox box(icon, emptyTitle, title, buttons, parent); QMessageBox box(icon, emptyTitle, title, buttons, parent);
box.setDefaultButton(defaultButton); box.setDefaultButton(defaultButton);
box.setInformativeText(text); box.setInformativeText(text);
// Get this thing off a proper size
QSpacerItem* horizontalSpacer = new QSpacerItem(500, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout* layout = (QGridLayout*)box.layout();
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
#else #else
QMessageBox box(icon, title, text, buttons, parent); QMessageBox box(icon, title, text, buttons, parent);
box.setDefaultButton(defaultButton); box.setDefaultButton(defaultButton);
......
...@@ -21,86 +21,97 @@ This file is part of the QGROUNDCONTROL project ...@@ -21,86 +21,97 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/ ======================================================================*/
/** /*!
* @file @file
* @brief Definition of class CommConfigurationWindow @brief Link specific configuration base class
* @author Gus Grubba <mavlink@grubba.com>
* @author Lorenz Meier <mavteam@student.ethz.ch> */
*
*/
#ifndef _COMMCONFIGURATIONWINDOW_H_
#define _COMMCONFIGURATIONWINDOW_H_
#include <QObject>
#include <QDialog>
#include <QAction>
#include "LinkInterface.h"
#include "ProtocolInterface.h"
#include "ui_CommSettings.h"
enum qgc_link_t {
QGC_LINK_SERIAL,
QGC_LINK_UDP,
QGC_LINK_TCP,
QGC_LINK_SIMULATION,
QGC_LINK_FORWARDING,
#ifdef UNITTEST_BUILD
QGC_LINK_MOCK,
#endif
#ifdef QGC_XBEE_ENABLED
QGC_LINK_XBEE,
#endif
#ifdef QGC_RTLAB_ENABLED
QGC_LINK_OPAL
#endif
};
enum qgc_protocol_t {
QGC_PROTOCOL_MAVLINK,
};
#include "LinkConfiguration.h"
#include "SerialLink.h"
#include "UDPLink.h"
#ifdef QGC_RTLAB_ENABLED #ifdef UNITTEST_BUILD
#include "OpalLink.h" #include "MockLink.h"
#endif #endif
/** #define LINK_SETTING_ROOT "LinkConfigurations"
* @brief Configuration window for communication links
*/
class CommConfigurationWindow : public QDialog
{
Q_OBJECT
public:
CommConfigurationWindow(LinkInterface* link, QWidget *parent = 0);
~CommConfigurationWindow();
QAction* getAction();
void setLinkType(qgc_link_t linktype);
private slots:
void linkCurrentIndexChanged(int currentIndex);
public slots:
/** @brief Set the protocol for this link */
void setProtocol(int protocol);
void setConnection();
void setLinkName(QString name);
/** @brief Disconnects the associated link, removes it from all menus and closes the window. */
void remove();
private slots: LinkConfiguration::LinkConfiguration(const QString& name)
void _linkConnected(void); : _preferred(false)
void _linkDisconnected(void); {
_link = NULL;
private: _name = name;
void _connectionState(bool connect); Q_ASSERT(!_name.isEmpty());
}
Ui::commSettings ui;
LinkInterface* link;
QAction* action;
};
LinkConfiguration::LinkConfiguration(LinkConfiguration* copy)
{
_link = copy->getLink();
_name = copy->name();
_preferred = copy->isPreferred();
Q_ASSERT(!_name.isEmpty());
}
#endif // _COMMCONFIGURATIONWINDOW_H_ void LinkConfiguration::copyFrom(LinkConfiguration* source)
{
Q_ASSERT(source != NULL);
_link = source->getLink();
_name = source->name();
_preferred = source->isPreferred();
}
/*!
Where the settings are saved
@return The root path of the setting.
*/
const QString LinkConfiguration::settingsRoot()
{
return QString(LINK_SETTING_ROOT);
}
/*!
Configuration Factory
@return A new instance of the given type
*/
LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& name)
{
LinkConfiguration* config = NULL;
switch(type) {
case LinkConfiguration::TypeSerial:
config = new SerialConfiguration(name);
break;
case LinkConfiguration::TypeUdp:
config = new UDPConfiguration(name);
break;
#ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock:
config = new MockConfiguration(name);
break;
#endif
}
return config;
}
/*!
Duplicate link settings
@return A new copy of the given settings instance
*/
LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* source)
{
LinkConfiguration* dupe = NULL;
switch(source->type()) {
case TypeSerial:
dupe = new SerialConfiguration(dynamic_cast<SerialConfiguration*>(source));
break;
case TypeUdp:
dupe = new UDPConfiguration(dynamic_cast<UDPConfiguration*>(source));
break;
#ifdef UNITTEST_BUILD
case TypeMock:
dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source));
break;
#endif
}
return dupe;
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef LINKCONFIGURATION_H
#define LINKCONFIGURATION_H
#include <QSettings>
class LinkInterface;
/// Interface holding link specific settings.
class LinkConfiguration
{
public:
LinkConfiguration(const QString& name);
LinkConfiguration(LinkConfiguration* copy);
virtual ~LinkConfiguration() {}
/// The link types supported by QGC
enum {
TypeSerial, ///< Serial Link
TypeUdp, ///< UDP Link
// TODO Below is not yet implemented
#if 0
TypeTcp, ///< TCP Link
TypeSimulation, ///< Simulation Link
TypeForwarding, ///< Forwarding Link
TypeXbee, ///< XBee Proprietary Link
TypeOpal, ///< Opal-RT Link
#endif
#ifdef UNITTEST_BUILD
TypeMock, ///< Mock Link for Unitesting
#endif
TypeLast // Last type value (type >= TypeLast == invalid)
};
/*!
* @brief Get configuration name
*
* This is the user friendly name shown in the connection drop down box and the name used to save the configuration in the settings.
* @return The name of this link.
*/
const QString name() { return _name; }
/*!
* @brief Set the name of this link configuration.
*
* This is the user friendly name shown in the connection drop down box and the name used to save the configuration in the settings.
* @param[in] name The configuration name
*/
void setName(const QString name) {_name = name; }
/*!
* @brief Set the link this configuration is currently attched to.
*
* @param[in] link The pointer to the current LinkInterface instance (if any)
*/
void setLink(LinkInterface* link) { _link = link; }
/*!
* @brief Get the link this configuration is currently attched to.
*
* @return The pointer to the current LinkInterface instance (if any)
*/
LinkInterface* getLink() { return _link; }
/*!
*
* Is this a preferred configuration? (decided at runtime)
* @return True if this is a known configuration (PX4, etc.)
*/
bool isPreferred() { return _preferred; }
/*!
* Set if this is this a preferred configuration. (decided at runtime)
*/
void setPreferred(bool preferred = true) { _preferred = preferred; }
/// Virtual Methods
/*!
* @brief Connection type
*
* Pure virtual method returning one of the -TypeXxx types above.
* @return The type of links these settings belong to.
*/
virtual int type() = 0;
/*!
* @brief Load settings
*
* Pure virtual method telling the instance to load its configuration.
* @param[in] settings The QSettings instance to use
* @param[in] root The root path of the setting.
*/
virtual void loadSettings(QSettings& settings, const QString& root) = 0;
/*!
* @brief Save settings
*
* Pure virtual method telling the instance to save its configuration.
* @param[in] settings The QSettings instance to use
* @param[in] root The root path of the setting.
*/
virtual void saveSettings(QSettings& settings, const QString& root) = 0;
/*!
* @brief Update settings
*
* After editing the settings, use this method to tell the connected link (if any) to reload its configuration.
*/
virtual void updateSettings() {}
/*!
* @brief Copy instance data
*
* When manipulating data, you create a copy of the configuration using the copy constructor,
* edit it and then transfer its content to the original using this method.
* @param[in] source The source instance (the edited copy)
*/
virtual void copyFrom(LinkConfiguration* source);
/// Helper static methods
/*!
* @brief Root path for QSettings
*
* @return The root path of the settings.
*/
static const QString settingsRoot();
/*!
* @brief Create new link configuration instance
*
* Configuration Factory. Creates an appropriate configuration instance based on the given type.
* @return A new instance of the given type
*/
static LinkConfiguration* createSettings(int type, const QString& name);
/*!
* @brief Duplicate configuration instance
*
* Helper method to create a new instance copy for editing.
* @return A new copy of the given settings instance
*/
static LinkConfiguration* duplicateSettings(LinkConfiguration *source);
protected:
LinkInterface* _link; ///< Link currently using this configuration (if any)
private:
QString _name;
bool _preferred; ///< Determined internally if this is a preferred connection. It comes up first in the drop down box.
};
#endif // LINKCONFIGURATION_H
...@@ -39,6 +39,7 @@ along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>. ...@@ -39,6 +39,7 @@ along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.
#include <QMetaType> #include <QMetaType>
class LinkManager; class LinkManager;
class LinkConfiguration;
/** /**
* The link interface defines the interface for all links used to communicate * The link interface defines the interface for all links used to communicate
...@@ -48,10 +49,10 @@ class LinkManager; ...@@ -48,10 +49,10 @@ class LinkManager;
class LinkInterface : public QThread class LinkInterface : public QThread
{ {
Q_OBJECT Q_OBJECT
// Only LinkManager is allowed to _connect, _disconnect or delete a link // Only LinkManager is allowed to _connect, _disconnect or delete a link
friend class LinkManager; friend class LinkManager;
public: public:
LinkInterface() : LinkInterface() :
QThread(0), QThread(0),
...@@ -59,27 +60,33 @@ public: ...@@ -59,27 +60,33 @@ public:
_deletedByLinkManager(false) _deletedByLinkManager(false)
{ {
// Initialize everything for the data rate calculation buffers. // Initialize everything for the data rate calculation buffers.
inDataIndex = 0; inDataIndex = 0;
outDataIndex = 0; outDataIndex = 0;
// Initialize our data rate buffers manually, cause C++<03 is dumb. // Initialize our data rate buffers.
for (int i = 0; i < dataRateBufferSize; ++i) memset(inDataWriteAmounts, 0, sizeof(inDataWriteAmounts));
{ memset(inDataWriteTimes, 0, sizeof(inDataWriteTimes));
inDataWriteAmounts[i] = 0; memset(outDataWriteAmounts,0, sizeof(outDataWriteAmounts));
inDataWriteTimes[i] = 0; memset(outDataWriteTimes, 0, sizeof(outDataWriteTimes));
outDataWriteAmounts[i] = 0;
outDataWriteTimes[i] = 0;
}
qRegisterMetaType<LinkInterface*>("LinkInterface*"); qRegisterMetaType<LinkInterface*>("LinkInterface*");
} }
/**
* @brief Destructor
* LinkManager take ownership of Links once they are added to it. Once added to LinkManager
* use LinkManager::deleteLink to remove if necessary.
**/
virtual ~LinkInterface() { virtual ~LinkInterface() {
// LinkManager take ownership of Links once they are added to it. Once added to LinkManager
// user LinkManager::deleteLink to remove if necessary/
Q_ASSERT(!_ownedByLinkManager || _deletedByLinkManager); Q_ASSERT(!_ownedByLinkManager || _deletedByLinkManager);
} }
/**
* @brief Get link configuration (if used)
* @return A pointer to the instance of LinkConfiguration if supported. NULL otherwise.
**/
virtual LinkConfiguration* getLinkConfiguration() { return NULL; }
/* Connection management */ /* Connection management */
/** /**
...@@ -142,7 +149,7 @@ public: ...@@ -142,7 +149,7 @@ public:
{ {
return getCurrentDataRate(outDataIndex, outDataWriteTimes, outDataWriteAmounts); return getCurrentDataRate(outDataIndex, outDataWriteTimes, outDataWriteAmounts);
} }
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of // These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager. // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void); bool connect(void);
...@@ -323,14 +330,14 @@ private: ...@@ -323,14 +330,14 @@ private:
* @return True if connection could be established, false otherwise * @return True if connection could be established, false otherwise
**/ **/
virtual bool _connect(void) = 0; virtual bool _connect(void) = 0;
/** /**
* @brief Disconnect this interface logically * @brief Disconnect this interface logically
* *
* @return True if connection could be terminated, false otherwise * @return True if connection could be terminated, false otherwise
**/ **/
virtual bool _disconnect(void) = 0; virtual bool _disconnect(void) = 0;
bool _ownedByLinkManager; ///< true: This link has been added to LinkManager, false: Link not added to LinkManager bool _ownedByLinkManager; ///< true: This link has been added to LinkManager, false: Link not added to LinkManager
bool _deletedByLinkManager; ///< true: Link being deleted from LinkManager, false: error, Links should only be deleted from LinkManager bool _deletedByLinkManager; ///< true: Link being deleted from LinkManager, false: error, Links should only be deleted from LinkManager
}; };
......
This diff is collapsed.
...@@ -31,8 +31,17 @@ This file is part of the PIXHAWK project ...@@ -31,8 +31,17 @@ This file is part of the PIXHAWK project
#include <QMultiMap> #include <QMultiMap>
#include <QMutex> #include <QMutex>
#include "LinkConfiguration.h"
#include "LinkInterface.h" #include "LinkInterface.h"
// Links
#include "SerialLink.h" #include "SerialLink.h"
#include "UDPLink.h"
#ifdef UNITTEST_BUILD
#include "MockLink.h"
#endif
#include "ProtocolInterface.h" #include "ProtocolInterface.h"
#include "QGCSingleton.h" #include "QGCSingleton.h"
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
...@@ -48,14 +57,38 @@ class LinkManagerTest; ...@@ -48,14 +57,38 @@ class LinkManagerTest;
class LinkManager : public QGCSingleton class LinkManager : public QGCSingleton
{ {
Q_OBJECT Q_OBJECT
DECLARE_QGC_SINGLETON(LinkManager, LinkManager) DECLARE_QGC_SINGLETON(LinkManager, LinkManager)
/// Unit Test has access to private constructor/destructor /// Unit Test has access to private constructor/destructor
friend class LinkManagerTest; friend class LinkManagerTest;
public: public:
/*!
Add a new link configuration setting to the list
@param[in] link An instance of the link setting.
*/
void addLinkConfiguration(LinkConfiguration* link);
/*!
Removes (and deletes) an existing link configuration setting from the list
@param[in] link An instance of the link setting.
*/
void removeLinkConfiguration(LinkConfiguration* link);
/// Load list of link configurations from disk
void loadLinkConfigurationList();
/// Save list of link configurations from disk
void saveLinkConfigurationList();
/// Get a list of the configured links. This is the list of configured links that can be used by QGC.
const QList<LinkConfiguration*> getLinkConfigurationList();
/// Suspend automatic confguration updates (during link maintenance for instance)
void suspendConfigurationUpdates(bool suspend);
/// Returns list of all links /// Returns list of all links
const QList<LinkInterface*> getLinks(); const QList<LinkInterface*> getLinks();
...@@ -65,53 +98,69 @@ public: ...@@ -65,53 +98,69 @@ public:
/// Sets the flag to suspend the all new connections /// Sets the flag to suspend the all new connections
/// @param reason User visible reason to suspend connections /// @param reason User visible reason to suspend connections
void setConnectionsSuspended(QString reason); void setConnectionsSuspended(QString reason);
/// Sets the flag to allow new connections to be made /// Sets the flag to allow new connections to be made
void setConnectionsAllowed(void) { _connectionsSuspended = false; } void setConnectionsAllowed(void) { _connectionsSuspended = false; }
/// Creates (and adds) a link based on the given configuration instance. LinkManager takes ownership of this object. To delete
/// it, call LinkManager::deleteLink.
LinkInterface* createLink(LinkConfiguration* config);
/// Creates (and adds) a link based on the given configuration name. LinkManager takes ownership of this object. To delete
/// it, call LinkManager::deleteLink.
LinkInterface* createLink(const QString& name);
/// Adds the link to the LinkManager. LinkManager takes ownership of this object. To delete /// Adds the link to the LinkManager. LinkManager takes ownership of this object. To delete
/// it, call LinkManager::deleteLink. /// it, call LinkManager::deleteLink.
void addLink(LinkInterface* link); void addLink(LinkInterface* link);
/// Deletes the specified link. Will disconnect if connected. /// Deletes the specified link. Will disconnect if connected.
// TODO Will also crash if called. MAVLink protocol is not handling the disconnect properly.
void deleteLink(LinkInterface* link); void deleteLink(LinkInterface* link);
/// Re-connects all existing links /// Re-connects all existing links
bool connectAll(); bool connectAll();
/// Disconnects all existing links /// Disconnects all existing links
bool disconnectAll(); bool disconnectAll();
/// Connect the specified link /// Connect the specified link
bool connectLink(LinkInterface* link); bool connectLink(LinkInterface* link);
/// Disconnect the specified link /// Disconnect the specified link
bool disconnectLink(LinkInterface* link); bool disconnectLink(LinkInterface* link);
signals: signals:
void newLink(LinkInterface* link); void newLink(LinkInterface* link);
void linkDeleted(LinkInterface* link); void linkDeleted(LinkInterface* link);
void linkConnected(LinkInterface* link); void linkConnected(LinkInterface* link);
void linkDisconnected(LinkInterface* link); void linkDisconnected(LinkInterface* link);
void linkConfigurationChanged();
private slots: private slots:
void _linkConnected(void); void _linkConnected(void);
void _linkDisconnected(void); void _linkDisconnected(void);
private: private:
/// All access to LinkManager is through LinkManager::instance /// All access to LinkManager is through LinkManager::instance
LinkManager(QObject* parent = NULL); LinkManager(QObject* parent = NULL);
~LinkManager(); ~LinkManager();
virtual void _shutdown(void); virtual void _shutdown(void);
bool _connectionsSuspendedMsg(void); bool _connectionsSuspendedMsg(void);
void _updateConfigurationList(void);
QList<LinkInterface*> _links; ///< List of available links SerialConfiguration* _findSerialConfiguration(const QString& portName);
QMutex _linkListMutex; ///< Mutex for thread safe access to _links list
QList<LinkConfiguration*> _linkConfigurations; ///< List of configured links
bool _connectionsSuspended; ///< true: all new connections should not be allowed QList<LinkInterface*> _links; ///< List of available links
QString _connectionsSuspendedReason; ///< User visible reason for suspension QMutex _linkListMutex; ///< Mutex for thread safe access to _links list
bool _configUpdateSuspended; ///< true: stop updating configuration list
bool _configurationsLoaded; ///< true: Link configurations have been loaded
bool _connectionsSuspended; ///< true: all new connections should not be allowed
QString _connectionsSuspendedReason; ///< User visible reason for suspension
QTimer _portListTimer;
}; };
#endif #endif
This diff is collapsed.
...@@ -32,18 +32,65 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,18 +32,65 @@ This file is part of the QGROUNDCONTROL project
#ifndef SERIALLINK_H #ifndef SERIALLINK_H
#define SERIALLINK_H #define SERIALLINK_H
class LinkInterface;
class SerialConfiguration;
class SerialLink;
#include <QObject> #include <QObject>
#include <QThread> #include <QThread>
#include <QMutex> #include <QMutex>
#include <QString> #include <QString>
#include "QGCConfig.h"
#include "SerialLinkInterface.h"
// We use QSerialPort::SerialPortError in a signal so we must declare it as a meta type
#include <QSerialPort> #include <QSerialPort>
#include <QMetaType> #include <QMetaType>
// We use QSerialPort::SerialPortError in a signal so we must declare it as a meta type
Q_DECLARE_METATYPE(QSerialPort::SerialPortError) Q_DECLARE_METATYPE(QSerialPort::SerialPortError)
#include "QGCConfig.h"
#include "LinkManager.h"
class SerialConfiguration : public LinkConfiguration
{
public:
SerialConfiguration(const QString& name);
SerialConfiguration(SerialConfiguration* copy);
int baud() { return _baud; }
int dataBits() { return _dataBits; }
int flowControl() { return _flowControl; } ///< QSerialPort Enums
int stopBits() { return _stopBits; }
int parity() { return _parity; } ///< QSerialPort Enums
const QString portName() { return _portName; }
void setBaud (int baud);
void setDataBits (int databits);
void setFlowControl (int flowControl); ///< QSerialPort Enums
void setStopBits (int stopBits);
void setParity (int parity); ///< QSerialPort Enums
void setPortName (const QString& portName);
/// From LinkConfiguration
int type() { return LinkConfiguration::TypeSerial; }
void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root);
void updateSettings();
/*! @brief Get a list of the currently available ports */
static QList<QString> getCurrentPorts();
private:
int _baud;
int _dataBits;
int _flowControl;
int _stopBits;
int _parity;
QString _portName;
};
/** /**
* @brief The SerialLink class provides cross-platform access to serial links. * @brief The SerialLink class provides cross-platform access to serial links.
* It takes care of the link management and provides a common API to higher * It takes care of the link management and provides a common API to higher
...@@ -52,84 +99,36 @@ Q_DECLARE_METATYPE(QSerialPort::SerialPortError) ...@@ -52,84 +99,36 @@ Q_DECLARE_METATYPE(QSerialPort::SerialPortError)
* safe. * safe.
* *
*/ */
class SerialLink : public SerialLinkInterface class SerialLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
//Q_INTERFACES(SerialLinkInterface:LinkInterface) friend class SerialConfiguration;
public: public:
SerialLink(QString portname = "",
int baudrate=57600,
bool flow=false,
bool parity=false,
int dataBits=8,
int stopBits=1);
~SerialLink();
static const int poll_interval = SERIAL_POLL_INTERVAL; ///< Polling interval, defined in QGCConfig.h
/** @brief Get a list of the currently available ports */ SerialLink(SerialConfiguration* config);
QList<QString> getCurrentPorts(); ~SerialLink();
/** @brief Check if the current port is a bootloader */
bool isBootloader();
void requestReset();
bool isConnected() const; // LinkInterface
/** LinkConfiguration* getLinkConfiguration();
* @brief The port handle int getId() const;
*/
QString getPortName() const;
/**
* @brief The human readable port name
*/
QString getName() const; QString getName() const;
int getBaudRate() const; void requestReset();
int getDataBits() const; bool isConnected() const;
int getStopBits() const; qint64 getConnectionSpeed() const;
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// ENUM values // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
int getBaudRateType() const; bool connect(void);
int getFlowType() const; bool disconnect(void);
int getParityType() const;
int getDataBitsType() const;
int getStopBitsType() const;
qint64 getConnectionSpeed() const;
qint64 getCurrentInDataRate() const;
qint64 getCurrentOutDataRate() const;
void loadSettings();
void writeSettings();
void checkIfCDC();
void run(); void run();
void run2();
int getId() const; static const int poll_interval = SERIAL_POLL_INTERVAL; ///< Polling interval, defined in QGCConfig.h
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void);
bool disconnect(void);
signals: //[TODO] Refactor to Linkinterface signals: //[TODO] Refactor to Linkinterface
void updateLink(LinkInterface*); void updateLink(LinkInterface*);
public slots: public slots:
bool setPortName(QString portName);
bool setBaudRate(int rate);
// Set ENUM values
bool setBaudRateType(int rateIndex);
bool setFlowType(int flow);
bool setParityType(int parity);
bool setDataBitsType(int dataBits);
bool setStopBitsType(int stopBits);
void readBytes(); void readBytes();
/** /**
...@@ -143,37 +142,34 @@ public slots: ...@@ -143,37 +142,34 @@ public slots:
void linkError(QSerialPort::SerialPortError error); void linkError(QSerialPort::SerialPortError error);
protected: protected:
quint64 m_bytesRead; QSerialPort* _port;
QSerialPort* m_port; quint64 _bytesRead;
int m_baud; int _timeout;
int m_dataBits; int _id;
int m_flowControl; QMutex _dataMutex; // Mutex for reading data from _port
int m_stopBits; QMutex _writeMutex; // Mutex for accessing the _transmitBuffer.
int m_parity; QString _type;
QString m_portName;
int m_timeout;
int m_id;
QMutex m_dataMutex; // Mutex for reading data from m_port
QMutex m_writeMutex; // Mutex for accessing the m_transmitBuffer.
QString type;
bool m_is_cdc;
private slots: private slots:
void _rerouteDisconnected(void); void _rerouteDisconnected(void);
private: private:
// From LinkInterface // From LinkInterface
virtual bool _connect(void); bool _connect(void);
virtual bool _disconnect(void); bool _disconnect(void);
void _emitLinkError(const QString& errorMsg);
volatile bool m_stopp; // Internal methods
volatile bool m_reqReset; void _emitLinkError(const QString& errorMsg);
QMutex m_stoppMutex; // Mutex for accessing m_stopp bool _hardwareConnect(QString &_type);
QByteArray m_transmitBuffer; // An internal buffer for receiving data from member functions and actually transmitting them via the serial port. bool _isBootloader();
void _resetConfiguration();
bool hardwareConnect(QString &type);
// Local data
volatile bool _stopp;
volatile bool _reqReset;
QMutex _stoppMutex; // Mutex for accessing _stopp
QByteArray _transmitBuffer; // An internal buffer for receiving data from member functions and actually transmitting them via the serial port.
SerialConfiguration* _config;
signals: signals:
void aboutToCloseFlag(); void aboutToCloseFlag();
......
...@@ -37,12 +37,12 @@ This file is part of the QGROUNDCONTROL project ...@@ -37,12 +37,12 @@ This file is part of the QGROUNDCONTROL project
#include <QVector> #include <QVector>
#include <LinkInterface.h> #include <LinkInterface.h>
/*
class SerialLinkInterface : public LinkInterface class SerialLinkInterface : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
virtual QList<QString> getCurrentPorts() = 0;
virtual QString getPortName() const = 0; virtual QString getPortName() const = 0;
virtual int getBaudRate() const = 0; virtual int getBaudRate() const = 0;
virtual int getDataBits() const = 0; virtual int getDataBits() const = 0;
...@@ -66,7 +66,7 @@ public slots: ...@@ -66,7 +66,7 @@ public slots:
virtual void writeSettings() = 0; virtual void writeSettings() = 0;
}; };
*/
/* Declare C++ interface as Qt interface */ /* Declare C++ interface as Qt interface */
//Q_DECLARE_INTERFACE(SerialLinkInterface, "org.openground.comm.links.SerialLinkInterface/1.0") //Q_DECLARE_INTERFACE(SerialLinkInterface, "org.openground.comm.links.SerialLinkInterface/1.0")
......
This diff is collapsed.
...@@ -21,7 +21,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -21,7 +21,7 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/ ======================================================================*/
/** /*!
* @file * @file
* @brief UDP connection (server) for unmanned vehicles * @brief UDP connection (server) for unmanned vehicles
* @author Lorenz Meier <mavteam@student.ethz.ch> * @author Lorenz Meier <mavteam@student.ethz.ch>
...@@ -36,39 +36,120 @@ This file is part of the QGROUNDCONTROL project ...@@ -36,39 +36,120 @@ This file is part of the QGROUNDCONTROL project
#include <QMap> #include <QMap>
#include <QMutex> #include <QMutex>
#include <QUdpSocket> #include <QUdpSocket>
#include <LinkInterface.h>
#include "QGCConfig.h" #include "QGCConfig.h"
#include "LinkManager.h"
#define QGC_UDP_PORT 14550
class UDPConfiguration : public LinkConfiguration
{
public:
/*!
* @brief Regular constructor
*
* @param[in] name Configuration (user friendly) name
*/
UDPConfiguration(const QString& name);
/*!
* @brief Copy contructor
*
* When manipulating data, you create a copy of the configuration, edit it
* and then transfer its content to the original (using copyFrom() below). Use this
* contructor to create an editable copy.
*
* @param[in] source Original configuration
*/
UDPConfiguration(UDPConfiguration* source);
/*!
* @brief Begin iteration through the list of target hosts
*
* @param[out] host Host name
* @param[out] port Port number
* @return Returns false if list is empty
*/
bool firstHost (QString& host, int& port);
/*!
* @brief Continues iteration through the list of target hosts
*
* @param[out] host Host name
* @param[out] port Port number
* @return Returns false if reached the end of the list (in which case, both host and port are unchanged)
*/
bool nextHost (QString& host, int& port);
/*!
* @brief Get the number of target hosts
*
* @return Number of hosts in list
*/
int hostCount () { return _hosts.count(); }
/*!
* @brief The UDP port we bind to
*
* @return Port number
*/
quint16 localPort () { return _localPort; }
/*!
* @brief Add a target host
*
* @param[in] host Host name in standard formatt, e.g. localhost:14551 or 192.168.1.1:14551
*/
void addHost (const QString& host);
/*!
* @brief Add a target host
*
* @param[in] host Host name, e.g. localhost or 192.168.1.1
* @param[in] port Port number
*/
void addHost (const QString& host, int port);
/*!
* @brief Remove a target host from the list
*
* @param[in] host Host name, e.g. localhost or 192.168.1.1
*/
void removeHost (const QString& host);
/*!
* @brief Set the UDP port we bind to
*
* @param[in] port Port number
*/
void setLocalPort (quint16 port);
/// From LinkConfiguration
int type() { return LinkConfiguration::TypeUdp; }
void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root);
void updateSettings();
private:
QMutex _confMutex;
QMap<QString, int>::iterator _it;
QMap<QString, int> _hosts; ///< ("host", port)
quint16 _localPort;
};
class UDPLink : public LinkInterface class UDPLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
//Q_INTERFACES(UDPLinkInterface:LinkInterface) friend class UDPConfiguration;
public: public:
UDPLink(QHostAddress host = QHostAddress::Any, quint16 port = 14550); UDPLink(UDPConfiguration* config);
//UDPLink(QHostAddress host = "239.255.76.67", quint16 port = 7667);
~UDPLink(); ~UDPLink();
void requestReset() { } void requestReset() { }
bool isConnected() const; bool isConnected() const;
int getPort() const {
return port;
}
/**
* @brief The human readable port name
*/
QString getName() const; QString getName() const;
int getBaudRate() const;
int getBaudRateType() const;
int getFlowType() const;
int getParityType() const;
int getDataBitsType() const;
int getStopBitsType() const;
QList<QHostAddress> getHosts() const {
return hosts;
}
// Extensive statistics for scientific purposes // Extensive statistics for scientific purposes
qint64 getConnectionSpeed() const; qint64 getConnectionSpeed() const;
...@@ -76,25 +157,25 @@ public: ...@@ -76,25 +157,25 @@ public:
qint64 getCurrentOutDataRate() const; qint64 getCurrentOutDataRate() const;
void run(); void run();
int getId() const; int getId() const;
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of // These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager. // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void); bool connect(void);
bool disconnect(void); bool disconnect(void);
LinkConfiguration* getLinkConfiguration() { return _config; }
public slots: public slots:
void setAddress(QHostAddress host);
void setPort(int port); /*! @brief Add a new host to broadcast messages to */
/** @brief Add a new host to broadcast messages to */ void addHost (const QString& host);
void addHost(const QString& host); /*! @brief Remove a host from broadcasting messages to */
/** @brief Remove a host from broadcasting messages to */ void removeHost (const QString& host);
void removeHost(const QString& host);
// void readPendingDatagrams();
void readBytes(); void readBytes();
/**
/*!
* @brief Write a number of bytes to the interface. * @brief Write a number of bytes to the interface.
* *
* @param data Pointer to the data byte array * @param data Pointer to the data byte array
...@@ -103,25 +184,19 @@ public slots: ...@@ -103,25 +184,19 @@ public slots:
void writeBytes(const char* data, qint64 length); void writeBytes(const char* data, qint64 length);
protected: protected:
QString name;
QHostAddress host;
quint16 port;
int id;
QUdpSocket* socket;
bool connectState;
QList<QHostAddress> hosts;
QList<quint16> ports;
QMutex dataMutex;
void setName(QString name); QUdpSocket* _socket;
UDPConfiguration* _config;
bool _connectState;
int _id;
private: private:
// From LinkInterface // From LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual bool _disconnect(void); virtual bool _disconnect(void);
bool hardwareConnect(void); bool _hardwareConnect();
void _restartConnection();
signals: signals:
//Signals are defined by LinkInterface //Signals are defined by LinkInterface
......
...@@ -34,8 +34,6 @@ This file is part of the QGROUNDCONTROL project ...@@ -34,8 +34,6 @@ This file is part of the QGROUNDCONTROL project
#include "QGCApplication.h" #include "QGCApplication.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "configuration.h" #include "configuration.h"
#include "SerialLink.h"
#include "TCPLink.h"
#ifdef QT_DEBUG #ifdef QT_DEBUG
#include "UnitTest.h" #include "UnitTest.h"
#include "CmdLineOptParser.h" #include "CmdLineOptParser.h"
...@@ -67,7 +65,7 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString ...@@ -67,7 +65,7 @@ void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString
int WindowsCrtReportHook(int reportType, char* message, int* returnValue) int WindowsCrtReportHook(int reportType, char* message, int* returnValue)
{ {
Q_UNUSED(reportType); Q_UNUSED(reportType);
std::cerr << message << std::endl; // Output message to stderr std::cerr << message << std::endl; // Output message to stderr
*returnValue = 0; // Don't break into debugger *returnValue = 0; // Don't break into debugger
return true; // We handled this fully ourselves return true; // We handled this fully ourselves
...@@ -103,23 +101,23 @@ int main(int argc, char *argv[]) ...@@ -103,23 +101,23 @@ int main(int argc, char *argv[])
// anyway to silence the debug output. // anyway to silence the debug output.
qRegisterMetaType<QSerialPort::SerialPortError>(); qRegisterMetaType<QSerialPort::SerialPortError>();
qRegisterMetaType<QAbstractSocket::SocketError>(); qRegisterMetaType<QAbstractSocket::SocketError>();
bool runUnitTests = false; // Run unit tests bool runUnitTests = false; // Run unit tests
#ifdef QT_DEBUG #ifdef QT_DEBUG
// We parse a small set of command line options here prior to QGCApplication in order to handle the ones // We parse a small set of command line options here prior to QGCApplication in order to handle the ones
// which need to be handled before a QApplication object is started. // which need to be handled before a QApplication object is started.
bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes
CmdLineOpt_t rgCmdLineOptions[] = { CmdLineOpt_t rgCmdLineOptions[] = {
{ "--unittest", &runUnitTests, QString() }, { "--unittest", &runUnitTests, QString() },
{ "--no-windows-assert-ui", &quietWindowsAsserts, QString() }, { "--no-windows-assert-ui", &quietWindowsAsserts, QString() },
// Add additional command line option flags here // Add additional command line option flags here
}; };
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false); ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
if (quietWindowsAsserts) { if (quietWindowsAsserts) {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
_CrtSetReportHook(WindowsCrtReportHook); _CrtSetReportHook(WindowsCrtReportHook);
...@@ -135,27 +133,27 @@ int main(int argc, char *argv[]) ...@@ -135,27 +133,27 @@ int main(int argc, char *argv[])
} }
#endif #endif
#endif // QT_DEBUG #endif // QT_DEBUG
QGCApplication* app = new QGCApplication(argc, argv, runUnitTests); QGCApplication* app = new QGCApplication(argc, argv, runUnitTests);
Q_CHECK_PTR(app); Q_CHECK_PTR(app);
// There appears to be a threading issue in qRegisterMetaType which can cause it to throw a qWarning // There appears to be a threading issue in qRegisterMetaType which can cause it to throw a qWarning
// about duplicate type converters. This is caused by a race condition in the Qt code. Still working // about duplicate type converters. This is caused by a race condition in the Qt code. Still working
// with them on tracking down the bug. For now we register the type which is giving us problems here // with them on tracking down the bug. For now we register the type which is giving us problems here
// while we only have the main thread. That should prevent it from hitting the race condition later // while we only have the main thread. That should prevent it from hitting the race condition later
// on in the code. // on in the code.
qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >(); qRegisterMetaType<QList<QPair<QByteArray,QByteArray> > >();
app->_initCommon(); app->_initCommon();
int exitCode; int exitCode;
#ifdef QT_DEBUG #ifdef QT_DEBUG
if (runUnitTests) { if (runUnitTests) {
if (!app->_initForUnitTests()) { if (!app->_initForUnitTests()) {
return -1; return -1;
} }
// Run the test // Run the test
int failures = UnitTest::run(rgCmdLineOptions[0].optionArg); int failures = UnitTest::run(rgCmdLineOptions[0].optionArg);
if (failures == 0) { if (failures == 0) {
...@@ -172,10 +170,10 @@ int main(int argc, char *argv[]) ...@@ -172,10 +170,10 @@ int main(int argc, char *argv[])
} }
exitCode = app->exec(); exitCode = app->exec();
} }
delete app; delete app;
qDebug() << "After app delete"; qDebug() << "After app delete";
return exitCode; return exitCode;
} }
This diff is collapsed.
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#ifndef MOCKLINK_H #ifndef MOCKLINK_H
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <QLoggingCategory> #include <QLoggingCategory>
#include "MockLinkMissionItemHandler.h" #include "MockLinkMissionItemHandler.h"
#include "LinkInterface.h" #include "LinkManager.h"
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
Q_DECLARE_LOGGING_CATEGORY(MockLinkLog) Q_DECLARE_LOGGING_CATEGORY(MockLinkLog)
...@@ -38,14 +38,28 @@ Q_DECLARE_LOGGING_CATEGORY(MockLinkLog) ...@@ -38,14 +38,28 @@ Q_DECLARE_LOGGING_CATEGORY(MockLinkLog)
/// ///
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
class MockConfiguration : public LinkConfiguration
{
public:
MockConfiguration(const QString& name) : LinkConfiguration(name) {}
MockConfiguration(MockConfiguration* source) : LinkConfiguration(source) {}
int type() { return LinkConfiguration::TypeMock; }
void copyFrom(LinkConfiguration* source) { LinkConfiguration::copyFrom(source); }
void loadSettings(QSettings& settings, const QString& root) { Q_UNUSED(settings); Q_UNUSED(root); }
void saveSettings(QSettings& settings, const QString& root) { Q_UNUSED(settings); Q_UNUSED(root); }
void updateSettings() {}
};
class MockLink : public LinkInterface class MockLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
public: public:
MockLink(void); // LinkConfiguration is optional for MockLink
MockLink(MockConfiguration* config = NULL);
~MockLink(void); ~MockLink(void);
// Virtuals from LinkInterface // Virtuals from LinkInterface
virtual int getId(void) const { return _linkId; } virtual int getId(void) const { return _linkId; }
virtual QString getName(void) const { return _name; } virtual QString getName(void) const { return _name; }
...@@ -53,40 +67,42 @@ public: ...@@ -53,40 +67,42 @@ public:
virtual bool isConnected(void) const { return _connected; } virtual bool isConnected(void) const { return _connected; }
virtual qint64 getConnectionSpeed(void) const { return 100000000; } virtual qint64 getConnectionSpeed(void) const { return 100000000; }
virtual qint64 bytesAvailable(void) { return 0; } virtual qint64 bytesAvailable(void) { return 0; }
// MockLink methods // MockLink methods
MAV_AUTOPILOT getAutopilotType(void) { return _autopilotType; } MAV_AUTOPILOT getAutopilotType(void) { return _autopilotType; }
void setAutopilotType(MAV_AUTOPILOT autopilot) { _autopilotType = autopilot; } void setAutopilotType(MAV_AUTOPILOT autopilot) { _autopilotType = autopilot; }
// These are left unimplemented in order to cause linker errors which indicate incorrect usage of // These are left unimplemented in order to cause linker errors which indicate incorrect usage of
// connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager. // connect/disconnect on link directly. All connect/disconnect calls should be made through LinkManager.
bool connect(void); bool connect(void);
bool disconnect(void); bool disconnect(void);
LinkConfiguration* getLinkConfiguration() { return _config; }
signals: signals:
/// @brief Used internally to move data to the thread. /// @brief Used internally to move data to the thread.
void _incomingBytes(const QByteArray bytes); void _incomingBytes(const QByteArray bytes);
public slots: public slots:
virtual void writeBytes(const char *bytes, qint64 cBytes); virtual void writeBytes(const char *bytes, qint64 cBytes);
protected slots: protected slots:
// FIXME: This should not be part of LinkInterface. It is an internal link implementation detail. // FIXME: This should not be part of LinkInterface. It is an internal link implementation detail.
virtual void readBytes(void); virtual void readBytes(void);
private slots: private slots:
void _run1HzTasks(void); void _run1HzTasks(void);
void _run10HzTasks(void); void _run10HzTasks(void);
void _run50HzTasks(void); void _run50HzTasks(void);
private: private:
// From LinkInterface // From LinkInterface
virtual bool _connect(void); virtual bool _connect(void);
virtual bool _disconnect(void); virtual bool _disconnect(void);
// QThread override // QThread override
virtual void run(void); virtual void run(void);
// MockLink methods // MockLink methods
void _sendHeartBeat(void); void _sendHeartBeat(void);
void _handleIncomingBytes(const QByteArray bytes); void _handleIncomingBytes(const QByteArray bytes);
...@@ -106,27 +122,28 @@ private: ...@@ -106,27 +122,28 @@ private:
void _setParamFloatUnionIntoMap(const QString& paramName, float paramFloat); void _setParamFloatUnionIntoMap(const QString& paramName, float paramFloat);
MockLinkMissionItemHandler* _missionItemHandler; MockLinkMissionItemHandler* _missionItemHandler;
int _linkId; int _linkId;
QString _name; QString _name;
bool _connected; bool _connected;
uint8_t _vehicleSystemId; uint8_t _vehicleSystemId;
uint8_t _vehicleComponentId; uint8_t _vehicleComponentId;
bool _inNSH; bool _inNSH;
bool _mavlinkStarted; bool _mavlinkStarted;
QMap<QString, QVariant> _mapParamName2Value; QMap<QString, QVariant> _mapParamName2Value;
QMap<QString, MAV_PARAM_TYPE> _mapParamName2MavParamType; QMap<QString, MAV_PARAM_TYPE> _mapParamName2MavParamType;
typedef QMap<uint16_t, mavlink_mission_item_t> MissionList_t; typedef QMap<uint16_t, mavlink_mission_item_t> MissionList_t;
MissionList_t _missionItems; MissionList_t _missionItems;
uint8_t _mavBaseMode; uint8_t _mavBaseMode;
uint8_t _mavCustomMode; uint8_t _mavCustomMode;
uint8_t _mavState; uint8_t _mavState;
MockConfiguration* _config;
MAV_AUTOPILOT _autopilotType; MAV_AUTOPILOT _autopilotType;
}; };
......
/*===================================================================== /*=====================================================================
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful, QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>. along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/ ======================================================================*/
#ifndef MOCKLINKMISSIONITEMHANDLER_H #ifndef MOCKLINKMISSIONITEMHANDLER_H
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "MAVLinkSimulationLink.h" #include "MAVLinkSimulationLink.h"
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
/* Alreedy defined in MAVLinkSimulationLink.h above!
enum PX_WAYPOINTPLANNER_STATES { enum PX_WAYPOINTPLANNER_STATES {
PX_WPP_IDLE = 0, PX_WPP_IDLE = 0,
PX_WPP_SENDLIST, PX_WPP_SENDLIST,
...@@ -40,14 +41,15 @@ enum PX_WAYPOINTPLANNER_STATES { ...@@ -40,14 +41,15 @@ enum PX_WAYPOINTPLANNER_STATES {
PX_WPP_GETLIST_GETWPS, PX_WPP_GETLIST_GETWPS,
PX_WPP_GETLIST_GOTALL PX_WPP_GETLIST_GOTALL
}; };
*/
class MockLinkMissionItemHandler : public QObject class MockLinkMissionItemHandler : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
MockLinkMissionItemHandler(uint16_t systemId, QObject* parent = NULL); MockLinkMissionItemHandler(uint16_t systemId, QObject* parent = NULL);
/// @brief Called to handle mission item related messages. All messages should be passed to this method. /// @brief Called to handle mission item related messages. All messages should be passed to this method.
/// It will handle the appropriate set. /// It will handle the appropriate set.
void handleMessage(const mavlink_message_t& msg); void handleMessage(const mavlink_message_t& msg);
...@@ -98,10 +100,10 @@ protected: ...@@ -98,10 +100,10 @@ protected:
float distanceToPoint(uint16_t seq, float x, float y); float distanceToPoint(uint16_t seq, float x, float y);
void mavlink_handler(const mavlink_message_t* msg); void mavlink_handler(const mavlink_message_t* msg);
#endif #endif
private: private:
uint16_t _vehicleSystemId; ///< System id of this vehicle uint16_t _vehicleSystemId; ///< System id of this vehicle
QList<mavlink_mission_item_t> _missionItems; ///< Current set of mission itemss QList<mavlink_mission_item_t> _missionItems; ///< Current set of mission itemss
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -91,13 +91,13 @@ public: ...@@ -91,13 +91,13 @@ public:
/// @brief Returns the MainWindow singleton. Will not create the MainWindow if it has not already /// @brief Returns the MainWindow singleton. Will not create the MainWindow if it has not already
/// been created. /// been created.
static MainWindow* instance(void); static MainWindow* instance(void);
/// @brief Deletes the MainWindow singleton /// @brief Deletes the MainWindow singleton
void deleteInstance(void); void deleteInstance(void);
/// @brief Creates the MainWindow singleton. Should only be called once by QGCApplication. /// @brief Creates the MainWindow singleton. Should only be called once by QGCApplication.
static MainWindow* _create(QSplashScreen* splashScreen); static MainWindow* _create(QSplashScreen* splashScreen);
/// @brief Called to indicate that splash screen is no longer being displayed. /// @brief Called to indicate that splash screen is no longer being displayed.
void splashScreenFinished(void) { _splashScreen = NULL; } void splashScreenFinished(void) { _splashScreen = NULL; }
...@@ -117,14 +117,19 @@ public: ...@@ -117,14 +117,19 @@ public:
} }
QList<QAction*> listLinkMenuActions(); QList<QAction*> listLinkMenuActions();
void hideSplashScreen(void); void hideSplashScreen(void);
/// @brief Saves the last used connection
void saveLastUsedConnection(const QString connection);
/// @brief Restore (and connects) the last used connection (if any)
void restoreLastUsedConnection();
public slots: public slots:
/** @brief Show the application settings */ /** @brief Show the application settings */
void showSettings(); void showSettings();
/** @brief Add a communication link */
LinkInterface* addLink();
bool configLink(LinkInterface *link); bool configLink(LinkInterface *link);
/** @brief Simulate a link */ /** @brief Simulate a link */
void simulateLink(bool simulate); void simulateLink(bool simulate);
...@@ -158,6 +163,8 @@ public slots: ...@@ -158,6 +163,8 @@ public slots:
void loadGoogleEarthView(); void loadGoogleEarthView();
/** @brief Load local 3D view */ /** @brief Load local 3D view */
void loadLocal3DView(); void loadLocal3DView();
/** @brief Manage Links */
void manageLinks();
/** @brief Show the online help for users */ /** @brief Show the online help for users */
void showHelp(); void showHelp();
...@@ -178,7 +185,7 @@ public slots: ...@@ -178,7 +185,7 @@ public slots:
void configureWindowName(); void configureWindowName();
void commsWidgetDestroyed(QObject *obj); void commsWidgetDestroyed(QObject *obj);
protected slots: protected slots:
/** /**
* @brief Unchecks the normalActionItem. * @brief Unchecks the normalActionItem.
...@@ -243,7 +250,7 @@ protected: ...@@ -243,7 +250,7 @@ protected:
QPointer<QWidget> q3DWidget; QPointer<QWidget> q3DWidget;
#endif #endif
#ifdef QGC_GOOGLE_EARTH_ENABLED #ifdef QGC_GOOGLE_EARTH_ENABLED
QPointer<QGCGoogleEarthView> earthWidget; QPointer<QGCGoogleEarthView> earthWidget;
#endif #endif
QPointer<QGCFirmwareUpdate> firmwareUpdateWidget; QPointer<QGCFirmwareUpdate> firmwareUpdateWidget;
...@@ -288,9 +295,8 @@ protected: ...@@ -288,9 +295,8 @@ protected:
bool lowPowerMode; ///< If enabled, QGC reduces the update rates of all widgets bool lowPowerMode; ///< If enabled, QGC reduces the update rates of all widgets
QGCFlightGearLink* fgLink; QGCFlightGearLink* fgLink;
QTimer windowNameUpdateTimer; QTimer windowNameUpdateTimer;
private slots: private slots:
void _addLinkMenu(LinkInterface* link);
void _showDockWidgetAction(bool show); void _showDockWidgetAction(bool show);
void _loadCustomWidgetFromFile(void); void _loadCustomWidgetFromFile(void);
void _createNewCustomWidget(void); void _createNewCustomWidget(void);
...@@ -301,9 +307,9 @@ private slots: ...@@ -301,9 +307,9 @@ private slots:
private: private:
/// Constructor is private since all creation should be through MainWindow::_create /// Constructor is private since all creation should be through MainWindow::_create
MainWindow(QSplashScreen* splashScreen); MainWindow(QSplashScreen* splashScreen);
void _openUrl(const QString& url, const QString& errorMessage); void _openUrl(const QString& url, const QString& errorMessage);
// Center widgets // Center widgets
QPointer<QWidget> _plannerView; QPointer<QWidget> _plannerView;
QPointer<QWidget> _pilotView; QPointer<QWidget> _pilotView;
...@@ -313,10 +319,10 @@ private: ...@@ -313,10 +319,10 @@ private:
QPointer<QWidget> _terminalView; QPointer<QWidget> _terminalView;
QPointer<QWidget> _googleEarthView; QPointer<QWidget> _googleEarthView;
QPointer<QWidget> _local3DView; QPointer<QWidget> _local3DView;
VIEW_SECTIONS _currentView; ///< Currently displayed view VIEW_SECTIONS _currentView; ///< Currently displayed view
QWidget* _currentViewWidget; ///< Currently displayed view widget QWidget* _currentViewWidget; ///< Currently displayed view widget
// Dock widget names // Dock widget names
static const char* _uasControlDockWidgetName; static const char* _uasControlDockWidgetName;
static const char* _uasListDockWidgetName; static const char* _uasListDockWidgetName;
...@@ -333,11 +339,11 @@ private: ...@@ -333,11 +339,11 @@ private:
static const char* _hudDockWidgetName; static const char* _hudDockWidgetName;
static const char* _uasInfoViewDockWidgetName; static const char* _uasInfoViewDockWidgetName;
static const char* _debugConsoleDockWidgetName; static const char* _debugConsoleDockWidgetName;
QMap<QString, QDockWidget*> _mapName2DockWidget; QMap<QString, QDockWidget*> _mapName2DockWidget;
QMap<int, QDockWidget*> _mapUasId2HilDockWidget; QMap<int, QDockWidget*> _mapUasId2HilDockWidget;
QMap<QDockWidget*, QAction*> _mapDockWidget2Action; QMap<QDockWidget*, QAction*> _mapDockWidget2Action;
void _buildPlannerView(void); void _buildPlannerView(void);
void _buildPilotView(void); void _buildPilotView(void);
void _buildSetupView(void); void _buildSetupView(void);
...@@ -346,10 +352,10 @@ private: ...@@ -346,10 +352,10 @@ private:
void _buildTerminalView(void); void _buildTerminalView(void);
void _buildGoogleEarthView(void); void _buildGoogleEarthView(void);
void _buildLocal3DView(void); void _buildLocal3DView(void);
void _storeCurrentViewState(void); void _storeCurrentViewState(void);
void _loadCurrentViewState(void); void _loadCurrentViewState(void);
void _createDockWidget(const QString& title, const QString& name, Qt::DockWidgetArea area, QWidget* innerWidget); void _createDockWidget(const QString& title, const QString& name, Qt::DockWidgetArea area, QWidget* innerWidget);
void _createInnerDockWidget(const QString& widgetName); void _createInnerDockWidget(const QString& widgetName);
void _buildCustomWidgets(void); void _buildCustomWidgets(void);
...@@ -358,18 +364,18 @@ private: ...@@ -358,18 +364,18 @@ private:
void _hideAllDockWidgets(void); void _hideAllDockWidgets(void);
void _showDockWidget(const QString &name, bool show); void _showDockWidget(const QString &name, bool show);
void _showHILConfigurationWidgets(void); void _showHILConfigurationWidgets(void);
QList<QGCToolWidget*> _customWidgets; QList<QGCToolWidget*> _customWidgets;
QVBoxLayout* _centralLayout; QVBoxLayout* _centralLayout;
QList<QObject*> commsWidgetList; QList<QObject*> commsWidgetList;
MenuActionHelper *menuActionHelper; MenuActionHelper *menuActionHelper;
Ui::MainWindow ui; Ui::MainWindow ui;
QString getWindowStateKey(); QString getWindowStateKey();
QString getWindowGeometryKey(); QString getWindowGeometryKey();
QSplashScreen* _splashScreen; ///< Splash screen, NULL is splash screen not currently being shown QSplashScreen* _splashScreen; ///< Splash screen, NULL is splash screen not currently being shown
friend class MenuActionHelper; //For VIEW_SECTIONS friend class MenuActionHelper; //For VIEW_SECTIONS
......
...@@ -170,12 +170,8 @@ ...@@ -170,12 +170,8 @@
</property> </property>
</action> </action>
<action name="actionAdd_Link"> <action name="actionAdd_Link">
<property name="icon">
<iconset resource="../../qgroundcontrol.qrc">
<normaloff>:/files/images/actions/list-add.svg</normaloff>:/files/images/actions/list-add.svg</iconset>
</property>
<property name="text"> <property name="text">
<string>Add Link</string> <string>Manage Links</string>
</property> </property>
</action> </action>
<action name="actionSimulate"> <action name="actionSimulate">
......
This diff is collapsed.
#ifndef QGCCOMMCONFIGURATION_H
#define QGCCOMMCONFIGURATION_H
#include <QWidget>
#include <QDialog>
#include "LinkConfiguration.h"
namespace Ui {
class QGCCommConfiguration;
}
class QGCCommConfiguration : public QDialog
{
Q_OBJECT
public:
explicit QGCCommConfiguration(QWidget *parent, LinkConfiguration* config = 0);
~QGCCommConfiguration();
enum {
QGC_LINK_SERIAL,
QGC_LINK_UDP,
QGC_LINK_TCP,
QGC_LINK_SIMULATION,
QGC_LINK_FORWARDING,
#ifdef UNITTEST_BUILD
QGC_LINK_MOCK,
#endif
#ifdef QGC_XBEE_ENABLED
QGC_LINK_XBEE,
#endif
#ifdef QGC_RTLAB_ENABLED
QGC_LINK_OPAL
#endif
};
LinkConfiguration* getConfig() { return _config; }
private slots:
void on_typeCombo_currentIndexChanged(int index);
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_nameEdit_textEdited(const QString &arg1);
private:
void _changeLinkType(int type);
void _loadTypeConfigWidget(int type);
void _updateUI();
Ui::QGCCommConfiguration* _ui;
LinkConfiguration* _config;
};
#endif // QGCCOMMCONFIGURATION_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,9 +10,8 @@ QGCUnconnectedInfoWidget::QGCUnconnectedInfoWidget(QWidget *parent) : ...@@ -10,9 +10,8 @@ QGCUnconnectedInfoWidget::QGCUnconnectedInfoWidget(QWidget *parent) :
ui(new Ui::QGCUnconnectedInfoWidget) ui(new Ui::QGCUnconnectedInfoWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
//connect(ui->simulationButton, SIGNAL(clicked()), this, SLOT(simulate())); //connect(ui->simulationButton, SIGNAL(clicked()), this, SLOT(simulate()));
connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(addLink())); //connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(addLink()));
} }
QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget() QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget()
...@@ -25,6 +24,7 @@ QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget() ...@@ -25,6 +24,7 @@ QGCUnconnectedInfoWidget::~QGCUnconnectedInfoWidget()
*/ */
void QGCUnconnectedInfoWidget::simulate() void QGCUnconnectedInfoWidget::simulate()
{ {
// TODO What is this?
// Try to get reference to MAVLinkSimulationlink // Try to get reference to MAVLinkSimulationlink
QList<LinkInterface*> links = LinkManager::instance()->getLinks(); QList<LinkInterface*> links = LinkManager::instance()->getLinks();
foreach(LinkInterface* link, links) { foreach(LinkInterface* link, links) {
...@@ -40,5 +40,6 @@ void QGCUnconnectedInfoWidget::simulate() ...@@ -40,5 +40,6 @@ void QGCUnconnectedInfoWidget::simulate()
*/ */
void QGCUnconnectedInfoWidget::addLink() void QGCUnconnectedInfoWidget::addLink()
{ {
MainWindow::instance()->addLink(); // TODO This doesn't make sense. If you want to connect, use the connect on the toolbar
//MainWindow::instance()->addLink();
} }
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