1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-19 09:54:15 +01:00

OP-249 : GCS / Pause scopes during log replay if pause button is pressed. Was more difficult than planned! You will have to clean your GCS build or at least delete the scope and logging shadow build dirs in order for this to work properly.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2597 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-01-26 22:21:54 +00:00 committed by edouard
parent 63ec10a5e8
commit ba606c7054
17 changed files with 577 additions and 473 deletions

View File

@ -6,5 +6,6 @@
<url>http://www.openpilot.org</url>
<dependencyList>
<dependency name="Core" version="1.0.0"/>
<dependency name="ScopeGadget" version="1.0.0"/>
</dependencyList>
</plugin>

View File

@ -3,8 +3,6 @@ TARGET = LoggingGadget
DEFINES += LOGGING_LIBRARY
QT += svg
include(../../openpilotgcsplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(logging_dependencies.pri)
HEADERS += loggingplugin.h \
logfile.h \

View File

@ -27,16 +27,16 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="2,2,0,0">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item>
<widget class="QCommandLinkButton" name="playButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>30</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -59,7 +59,7 @@
<item>
<widget class="QCommandLinkButton" name="pauseButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>30</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -79,31 +79,6 @@
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="playbackSpeed">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>-100</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>50</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
@ -120,6 +95,43 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Playback speed:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="playbackSpeed">
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>

View File

@ -1 +1,4 @@
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../plugins/scope/scope.pri)

View File

@ -1,68 +1,75 @@
/**
******************************************************************************
*
* @file GCSControlgadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
* @{
* @brief A gadget to control the UAV, either from the keyboard or a joystick
*****************************************************************************/
/*
* 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 "logginggadgetwidget.h"
#include "ui_logging.h"
#include <QDebug>
#include <QStringList>
#include <QtGui/QWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
#include <loggingplugin.h>
LoggingGadgetWidget::LoggingGadgetWidget(QWidget *parent) : QLabel(parent)
{
m_logging = new Ui_Logging();
m_logging->setupUi(this);
}
LoggingGadgetWidget::~LoggingGadgetWidget()
{
// Do nothing
}
void LoggingGadgetWidget::setPlugin(LoggingPlugin * p)
{
loggingPlugin = p;
connect(p,SIGNAL(stateChanged(QString)),this,SLOT(stateChanged(QString)));
connect(m_logging->playButton,SIGNAL(clicked()),p->getLogfile(),SLOT(resumeReplay()));
connect(m_logging->pauseButton,SIGNAL(clicked()),p->getLogfile(),SLOT(pauseReplay()));
connect(m_logging->playbackSpeed,SIGNAL(valueChanged(int)),p->getLogfile(),SLOT(setReplaySpeed(int)));
void pauseReplay();
void resumeReplay();
}
void LoggingGadgetWidget::stateChanged(QString status)
{
m_logging->statusLabel->setText(status);
}
/**
* @}
* @}
*/
/**
******************************************************************************
*
* @file GCSControlgadgetwidget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin
* @{
* @brief A gadget to control the UAV, either from the keyboard or a joystick
*****************************************************************************/
/*
* 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 "logginggadgetwidget.h"
#include "ui_logging.h"
#include <QDebug>
#include <QStringList>
#include <QtGui/QWidget>
#include <QtGui/QTextEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
#include <loggingplugin.h>
LoggingGadgetWidget::LoggingGadgetWidget(QWidget *parent) : QLabel(parent)
{
m_logging = new Ui_Logging();
m_logging->setupUi(this);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
scpPlugin = pm->getObject<ScopeGadgetFactory>();
}
LoggingGadgetWidget::~LoggingGadgetWidget()
{
// Do nothing
}
void LoggingGadgetWidget::setPlugin(LoggingPlugin * p)
{
loggingPlugin = p;
connect(p,SIGNAL(stateChanged(QString)),this,SLOT(stateChanged(QString)));
connect(m_logging->playButton,SIGNAL(clicked()),p->getLogfile(),SLOT(resumeReplay()));
connect(m_logging->playButton, SIGNAL(clicked()), scpPlugin, SLOT(startPlotting()));
connect(m_logging->pauseButton,SIGNAL(clicked()),p->getLogfile(),SLOT(pauseReplay()));
connect(m_logging->pauseButton, SIGNAL(clicked()), scpPlugin, SLOT(stopPlotting()));
connect(m_logging->playbackSpeed,SIGNAL(valueChanged(int)),p->getLogfile(),SLOT(setReplaySpeed(int)));
void pauseReplay();
void resumeReplay();
}
void LoggingGadgetWidget::stateChanged(QString status)
{
m_logging->statusLabel->setText(status);
}
/**
* @}
* @}
*/

View File

@ -1,59 +1,64 @@
/**
******************************************************************************
*
* @file GCSControlgadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GCSControlGadgetPlugin GCSControl 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 LoggingGADGETWIDGET_H_
#define LoggingGADGETWIDGET_H_
#include <QtGui/QLabel>
class Ui_Logging;
class LoggingPlugin;
class LoggingGadgetWidget : public QLabel
{
Q_OBJECT
public:
LoggingGadgetWidget(QWidget *parent = 0);
~LoggingGadgetWidget();
void setPlugin(LoggingPlugin * p);
protected slots:
void stateChanged(QString status);
signals:
void pause();
void play();
private:
Ui_Logging *m_logging;
LoggingPlugin * loggingPlugin;
};
#endif /* LoggingGADGETWIDGET_H_ */
/**
******************************************************************************
*
* @file GCSControlgadgetwidget.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup GCSControlGadgetPlugin GCSControl 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 LoggingGADGETWIDGET_H_
#define LoggingGADGETWIDGET_H_
#include <QtGui/QLabel>
#include "extensionsystem/pluginmanager.h"
#include "scope/scopeplugin.h"
#include "scope/scopegadgetfactory.h"
class Ui_Logging;
class LoggingPlugin;
class LoggingGadgetWidget : public QLabel
{
Q_OBJECT
public:
LoggingGadgetWidget(QWidget *parent = 0);
~LoggingGadgetWidget();
void setPlugin(LoggingPlugin * p);
protected slots:
void stateChanged(QString status);
signals:
void pause();
void play();
private:
Ui_Logging *m_logging;
LoggingPlugin * loggingPlugin;
ScopeGadgetFactory * scpPlugin;
};
#endif /* LoggingGADGETWIDGET_H_ */

View File

@ -0,0 +1,3 @@
include(scope_dependencies.pri)
LIBS *= -l$$qtLibraryTarget(ScopeGadget)

View File

@ -1,12 +1,11 @@
TEMPLATE = lib
TARGET = ScopeGadget
DEFINES += SCOPE_LIBRARY
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../libs/qwt/qwt.pri)
include (scope_dependencies.pri)
HEADERS += scopeplugin.h \
plotdata.h
plotdata.h \
scope_global.h
HEADERS += scopegadgetoptionspage.h
HEADERS += scopegadgetconfiguration.h
HEADERS += scopegadget.h

View File

@ -0,0 +1,5 @@
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../libs/utils/utils.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../libs/qwt/qwt.pri)

View File

@ -0,0 +1,41 @@
/**
******************************************************************************
*
* @file uavobjects_global.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{
* @brief The UAVUObjects GCS 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 SCOPE_GLOBAL_H
#define SCOPE_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(SCOPE_LIBRARY)
# define SCOPE_EXPORT Q_DECL_EXPORT
#else
# define SCOPE_EXPORT Q_DECL_IMPORT
#endif
#endif // UAVOBJECTS_GLOBAL_H

View File

@ -1,80 +1,82 @@
/**
******************************************************************************
*
* @file scopegadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopegadget.h"
#include "scopegadgetconfiguration.h"
#include "scopegadgetwidget.h"
#include <QtGui/qcolor.h>
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget),
configLoaded(false)
{
}
void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration*>(config);
ScopeGadgetWidget* widget = qobject_cast<ScopeGadgetWidget*>(m_widget);
widget->setXWindowSize(sgConfig->dataSize());
widget->setRefreshInterval(sgConfig->refreshInterval());
if(sgConfig->plotType() == SequencialPlot )
widget->setupSequencialPlot();
else if(sgConfig->plotType() == ChronoPlot)
widget->setupChronoPlot();
// else if(sgConfig->plotType() == UAVObjectPlot)
// widget->setupUAVObjectPlot();
foreach (PlotCurveConfiguration* plotCurveConfig, sgConfig->plotCurveConfigs()) {
QString uavObject = plotCurveConfig->uavObject;
QString uavField = plotCurveConfig->uavField;
int scale = plotCurveConfig->yScalePower;
QRgb color = plotCurveConfig->color;
widget->addCurvePlot(
uavObject,
uavField,
scale,
QPen( QBrush(QColor(color),Qt::SolidPattern),
(qreal)2,
Qt::SolidLine,
Qt::SquareCap,
Qt::BevelJoin)
);
}
}
ScopeGadget::~ScopeGadget()
{
}
/**
******************************************************************************
*
* @file scopegadget.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopeplugin.h"
#include "scopegadget.h"
#include "scopegadgetconfiguration.h"
#include "scopegadgetwidget.h"
#include <QtGui/qcolor.h>
ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *parent) :
IUAVGadget(classId, parent),
m_widget(widget),
configLoaded(false)
{
}
void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)
{
ScopeGadgetConfiguration *sgConfig = qobject_cast<ScopeGadgetConfiguration*>(config);
ScopeGadgetWidget* widget = qobject_cast<ScopeGadgetWidget*>(m_widget);
widget->setXWindowSize(sgConfig->dataSize());
widget->setRefreshInterval(sgConfig->refreshInterval());
if(sgConfig->plotType() == SequencialPlot )
widget->setupSequencialPlot();
else if(sgConfig->plotType() == ChronoPlot)
widget->setupChronoPlot();
// else if(sgConfig->plotType() == UAVObjectPlot)
// widget->setupUAVObjectPlot();
foreach (PlotCurveConfiguration* plotCurveConfig, sgConfig->plotCurveConfigs()) {
QString uavObject = plotCurveConfig->uavObject;
QString uavField = plotCurveConfig->uavField;
int scale = plotCurveConfig->yScalePower;
QRgb color = plotCurveConfig->color;
widget->addCurvePlot(
uavObject,
uavField,
scale,
QPen( QBrush(QColor(color),Qt::SolidPattern),
(qreal)2,
Qt::SolidLine,
Qt::SquareCap,
Qt::BevelJoin)
);
}
}
ScopeGadget::~ScopeGadget()
{
}

View File

@ -1,59 +1,72 @@
/**
******************************************************************************
*
* @file scopegadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopegadgetfactory.h"
#include "scopegadgetwidget.h"
#include "scopegadgetconfiguration.h"
#include "scopegadgetoptionspage.h"
#include "scopegadget.h"
#include <coreplugin/iuavgadget.h>
ScopeGadgetFactory::ScopeGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("ScopeGadget"),
tr("Scope Gadget"),
parent)
{
}
ScopeGadgetFactory::~ScopeGadgetFactory()
{
}
Core::IUAVGadget* ScopeGadgetFactory::createGadget(QWidget *parent)
{
ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent);
return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new ScopeGadgetConfiguration(QString("ScopeGadget"), qSettings);
}
IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new ScopeGadgetOptionsPage(qobject_cast<ScopeGadgetConfiguration*>(config));
}
/**
******************************************************************************
*
* @file scopegadgetfactory.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopegadgetfactory.h"
#include "scopegadgetwidget.h"
#include "scopegadgetconfiguration.h"
#include "scopegadgetoptionspage.h"
#include "scopegadget.h"
#include <coreplugin/iuavgadget.h>
ScopeGadgetFactory::ScopeGadgetFactory(QObject *parent) :
IUAVGadgetFactory(QString("ScopeGadget"),
tr("Scope Gadget"),
parent)
{
}
ScopeGadgetFactory::~ScopeGadgetFactory()
{
}
void ScopeGadgetFactory::stopPlotting()
{
emit onStopPlotting();
}
void ScopeGadgetFactory::startPlotting()
{
emit onStartPlotting();
}
Core::IUAVGadget* ScopeGadgetFactory::createGadget(QWidget *parent)
{
ScopeGadgetWidget* gadgetWidget = new ScopeGadgetWidget(parent);
connect(this,SIGNAL(onStartPlotting()), gadgetWidget, SLOT(startPlotting()));
connect(this,SIGNAL(onStopPlotting()), gadgetWidget, SLOT(stopPlotting()));
return new ScopeGadget(QString("ScopeGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new ScopeGadgetConfiguration(QString("ScopeGadget"), qSettings);
}
IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{
return new ScopeGadgetOptionsPage(qobject_cast<ScopeGadgetConfiguration*>(config));
}

View File

@ -1,53 +1,63 @@
/**
******************************************************************************
*
* @file scopegadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 SCOPEGADGETFACTORY_H_
#define SCOPEGADGETFACTORY_H_
#include <coreplugin/iuavgadgetfactory.h>
namespace Core
{
class IUAVGadget;
class IUAVGadgetFactory;
}
using namespace Core;
class ScopeGadgetFactory : public IUAVGadgetFactory
{
Q_OBJECT
public:
ScopeGadgetFactory(QObject *parent = 0);
~ScopeGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};
#endif // SCOPEGADGETFACTORY_H_
/**
******************************************************************************
*
* @file scopegadgetfactory.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 SCOPEGADGETFACTORY_H_
#define SCOPEGADGETFACTORY_H_
#include "scope_global.h"
#include <coreplugin/iuavgadgetfactory.h>
namespace Core
{
class IUAVGadget;
class IUAVGadgetFactory;
}
using namespace Core;
class SCOPE_EXPORT ScopeGadgetFactory : public IUAVGadgetFactory
{
Q_OBJECT
public:
ScopeGadgetFactory(QObject *parent = 0);
~ScopeGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
public slots:
void stopPlotting();
void startPlotting();
signals:
void onStopPlotting();
void onStartPlotting();
};
#endif // SCOPEGADGETFACTORY_H_

View File

@ -67,21 +67,21 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
// running the scopes if we are not connected and not replaying logs
// Also listen to disconnect actions from the user
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(onTelemetryDisconnected()));
connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(onTelemetryConnected()));
connect(cm, SIGNAL(deviceDisconnected()), this, SLOT(stopPlotting()));
connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(startPlotting()));
}
/**
* Starts/stops telemetry
*/
void ScopeGadgetWidget::onTelemetryConnected()
void ScopeGadgetWidget::startPlotting()
{
if(!replotTimer->isActive())
replotTimer->start(m_refreshInterval);
}
void ScopeGadgetWidget::onTelemetryDisconnected()
void ScopeGadgetWidget::stopPlotting()
{
replotTimer->stop();
}

View File

@ -120,8 +120,8 @@ private slots:
void uavObjectReceived(UAVObject*);
void replotNewData();
void showCurve(QwtPlotItem *item, bool on);
void onTelemetryConnected();
void onTelemetryDisconnected();
void startPlotting();
void stopPlotting();
private:

View File

@ -1,66 +1,67 @@
/**
******************************************************************************
*
* @file scopeplugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopeplugin.h"
#include "scopegadgetfactory.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
ScopePlugin::ScopePlugin()
{
// Do nothing
}
ScopePlugin::~ScopePlugin()
{
// Do nothing
}
bool ScopePlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
mf = new ScopeGadgetFactory(this);
addAutoReleasedObject(mf);
return true;
}
void ScopePlugin::extensionsInitialized()
{
// Do nothing
}
void ScopePlugin::shutdown()
{
// Do nothing
}
Q_EXPORT_PLUGIN(ScopePlugin)
/**
******************************************************************************
*
* @file scopeplugin.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 "scopeplugin.h"
#include "scopegadgetfactory.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
ScopePlugin::ScopePlugin()
{
// Do nothing
}
ScopePlugin::~ScopePlugin()
{
// Do nothing
}
bool ScopePlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);
Q_UNUSED(errMsg);
mf = new ScopeGadgetFactory(this);
addAutoReleasedObject(mf);
return true;
}
void ScopePlugin::extensionsInitialized()
{
// Do nothing
}
void ScopePlugin::shutdown()
{
// Do nothing
}
Q_EXPORT_PLUGIN(ScopePlugin)

View File

@ -1,46 +1,50 @@
/**
******************************************************************************
*
* @file scopeplugin.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 SCOPEPLUGIN_H_
#define SCOPEPLUGIN_H_
#include <extensionsystem/iplugin.h>
class ScopeGadgetFactory;
class ScopePlugin : public ExtensionSystem::IPlugin
{
public:
ScopePlugin();
~ScopePlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
ScopeGadgetFactory *mf;
};
#endif /* SCOPEPLUGIN_H_ */
/**
******************************************************************************
*
* @file scopeplugin.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @addtogroup GCSPlugins GCS Plugins
* @{
* @addtogroup ScopePlugin Scope Gadget Plugin
* @{
* @brief The scope Gadget, graphically plots the states of UAVObjects
*****************************************************************************/
/*
* 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 SCOPEPLUGIN_H_
#define SCOPEPLUGIN_H_
#include "scope_global.h"
#include <extensionsystem/iplugin.h>
class ScopeGadgetFactory;
class ScopePlugin : public ExtensionSystem::IPlugin
{
public:
ScopePlugin();
~ScopePlugin();
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
ScopeGadgetFactory *mf;
};
#endif /* SCOPEPLUGIN_H_ */