mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +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 "extensionsystem/pluginmanager.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "debuglogcontrol.h"
|
||||
#include "uavobjecthelper.h"
|
||||
|
||||
@ -94,6 +96,8 @@ void FlightLogManager::clearAllLogs()
|
||||
|
||||
void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
UAVObjectUpdaterHelper updateHelper;
|
||||
UAVObjectRequestHelper requestHelper;
|
||||
|
||||
@ -104,7 +108,6 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||
emit logEntriesChanged();
|
||||
|
||||
// Set up what to retrieve
|
||||
bool timedOut = false;
|
||||
int startFlight = (flightToRetrieve == -1) ? 0 : 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
|
||||
m_flightLogControl->setEntry(entry);
|
||||
|
||||
UAVObjectUpdaterHelper::Result result = updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT);
|
||||
if (result == UAVObjectUpdaterHelper::SUCCESS) {
|
||||
result = requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT);
|
||||
if (result == UAVObjectUpdaterHelper::TIMEOUT) {
|
||||
timedOut = true;
|
||||
break;
|
||||
} else {
|
||||
if (!m_flightLogEntry->getType() == DebugLogEntry::TYPE_EMPTY &&
|
||||
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;
|
||||
if (updateHelper.doObjectAndWait(m_flightLogControl, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS &&
|
||||
requestHelper.doObjectAndWait(m_flightLogEntry, UAVTALK_TIMEOUT) == UAVObjectUpdaterHelper::SUCCESS) {
|
||||
if (m_flightLogEntry->getType() != DebugLogEntry::TYPE_EMPTY) {
|
||||
// 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
|
||||
entry++;
|
||||
} else {
|
||||
// We are done, not more entries on this flight
|
||||
break;
|
||||
}
|
||||
// Increment to get next entry from flight side
|
||||
entry++;
|
||||
} else {
|
||||
// We are done, not more entries on this flight
|
||||
gotLast = true;
|
||||
}
|
||||
} else {
|
||||
// We failed for some reason
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (timedOut) {
|
||||
// We timed out, do something smart here to alert the user
|
||||
break;
|
||||
}
|
||||
}
|
||||
emit logEntriesChanged();
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void FlightLogManager::exportLogs()
|
||||
|
@ -30,8 +30,7 @@
|
||||
|
||||
AbstractUAVObjectHelper::AbstractUAVObjectHelper(QObject *parent) :
|
||||
QObject(parent), m_transactionResult(false), m_transactionCompleted(false)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObject *object, int timeout)
|
||||
{
|
||||
@ -41,14 +40,14 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje
|
||||
m_object = object;
|
||||
|
||||
// Reset variables
|
||||
m_transactionResult = false;
|
||||
m_transactionResult = false;
|
||||
m_transactionCompleted = false;
|
||||
|
||||
// Create timer and connect it, connect object tx completed to local slot
|
||||
QTimer timeoutTimer;
|
||||
timeoutTimer.setSingleShot(true);
|
||||
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
|
||||
timeoutTimer.start(timeout);
|
||||
@ -63,7 +62,7 @@ AbstractUAVObjectHelper::Result AbstractUAVObjectHelper::doObjectAndWait(UAVObje
|
||||
timeoutTimer.stop();
|
||||
|
||||
// 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()));
|
||||
|
||||
// Return result
|
||||
@ -79,14 +78,13 @@ void AbstractUAVObjectHelper::transactionCompleted(UAVObject *object, bool succe
|
||||
Q_UNUSED(object)
|
||||
|
||||
// Set variables and quit event loop
|
||||
m_transactionResult = success;
|
||||
m_transactionResult = success;
|
||||
m_transactionCompleted = true;
|
||||
m_eventLoop.quit();
|
||||
}
|
||||
|
||||
UAVObjectUpdaterHelper::UAVObjectUpdaterHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void UAVObjectUpdaterHelper::doObjectAndWaitImpl()
|
||||
{
|
||||
@ -94,8 +92,7 @@ void UAVObjectUpdaterHelper::doObjectAndWaitImpl()
|
||||
}
|
||||
|
||||
UAVObjectRequestHelper::UAVObjectRequestHelper(QObject *parent) : AbstractUAVObjectHelper(parent)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void UAVObjectRequestHelper::doObjectAndWaitImpl()
|
||||
{
|
||||
|
@ -35,14 +35,13 @@
|
||||
|
||||
#include "uavobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject
|
||||
{
|
||||
class UAVOBJECTS_EXPORT AbstractUAVObjectHelper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractUAVObjectHelper(QObject *parent = 0);
|
||||
|
||||
enum Result {SUCCESS, FAIL, TIMEOUT};
|
||||
Result doObjectAndWait(UAVObject* object, int timeout);
|
||||
enum Result { SUCCESS, FAIL, TIMEOUT };
|
||||
Result doObjectAndWait(UAVObject *object, int timeout);
|
||||
|
||||
protected:
|
||||
virtual void doObjectAndWaitImpl() = 0;
|
||||
@ -58,8 +57,7 @@ private:
|
||||
bool m_transactionCompleted;
|
||||
};
|
||||
|
||||
class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper
|
||||
{
|
||||
class UAVOBJECTS_EXPORT UAVObjectUpdaterHelper : public AbstractUAVObjectHelper {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVObjectUpdaterHelper(QObject *parent = 0);
|
||||
@ -68,8 +66,7 @@ protected:
|
||||
virtual void doObjectAndWaitImpl();
|
||||
};
|
||||
|
||||
class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper
|
||||
{
|
||||
class UAVOBJECTS_EXPORT UAVObjectRequestHelper : public AbstractUAVObjectHelper {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UAVObjectRequestHelper(QObject *parent = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user