mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +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/threadmanager.h>
|
||||
|
||||
TelemetryManager::TelemetryManager() : m_isAutopilotConnected(false)
|
||||
TelemetryManager::TelemetryManager() : m_connectionState(TELEMETRY_DISCONNECTED)
|
||||
{
|
||||
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
||||
// Get UAVObjectManager instance
|
||||
@ -47,13 +47,20 @@ TelemetryManager::TelemetryManager() : m_isAutopilotConnected(false)
|
||||
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)
|
||||
{
|
||||
m_connectionState = TELEMETRY_CONNECTING;
|
||||
emit connecting();
|
||||
|
||||
m_telemetryDevice = dev;
|
||||
// OP-1383
|
||||
// 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()
|
||||
{
|
||||
m_connectionState = TELEMETRY_DISCONNECTING;
|
||||
emit disconnecting();
|
||||
emit myStop();
|
||||
|
||||
if (false) {
|
||||
@ -117,13 +126,13 @@ void TelemetryManager::onStop()
|
||||
|
||||
void TelemetryManager::onConnect()
|
||||
{
|
||||
m_isAutopilotConnected = true;
|
||||
m_connectionState = TELEMETRY_CONNECTED;
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void TelemetryManager::onDisconnect()
|
||||
{
|
||||
m_isAutopilotConnected = false;
|
||||
m_connectionState = TELEMETRY_DISCONNECTED;
|
||||
emit disconnected();
|
||||
}
|
||||
|
||||
|
@ -41,15 +41,25 @@ class UAVTALK_EXPORT TelemetryManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ConnectionState {
|
||||
TELEMETRY_DISCONNECTED,
|
||||
TELEMETRY_CONNECTED,
|
||||
TELEMETRY_DISCONNECTING,
|
||||
TELEMETRY_CONNECTING
|
||||
};
|
||||
|
||||
TelemetryManager();
|
||||
~TelemetryManager();
|
||||
|
||||
void start(QIODevice *dev);
|
||||
void stop();
|
||||
bool isConnected();
|
||||
bool isConnected() const;
|
||||
ConnectionState connectionState() const;
|
||||
|
||||
signals:
|
||||
void connecting();
|
||||
void connected();
|
||||
void disconnecting();
|
||||
void disconnected();
|
||||
void telemetryUpdated(double txRate, double rxRate);
|
||||
void myStart();
|
||||
@ -68,7 +78,7 @@ private:
|
||||
Telemetry *m_telemetry;
|
||||
TelemetryMonitor *m_telemetryMonitor;
|
||||
QIODevice *m_telemetryDevice;
|
||||
bool m_isAutopilotConnected;
|
||||
ConnectionState m_connectionState;
|
||||
QThread m_telemetryReaderThread;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user