From 56190d7593d4ef7bbc7aadb185f9170e6eb9df31 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 1 Oct 2012 17:27:08 +0200 Subject: [PATCH] HIL fixes --- src/comm/QGCXPlaneLink.cc | 19 +++++++++++++------ src/comm/QGCXPlaneLink.h | 2 ++ src/ui/QGCHilConfiguration.ui | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index 89bc2ecaa..2dfc45222 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -42,6 +42,8 @@ This file is part of the QGROUNDCONTROL project QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress localHost, quint16 localPort) : mav(mav), + remoteHost(QHostAddress("127.0.0.1")), + remotePort(49000), socket(NULL), process(NULL), terraSync(NULL), @@ -72,7 +74,7 @@ void QGCXPlaneLink::loadSettings() settings.sync(); settings.beginGroup("QGC_XPLANE_LINK"); setRemoteHost(settings.value("REMOTE_HOST", QString("%1:%2").arg(remoteHost.toString()).arg(remotePort)).toString()); - setVersion(settings.value("XPLANE_VERSION", 10).toString()); + setVersion(settings.value("XPLANE_VERSION", 10).toInt()); selectPlane(settings.value("AIRFRAME", "default").toString()); settings.endGroup(); } @@ -115,11 +117,12 @@ void QGCXPlaneLink::setVersion(const QString& version) } } -//void QGCXPlaneLink::setVersion(unsigned int version) -//{ -//// bool changed = (xPlaneVersion != version); -// xPlaneVersion = version; -//} +void QGCXPlaneLink::setVersion(unsigned int version) +{ + bool changed = (xPlaneVersion != version); + xPlaneVersion = version; + if (changed) emit versionChanged(QString("X-Plane %1").arg(xPlaneVersion)); +} /** @@ -174,6 +177,9 @@ QString QGCXPlaneLink::getRemoteHost() */ void QGCXPlaneLink::setRemoteHost(const QString& newHost) { + if (newHost.length() == 0) + return; + if (newHost.contains(":")) { //qDebug() << "HOST: " << newHost.split(":").first(); @@ -204,6 +210,7 @@ void QGCXPlaneLink::setRemoteHost(const QString& newHost) { // Add newHost remoteHost = info.addresses().first(); + if (remotePort == 0) remotePort = 49000; } } diff --git a/src/comm/QGCXPlaneLink.h b/src/comm/QGCXPlaneLink.h index 14eec118b..f2f202a77 100644 --- a/src/comm/QGCXPlaneLink.h +++ b/src/comm/QGCXPlaneLink.h @@ -102,6 +102,8 @@ public slots: void updateActuators(uint64_t time, float act1, float act2, float act3, float act4, float act5, float act6, float act7, float act8); /** @brief Set the simulator version as text string */ void setVersion(const QString& version); + /** @brief Set the simulator version as integer */ + void setVersion(unsigned int version); QString getVersion() { return QString("X-Plane %1").arg(xPlaneVersion); diff --git a/src/ui/QGCHilConfiguration.ui b/src/ui/QGCHilConfiguration.ui index 29d5f0036..04e65c124 100644 --- a/src/ui/QGCHilConfiguration.ui +++ b/src/ui/QGCHilConfiguration.ui @@ -101,6 +101,9 @@ + + true + X-Plane 10 -- 2.22.0