1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11: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

@ -39,6 +39,10 @@ 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()
@ -51,12 +55,15 @@ 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

@ -29,6 +29,10 @@
#define LoggingGADGETWIDGET_H_
#include <QtGui/QLabel>
#include "extensionsystem/pluginmanager.h"
#include "scope/scopeplugin.h"
#include "scope/scopegadgetfactory.h"
class Ui_Logging;
class LoggingPlugin;
@ -52,6 +56,7 @@ signals:
private:
Ui_Logging *m_logging;
LoggingPlugin * loggingPlugin;
ScopeGadgetFactory * scpPlugin;
};

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

@ -25,6 +25,7 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "scopeplugin.h"
#include "scopegadget.h"
#include "scopegadgetconfiguration.h"
#include "scopegadgetwidget.h"
@ -36,6 +37,7 @@ ScopeGadget::ScopeGadget(QString classId, ScopeGadgetWidget *widget, QWidget *pa
m_widget(widget),
configLoaded(false)
{
}
void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)

View File

@ -42,9 +42,22 @@ 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);
}

View File

@ -28,6 +28,7 @@
#ifndef SCOPEGADGETFACTORY_H_
#define SCOPEGADGETFACTORY_H_
#include "scope_global.h"
#include <coreplugin/iuavgadgetfactory.h>
namespace Core
@ -38,7 +39,7 @@ class IUAVGadgetFactory;
using namespace Core;
class ScopeGadgetFactory : public IUAVGadgetFactory
class SCOPE_EXPORT ScopeGadgetFactory : public IUAVGadgetFactory
{
Q_OBJECT
public:
@ -48,6 +49,15 @@ public:
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

@ -43,6 +43,7 @@ ScopePlugin::~ScopePlugin()
// Do nothing
}
bool ScopePlugin::initialize(const QStringList& args, QString *errMsg)
{
Q_UNUSED(args);

View File

@ -27,6 +27,7 @@
#ifndef SCOPEPLUGIN_H_
#define SCOPEPLUGIN_H_
#include "scope_global.h"
#include <extensionsystem/iplugin.h>
class ScopeGadgetFactory;
@ -40,7 +41,10 @@ public:
void extensionsInitialized();
bool initialize(const QStringList & arguments, QString * errorString);
void shutdown();
private:
ScopeGadgetFactory *mf;
};
#endif /* SCOPEPLUGIN_H_ */