diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index aa07a527ea1596b52ab7509d13bbe8609b3486b3..56c8a4161dbc36bd10af67731c9d33b226c9d16b 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -234,11 +234,14 @@ win32:exists(src/lib/opalrt/OpalApi.h) { src/comm/OpalLink.h \ src/comm/Parameter.h \ src/comm/QGCParamID.h \ - src/comm/ParameterList.h + src/comm/ParameterList.h \ + src/ui/OpalLinkConfigurationWindow.h SOURCES += src/comm/OpalRT.cc \ src/comm/OpalLink.cc \ src/comm/Parameter.cc \ src/comm/QGCParamID.cc \ - src/comm/ParameterList.cc + src/comm/ParameterList.cc \ + src/ui/OpalLinkConfigurationWindow.cc + FORMS += src/ui/OpalLinkSettings.ui DEFINES += OPAL_RT } diff --git a/src/comm/OpalLink.cc b/src/comm/OpalLink.cc index 6dba8e3906b23819c472f1ee84e88d288dd9f011..7fa51b6830dac3ae5936a55d17d200b7d7b5154b 100644 --- a/src/comm/OpalLink.cc +++ b/src/comm/OpalLink.cc @@ -39,7 +39,8 @@ OpalLink::OpalLink() : receiveBuffer(new QQueue()), systemID(1), componentID(1), - params(NULL) + params(NULL), + opalInstID(101) { start(QThread::LowPriority); @@ -302,7 +303,7 @@ bool OpalLink::connect() short modelState; /// \todo allow configuration of instid in window - if ((OpalConnect(101, false, &modelState) == EOK) + if ((OpalConnect(opalInstID, false, &modelState) == EOK) && (OpalGetSignalControl(0, true) == EOK) && (OpalGetParameterControl(true) == EOK)) { @@ -330,6 +331,8 @@ bool OpalLink::disconnect() OpalDisconnect(); heartbeatTimer->stop(); getSignalsTimer->stop(); + connectState = false; + emit connected(connectState); return true; } diff --git a/src/comm/OpalLink.h b/src/comm/OpalLink.h index 36f36e16da413b324b00fcac0d562391deb52b02..c640ca6712372eac6d34880d0e9b7040cba199f6 100644 --- a/src/comm/OpalLink.h +++ b/src/comm/OpalLink.h @@ -103,6 +103,8 @@ public: void run(); + int getOpalInstID() {return static_cast(opalInstID);} + public slots: void writeBytes(const char *bytes, qint64 length); @@ -113,6 +115,8 @@ public slots: void getSignals(); + void setOpalInstID(int instID) {opalInstID = static_cast(instID);} + protected slots: void receiveMessage(mavlink_message_t message); @@ -151,6 +155,8 @@ protected: void getParameterList(); OpalRT::ParameterList *params; + + unsigned short opalInstID; }; #endif // OPALLINK_H diff --git a/src/ui/CommConfigurationWindow.cc b/src/ui/CommConfigurationWindow.cc index a51303e885c4926de4372ae72ed3d7e02c208730..5aba706ef7494e04afa19a83e73594c83be68501 100644 --- a/src/ui/CommConfigurationWindow.cc +++ b/src/ui/CommConfigurationWindow.cc @@ -43,6 +43,7 @@ This file is part of the QGROUNDCONTROL project #include "MAVLinkSimulationLink.h" #ifdef OPAL_RT #include "OpalLink.h" +#include "OpalLinkConfigurationWindow.h" #endif #include "MAVLinkProtocol.h" #include "MAVLinkSettingsWidget.h" @@ -114,6 +115,10 @@ CommConfigurationWindow::CommConfigurationWindow(LinkInterface* link, ProtocolIn OpalLink* opal = dynamic_cast(link); if (opal != 0) { + QWidget* conf = new OpalLinkConfigurationWindow(opal, this); + QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight, ui.linkGroupBox); + layout->addWidget(conf); + ui.linkGroupBox->setLayout(layout); ui.linkGroupBox->setTitle(tr("Opal-RT Link")); } #endif diff --git a/src/ui/OpalLinkConfigurationWindow.cc b/src/ui/OpalLinkConfigurationWindow.cc new file mode 100644 index 0000000000000000000000000000000000000000..eba4328156d593d7a229c64ae2857c7dce5c8e52 --- /dev/null +++ b/src/ui/OpalLinkConfigurationWindow.cc @@ -0,0 +1,25 @@ +#include "OpalLinkConfigurationWindow.h" + +OpalLinkConfigurationWindow::OpalLinkConfigurationWindow(OpalLink* link, + QWidget *parent, + Qt::WindowFlags flags) : + QWidget(parent, flags), + link(link) + +{ + + + ui.setupUi(this); + + ui.opalInstIDSpinBox->setValue(this->link->getOpalInstID()); + + connect(ui.opalInstIDSpinBox, SIGNAL(valueChanged(int)), link, SLOT(setOpalInstID(int))); + connect(link, SIGNAL(connected(bool)), this, SLOT(allowSettingsAccess(bool))); + this->show(); +} + +void OpalLinkConfigurationWindow::allowSettingsAccess(bool enabled) +{ + ui.paramFileButton->setEnabled(enabled); + ui.servoConfigFileButton->setEnabled(enabled); +} diff --git a/src/ui/OpalLinkConfigurationWindow.h b/src/ui/OpalLinkConfigurationWindow.h new file mode 100644 index 0000000000000000000000000000000000000000..a26e0b9bfcf1e10b3baa56d25e9eee3d8db07927 --- /dev/null +++ b/src/ui/OpalLinkConfigurationWindow.h @@ -0,0 +1,28 @@ +#ifndef OPALLINKCONFIGURATIONWINDOW_H +#define OPALLINKCONFIGURATIONWINDOW_H + +#include +#include + +#include "LinkInterface.h" +#include "ui_OpalLinkSettings.h" +#include "OpalLink.h" + +class OpalLinkConfigurationWindow : public QWidget +{ +Q_OBJECT +public: + explicit OpalLinkConfigurationWindow(OpalLink* link, QWidget *parent = 0, Qt::WindowFlags flags = Qt::Sheet); + +signals: + +public slots: + + void allowSettingsAccess(bool enabled); + +private: + Ui::OpalLinkSettings ui; + OpalLink* link; +}; + +#endif // OPALLINKCONFIGURATIONWINDOW_H diff --git a/src/ui/OpalLinkSettings.ui b/src/ui/OpalLinkSettings.ui new file mode 100644 index 0000000000000000000000000000000000000000..8fd6796fb68e9073cb0da17ba018b4f23d91b709 --- /dev/null +++ b/src/ui/OpalLinkSettings.ui @@ -0,0 +1,173 @@ + + + OpalLinkSettings + + + + 0 + 0 + 537 + 250 + + + + OpalLink Configuration + + + + 6 + + + + + Model Instance ID + + + + + + + Opal-RT Parameter File + + + + + + + Servo Configuration File + + + + + + + Qt::Vertical + + + + 431 + 47 + + + + + + + + + + + + + + + + + + + + + + false + + + Change + + + + :/images/status/folder-open.svg:/images/status/folder-open.svg + + + + + + + false + + + Change + + + + :/images/status/folder-open.svg:/images/status/folder-open.svg + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 101 + + + 200 + + + 101 + + + + + + + + + Delete + + + Delete this link + + + + + Connect + + + Connect this link + + + + + Close + + + Close the configuration window + + + + + + + + + actionClose + triggered() + OpalLinkSettings + close() + + + -1 + -1 + + + 224 + 195 + + + + +