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

OP-263 Scopes now only run when telemetry is connected.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2495 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2011-01-20 22:30:49 +00:00 committed by edouard
parent c0218be369
commit c37403a480
4 changed files with 67 additions and 32 deletions

View File

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

View File

@ -3,6 +3,7 @@ TARGET = ScopeGadget
include(../../openpilotgcsplugin.pri)
include(../../plugins/coreplugin/coreplugin.pri)
include(../../plugins/uavobjects/uavobjects.pri)
include(../../plugins/uavtalk/uavtalk.pri)
include(../../libs/qwt/qwt.pri)
HEADERS += scopeplugin.h \
plotdata.h

View File

@ -26,11 +26,16 @@
*/
#include "uavobjects/uavobjectmanager.h"
#include "extensionsystem/pluginmanager.h"
#include "scopegadgetwidget.h"
#include "utils/stylehelper.h"
#include "uavtalk/telemetrymanager.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/uavobject.h"
#include "coreplugin/icore.h"
#include "coreplugin/connectionmanager.h"
#include "qwt/src/qwt_plot_curve.h"
#include "qwt/src/qwt_legend.h"
#include "qwt/src/qwt_legend_item.h"
@ -45,6 +50,7 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QPushButton>
using namespace Core;
TestDataGen* ScopeGadgetWidget::testDataGen;
@ -56,6 +62,28 @@ ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
//Setup the timer that replots data
replotTimer = new QTimer(this);
connect(replotTimer, SIGNAL(timeout()), this, SLOT(replotNewData()));
// Listen to telemetry connection/disconnection events, no point
// 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()));
}
/**
* Starts/stops telemetry
*/
void ScopeGadgetWidget::onTelemetryConnected()
{
if(!replotTimer->isActive())
replotTimer->start(m_refreshInterval);
}
void ScopeGadgetWidget::onTelemetryDisconnected()
{
replotTimer->stop();
}
void ScopeGadgetWidget::preparePlot(PlotType plotType)
@ -87,12 +115,16 @@ void ScopeGadgetWidget::preparePlot(PlotType plotType)
connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),this, SLOT(showCurve(QwtPlotItem *, bool)));
// Only start the timer if we are already connected
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
if (cm->getCurrentConnection()) {
if(!replotTimer->isActive())
replotTimer->start(m_refreshInterval);
else
{
replotTimer->setInterval(m_refreshInterval);
}
}
}

View File

@ -29,9 +29,6 @@
#define SCOPEGADGETWIDGET_H_
#include "plotdata.h"
#include "uavobjects/uavobject.h"
#include "uavobjects/baroaltitude.h"
#include "uavobjects/positionactual.h"
#include "qwt/src/qwt.h"
@ -44,6 +41,7 @@
#include <QTime>
#include <QVector>
/*!
\brief This class is used to render the time values on the horizontal axis for the
ChronoPlot.
@ -122,6 +120,8 @@ private slots:
void uavObjectReceived(UAVObject*);
void replotNewData();
void showCurve(QwtPlotItem *item, bool on);
void onTelemetryConnected();
void onTelemetryDisconnected();
private: