mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
GCS/UAVTalk Added TelemetryMonitor, generates signals on autopilot connect/disconnect
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@682 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
4893dead52
commit
7bc37e891d
69
ground/src/plugins/uavtalk/telemetrymanager.cpp
Normal file
69
ground/src/plugins/uavtalk/telemetrymanager.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file telemetrymanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 "telemetrymanager.h"
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
TelemetryManager::TelemetryManager()
|
||||
{
|
||||
// Get UAVObjectManager instance
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
objMngr = pm->getObject<UAVObjectManager>();
|
||||
}
|
||||
|
||||
TelemetryManager::~TelemetryManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TelemetryManager::start(QIODevice *dev)
|
||||
{
|
||||
utalk = new UAVTalk(dev, objMngr);
|
||||
telemetry = new Telemetry(utalk, objMngr);
|
||||
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
|
||||
connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect()));
|
||||
connect(telemetryMon, SIGNAL(disconnected()), this, SLOT(onDisconnect()));
|
||||
}
|
||||
|
||||
void TelemetryManager::stop()
|
||||
{
|
||||
telemetryMon->disconnect(this);
|
||||
delete telemetryMon;
|
||||
delete telemetry;
|
||||
delete utalk;
|
||||
}
|
||||
|
||||
void TelemetryManager::onConnect()
|
||||
{
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void TelemetryManager::onDisconnect()
|
||||
{
|
||||
emit disconnected();
|
||||
}
|
66
ground/src/plugins/uavtalk/telemetrymanager.h
Normal file
66
ground/src/plugins/uavtalk/telemetrymanager.h
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file telemetrymanager.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup
|
||||
* @{
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* 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 TELEMETRYMANAGER_H
|
||||
#define TELEMETRYMANAGER_H
|
||||
|
||||
#include "uavtalk_global.h"
|
||||
#include "telemetrymonitor.h"
|
||||
#include "telemetry.h"
|
||||
#include "uavtalk.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include <QIODevice>
|
||||
#include <QObject>
|
||||
|
||||
class UAVTALK_EXPORT TelemetryManager: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TelemetryManager();
|
||||
~TelemetryManager();
|
||||
|
||||
void start(QIODevice *dev);
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
|
||||
private slots:
|
||||
void onConnect();
|
||||
void onDisconnect();
|
||||
|
||||
private:
|
||||
UAVObjectManager* objMngr;
|
||||
UAVTalk* utalk;
|
||||
Telemetry* telemetry;
|
||||
TelemetryMonitor* telemetryMon;
|
||||
};
|
||||
|
||||
#endif // TELEMETRYMANAGER_H
|
@ -116,6 +116,7 @@ void TelemetryMonitor::retrieveNextObject()
|
||||
if ( queue.isEmpty() )
|
||||
{
|
||||
qxtLog->debug("Object retrieval completed");
|
||||
emit connected();
|
||||
return;
|
||||
}
|
||||
// Get next object from the queue
|
||||
@ -247,6 +248,7 @@ void TelemetryMonitor::processStatsUpdates()
|
||||
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
|
||||
qxtLog->info("Connection with the autopilot lost");
|
||||
qxtLog->info("Trying to connect to the autopilot");
|
||||
emit disconnected();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,10 @@ class TelemetryMonitor : public QObject
|
||||
public:
|
||||
TelemetryMonitor(UAVObjectManager* objMngr, Telemetry* tel);
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
void disconnected();
|
||||
|
||||
public slots:
|
||||
void transactionCompleted(UAVObject* obj, bool success);
|
||||
void processStatsUpdates();
|
||||
|
@ -4,10 +4,14 @@ include(../../openpilotgcsplugin.pri)
|
||||
include(uavtalk_dependencies.pri)
|
||||
HEADERS += uavtalk.h \
|
||||
uavtalkplugin.h \
|
||||
telemetrymonitor.h
|
||||
telemetrymonitor.h \
|
||||
telemetrymanager.h \
|
||||
uavtalk_global.h \
|
||||
telemetry.h
|
||||
SOURCES += uavtalk.cpp \
|
||||
uavtalkplugin.cpp \
|
||||
telemetrymonitor.cpp
|
||||
HEADERS += telemetry.h
|
||||
SOURCES += telemetry.cpp
|
||||
telemetrymonitor.cpp \
|
||||
telemetrymanager.cpp \
|
||||
telemetry.cpp
|
||||
DEFINES += UAVTALK_LIBRARY
|
||||
OTHER_FILES += UAVTalk.pluginspec
|
||||
|
40
ground/src/plugins/uavtalk/uavtalk_global.h
Normal file
40
ground/src/plugins/uavtalk/uavtalk_global.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file uavobjects_global.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||
* @brief
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
* @defgroup uavobjects_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 UAVTALK_GLOBAL_H
|
||||
#define UAVTALK_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(UAVTALK_LIBRARY)
|
||||
# define UAVTALK_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define UAVTALK_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // UAVTALK_GLOBAL_H
|
@ -46,6 +46,10 @@ void UAVTalkPlugin::extensionsInitialized()
|
||||
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
||||
objMngr = pm->getObject<UAVObjectManager>();
|
||||
|
||||
// Create TelemetryManager
|
||||
telMngr = new TelemetryManager();
|
||||
addAutoReleasedObject(telMngr);
|
||||
|
||||
// Connect to connection manager so we get notified when the user connect to his device
|
||||
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
|
||||
QObject::connect(cm, SIGNAL(deviceConnected(QIODevice *)),
|
||||
@ -69,16 +73,12 @@ void UAVTalkPlugin::shutdown()
|
||||
|
||||
void UAVTalkPlugin::onDeviceConnect(QIODevice *dev)
|
||||
{
|
||||
utalk = new UAVTalk(dev, objMngr);
|
||||
telemetry = new Telemetry(utalk, objMngr);
|
||||
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
|
||||
telMngr->start(dev);
|
||||
}
|
||||
|
||||
void UAVTalkPlugin::onDeviceDisconnect()
|
||||
{
|
||||
delete telemetryMon;
|
||||
delete telemetry;
|
||||
delete utalk;
|
||||
telMngr->stop();
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(UAVTalkPlugin)
|
||||
|
@ -34,9 +34,10 @@
|
||||
#include "telemetrymonitor.h"
|
||||
#include "telemetry.h"
|
||||
#include "uavtalk.h"
|
||||
#include "telemetrymanager.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
|
||||
class UAVTalkPlugin: public ExtensionSystem::IPlugin
|
||||
class UAVTALK_EXPORT UAVTalkPlugin: public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -54,9 +55,7 @@ protected slots:
|
||||
|
||||
private:
|
||||
UAVObjectManager* objMngr;
|
||||
UAVTalk* utalk;
|
||||
Telemetry* telemetry;
|
||||
TelemetryMonitor* telemetryMon;
|
||||
TelemetryManager* telMngr;
|
||||
};
|
||||
|
||||
#endif // UAVTALKPLUGIN_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user