mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Merge branch 'master' of git://git.openpilot.org/OpenPilot
This commit is contained in:
commit
471a8d64ff
@ -28,7 +28,7 @@
|
||||
#include "ui_ccattitude.h"
|
||||
#include "utils/coordinateconversions.h"
|
||||
#include <QMutexLocker>
|
||||
#include <QErrorMessage>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) :
|
||||
@ -89,9 +89,12 @@ void ConfigCCAttitudeWidget::timeout() {
|
||||
disconnect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(attitudeRawUpdated(UAVObject*)));
|
||||
disconnect(&timer,SIGNAL(timeout()),this,SLOT(timeout()));
|
||||
|
||||
QErrorMessage errmsg;
|
||||
errmsg.showMessage("Calibration timed out before receiving required updates");
|
||||
errmsg.exec();
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Calibration timed out before receiving required updates."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::attitudeBiasChanged(int val) {
|
||||
@ -121,7 +124,7 @@ void ConfigCCAttitudeWidget::startAccelCalibration() {
|
||||
y_accum.clear();
|
||||
z_accum.clear();
|
||||
|
||||
ui->status->setText("Calibrating...");
|
||||
ui->status->setText(tr("Calibrating..."));
|
||||
|
||||
// Set up to receive updates
|
||||
UAVDataObject * obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AttitudeRaw")));
|
||||
|
@ -28,8 +28,10 @@
|
||||
#include "configgadgetfactory.h"
|
||||
#include <QtPlugin>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
|
||||
ConfigPlugin::ConfigPlugin()
|
||||
{
|
||||
// Do nothing
|
||||
@ -47,16 +49,133 @@ bool ConfigPlugin::initialize(const QStringList& args, QString *errMsg)
|
||||
cf = new ConfigGadgetFactory(this);
|
||||
addAutoReleasedObject(cf);
|
||||
|
||||
// Add Menu entry to erase all settings
|
||||
Core::ActionManager* am = Core::ICore::instance()->actionManager();
|
||||
Core::ActionContainer* ac = am->actionContainer(Core::Constants::M_TOOLS);
|
||||
|
||||
// Command to erase all settings from the board
|
||||
cmd = am->registerAction(new QAction(this),
|
||||
"ConfigPlugin.EraseAll",
|
||||
QList<int>() <<
|
||||
Core::Constants::C_GLOBAL_ID);
|
||||
cmd->action()->setText("Erase all settings from board...");
|
||||
|
||||
ac->menu()->addSeparator();
|
||||
ac->appendGroup("Utilities");
|
||||
ac->addAction(cmd, "Utilities");
|
||||
|
||||
connect(cmd->action(), SIGNAL(triggered(bool)), this, SLOT(eraseAllSettings()));
|
||||
|
||||
// *********************
|
||||
// Listen to autopilot connection events
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
|
||||
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
|
||||
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
|
||||
|
||||
// And check whether by any chance we are not already connected
|
||||
if (telMngr->isConnected())
|
||||
onAutopilotConnect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConfigPlugin::extensionsInitialized()
|
||||
{
|
||||
// Do nothing
|
||||
cmd->action()->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void ConfigPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the menu entry when the autopilot connects
|
||||
*/
|
||||
void ConfigPlugin::onAutopilotConnect()
|
||||
{
|
||||
cmd->action()->setEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the menu entry when the autopilot connects
|
||||
*/
|
||||
void ConfigPlugin::onAutopilotDisconnect()
|
||||
{
|
||||
cmd->action()->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Erase all settings from the board
|
||||
*/
|
||||
void ConfigPlugin::eraseAllSettings()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Are you sure you want to erase all board settings?."));
|
||||
msgBox.setInformativeText(tr("All settings stored in your board flash will be deleted."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
if (msgBox.exec() != QMessageBox::Ok)
|
||||
return;
|
||||
|
||||
settingsErased = false;
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( objMngr->getObject(ObjectPersistence::NAME) );
|
||||
Q_ASSERT(objper);
|
||||
connect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *)));
|
||||
ObjectPersistence::DataFields data;
|
||||
data.Operation = ObjectPersistence::OPERATION_DELETE;
|
||||
data.Selection = ObjectPersistence::SELECTION_ALLSETTINGS;
|
||||
objper->setData(data);
|
||||
objper->updated();
|
||||
QTimer::singleShot(1500,this,SLOT(eraseFailed()));
|
||||
|
||||
}
|
||||
|
||||
void ConfigPlugin::eraseFailed()
|
||||
{
|
||||
if (settingsErased)
|
||||
return;
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager * objMngr = pm->getObject<UAVObjectManager>();
|
||||
Q_ASSERT(objMngr);
|
||||
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>( objMngr->getObject(ObjectPersistence::NAME));
|
||||
disconnect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *)));
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("Error trying to erase settings."));
|
||||
msgBox.setInformativeText(tr("Power-cycle your board. Settings might be inconsistent."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void ConfigPlugin::eraseDone(UAVObject * obj)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
ObjectPersistence* objper = dynamic_cast<ObjectPersistence*>(sender());
|
||||
Q_ASSERT(obj->getName().compare("ObjectPersistence") == 0);
|
||||
QString tmp = obj->getField("Operation")->getValue().toString();
|
||||
if (obj->getField("Operation")->getValue().toString().compare(QString("Delete")) == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(objper, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(eraseDone(UAVObject *)));
|
||||
if (obj->getField("Operation")->getValue().toString().compare(QString("Completed")) == 0) {
|
||||
settingsErased = true;
|
||||
msgBox.setText(tr("Settings are now erased."));
|
||||
msgBox.setInformativeText(tr("Please now power-cycle your board to complete reset."));
|
||||
} else {
|
||||
msgBox.setText(tr("Error trying to erase settings."));
|
||||
msgBox.setInformativeText(tr("Power-cycle your board. Settings might be inconsistent."));
|
||||
}
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(ConfigPlugin)
|
||||
|
@ -28,11 +28,22 @@
|
||||
#define CONFIGPLUGIN_H
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
#include "objectpersistence.h"
|
||||
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
class ConfigGadgetFactory;
|
||||
|
||||
class ConfigPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ConfigPlugin();
|
||||
~ConfigPlugin();
|
||||
@ -40,8 +51,19 @@ public:
|
||||
void extensionsInitialized();
|
||||
bool initialize(const QStringList & arguments, QString * errorString);
|
||||
void shutdown();
|
||||
|
||||
private slots:
|
||||
void eraseAllSettings();
|
||||
void onAutopilotConnect();
|
||||
void onAutopilotDisconnect();
|
||||
void eraseDone(UAVObject *);
|
||||
void eraseFailed();
|
||||
|
||||
private:
|
||||
ConfigGadgetFactory *cf;
|
||||
Core::Command* cmd;
|
||||
bool settingsErased;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONFIGPLUGIN_H
|
||||
|
@ -38,9 +38,21 @@ UAVTalkPlugin::~UAVTalkPlugin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called once all the plugins which depend on us have been loaded
|
||||
*/
|
||||
void UAVTalkPlugin::extensionsInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called at startup, before any plugin which depends on us is initialized
|
||||
*/
|
||||
bool UAVTalkPlugin::initialize(const QStringList & arguments, QString * errorString)
|
||||
{
|
||||
// Done
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorString);
|
||||
// Get UAVObjectManager instance
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
objMngr = pm->getObject<UAVObjectManager>();
|
||||
@ -55,13 +67,6 @@ void UAVTalkPlugin::extensionsInitialized()
|
||||
this, SLOT(onDeviceConnect(QIODevice *)));
|
||||
QObject::connect(cm, SIGNAL(deviceAboutToDisconnect()),
|
||||
this, SLOT(onDeviceDisconnect()));
|
||||
}
|
||||
|
||||
bool UAVTalkPlugin::initialize(const QStringList & arguments, QString * errorString)
|
||||
{
|
||||
// Done
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorString);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user