mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP-1119 Code cleanup and more uncrustification
This commit is contained in:
parent
a11d98aa0d
commit
8054cd5296
@ -28,6 +28,8 @@
|
|||||||
#include "flightlogmanager.h"
|
#include "flightlogmanager.h"
|
||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "debuglogcontrol.h"
|
#include "debuglogcontrol.h"
|
||||||
#include "uavobjecthelper.h"
|
#include "uavobjecthelper.h"
|
||||||
|
|
||||||
@ -94,6 +96,8 @@ void FlightLogManager::clearAllLogs()
|
|||||||
|
|
||||||
void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||||
{
|
{
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
|
||||||
UAVObjectUpdaterHelper updateHelper;
|
UAVObjectUpdaterHelper updateHelper;
|
||||||
UAVObjectRequestHelper requestHelper;
|
UAVObjectRequestHelper requestHelper;
|
||||||
|
|
||||||
@ -104,7 +108,6 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
|||||||
emit logEntriesChanged();
|
emit logEntriesChanged();
|
||||||
|
|
||||||
// Set up what to retrieve
|
// Set up what to retrieve
|
||||||
bool timedOut = false;
|
|
||||||
int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve;
|
int startFlight = (flightToRetrieve == -1) ? 0 : flightToRetrieve;
|
||||||
int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve;
|
int endFlight = (flightToRetrieve == -1) ? m_flightLogStatus->getFlight() : flightToRetrieve;
|
||||||
|
|
||||||
@ -118,38 +121,29 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
|||||||
// Send request for loading flight entry on flight side and wait for ack/nack
|
// Send request for loading flight entry on flight side and wait for ack/nack
|
||||||
m_flightLogControl->setEntry(entry);
|
m_flightLogControl->setEntry(entry);
|
||||||
|
|
||||||
UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT);
|
if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS &&
|
||||||
if (result == UAVObjectUpdaterHelper::SUCCESS) {
|
requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) {
|
||||||
result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT);
|
if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) {
|
||||||
if (result == UAVObjectUpdaterHelper::TIMEOUT) {
|
// Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list
|
||||||
timedOut = true;
|
ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry();
|
||||||
break;
|
logEntry->setObjectManager(m_objectManager);
|
||||||
} else {
|
logEntry->setData(m_flightLogEntry->getData());
|
||||||
if (!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY &&
|
m_logEntries << logEntry;
|
||||||
m_flightLogEntry->getFlight() == flight && m_flightLogEntry->getEntry() == entry) {
|
|
||||||
// Ok, we retrieved the entry, and it was the correct one. clone it and add it to the list
|
|
||||||
ExtendedDebugLogEntry *logEntry = new ExtendedDebugLogEntry();
|
|
||||||
logEntry->setObjectManager(m_objectManager);
|
|
||||||
logEntry->setData(m_flightLogEntry->getData());
|
|
||||||
m_logEntries << logEntry;
|
|
||||||
|
|
||||||
// Increment to get next entry from flight side
|
// Increment to get next entry from flight side
|
||||||
entry++;
|
entry++;
|
||||||
} else {
|
} else {
|
||||||
// We are done, not more entries on this flight
|
// We are done, not more entries on this flight
|
||||||
break;
|
gotLast = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// We failed for some reason
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timedOut) {
|
|
||||||
// We timed out, do something smart here to alert the user
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
emit logEntriesChanged();
|
emit logEntriesChanged();
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightLogManager::exportLogs()
|
void FlightLogManager::exportLogs()
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
|
|
||||||
AbstractUAVObjectHelper::AbstractUAVObjectHelper(QObject *parent) :
|
AbstractUAVObjectHelper::AbstractUAVObjectHelper(QObject *parent) :
|
||||||
QObject(parent), m_transactionResult(false), m_transactionCompleted(false)
|
QObject(parent), m_transactionResult(false), m_transactionCompleted(false)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObject *object, int timeout)
|
AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObject *object, int timeout)
|
||||||
{
|
{
|
||||||
@ -41,14 +40,14 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje
|
|||||||
m_object = object;
|
m_object = object;
|
||||||
|
|
||||||
// Reset variables
|
// Reset variables
|
||||||
m_transactionResult = false;
|
m_transactionResult = false;
|
||||||
m_transactionCompleted = false;
|
m_transactionCompleted = false;
|
||||||
|
|
||||||
// Create timer and connect it, connect object tx completed to local slot
|
// Create timer and connect it, connect object tx completed to local slot
|
||||||
QTimer timeoutTimer;
|
QTimer timeoutTimer;
|
||||||
timeoutTimer.setSingleShot(true);
|
timeoutTimer.setSingleShot(true);
|
||||||
connect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
connect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
||||||
connect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool)));
|
connect(object, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool)));
|
||||||
|
|
||||||
// Start timeout timer
|
// Start timeout timer
|
||||||
timeoutTimer.start(timeout);
|
timeoutTimer.start(timeout);
|
||||||
@ -63,7 +62,7 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje
|
|||||||
timeoutTimer.stop();
|
timeoutTimer.stop();
|
||||||
|
|
||||||
// Disconnect
|
// Disconnect
|
||||||
disconnect(object, SIGNAL(transactionCompleted(UAVObject*, bool)), this, SLOT(transactionCompleted(UAVObject*, bool)));
|
disconnect(object, SIGNAL(transactionCompleted(UAVObject *, bool)), this, SLOT(transactionCompleted(UAVObject *, bool)));
|
||||||
disconnect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
disconnect(&timeoutTimer, SIGNAL(timeout()), &m_eventLoop, SLOT(quit()));
|
||||||
|
|
||||||
// Return result
|
// Return result
|
||||||
@ -79,14 +78,13 @@ void AbstractUAVObjectHelper::transactionCompleted(UAVObject *object, bool succe
|
|||||||
Q_UNUSED(object)
|
Q_UNUSED(object)
|
||||||
|
|
||||||
// Set variables and quit event loop
|
// Set variables and quit event loop
|
||||||
m_transactionResult = success;
|
m_transactionResult = success;
|
||||||
m_transactionCompleted = true;
|
m_transactionCompleted = true;
|
||||||
m_eventLoop.quit();
|
m_eventLoop.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
UAVObjectUpdaterHelper::UAVObjectUpdaterHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
UAVObjectUpdaterHelper::UAVObjectUpdaterHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void UAVObjectUpdaterHelper::doObjectAndWaitImpl()
|
void UAVObjectUpdaterHelper::doObjectAndWaitImpl()
|
||||||
{
|
{
|
||||||
@ -94,8 +92,7 @@ void UAVObjectUpdaterHelper::doObjectAndWaitImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
UAVObjectRequestHelper::UAVObjectRequestHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
UAVObjectRequestHelper::UAVObjectRequestHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void UAVObjectRequestHelper::doObjectAndWaitImpl()
|
void UAVObjectRequestHelper::doObjectAndWaitImpl()
|
||||||
{
|
{
|
||||||
|
@ -35,14 +35,13 @@
|
|||||||
|
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
|
|
||||||
class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject
|
class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit AbstractUAVObjectHelper(QObject *parent = 0);
|
explicit AbstractUAVObjectHelper(QObject *parent = 0);
|
||||||
|
|
||||||
enum Result {SUCCESS, FAIL, TIMEOUT};
|
enum Result { SUCCESS, FAIL, TIMEOUT };
|
||||||
Result doObjectAndWait(UAVObject* object, int timeout);
|
Result doObjectAndWait(UAVObject *object, int timeout);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void doObjectAndWaitImpl() = 0;
|
virtual void doObjectAndWaitImpl() = 0;
|
||||||
@ -58,8 +57,7 @@ private:
|
|||||||
bool m_transactionCompleted;
|
bool m_transactionCompleted;
|
||||||
};
|
};
|
||||||
|
|
||||||
class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper
|
class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit UAVObjectUpdaterHelper(QObject *parent = 0);
|
explicit UAVObjectUpdaterHelper(QObject *parent = 0);
|
||||||
@ -68,8 +66,7 @@ protected:
|
|||||||
virtual void doObjectAndWaitImpl();
|
virtual void doObjectAndWaitImpl();
|
||||||
};
|
};
|
||||||
|
|
||||||
class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper
|
class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit UAVObjectRequestHelper(QObject *parent = 0);
|
explicit UAVObjectRequestHelper(QObject *parent = 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user