Commit 64e8919c authored by Don Gagne's avatar Don Gagne

Merge pull request #1254 from dogmaphobic/linkManagerTCP

Adding TCP to the Link Configuration Manager
parents 2e85fa8f a5c618e7
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project
#include "LinkConfiguration.h" #include "LinkConfiguration.h"
#include "SerialLink.h" #include "SerialLink.h"
#include "UDPLink.h" #include "UDPLink.h"
#include "TCPLink.h"
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
#include "MockLink.h" #include "MockLink.h"
...@@ -84,6 +85,9 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na ...@@ -84,6 +85,9 @@ LinkConfiguration* LinkConfiguration::createSettings(int type, const QString& na
case LinkConfiguration::TypeUdp: case LinkConfiguration::TypeUdp:
config = new UDPConfiguration(name); config = new UDPConfiguration(name);
break; break;
case LinkConfiguration::TypeTcp:
config = new TCPConfiguration(name);
break;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock: case LinkConfiguration::TypeMock:
config = new MockConfiguration(name); config = new MockConfiguration(name);
...@@ -107,6 +111,9 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc ...@@ -107,6 +111,9 @@ LinkConfiguration* LinkConfiguration::duplicateSettings(LinkConfiguration* sourc
case TypeUdp: case TypeUdp:
dupe = new UDPConfiguration(dynamic_cast<UDPConfiguration*>(source)); dupe = new UDPConfiguration(dynamic_cast<UDPConfiguration*>(source));
break; break;
case TypeTcp:
dupe = new TCPConfiguration(dynamic_cast<TCPConfiguration*>(source));
break;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
case TypeMock: case TypeMock:
dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source)); dupe = new MockConfiguration(dynamic_cast<MockConfiguration*>(source));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -41,9 +41,9 @@ public: ...@@ -41,9 +41,9 @@ public:
enum { enum {
TypeSerial, ///< Serial Link TypeSerial, ///< Serial Link
TypeUdp, ///< UDP Link TypeUdp, ///< UDP Link
TypeTcp, ///< TCP Link
// TODO Below is not yet implemented // TODO Below is not yet implemented
#if 0 #if 0
TypeTcp, ///< TCP Link
TypeSimulation, ///< Simulation Link TypeSimulation, ///< Simulation Link
TypeForwarding, ///< Forwarding Link TypeForwarding, ///< Forwarding Link
TypeXbee, ///< XBee Proprietary Link TypeXbee, ///< XBee Proprietary Link
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -79,6 +79,9 @@ LinkInterface* LinkManager::createLink(LinkConfiguration* config) ...@@ -79,6 +79,9 @@ LinkInterface* LinkManager::createLink(LinkConfiguration* config)
case LinkConfiguration::TypeUdp: case LinkConfiguration::TypeUdp:
pLink = new UDPLink(dynamic_cast<UDPConfiguration*>(config)); pLink = new UDPLink(dynamic_cast<UDPConfiguration*>(config));
break; break;
case LinkConfiguration::TypeTcp:
pLink = new TCPLink(dynamic_cast<TCPConfiguration*>(config));
break;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock: case LinkConfiguration::TypeMock:
pLink = new MockLink(dynamic_cast<MockConfiguration*>(config)); pLink = new MockLink(dynamic_cast<MockConfiguration*>(config));
...@@ -375,6 +378,10 @@ void LinkManager::loadLinkConfigurationList() ...@@ -375,6 +378,10 @@ void LinkManager::loadLinkConfigurationList()
pLink = (LinkConfiguration*)new UDPConfiguration(name); pLink = (LinkConfiguration*)new UDPConfiguration(name);
pLink->setPreferred(preferred); pLink->setPreferred(preferred);
break; break;
case LinkConfiguration::TypeTcp:
pLink = (LinkConfiguration*)new TCPConfiguration(name);
pLink->setPreferred(preferred);
break;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock: case LinkConfiguration::TypeMock:
pLink = (LinkConfiguration*)new MockConfiguration(name); pLink = (LinkConfiguration*)new MockConfiguration(name);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
PIXHAWK Micro Air Vehicle Flying Robotics Toolkit PIXHAWK Micro Air Vehicle Flying Robotics Toolkit
(c) 2009, 2010 PIXHAWK PROJECT <http://pixhawk.ethz.ch> (c) 2009, 2015 PIXHAWK PROJECT <http://pixhawk.ethz.ch>
This file is part of the PIXHAWK project This file is part of the PIXHAWK project
...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project ...@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
// Links // Links
#include "SerialLink.h" #include "SerialLink.h"
#include "UDPLink.h" #include "UDPLink.h"
#include "TCPLink.h"
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
#include "MockLink.h" #include "MockLink.h"
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 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/>.
======================================================================*/
/**
* @file
* @brief Brief Description
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef SERIALLINKINTERFACE_H_
#define SERIALLINKINTERFACE_H_
#include <QObject>
#include <QString>
#include <QVector>
#include <LinkInterface.h>
/*
class SerialLinkInterface : public LinkInterface
{
Q_OBJECT
public:
virtual QString getPortName() const = 0;
virtual int getBaudRate() const = 0;
virtual int getDataBits() const = 0;
virtual int getStopBits() const = 0;
virtual void requestReset() = 0;
virtual int getBaudRateType() const = 0;
virtual int getFlowType() const = 0;
virtual int getParityType() const = 0;
virtual int getDataBitsType() const = 0;
virtual int getStopBitsType() const = 0;
public slots:
virtual bool setPortName(QString portName) = 0;
virtual bool setBaudRate(int rate) = 0;
virtual bool setBaudRateType(int rateIndex) = 0;
virtual bool setFlowType(int flow) = 0;
virtual bool setParityType(int parity) = 0;
virtual bool setDataBitsType(int dataBits) = 0;
virtual bool setStopBitsType(int stopBits) = 0;
virtual void loadSettings() = 0;
virtual void writeSettings() = 0;
};
*/
/* Declare C++ interface as Qt interface */
//Q_DECLARE_INTERFACE(SerialLinkInterface, "org.openground.comm.links.SerialLinkInterface/1.0")
#endif // SERIALLINKINTERFACE_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -37,26 +37,22 @@ ...@@ -37,26 +37,22 @@
/// ///
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
TCPLink::TCPLink(QHostAddress hostAddress, quint16 socketPort) : TCPLink::TCPLink(TCPConfiguration *config)
_hostAddress(hostAddress), : _config(config)
_port(socketPort), , _socket(NULL)
_socket(NULL), , _socketIsConnected(false)
_socketIsConnected(false)
{ {
Q_ASSERT(_config != NULL);
// We're doing it wrong - because the Qt folks got the API wrong: // We're doing it wrong - because the Qt folks got the API wrong:
// http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/ // http://blog.qt.digia.com/blog/2010/06/17/youre-doing-it-wrong/
moveToThread(this); moveToThread(this);
_linkId = getNextLinkId(); _linkId = getNextLinkId();
_resetName(); qDebug() << "TCP Created " << _config->name();
qDebug() << "TCP Created " << _name;
} }
TCPLink::~TCPLink() TCPLink::~TCPLink()
{ {
_disconnect(); _disconnect();
// Tell the thread to exit // Tell the thread to exit
quit(); quit();
// Wait for it to exit // Wait for it to exit
...@@ -66,49 +62,9 @@ TCPLink::~TCPLink() ...@@ -66,49 +62,9 @@ TCPLink::~TCPLink()
void TCPLink::run() void TCPLink::run()
{ {
_hardwareConnect(); _hardwareConnect();
exec(); exec();
} }
void TCPLink::setHostAddress(QHostAddress hostAddress)
{
bool reconnect = false;
if (this->isConnected()) {
_disconnect();
reconnect = true;
}
_hostAddress = hostAddress;
_resetName();
if (reconnect) {
_connect();
}
}
void TCPLink::setHostAddress(const QString& hostAddress)
{
setHostAddress(QHostAddress(hostAddress));
}
void TCPLink::setPort(int port)
{
bool reconnect = false;
if (this->isConnected()) {
_disconnect();
reconnect = true;
}
_port = port;
_resetName();
if (reconnect) {
_connect();
}
}
#ifdef TCPLINK_READWRITE_DEBUG #ifdef TCPLINK_READWRITE_DEBUG
void TCPLink::_writeDebugBytes(const char *data, qint16 size) void TCPLink::_writeDebugBytes(const char *data, qint16 size)
{ {
...@@ -127,7 +83,7 @@ void TCPLink::_writeDebugBytes(const char *data, qint16 size) ...@@ -127,7 +83,7 @@ void TCPLink::_writeDebugBytes(const char *data, qint16 size)
ascii.append(219); ascii.append(219);
} }
} }
qDebug() << "Sent" << size << "bytes to" << _hostAddress.toString() << ":" << _port << "data:"; qDebug() << "Sent" << size << "bytes to" << _config->address().toString() << ":" << _config->port() << "data:";
qDebug() << bytes; qDebug() << bytes;
qDebug() << "ASCII:" << ascii; qDebug() << "ASCII:" << ascii;
} }
...@@ -139,7 +95,6 @@ void TCPLink::writeBytes(const char* data, qint64 size) ...@@ -139,7 +95,6 @@ void TCPLink::writeBytes(const char* data, qint64 size)
_writeDebugBytes(data, size); _writeDebugBytes(data, size);
#endif #endif
_socket->write(data, size); _socket->write(data, size);
// Log the amount and time written out for future data rate calculations. // Log the amount and time written out for future data rate calculations.
QMutexLocker dataRateLocker(&dataRateMutex); QMutexLocker dataRateLocker(&dataRateMutex);
logDataRateToBuffer(outDataWriteAmounts, outDataWriteTimes, &outDataIndex, size, QDateTime::currentMSecsSinceEpoch()); logDataRateToBuffer(outDataWriteAmounts, outDataWriteTimes, &outDataIndex, size, QDateTime::currentMSecsSinceEpoch());
...@@ -154,20 +109,15 @@ void TCPLink::writeBytes(const char* data, qint64 size) ...@@ -154,20 +109,15 @@ void TCPLink::writeBytes(const char* data, qint64 size)
void TCPLink::readBytes() void TCPLink::readBytes()
{ {
qint64 byteCount = _socket->bytesAvailable(); qint64 byteCount = _socket->bytesAvailable();
if (byteCount) if (byteCount)
{ {
QByteArray buffer; QByteArray buffer;
buffer.resize(byteCount); buffer.resize(byteCount);
_socket->read(buffer.data(), buffer.size()); _socket->read(buffer.data(), buffer.size());
emit bytesReceived(this, buffer); emit bytesReceived(this, buffer);
// Log the amount and time received for future data rate calculations. // Log the amount and time received for future data rate calculations.
QMutexLocker dataRateLocker(&dataRateMutex); QMutexLocker dataRateLocker(&dataRateMutex);
logDataRateToBuffer(inDataWriteAmounts, inDataWriteTimes, &inDataIndex, byteCount, QDateTime::currentMSecsSinceEpoch()); logDataRateToBuffer(inDataWriteAmounts, inDataWriteTimes, &inDataIndex, byteCount, QDateTime::currentMSecsSinceEpoch());
#ifdef TCPLINK_READWRITE_DEBUG #ifdef TCPLINK_READWRITE_DEBUG
writeDebugBytes(buffer.data(), buffer.size()); writeDebugBytes(buffer.data(), buffer.size());
#endif #endif
...@@ -183,16 +133,13 @@ bool TCPLink::_disconnect(void) ...@@ -183,16 +133,13 @@ bool TCPLink::_disconnect(void)
{ {
quit(); quit();
wait(); wait();
if (_socket) if (_socket)
{ {
_socketIsConnected = false; _socketIsConnected = false;
_socket->deleteLater(); // Make sure delete happens on correct thread _socket->deleteLater(); // Make sure delete happens on correct thread
_socket = NULL; _socket = NULL;
emit disconnected(); emit disconnected();
} }
return true; return true;
} }
...@@ -208,24 +155,18 @@ bool TCPLink::_connect(void) ...@@ -208,24 +155,18 @@ bool TCPLink::_connect(void)
quit(); quit();
wait(); wait();
} }
start(HighPriority); start(HighPriority);
return true; return true;
} }
bool TCPLink::_hardwareConnect(void) bool TCPLink::_hardwareConnect()
{ {
Q_ASSERT(_socket == NULL); Q_ASSERT(_socket == NULL);
_socket = new QTcpSocket(); _socket = new QTcpSocket();
QSignalSpy errorSpy(_socket, SIGNAL(error(QAbstractSocket::SocketError))); QSignalSpy errorSpy(_socket, SIGNAL(error(QAbstractSocket::SocketError)));
_socket->connectToHost(_config->address(), _config->port());
_socket->connectToHost(_hostAddress, _port);
QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readBytes())); QObject::connect(_socket, SIGNAL(readyRead()), this, SLOT(readBytes()));
QObject::connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_socketError(QAbstractSocket::SocketError))); QObject::connect(_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_socketError(QAbstractSocket::SocketError)));
// Give the socket a second to connect to the other side otherwise error out // Give the socket a second to connect to the other side otherwise error out
if (!_socket->waitForConnected(1000)) if (!_socket->waitForConnected(1000))
{ {
...@@ -238,10 +179,8 @@ bool TCPLink::_hardwareConnect(void) ...@@ -238,10 +179,8 @@ bool TCPLink::_hardwareConnect(void)
_socket = NULL; _socket = NULL;
return false; return false;
} }
_socketIsConnected = true; _socketIsConnected = true;
emit connected(); emit connected();
return true; return true;
} }
...@@ -268,7 +207,7 @@ int TCPLink::getId() const ...@@ -268,7 +207,7 @@ int TCPLink::getId() const
QString TCPLink::getName() const QString TCPLink::getName() const
{ {
return _name; return _config->name();
} }
qint64 TCPLink::getConnectionSpeed() const qint64 TCPLink::getConnectionSpeed() const
...@@ -286,12 +225,6 @@ qint64 TCPLink::getCurrentOutDataRate() const ...@@ -286,12 +225,6 @@ qint64 TCPLink::getCurrentOutDataRate() const
return 0; return 0;
} }
void TCPLink::_resetName(void)
{
_name = QString("TCP Link (host:%1 port:%2)").arg(_hostAddress.toString()).arg(_port);
emit nameChanged(_name);
}
void TCPLink::waitForBytesWritten(int msecs) void TCPLink::waitForBytesWritten(int msecs)
{ {
Q_ASSERT(_socket); Q_ASSERT(_socket);
...@@ -303,3 +236,73 @@ void TCPLink::waitForReadyRead(int msecs) ...@@ -303,3 +236,73 @@ void TCPLink::waitForReadyRead(int msecs)
Q_ASSERT(_socket); Q_ASSERT(_socket);
_socket->waitForReadyRead(msecs); _socket->waitForReadyRead(msecs);
} }
void TCPLink::_restartConnection()
{
if(this->isConnected())
{
_disconnect();
_connect();
}
}
//--------------------------------------------------------------------------
//-- TCPConfiguration
TCPConfiguration::TCPConfiguration(const QString& name) : LinkConfiguration(name)
{
_port = QGC_TCP_PORT;
_address = QHostAddress::Any;
}
TCPConfiguration::TCPConfiguration(TCPConfiguration* source) : LinkConfiguration(source)
{
_port = source->port();
_address = source->address();
}
void TCPConfiguration::copyFrom(LinkConfiguration *source)
{
LinkConfiguration::copyFrom(source);
TCPConfiguration* usource = dynamic_cast<TCPConfiguration*>(source);
Q_ASSERT(usource != NULL);
_port = usource->port();
_address = usource->address();
}
void TCPConfiguration::setPort(quint16 port)
{
_port = port;
}
void TCPConfiguration::setAddress(const QHostAddress& address)
{
_address = address;
}
void TCPConfiguration::saveSettings(QSettings& settings, const QString& root)
{
settings.beginGroup(root);
settings.setValue("port", (int)_port);
settings.setValue("host", address().toString());
settings.endGroup();
}
void TCPConfiguration::loadSettings(QSettings& settings, const QString& root)
{
settings.beginGroup(root);
_port = (quint16)settings.value("port", QGC_UDP_PORT).toUInt();
QString address = settings.value("host", _address.toString()).toString();
_address = address;
settings.endGroup();
}
void TCPConfiguration::updateSettings()
{
if(_link) {
TCPLink* ulink = dynamic_cast<TCPLink*>(_link);
if(ulink) {
ulink->_restartConnection();
}
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <QHostAddress> #include <QHostAddress>
#include <LinkInterface.h> #include <LinkInterface.h>
#include "QGCConfig.h" #include "QGCConfig.h"
#include "LinkManager.h"
// Even though QAbstractSocket::SocketError is used in a signal by Qt, Qt doesn't declare it as a meta type. // Even though QAbstractSocket::SocketError is used in a signal by Qt, Qt doesn't declare it as a meta type.
// This in turn causes debug output to be kicked out about not being able to queue the signal. We declare it // This in turn causes debug output to be kicked out about not being able to queue the signal. We declare it
...@@ -47,20 +48,79 @@ ...@@ -47,20 +48,79 @@
class TCPLinkUnitTest; class TCPLinkUnitTest;
#define QGC_TCP_PORT 5760
class TCPConfiguration : public LinkConfiguration
{
public:
/*!
* @brief Regular constructor
*
* @param[in] name Configuration (user friendly) name
*/
TCPConfiguration(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
*/
TCPConfiguration(TCPConfiguration* source);
/*!
* @brief The TCP port
*
* @return Port number
*/
quint16 port () { return _port; }
/*!
* @brief Set the TCP port
*
* @param[in] port Port number
*/
void setPort (quint16 port);
/*!
* @brief The host address
*
* @return Host address
*/
const QHostAddress& address () { return _address; }
/*!
* @brief Set the host address
*
* @param[in] address Host address
*/
void setAddress (const QHostAddress& address);
/// From LinkConfiguration
int type() { return LinkConfiguration::TypeTcp; }
void copyFrom(LinkConfiguration* source);
void loadSettings(QSettings& settings, const QString& root);
void saveSettings(QSettings& settings, const QString& root);
void updateSettings();
private:
QHostAddress _address;
quint16 _port;
};
class TCPLink : public LinkInterface class TCPLink : public LinkInterface
{ {
Q_OBJECT Q_OBJECT
friend class TCPLinkUnitTest; friend class TCPLinkUnitTest;
friend class TCPConfiguration;
public: public:
TCPLink(QHostAddress hostAddress = QHostAddress::LocalHost, quint16 socketPort = 5760); TCPLink(TCPConfiguration* config);
~TCPLink(); ~TCPLink();
void setHostAddress(QHostAddress hostAddress);
QHostAddress getHostAddress(void) const { return _hostAddress; }
quint16 getPort(void) const { return _port; }
QTcpSocket* getSocket(void) { return _socket; } QTcpSocket* getSocket(void) { return _socket; }
void signalBytesWritten(void); void signalBytesWritten(void);
...@@ -82,12 +142,9 @@ public: ...@@ -82,12 +142,9 @@ public:
bool disconnect(void); bool disconnect(void);
public slots: public slots:
void setHostAddress(const QString& hostAddress);
void setPort(int port);
// From LinkInterface // From LinkInterface
virtual void writeBytes(const char* data, qint64 length); void writeBytes(const char* data, qint64 length);
void waitForBytesWritten(int msecs); void waitForBytesWritten(int msecs);
void waitForReadyRead(int msecs); void waitForReadyRead(int msecs);
...@@ -103,21 +160,20 @@ protected: ...@@ -103,21 +160,20 @@ protected:
private: private:
// From LinkInterface // From LinkInterface
virtual bool _connect(void); bool _connect(void);
virtual bool _disconnect(void); bool _disconnect(void);
bool _hardwareConnect();
void _restartConnection();
void _resetName(void);
bool _hardwareConnect(void);
#ifdef TCPLINK_READWRITE_DEBUG #ifdef TCPLINK_READWRITE_DEBUG
void _writeDebugBytes(const char *data, qint16 size); void _writeDebugBytes(const char *data, qint16 size);
#endif #endif
QString _name; int _linkId;
QHostAddress _hostAddress; TCPConfiguration* _config;
quint16 _port; QTcpSocket* _socket;
int _linkId; bool _socketIsConnected;
QTcpSocket* _socket;
bool _socketIsConnected;
quint64 _bitsSentTotal; quint64 _bitsSentTotal;
quint64 _bitsSentCurrent; quint64 _bitsSentCurrent;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -286,7 +286,7 @@ UDPConfiguration::UDPConfiguration(UDPConfiguration* source) : LinkConfiguration ...@@ -286,7 +286,7 @@ UDPConfiguration::UDPConfiguration(UDPConfiguration* source) : LinkConfiguration
void UDPConfiguration::copyFrom(LinkConfiguration *source) void UDPConfiguration::copyFrom(LinkConfiguration *source)
{ {
_confMutex.lock(); _confMutex.lock();
LinkConfiguration::copyFrom(dynamic_cast<LinkConfiguration*>(this)); LinkConfiguration::copyFrom(source);
UDPConfiguration* usource = dynamic_cast<UDPConfiguration*>(source); UDPConfiguration* usource = dynamic_cast<UDPConfiguration*>(source);
Q_ASSERT(usource != NULL); Q_ASSERT(usource != NULL);
_localPort = usource->localPort(); _localPort = usource->localPort();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
......
...@@ -33,13 +33,14 @@ ...@@ -33,13 +33,14 @@
// time to debug. // time to debug.
//UT_REGISTER_TEST(TCPLinkUnitTest) //UT_REGISTER_TEST(TCPLinkUnitTest)
TCPLinkUnitTest::TCPLinkUnitTest(void) : TCPLinkUnitTest::TCPLinkUnitTest(void)
_link(NULL), : _config(NULL)
_hostAddress(QHostAddress::LocalHost), , _link(NULL)
_port(5760), , _multiSpy(NULL)
_multiSpy(NULL)
{ {
_config = new TCPConfiguration("MockTCP");
_config->setAddress(QHostAddress::LocalHost);
_config->setPort(5760);
} }
// Called before every test // Called before every test
...@@ -50,13 +51,12 @@ void TCPLinkUnitTest::init(void) ...@@ -50,13 +51,12 @@ void TCPLinkUnitTest::init(void)
Q_ASSERT(_link == NULL); Q_ASSERT(_link == NULL);
Q_ASSERT(_multiSpy == NULL); Q_ASSERT(_multiSpy == NULL);
_link = new TCPLink(_hostAddress, _port); _link = new TCPLink(_config);
Q_ASSERT(_link != NULL); Q_ASSERT(_link != NULL);
_rgSignals[bytesReceivedSignalIndex] = SIGNAL(bytesReceived(LinkInterface*, QByteArray)); _rgSignals[bytesReceivedSignalIndex] = SIGNAL(bytesReceived(LinkInterface*, QByteArray));
_rgSignals[connectedSignalIndex] = SIGNAL(connected(void)); _rgSignals[connectedSignalIndex] = SIGNAL(connected(void));
_rgSignals[disconnectedSignalIndex] = SIGNAL(disconnected(void)); _rgSignals[disconnectedSignalIndex] = SIGNAL(disconnected(void));
_rgSignals[nameChangedSignalIndex] = SIGNAL(nameChanged(QString));
_rgSignals[communicationErrorSignalIndex] = SIGNAL(communicationError(const QString&, const QString&)); _rgSignals[communicationErrorSignalIndex] = SIGNAL(communicationError(const QString&, const QString&));
_rgSignals[communicationUpdateSignalIndex] = SIGNAL(communicationUpdate(const QString&, const QString&)); _rgSignals[communicationUpdateSignalIndex] = SIGNAL(communicationUpdate(const QString&, const QString&));
_rgSignals[deleteLinkSignalIndex] = SIGNAL(deleteLink(LinkInterface* const)); _rgSignals[deleteLinkSignalIndex] = SIGNAL(deleteLink(LinkInterface* const));
...@@ -70,50 +70,39 @@ void TCPLinkUnitTest::cleanup(void) ...@@ -70,50 +70,39 @@ void TCPLinkUnitTest::cleanup(void)
{ {
Q_ASSERT(_multiSpy); Q_ASSERT(_multiSpy);
Q_ASSERT(_link); Q_ASSERT(_link);
Q_ASSERT(_config);
delete _multiSpy; delete _multiSpy;
delete _link; delete _link;
delete _config;
_multiSpy = NULL; _multiSpy = NULL;
_link = NULL; _link = NULL;
_config = NULL;
UnitTest::cleanup(); UnitTest::cleanup();
} }
void TCPLinkUnitTest::_properties_test(void) void TCPLinkUnitTest::_properties_test(void)
{ {
Q_ASSERT(_config);
Q_ASSERT(_link); Q_ASSERT(_link);
Q_ASSERT(_multiSpy); Q_ASSERT(_multiSpy);
Q_ASSERT(_multiSpy->checkNoSignals() == true); Q_ASSERT(_multiSpy->checkNoSignals() == true);
// Make sure we get the right values back // Test no longer valid
QHostAddress hostAddressOut;
quint16 portOut;
hostAddressOut = _link->getHostAddress();
QCOMPARE(_hostAddress, hostAddressOut);
portOut = _link->getPort();
QCOMPARE(_port, portOut);
} }
void TCPLinkUnitTest::_nameChangedSignal_test(void) void TCPLinkUnitTest::_nameChangedSignal_test(void)
{ {
// Test no longer valid
Q_ASSERT(_config);
Q_ASSERT(_link); Q_ASSERT(_link);
Q_ASSERT(_multiSpy); Q_ASSERT(_multiSpy);
Q_ASSERT(_multiSpy->checkNoSignals() == true);
_link->setHostAddress(QHostAddress("127.1.1.1"));
QCOMPARE(_multiSpy->checkOnlySignalByMask(nameChangedSignalMask), true);
_multiSpy->clearSignalByIndex(nameChangedSignalIndex);
_link->setPort(42);
QCOMPARE(_multiSpy->checkOnlySignalByMask(nameChangedSignalMask), true);
_multiSpy->clearSignalByIndex(nameChangedSignalIndex);
} }
void TCPLinkUnitTest::_connectFail_test(void) void TCPLinkUnitTest::_connectFail_test(void)
{ {
Q_ASSERT(_config);
Q_ASSERT(_link); Q_ASSERT(_link);
Q_ASSERT(_multiSpy); Q_ASSERT(_multiSpy);
Q_ASSERT(_multiSpy->checkNoSignals() == true); Q_ASSERT(_multiSpy->checkNoSignals() == true);
...@@ -150,7 +139,7 @@ void TCPLinkUnitTest::_connectSucceed_test(void) ...@@ -150,7 +139,7 @@ void TCPLinkUnitTest::_connectSucceed_test(void)
Q_ASSERT(_multiSpy->checkNoSignals() == true); Q_ASSERT(_multiSpy->checkNoSignals() == true);
// Start the server side // Start the server side
TCPLoopBackServer* server = new TCPLoopBackServer(_hostAddress, _port); TCPLoopBackServer* server = new TCPLoopBackServer(_config->address(), _config->port());
Q_CHECK_PTR(server); Q_CHECK_PTR(server);
// Connect to the server // Connect to the server
......
...@@ -75,9 +75,8 @@ private: ...@@ -75,9 +75,8 @@ private:
deleteLinkSignalMask = 1 << deleteLinkSignalIndex, deleteLinkSignalMask = 1 << deleteLinkSignalIndex,
}; };
TCPConfiguration* _config;
TCPLink* _link; TCPLink* _link;
QHostAddress _hostAddress;
quint16 _port;
MultiSignalSpy* _multiSpy; MultiSignalSpy* _multiSpy;
static const size_t _cSignals = maxSignalIndex; static const size_t _cSignals = maxSignalIndex;
const char* _rgSignals[_cSignals]; const char* _rgSignals[_cSignals];
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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/>.
======================================================================*/
/**
* @file
* @brief Comm Link Configuration
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#include <QPushButton> #include <QPushButton>
#include "SerialLink.h" #include "SerialLink.h"
#include "SerialConfigurationWindow.h" #include "SerialConfigurationWindow.h"
#include "QGCUDPLinkConfiguration.h" #include "QGCUDPLinkConfiguration.h"
#include "QGCTCPLinkConfiguration.h"
#include "QGCCommConfiguration.h" #include "QGCCommConfiguration.h"
#include "ui_QGCCommConfiguration.h" #include "ui_QGCCommConfiguration.h"
...@@ -16,12 +47,12 @@ QGCCommConfiguration::QGCCommConfiguration(QWidget *parent, LinkConfiguration *c ...@@ -16,12 +47,12 @@ QGCCommConfiguration::QGCCommConfiguration(QWidget *parent, LinkConfiguration *c
_ui->typeCombo->addItem(tr("Select Type"), LinkConfiguration::TypeLast); _ui->typeCombo->addItem(tr("Select Type"), LinkConfiguration::TypeLast);
_ui->typeCombo->addItem(tr("Serial"), LinkConfiguration::TypeSerial); _ui->typeCombo->addItem(tr("Serial"), LinkConfiguration::TypeSerial);
_ui->typeCombo->addItem(tr("UDP"), LinkConfiguration::TypeUdp); _ui->typeCombo->addItem(tr("UDP"), LinkConfiguration::TypeUdp);
_ui->typeCombo->addItem(tr("TCP"), LinkConfiguration::TypeTcp);
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
_ui->typeCombo->addItem(tr("Mock"), LinkConfiguration::TypeMock); _ui->typeCombo->addItem(tr("Mock"), LinkConfiguration::TypeMock);
#endif #endif
#if 0 #if 0
_ui->typeCombo->addItem(tr("TCP"), LinkConfiguration::TypeTcp);
#ifdef QGC_RTLAB_ENABLED #ifdef QGC_RTLAB_ENABLED
_ui->typeCombo->addItem(tr("Opal-RT Link"), LinkConfiguration::TypeOpal); _ui->typeCombo->addItem(tr("Opal-RT Link"), LinkConfiguration::TypeOpal);
...@@ -96,6 +127,13 @@ void QGCCommConfiguration::_loadTypeConfigWidget(int type) ...@@ -96,6 +127,13 @@ void QGCCommConfiguration::_loadTypeConfigWidget(int type)
_ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeUdp)); _ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeUdp));
} }
break; break;
case LinkConfiguration::TypeTcp: {
QWidget* conf = new QGCTCPLinkConfiguration((TCPConfiguration*)_config, this);
_ui->linkScrollArea->setWidget(conf);
_ui->linkGroupBox->setTitle(tr("TCP Link"));
_ui->typeCombo->setCurrentIndex(_ui->typeCombo->findData(LinkConfiguration::TypeTcp));
}
break;
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock: { case LinkConfiguration::TypeMock: {
_ui->linkScrollArea->setWidget(NULL); _ui->linkScrollArea->setWidget(NULL);
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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/>.
======================================================================*/
/**
* @file
* @brief Comm Link Configuration
* @author Gus Grubba <mavlink@grubba.com>
*
*/
#ifndef QGCCOMMCONFIGURATION_H #ifndef QGCCOMMCONFIGURATION_H
#define QGCCOMMCONFIGURATION_H #define QGCCOMMCONFIGURATION_H
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -124,6 +124,38 @@ void QGCLinkConfiguration::on_editLinkButton_clicked() ...@@ -124,6 +124,38 @@ void QGCLinkConfiguration::on_editLinkButton_clicked()
_editLink(index.row()); _editLink(index.row());
} }
void QGCLinkConfiguration::_fixUnnamed(LinkConfiguration* config)
{
Q_ASSERT(config != NULL);
//-- Check for "Unnamed"
if (config->name() == tr("Unnamed")) {
switch(config->type()) {
case LinkConfiguration::TypeSerial:
config->setName(
QString("Serial Device on %1").arg(dynamic_cast<SerialConfiguration*>(config)->portName()));
break;
case LinkConfiguration::TypeUdp:
config->setName(
QString("UDP Link on Port %1").arg(dynamic_cast<UDPConfiguration*>(config)->localPort()));
break;
case LinkConfiguration::TypeTcp: {
TCPConfiguration* tconfig = dynamic_cast<TCPConfiguration*>(config);
if(tconfig) {
config->setName(
QString("TCP Link %1:%2").arg(tconfig->address().toString()).arg((int)tconfig->port()));
}
}
break;
#ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock:
config->setName(
QString("Mock Link"));
break;
#endif
}
}
}
void QGCLinkConfiguration::on_addLinkButton_clicked() void QGCLinkConfiguration::on_addLinkButton_clicked()
{ {
QGCCommConfiguration* commDialog = new QGCCommConfiguration(this); QGCCommConfiguration* commDialog = new QGCCommConfiguration(this);
...@@ -131,25 +163,7 @@ void QGCLinkConfiguration::on_addLinkButton_clicked() ...@@ -131,25 +163,7 @@ void QGCLinkConfiguration::on_addLinkButton_clicked()
// Save changes (if any) // Save changes (if any)
LinkConfiguration* config = commDialog->getConfig(); LinkConfiguration* config = commDialog->getConfig();
if(config) { if(config) {
//-- Check for "Unnamed" _fixUnnamed(config);
if (config->name() == tr("Unnamed")) {
switch(config->type()) {
case LinkConfiguration::TypeSerial:
config->setName(
QString("Serial Device on %1").arg(dynamic_cast<SerialConfiguration*>(config)->portName()));
break;
case LinkConfiguration::TypeUdp:
config->setName(
QString("UDP Link on Port %1").arg(dynamic_cast<UDPConfiguration*>(config)->localPort()));
break;
#ifdef UNITTEST_BUILD
case LinkConfiguration::TypeMock:
config->setName(
QString("Mock Link"));
break;
#endif
}
}
_viewModel->beginChange(); _viewModel->beginChange();
LinkManager::instance()->addLinkConfiguration(commDialog->getConfig()); LinkManager::instance()->addLinkConfiguration(commDialog->getConfig());
LinkManager::instance()->saveLinkConfigurationList(); LinkManager::instance()->saveLinkConfigurationList();
...@@ -172,6 +186,7 @@ void QGCLinkConfiguration::_editLink(int row) ...@@ -172,6 +186,7 @@ void QGCLinkConfiguration::_editLink(int row)
if(commDialog->exec() == QDialog::Accepted) { if(commDialog->exec() == QDialog::Accepted) {
// Save changes (if any) // Save changes (if any)
if(commDialog->getConfig()) { if(commDialog->getConfig()) {
_fixUnnamed(tmpConfig);
_viewModel->beginChange(); _viewModel->beginChange();
config->copyFrom(tmpConfig); config->copyFrom(tmpConfig);
// Save it // Save it
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCLINKCONFIGURATION_H #ifndef QGCLINKCONFIGURATION_H
#define QGCLINKCONFIGURATION_H #define QGCLINKCONFIGURATION_H
...@@ -30,6 +59,7 @@ private slots: ...@@ -30,6 +59,7 @@ private slots:
private: private:
void _editLink(int row); void _editLink(int row);
void _fixUnnamed(LinkConfiguration* config);
Ui::QGCLinkConfiguration* _ui; Ui::QGCLinkConfiguration* _ui;
LinkViewModel* _viewModel; LinkViewModel* _viewModel;
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCTCPLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#include <QInputDialog> #include <QInputDialog>
#include "QGCTCPLinkConfiguration.h" #include "QGCTCPLinkConfiguration.h"
#include "ui_QGCTCPLinkConfiguration.h" #include "ui_QGCTCPLinkConfiguration.h"
QGCTCPLinkConfiguration::QGCTCPLinkConfiguration(TCPLink* link, QWidget *parent) : QGCTCPLinkConfiguration::QGCTCPLinkConfiguration(TCPConfiguration *config, QWidget *parent)
QWidget(parent), : QWidget(parent)
link(link), , _ui(new Ui::QGCTCPLinkConfiguration)
ui(new Ui::QGCTCPLinkConfiguration) , _config(config)
{ {
ui->setupUi(this); Q_ASSERT(_config != NULL);
quint16 port = link->getPort(); _ui->setupUi(this);
ui->portSpinBox->setValue(port); quint16 port = config->port();
QString addr = link->getHostAddress().toString(); _ui->portSpinBox->setValue(port);
ui->hostAddressLineEdit->setText(addr); QString addr = config->address().toString();
connect(ui->portSpinBox, SIGNAL(valueChanged(int)), link, SLOT(setPort(int))); _ui->hostAddressLineEdit->setText(addr);
connect(ui->hostAddressLineEdit, SIGNAL(textChanged (const QString &)), link, SLOT(setHostAddress(const QString &)));
} }
QGCTCPLinkConfiguration::~QGCTCPLinkConfiguration() QGCTCPLinkConfiguration::~QGCTCPLinkConfiguration()
{ {
delete ui; delete _ui;
} }
void QGCTCPLinkConfiguration::changeEvent(QEvent *e) void QGCTCPLinkConfiguration::changeEvent(QEvent *e)
...@@ -27,9 +55,20 @@ void QGCTCPLinkConfiguration::changeEvent(QEvent *e) ...@@ -27,9 +55,20 @@ void QGCTCPLinkConfiguration::changeEvent(QEvent *e)
QWidget::changeEvent(e); QWidget::changeEvent(e);
switch (e->type()) { switch (e->type()) {
case QEvent::LanguageChange: case QEvent::LanguageChange:
ui->retranslateUi(this); _ui->retranslateUi(this);
break; break;
default: default:
break; break;
} }
} }
void QGCTCPLinkConfiguration::on_portSpinBox_valueChanged(int arg1)
{
_config->setPort(arg1);
}
void QGCTCPLinkConfiguration::on_hostAddressLineEdit_textChanged(const QString &arg1)
{
QHostAddress add(arg1);
_config->setAddress(add);
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCTCPLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCTCPLINKCONFIGURATION_H #ifndef QGCTCPLINKCONFIGURATION_H
#define QGCTCPLINKCONFIGURATION_H #define QGCTCPLINKCONFIGURATION_H
...@@ -13,20 +42,20 @@ class QGCTCPLinkConfiguration; ...@@ -13,20 +42,20 @@ class QGCTCPLinkConfiguration;
class QGCTCPLinkConfiguration : public QWidget class QGCTCPLinkConfiguration : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QGCTCPLinkConfiguration(TCPLink* link, QWidget *parent = 0); explicit QGCTCPLinkConfiguration(TCPConfiguration *config, QWidget *parent = 0);
~QGCTCPLinkConfiguration(); ~QGCTCPLinkConfiguration();
public slots:
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
TCPLink* link; ///< TCP link instance this widget configures private slots:
void on_portSpinBox_valueChanged(int arg1);
void on_hostAddressLineEdit_textChanged(const QString &arg1);
private: private:
Ui::QGCTCPLinkConfiguration *ui; Ui::QGCTCPLinkConfiguration* _ui;
TCPConfiguration* _config;
}; };
#endif // QGCTCPLINKCONFIGURATION_H #endif // QGCTCPLINKCONFIGURATION_H
...@@ -27,10 +27,13 @@ ...@@ -27,10 +27,13 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSpinBox" name="portSpinBox"> <widget class="QSpinBox" name="portSpinBox">
<property name="minimum"> <property name="minimum">
<number>3000</number> <number>1024</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<number>100000</number> <number>65535</number>
</property>
<property name="value">
<number>3000</number>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -42,7 +45,14 @@ ...@@ -42,7 +45,14 @@
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="hostAddressLineEdit"/> <widget class="QLineEdit" name="hostAddressLineEdit">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 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/>.
======================================================================*/
/**
* @file
* @brief Implementation of QGCUDPLinkConfiguration
* @author Gus Grubba <mavlink@grubba.com>
*/
#ifndef QGCUDPLINKCONFIGURATION_H #ifndef QGCUDPLINKCONFIGURATION_H
#define QGCUDPLINKCONFIGURATION_H #define QGCUDPLINKCONFIGURATION_H
......
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