mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-31 16:52:10 +01:00
OP-1628 Fixed review comments.
This commit is contained in:
parent
31a6a32fce
commit
a24fd253b4
@ -38,9 +38,9 @@ OPLinkWatchdog::OPLinkWatchdog() : QObject(),
|
||||
Q_ASSERT(pm);
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objManager);
|
||||
m_oplinkStatus = OPLinkStatus::GetInstance(objManager);
|
||||
Q_ASSERT(m_oplinkStatus);
|
||||
connect(m_oplinkStatus, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(onOPLinkStatusUpdate()));
|
||||
m_opLinkStatus = OPLinkStatus::GetInstance(objManager);
|
||||
Q_ASSERT(m_opLinkStatus);
|
||||
connect(m_opLinkStatus, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(onOPLinkStatusUpdate()));
|
||||
m_watchdog = new QTimer(this);
|
||||
connect(m_watchdog, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
||||
onOPLinkStatusUpdate();
|
||||
@ -53,38 +53,38 @@ OPLinkWatchdog::~OPLinkWatchdog()
|
||||
void OPLinkWatchdog::onOPLinkStatusUpdate()
|
||||
{
|
||||
m_watchdog->stop();
|
||||
quint8 type = m_oplinkStatus->getBoardType();
|
||||
quint8 type = m_opLinkStatus->getBoardType();
|
||||
if (!m_isConnected) {
|
||||
switch (type) {
|
||||
case 3:
|
||||
m_oplinkType = OPLINK_STANDALONE;
|
||||
m_opLinkType = OPLINK_MINI;
|
||||
m_isConnected = true;
|
||||
emit connected();
|
||||
emit standaloneConnected();
|
||||
emit opLinkMiniConnected();
|
||||
break;
|
||||
case 9:
|
||||
m_oplinkType = OPLINK_REVOLUTION;
|
||||
m_opLinkType = OPLINK_REVOLUTION;
|
||||
m_isConnected = true;
|
||||
emit connected();
|
||||
emit revolutionConnected();
|
||||
emit opLinkRevolutionConnected();
|
||||
break;
|
||||
default:
|
||||
m_isConnected = false;
|
||||
m_oplinkType = OPLINK_UNKNOWN;
|
||||
m_opLinkType = OPLINK_UNKNOWN;
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "OPLink connected";
|
||||
qDebug() << "OPLinkWatchdog - OPLink connected";
|
||||
}
|
||||
m_watchdog->start(m_oplinkStatus->getMetadata().flightTelemetryUpdatePeriod * 3);
|
||||
m_watchdog->start(m_opLinkStatus->getMetadata().flightTelemetryUpdatePeriod * 3);
|
||||
}
|
||||
|
||||
void OPLinkWatchdog::onTimeout()
|
||||
{
|
||||
if (m_isConnected) {
|
||||
m_isConnected = false;
|
||||
m_oplinkType = OPLINK_UNKNOWN;
|
||||
qDebug() << "OPLink disconnected";
|
||||
m_opLinkType = OPLINK_UNKNOWN;
|
||||
qDebug() << "OPLinkWatchdog - OPLink disconnected";
|
||||
emit disconnected();
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class OPLinkWatchdog : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum OPLinkType {
|
||||
OPLINK_STANDALONE,
|
||||
OPLINK_MINI,
|
||||
OPLINK_REVOLUTION,
|
||||
OPLINK_UNKNOWN
|
||||
};
|
||||
@ -43,12 +43,12 @@ public:
|
||||
OPLinkWatchdog();
|
||||
~OPLinkWatchdog();
|
||||
bool isConnected() const { return m_isConnected; }
|
||||
OPLinkWatchdog::OPLinkType oplinkType() const { return m_oplinkType; }
|
||||
OPLinkWatchdog::OPLinkType opLinkType() const { return m_opLinkType; }
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void standaloneConnected();
|
||||
void revolutionConnected();
|
||||
void opLinkMiniConnected();
|
||||
void opLinkRevolutionConnected();
|
||||
void disconnected();
|
||||
|
||||
private slots:
|
||||
@ -57,8 +57,8 @@ private slots:
|
||||
|
||||
private:
|
||||
bool m_isConnected;
|
||||
OPLinkType m_oplinkType;
|
||||
OPLinkType m_opLinkType;
|
||||
QTimer* m_watchdog;
|
||||
OPLinkStatus* m_oplinkStatus;
|
||||
OPLinkStatus* m_opLinkStatus;
|
||||
};
|
||||
#endif // OPLINKWATCHDOG_H
|
||||
|
@ -142,7 +142,7 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
m_currentIAPStep = IAP_STATE_READY;
|
||||
m_resetOnly = false;
|
||||
m_dfu = NULL;
|
||||
m_autoupdateClosing = false;
|
||||
m_autoUpdateClosing = false;
|
||||
|
||||
// Listen to autopilot connection events
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
@ -673,8 +673,8 @@ bool UploaderGadgetWidget::autoUpdateCapable()
|
||||
bool UploaderGadgetWidget::autoUpdate(bool erase)
|
||||
{
|
||||
if (m_oplinkwatchdog.isConnected() &&
|
||||
m_oplinkwatchdog.oplinkType() == OPLinkWatchdog::OPLINK_STANDALONE) {
|
||||
emit progressUpdate(FAILURE, QVariant(tr("To upgrade OPLink board please disconnect it from the USB port, "
|
||||
m_oplinkwatchdog.opLinkType() == OPLinkWatchdog::OPLINK_MINI) {
|
||||
emit progressUpdate(FAILURE, QVariant(tr("To upgrade the OPLinkMini board please disconnect it from the USB port, "
|
||||
"press the Upgrade again button and follow instructions on screen.")));
|
||||
emit autoUpdateFailed();
|
||||
return false;
|
||||
@ -1028,7 +1028,7 @@ void UploaderGadgetWidget::finishAutoUpdate()
|
||||
{
|
||||
disconnect(this, SIGNAL(progressUpdate(uploader::ProgressStep, QVariant)), this, SLOT(autoUpdateStatus(uploader::ProgressStep, QVariant)));
|
||||
m_config->autoUpdateOkButton->setEnabled(true);
|
||||
m_autoupdateClosing = true;
|
||||
m_autoUpdateClosing = true;
|
||||
|
||||
// wait a bit and "close" auto update
|
||||
QTimer::singleShot(AUTOUPDATE_CLOSE_TIMEOUT, this, SLOT(closeAutoUpdate()));
|
||||
@ -1036,12 +1036,12 @@ void UploaderGadgetWidget::finishAutoUpdate()
|
||||
|
||||
void UploaderGadgetWidget::closeAutoUpdate()
|
||||
{
|
||||
if (m_autoupdateClosing) {
|
||||
if (m_autoUpdateClosing) {
|
||||
m_config->autoUpdateGroupBox->setVisible(false);
|
||||
m_config->buttonFrame->setEnabled(true);
|
||||
m_config->splitter->setEnabled(true);
|
||||
}
|
||||
m_autoupdateClosing = false;
|
||||
m_autoUpdateClosing = false;
|
||||
}
|
||||
|
||||
void UploaderGadgetWidget::autoUpdateStatus(uploader::ProgressStep status, QVariant value)
|
||||
|
@ -147,7 +147,7 @@ private:
|
||||
IAPStep m_currentIAPStep;
|
||||
bool m_resetOnly;
|
||||
OPLinkWatchdog m_oplinkwatchdog;
|
||||
bool m_autoupdateClosing;
|
||||
bool m_autoUpdateClosing;
|
||||
|
||||
void clearLog();
|
||||
QString getPortDevice(const QString &friendName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user