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