mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Fixed widget disabling/enabling when main telemetry connects/disconnects
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2509 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c8b495a5c2
commit
ba0a089ad4
@ -179,7 +179,7 @@ halting a running board.</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -474,7 +474,7 @@ halting a running board.</string>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
@ -611,7 +611,7 @@ halting a running board.</string>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -30,6 +30,8 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
m_config = new Ui_PipXtremeWidget();
|
||||
m_config->setupUi(this);
|
||||
|
||||
m_ioDev = NULL;
|
||||
|
||||
currentStep = IAP_STATE_READY;
|
||||
rescueStep = RESCUE_STEP0;
|
||||
resetOnly = false;
|
||||
@ -71,8 +73,8 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
// Listen to autopilot connection events
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
|
||||
connect(telMngr, SIGNAL(connected()), this, SLOT(onModemConnect()));
|
||||
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onModemDisconnect()));
|
||||
connect(telMngr, SIGNAL(connected()), this, SLOT(onTelemetryConnect()));
|
||||
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onTelemetryDisconnect()));
|
||||
|
||||
// Note: remove listening to the connection manager, it overlaps with
|
||||
// listening to the telemetry manager, we should only listen to one, not both.
|
||||
@ -83,13 +85,13 @@ PipXtremeGadgetWidget::PipXtremeGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
|
||||
connect(m_config->connectButton, SIGNAL(clicked()), this, SLOT(goToAPIMode()));
|
||||
|
||||
getSerialPorts();
|
||||
getPorts();
|
||||
|
||||
QIcon rbi;
|
||||
rbi.addFile(QString(":pipxtreme/images/view-refresh.svg"));
|
||||
m_config->refreshPorts->setIcon(rbi);
|
||||
|
||||
connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getSerialPorts()));
|
||||
connect(m_config->refreshPorts, SIGNAL(clicked()), this, SLOT(getPorts()));
|
||||
|
||||
// delay::msleep(600); // just for pips reference
|
||||
}
|
||||
@ -122,32 +124,31 @@ bool sortPorts(const QextPortInfo &s1,const QextPortInfo &s2)
|
||||
return (s1.portName < s2.portName);
|
||||
}
|
||||
|
||||
// Gets the list of serial ports
|
||||
void PipXtremeGadgetWidget::getSerialPorts()
|
||||
void PipXtremeGadgetWidget::getPorts()
|
||||
{
|
||||
QStringList list;
|
||||
|
||||
m_config->refreshPorts->setEnabled(false);
|
||||
m_config->telemetryLink->setEnabled(false);
|
||||
// m_config->refreshPorts->setEnabled(false);
|
||||
// m_config->telemetryLink->setEnabled(false);
|
||||
|
||||
// Populate the telemetry combo box:
|
||||
m_config->telemetryLink->clear();
|
||||
// ********************************
|
||||
// Populate the telemetry combo box
|
||||
|
||||
// list.append(QString("USB"));
|
||||
// get usb port list
|
||||
|
||||
// get serial port list
|
||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||
|
||||
// sort the list by port number (nice idea from PT_Dreamer :))
|
||||
qSort(ports.begin(), ports.end(),sortPorts);
|
||||
qSort(ports.begin(), ports.end(), sortPorts); // sort the list by port number (nice idea from PT_Dreamer :))
|
||||
foreach (QextPortInfo port, ports)
|
||||
{
|
||||
list.append(port.friendName);
|
||||
}
|
||||
|
||||
m_config->telemetryLink->clear();
|
||||
m_config->telemetryLink->addItems(list);
|
||||
|
||||
m_config->refreshPorts->setEnabled(true);
|
||||
m_config->telemetryLink->setEnabled(true);
|
||||
// ********************************
|
||||
|
||||
// m_config->refreshPorts->setEnabled(true);
|
||||
// m_config->telemetryLink->setEnabled(true);
|
||||
}
|
||||
|
||||
QString PipXtremeGadgetWidget::getPortDevice(const QString &friendName)
|
||||
@ -168,6 +169,18 @@ QString PipXtremeGadgetWidget::getPortDevice(const QString &friendName)
|
||||
return "";
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::onTelemetryConnect()
|
||||
{
|
||||
m_config->connectButton->setEnabled(false);
|
||||
m_config->telemetryLink->setEnabled(false);
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::onTelemetryDisconnect()
|
||||
{
|
||||
m_config->connectButton->setEnabled(true);
|
||||
m_config->telemetryLink->setEnabled(true);
|
||||
}
|
||||
|
||||
void PipXtremeGadgetWidget::onModemConnect()
|
||||
{
|
||||
m_config->connectButton->setText(tr(" Disconnect "));
|
||||
@ -194,7 +207,7 @@ void PipXtremeGadgetWidget::goToAPIMode(UAVObject* callerObj, bool success)
|
||||
switch (currentStep)
|
||||
{
|
||||
case IAP_STATE_READY:
|
||||
getSerialPorts(); // Useful in case a new serial port appeared since the initial list,
|
||||
getPorts(); // Useful in case a new serial port appeared since the initial list,
|
||||
// otherwise we won't find it when we stop the board.
|
||||
|
||||
// The board is running, send the 1st IAP Reset order:
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#include "ui_pipxtreme.h"
|
||||
#include "delay.h"
|
||||
//#include "op_dfu.h"
|
||||
|
||||
#include <qextserialport.h>
|
||||
#include <qextserialenumerator.h>
|
||||
@ -45,9 +44,19 @@
|
||||
#include <QThread>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QLinkedList>
|
||||
/*
|
||||
class IConnection;
|
||||
|
||||
//using namespace OP_DFU;
|
||||
|
||||
struct devListItem
|
||||
{
|
||||
IConnection *connection;
|
||||
QString devName;
|
||||
QString displayedName;
|
||||
};
|
||||
*/
|
||||
class PipXtremeGadgetWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -60,6 +69,8 @@ public:
|
||||
typedef enum { RESCUE_STEP0, RESCUE_STEP1, RESCUE_STEP2, RESCUE_STEP3, RESCUE_POWER1, RESCUE_POWER2, RESCUE_DETECT } RescueStep;
|
||||
|
||||
public slots:
|
||||
void onTelemetryConnect();
|
||||
void onTelemetryDisconnect();
|
||||
void onModemConnect();
|
||||
void onModemDisconnect();
|
||||
|
||||
@ -67,20 +78,29 @@ protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
private:
|
||||
Ui_PipXtremeWidget *m_config;
|
||||
// DFUObject *dfu;
|
||||
IAPStep currentStep;
|
||||
RescueStep rescueStep;
|
||||
bool resetOnly;
|
||||
Ui_PipXtremeWidget *m_config;
|
||||
|
||||
QString getPortDevice(const QString &friendName);
|
||||
IAPStep currentStep;
|
||||
RescueStep rescueStep;
|
||||
bool resetOnly;
|
||||
|
||||
// QLinkedList<devListItem> m_devList;
|
||||
// QList<IConnection*> m_connectionsList;
|
||||
|
||||
// currently connected connection plugin
|
||||
// devListItem m_connectionDevice;
|
||||
|
||||
// currently connected QIODevice
|
||||
QIODevice *m_ioDev;
|
||||
|
||||
QString getPortDevice(const QString &friendName);
|
||||
|
||||
private slots:
|
||||
void error(QString errorString,int errorNumber);
|
||||
void goToAPIMode(UAVObject* = NULL, bool = false);
|
||||
void systemReset();
|
||||
void systemBoot();
|
||||
void getSerialPorts();
|
||||
void getPorts();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user