1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

mixer bug fix.

Also added a new debug plugin witch shows the debug messages normally not available on release builds
This commit is contained in:
zedamota 2011-09-25 19:30:32 +01:00
parent 352620e0ed
commit 797bb38081
18 changed files with 557 additions and 6 deletions

View File

@ -39,6 +39,7 @@
#include "systemsettings.h"
#include "mixersettings.h"
#include "actuatorsettings.h"
#include <QEventLoop>
/**
Helper delegate for the custom mixer editor table.
@ -447,12 +448,7 @@ void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList<double> list, d
void ConfigAirframeWidget::refreshWidgetsValues()
{
if(!allObjectsUpdated())
{
SystemSettings::GetInstance(getObjectManager())->requestUpdate();
MixerSettings::GetInstance(getObjectManager())->requestUpdate();
ActuatorSettings::GetInstance(getObjectManager())->requestUpdate();
return;
}
bool dirty=isDirty();
// Get the Airframe type from the system settings:
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));

View File

@ -65,7 +65,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
{
obj = objManager->getObject(QString(object));
Q_ASSERT(obj);
objectUpdates.insert(obj,false);
objectUpdates.insert(obj,true);
connect(obj, SIGNAL(objectUpdated(UAVObject*)),this, SLOT(objectUpdated(UAVObject*)));
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues()));
}
@ -163,6 +163,7 @@ void ConfigTaskWidget::onAutopilotDisconnect()
void ConfigTaskWidget::onAutopilotConnect()
{
invalidateObjects();
dirty=false;
isConnected=true;
enableControls(true);

View File

@ -0,0 +1,10 @@
<plugin name="DebugGadget" version="1.0.0" compatVersion="1.0.0">
<vendor>The OpenPilot Project</vendor>
<copyright>(C) 2010 OpenPilot Project</copyright>
<license>The GNU Public License (GPL) Version 3</license>
<description>An debug gadget</description>
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Save to file</string>
</property>
</widget>
</item>
<item>
<widget class="QTextBrowser" name="plainTextEdit"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,13 @@
#include "debugengine.h"
debugengine::debugengine()
{
}
void debugengine::writeToStdErr(const QString &level, const QList<QVariant> &msgs)
{
emit dbgMsgError(level,msgs);
}
void debugengine::writeToStdOut(const QString &level, const QList<QVariant> &msgs)
{
emit dbgMsg(level,msgs);
}

View File

@ -0,0 +1,18 @@
#ifndef DEBUGENGINE_H
#define DEBUGENGINE_H
#include "qxtbasicstdloggerengine.h"
#include <QObject>
class debugengine:public QObject,public QxtBasicSTDLoggerEngine
{
Q_OBJECT
public:
debugengine();
protected:
void writeToStdErr ( const QString & level, const QList<QVariant> & msgs );
void writeToStdOut ( const QString & level, const QList<QVariant> & msgs );
signals:
void dbgMsgError( const QString & level, const QList<QVariant> & msgs );
void dbgMsg( const QString & level, const QList<QVariant> & msgs );
};
#endif // DEBUGENGINE_H

View File

@ -0,0 +1,39 @@
/**
******************************************************************************
*
* @file debuggadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debuggadget.h"
#include "debuggadgetwidget.h"
DebugGadget::DebugGadget(QString classId, DebugGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget)
{
}
DebugGadget::~DebugGadget()
{
delete m_widget;
}

View File

@ -0,0 +1,59 @@
/**
******************************************************************************
*
* @file debuggadget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEBUGGADGET_H_
#define DEBUGGADGET_H_
#include <coreplugin/iuavgadget.h>
namespace Core {
class IUAVGadget;
}
//class QWidget;
//class QString;
class DebugGadgetWidget;
using namespace Core;
class DebugGadget : public Core::IUAVGadget
{
Q_OBJECT
public:
DebugGadget(QString classId, DebugGadgetWidget *widget, QWidget *parent = 0);
~DebugGadget();
QList<int> context() const { return m_context; }
QWidget *widget() { return m_widget; }
QString contextHelpId() const { return QString(); }
private:
QWidget *m_widget;
QList<int> m_context;
};
#endif // DEBUGGADGET_H_

View File

@ -0,0 +1,21 @@
TEMPLATE = lib
TARGET = DebugGadget
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/libqxt/core/logengines.pri)
HEADERS += debugplugin.h \
debugengine.h
HEADERS += debuggadget.h
HEADERS += debuggadgetwidget.h
HEADERS += debuggadgetfactory.h
SOURCES += debugplugin.cpp \
debugengine.cpp
SOURCES += debuggadget.cpp
SOURCES += debuggadgetfactory.cpp
SOURCES += debuggadgetwidget.cpp
OTHER_FILES += DebugGadget.pluginspec
FORMS += \
debug.ui

View File

@ -0,0 +1,47 @@
/**
******************************************************************************
*
* @file debuggadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debuggadgetfactory.h"
#include "debuggadgetwidget.h"
#include "debuggadget.h"
#include <coreplugin/iuavgadget.h>
DebugGadgetFactory::DebugGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("DebugGadget"),
tr("DebugGadget"),
parent)
{
}
DebugGadgetFactory::~DebugGadgetFactory()
{
}
IUAVGadget* DebugGadgetFactory::createGadget(QWidget *parent) {
DebugGadgetWidget* gadgetWidget = new DebugGadgetWidget(parent);
return new DebugGadget(QString("DebugGadget"), gadgetWidget, parent);
}

View File

@ -0,0 +1,50 @@
/**
******************************************************************************
*
* @file debuggadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEBUGGADGETFACTORY_H_
#define DEBUGGADGETFACTORY_H_
#include <coreplugin/iuavgadgetfactory.h>
namespace Core {
class IUAVGadget;
class IUAVGadgetFactory;
}
using namespace Core;
class DebugGadgetFactory : public IUAVGadgetFactory
{
Q_OBJECT
public:
DebugGadgetFactory(QObject *parent = 0);
~DebugGadgetFactory();
IUAVGadget *createGadget(QWidget *parent);
};
#endif // DEBUGGADGETFACTORY_H_

View File

@ -0,0 +1,96 @@
/**
******************************************************************************
*
* @file debuggadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debuggadgetwidget.h"
#include <QDebug>
#include <QStringList>
#include <QtGui/QWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
#include "qxtlogger.h"
#include "debugengine.h"
#include <QFile>
#include <QFileDialog>
#include <QMessageBox>
#include <QScrollBar>
DebugGadgetWidget::DebugGadgetWidget(QWidget *parent) : QLabel(parent)
{
m_config = new Ui_Form();
m_config->setupUi(this);
debugengine * de=new debugengine();
QxtLogger::getInstance()->addLoggerEngine("debugplugin", de);
connect(de,SIGNAL(dbgMsg(QString,QList<QVariant>)),this,SLOT(dbgMsg(QString,QList<QVariant>)));
connect(de,SIGNAL(dbgMsgError(QString,QList<QVariant>)),this,SLOT(dbgMsgError(QString,QList<QVariant>)));
connect(m_config->pushButton,SIGNAL(clicked()),this,SLOT(saveLog()));
}
DebugGadgetWidget::~DebugGadgetWidget()
{
// Do nothing
}
void DebugGadgetWidget::dbgMsg(const QString &level, const QList<QVariant> &msgs)
{
m_config->plainTextEdit->setTextColor(Qt::black);
foreach(QVariant str,msgs)
{
m_config->plainTextEdit->append(QString("[%0]%1").arg(level).arg(str.toString()));
}
QScrollBar *sb = m_config->plainTextEdit->verticalScrollBar();
sb->setValue(sb->maximum());
}
void DebugGadgetWidget::dbgMsgError(const QString &level, const QList<QVariant> &msgs)
{
m_config->plainTextEdit->setTextColor(Qt::red);
foreach(QVariant str,msgs)
{
m_config->plainTextEdit->append(QString("[%0]%1").arg(level).arg(str.toString()));
}
QScrollBar *sb = m_config->plainTextEdit->verticalScrollBar();
sb->setValue(sb->maximum());
}
void DebugGadgetWidget::saveLog()
{
QString fileName = QFileDialog::getSaveFileName(0, tr("Save log File As"), "");
if (fileName.isEmpty()) {
return;
}
QFile file(fileName);
if (file.open(QIODevice::WriteOnly) &&
(file.write(m_config->plainTextEdit->toHtml().toAscii()) != -1)) {
file.close();
} else {
QMessageBox::critical(0,
tr("Log Save"),
tr("Unable to save log: ") + fileName,
QMessageBox::Ok);
return;
}
}

View File

@ -0,0 +1,49 @@
/**
******************************************************************************
*
* @file debuggadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEBUGGADGETWIDGET_H_
#define DEBUGGADGETWIDGET_H_
#include <QtGui/QLabel>
#include "ui_debug.h"
class DebugGadgetWidget : public QLabel
{
Q_OBJECT
public:
DebugGadgetWidget(QWidget *parent = 0);
~DebugGadgetWidget();
private:
Ui_Form *m_config;
private slots:
void saveLog();
void dbgMsgError( const QString & level, const QList<QVariant> & msgs );
void dbgMsg( const QString & level, const QList<QVariant> & msgs );
};
#endif /* DEBUGGADGETWIDGET_H_ */

View File

@ -0,0 +1,65 @@
/**
******************************************************************************
*
* @file debugplugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "debugplugin.h"
#include "debuggadgetfactory.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
DebugPlugin::DebugPlugin()
{
// Do nothing
}
DebugPlugin::~DebugPlugin()
{
// Do nothing
}
bool DebugPlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
mf = new DebugGadgetFactory(this);
addAutoReleasedObject(mf);
return true;
}
void DebugPlugin::extensionsInitialized()
{
// Do nothing
}
void DebugPlugin::shutdown()
{
// Do nothing
}
Q_EXPORT_PLUGIN(DebugPlugin)

View File

@ -0,0 +1,47 @@
/**
******************************************************************************
*
* @file debugplugin.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup DebugGadgetPlugin Debug Gadget Plugin
* @{
* @brief A place holder gadget plugin
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DEBUGPLUGIN_H_
#define DEBUGPLUGIN_H_
#include <extensionsystem/iplugin.h>
class DebugGadgetFactory;
class DebugPlugin : public ExtensionSystem::IPlugin
{
public:
DebugPlugin();
~DebugPlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
DebugGadgetFactory *mf;
};
#endif /* DEBUGPLUGIN_H_ */

View File

@ -19,6 +19,12 @@ plugin_emptygadget.subdir = emptygadget
plugin_emptygadget.depends = plugin_coreplugin
SUBDIRS += plugin_emptygadget
# UAV Settings Import/Export plugin
plugin_debuggadget.subdir = debuggadget
#plugin_debughelper.depends = plugin_coreplugin
#plugin_debughelper.depends += plugin_uavobjects
SUBDIRS += plugin_debuggadget
# Welcome plugin
plugin_welcome.subdir = welcome
plugin_welcome.depends = plugin_coreplugin

View File

@ -115,6 +115,7 @@ void UAVSettingsImportExportFactory::importUAVSettings()
}
file.close();
emit importAboutToBegin();
qDebug()<<"Import about to begin";
QDomElement root = doc.documentElement();
if (root.tagName() != "settings") {
QMessageBox msgBox;
@ -188,6 +189,7 @@ void UAVSettingsImportExportFactory::importUAVSettings()
}
node = node.nextSibling();
}
qDebug()<<"End import";
swui.exec();

View File

@ -48,6 +48,7 @@ private slots:
void exportUAVData();
signals:
void importAboutToBegin();
void importEnded();
};