mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-706 Added code to handle isKnown for requested and retrieved UAVObjects.
This commit is contained in:
parent
1a28d17eff
commit
1e08528d54
@ -33,20 +33,22 @@
|
||||
#include <stdlib.h>
|
||||
#include <QDebug>
|
||||
|
||||
#define VERBOSE_TELEMETRY = 1;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Telemetry::Telemetry(TelemetryManager *telemetryManager, UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMngr), utalk(utalk)
|
||||
Telemetry::Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMngr), utalk(utalk)
|
||||
{
|
||||
mutex = new QMutex(QMutex::Recursive);
|
||||
|
||||
connect(this, SIGNAL(onKnownObjectsChanged(UAVObject *, bool)), telemetryManager, SLOT(onKnownObjectsChanged(UAVObject *, bool)));
|
||||
|
||||
// Register all objects in the list
|
||||
QList< QList<UAVObject *> > objs = objMngr->getObjects();
|
||||
for (int objidx = 0; objidx < objs.length(); ++objidx) {
|
||||
foreach(QList<UAVObject *> instances, objMngr->getObjects()) {
|
||||
foreach(UAVObject * object, instances) {
|
||||
// make sure we 'forget' all objects before we request it from the flight side
|
||||
object->setIsKnown(false);
|
||||
}
|
||||
// we only need to register one instance per object type
|
||||
registerObject(objs[objidx][0]);
|
||||
registerObject(instances.first());
|
||||
}
|
||||
|
||||
// Listen to new object creations
|
||||
@ -76,6 +78,12 @@ Telemetry::Telemetry(TelemetryManager *telemetryManager, UAVTalk *utalk, UAVObje
|
||||
Telemetry::~Telemetry()
|
||||
{
|
||||
closeAllTransactions();
|
||||
foreach(QList<UAVObject *> instances, objMngr->getObjects()) {
|
||||
foreach(UAVObject * object, instances) {
|
||||
// make sure we 'forget' all objects before we request it from the flight side
|
||||
object->setIsKnown(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,9 +91,6 @@ Telemetry::~Telemetry()
|
||||
*/
|
||||
void Telemetry::registerObject(UAVObject *obj)
|
||||
{
|
||||
// Forget this object
|
||||
emit onKnownObjectsChanged(obj, false);
|
||||
|
||||
// Setup object for periodic updates
|
||||
addObject(obj);
|
||||
|
||||
@ -241,13 +246,13 @@ void Telemetry::transactionCompleted(UAVObject *obj, bool success)
|
||||
if (transInfo) {
|
||||
if (success) {
|
||||
// We now know tat the flight side knows of this object.
|
||||
emit onKnownObjectsChanged(obj, true);
|
||||
obj->setIsKnown(true);
|
||||
|
||||
#ifdef VERBOSE_TELEMETRY
|
||||
qDebug() << "Telemetry - transaction successful for object" << obj->toStringBrief();
|
||||
#endif
|
||||
} else {
|
||||
emit onKnownObjectsChanged(obj, false);
|
||||
obj->setIsKnown(false);
|
||||
qWarning() << "Telemetry - !!! transaction failed for object" << obj->toStringBrief();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "uavtalk.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "telemetrymanager.h"
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QTimer>
|
||||
@ -74,15 +73,12 @@ public:
|
||||
quint32 rxCrcErrors;
|
||||
} TelemetryStats;
|
||||
|
||||
Telemetry(TelemetryManager *telemetryManager, UAVTalk *utalk, UAVObjectManager *objMngr);
|
||||
Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr);
|
||||
~Telemetry();
|
||||
TelemetryStats getStats();
|
||||
void resetStats();
|
||||
void transactionTimeout(ObjectTransactionInfo *info);
|
||||
|
||||
signals:
|
||||
void onKnownObjectsChanged(UAVObject *object, bool known);
|
||||
|
||||
private:
|
||||
// Constants
|
||||
static const int REQ_TIMEOUT_MS = 250;
|
||||
|
@ -52,11 +52,6 @@ bool TelemetryManager::isConnected()
|
||||
return m_isAutopilotConnected;
|
||||
}
|
||||
|
||||
bool TelemetryManager::isObjectKnown(UAVObject *object) const
|
||||
{
|
||||
return m_knownObjects.contains(object);
|
||||
}
|
||||
|
||||
void TelemetryManager::start(QIODevice *dev)
|
||||
{
|
||||
m_telemetryDevice = dev;
|
||||
@ -93,7 +88,7 @@ void TelemetryManager::onStart()
|
||||
connect(m_telemetryDevice, SIGNAL(readyRead()), m_uavTalk, SLOT(processInputStream()));
|
||||
}
|
||||
|
||||
m_telemetry = new Telemetry(this, m_uavTalk, m_uavobjectManager);
|
||||
m_telemetry = new Telemetry(m_uavTalk, m_uavobjectManager);
|
||||
m_telemetryMonitor = new TelemetryMonitor(m_uavobjectManager, m_telemetry);
|
||||
|
||||
connect(m_telemetryMonitor, SIGNAL(connected()), this, SLOT(onConnect()));
|
||||
@ -113,9 +108,6 @@ void TelemetryManager::stop()
|
||||
|
||||
void TelemetryManager::onStop()
|
||||
{
|
||||
foreach(UAVObject * object, m_knownObjects) {
|
||||
onKnownObjectsChanged(object, false);
|
||||
}
|
||||
m_telemetryMonitor->disconnect(this);
|
||||
delete m_telemetryMonitor;
|
||||
delete m_telemetry;
|
||||
@ -123,19 +115,6 @@ void TelemetryManager::onStop()
|
||||
onDisconnect();
|
||||
}
|
||||
|
||||
void TelemetryManager::onKnownObjectsChanged(UAVObject *object, bool known)
|
||||
{
|
||||
bool contains = m_knownObjects.contains(object);
|
||||
|
||||
if (known && !contains) {
|
||||
m_knownObjects.insert(object);
|
||||
emit knownObjectsChanged(object, known);
|
||||
} else if (contains) {
|
||||
m_knownObjects.remove(object);
|
||||
emit knownObjectsChanged(object, known);
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryManager::onConnect()
|
||||
{
|
||||
m_isAutopilotConnected = true;
|
||||
|
@ -47,7 +47,6 @@ public:
|
||||
void start(QIODevice *dev);
|
||||
void stop();
|
||||
bool isConnected();
|
||||
bool isObjectKnown(UAVObject *object) const;
|
||||
|
||||
signals:
|
||||
void connected();
|
||||
@ -55,7 +54,6 @@ signals:
|
||||
void telemetryUpdated(double txRate, double rxRate);
|
||||
void myStart();
|
||||
void myStop();
|
||||
void knownObjectsChanged(UAVObject *object, bool known);
|
||||
|
||||
private slots:
|
||||
void onConnect();
|
||||
@ -73,7 +71,6 @@ private:
|
||||
QIODevice *m_telemetryDevice;
|
||||
bool m_isAutopilotConnected;
|
||||
QThread m_telemetryReaderThread;
|
||||
QSet<UAVObject *> m_knownObjects;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user