mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
OP-1628 Adding more fine grained connection states to TelemetryManager.
This commit is contained in:
parent
e313d1ec67
commit
1cd46f049f
@ -32,7 +32,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/threadmanager.h>
|
#include <coreplugin/threadmanager.h>
|
||||||
|
|
||||||
TelemetryManager::TelemetryManager() : m_isAutopilotConnected(false)
|
TelemetryManager::TelemetryManager() : m_connectionState(TELEMETRY_DISCONNECTED)
|
||||||
{
|
{
|
||||||
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
||||||
// Get UAVObjectManager instance
|
// Get UAVObjectManager instance
|
||||||
@ -47,13 +47,20 @@ TelemetryManager::TelemetryManager() : m_isAutopilotConnected(false)
|
|||||||
TelemetryManager::~TelemetryManager()
|
TelemetryManager::~TelemetryManager()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool TelemetryManager::isConnected()
|
bool TelemetryManager::isConnected() const
|
||||||
{
|
{
|
||||||
return m_isAutopilotConnected;
|
return m_connectionState == TELEMETRY_CONNECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
TelemetryManager::ConnectionState TelemetryManager::connectionState() const {
|
||||||
|
return m_connectionState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryManager::start(QIODevice *dev)
|
void TelemetryManager::start(QIODevice *dev)
|
||||||
{
|
{
|
||||||
|
m_connectionState = TELEMETRY_CONNECTING;
|
||||||
|
emit connecting();
|
||||||
|
|
||||||
m_telemetryDevice = dev;
|
m_telemetryDevice = dev;
|
||||||
// OP-1383
|
// OP-1383
|
||||||
// take ownership of the device by moving it to the TelemetryManager thread (see TelemetryManager constructor)
|
// take ownership of the device by moving it to the TelemetryManager thread (see TelemetryManager constructor)
|
||||||
@ -98,6 +105,8 @@ void TelemetryManager::onStart()
|
|||||||
|
|
||||||
void TelemetryManager::stop()
|
void TelemetryManager::stop()
|
||||||
{
|
{
|
||||||
|
m_connectionState = TELEMETRY_DISCONNECTING;
|
||||||
|
emit disconnecting();
|
||||||
emit myStop();
|
emit myStop();
|
||||||
|
|
||||||
if (false) {
|
if (false) {
|
||||||
@ -117,13 +126,13 @@ void TelemetryManager::onStop()
|
|||||||
|
|
||||||
void TelemetryManager::onConnect()
|
void TelemetryManager::onConnect()
|
||||||
{
|
{
|
||||||
m_isAutopilotConnected = true;
|
m_connectionState = TELEMETRY_CONNECTED;
|
||||||
emit connected();
|
emit connected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TelemetryManager::onDisconnect()
|
void TelemetryManager::onDisconnect()
|
||||||
{
|
{
|
||||||
m_isAutopilotConnected = false;
|
m_connectionState = TELEMETRY_DISCONNECTED;
|
||||||
emit disconnected();
|
emit disconnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,15 +41,25 @@ class UAVTALK_EXPORT TelemetryManager : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum ConnectionState {
|
||||||
|
TELEMETRY_DISCONNECTED,
|
||||||
|
TELEMETRY_CONNECTED,
|
||||||
|
TELEMETRY_DISCONNECTING,
|
||||||
|
TELEMETRY_CONNECTING
|
||||||
|
};
|
||||||
|
|
||||||
TelemetryManager();
|
TelemetryManager();
|
||||||
~TelemetryManager();
|
~TelemetryManager();
|
||||||
|
|
||||||
void start(QIODevice *dev);
|
void start(QIODevice *dev);
|
||||||
void stop();
|
void stop();
|
||||||
bool isConnected();
|
bool isConnected() const;
|
||||||
|
ConnectionState connectionState() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void connecting();
|
||||||
void connected();
|
void connected();
|
||||||
|
void disconnecting();
|
||||||
void disconnected();
|
void disconnected();
|
||||||
void telemetryUpdated(double txRate, double rxRate);
|
void telemetryUpdated(double txRate, double rxRate);
|
||||||
void myStart();
|
void myStart();
|
||||||
@ -68,7 +78,7 @@ private:
|
|||||||
Telemetry *m_telemetry;
|
Telemetry *m_telemetry;
|
||||||
TelemetryMonitor *m_telemetryMonitor;
|
TelemetryMonitor *m_telemetryMonitor;
|
||||||
QIODevice *m_telemetryDevice;
|
QIODevice *m_telemetryDevice;
|
||||||
bool m_isAutopilotConnected;
|
ConnectionState m_connectionState;
|
||||||
QThread m_telemetryReaderThread;
|
QThread m_telemetryReaderThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user