Commit f1aee303 authored by Gus Grubba's avatar Gus Grubba

Just being really OCD.

parent c3f0a51f
...@@ -334,7 +334,7 @@ HEADERS += \ ...@@ -334,7 +334,7 @@ HEADERS += \
src/uas/UAS.h \ src/uas/UAS.h \
src/uas/UASInterface.h \ src/uas/UASInterface.h \
src/uas/UASMessageHandler.h \ src/uas/UASMessageHandler.h \
src/Vehicle/MavlinkLogManager.h \ src/Vehicle/MAVLinkLogManager.h \
src/ui/toolbar/MainToolBarController.h \ src/ui/toolbar/MainToolBarController.h \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.h \ src/AutoPilotPlugins/PX4/PX4AirframeLoader.h \
src/AutoPilotPlugins/APM/APMAirframeLoader.h \ src/AutoPilotPlugins/APM/APMAirframeLoader.h \
...@@ -499,7 +499,7 @@ SOURCES += \ ...@@ -499,7 +499,7 @@ SOURCES += \
src/QmlControls/QmlObjectListModel.cc \ src/QmlControls/QmlObjectListModel.cc \
src/uas/UAS.cc \ src/uas/UAS.cc \
src/uas/UASMessageHandler.cc \ src/uas/UASMessageHandler.cc \
src/Vehicle/MavlinkLogManager.cc \ src/Vehicle/MAVLinkLogManager.cc \
src/ui/toolbar/MainToolBarController.cc \ src/ui/toolbar/MainToolBarController.cc \
src/AutoPilotPlugins/PX4/PX4AirframeLoader.cc \ src/AutoPilotPlugins/PX4/PX4AirframeLoader.cc \
src/AutoPilotPlugins/APM/APMAirframeLoader.cc \ src/AutoPilotPlugins/APM/APMAirframeLoader.cc \
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "FollowMe.h" #include "FollowMe.h"
#include "PositionManager.h" #include "PositionManager.h"
#include "VideoManager.h" #include "VideoManager.h"
#include "MavlinkLogManager.h" #include "MAVLinkLogManager.h"
QGCToolbox::QGCToolbox(QGCApplication* app) QGCToolbox::QGCToolbox(QGCApplication* app)
: _audioOutput(NULL) : _audioOutput(NULL)
...@@ -73,7 +73,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app) ...@@ -73,7 +73,7 @@ QGCToolbox::QGCToolbox(QGCApplication* app)
_qgcPositionManager = new QGCPositionManager(app); _qgcPositionManager = new QGCPositionManager(app);
_followMe = new FollowMe(app); _followMe = new FollowMe(app);
_videoManager = new VideoManager(app); _videoManager = new VideoManager(app);
_mavlinkLogManager = new MavlinkLogManager(app); _mavlinkLogManager = new MAVLinkLogManager(app);
} }
void QGCToolbox::setChildToolboxes(void) void QGCToolbox::setChildToolboxes(void)
......
...@@ -32,7 +32,7 @@ class QGCImageProvider; ...@@ -32,7 +32,7 @@ class QGCImageProvider;
class UASMessageHandler; class UASMessageHandler;
class QGCPositionManager; class QGCPositionManager;
class VideoManager; class VideoManager;
class MavlinkLogManager; class MAVLinkLogManager;
/// This is used to manage all of our top level services/tools /// This is used to manage all of our top level services/tools
class QGCToolbox { class QGCToolbox {
...@@ -57,7 +57,7 @@ public: ...@@ -57,7 +57,7 @@ public:
FollowMe* followMe(void) { return _followMe; } FollowMe* followMe(void) { return _followMe; }
QGCPositionManager* qgcPositionManager(void) { return _qgcPositionManager; } QGCPositionManager* qgcPositionManager(void) { return _qgcPositionManager; }
VideoManager* videoManager(void) { return _videoManager; } VideoManager* videoManager(void) { return _videoManager; }
MavlinkLogManager* mavlinkLogManager(void) { return _mavlinkLogManager; } MAVLinkLogManager* mavlinkLogManager(void) { return _mavlinkLogManager; }
#ifndef __mobile__ #ifndef __mobile__
GPSManager* gpsManager(void) { return _gpsManager; } GPSManager* gpsManager(void) { return _gpsManager; }
...@@ -86,7 +86,7 @@ private: ...@@ -86,7 +86,7 @@ private:
FollowMe* _followMe; FollowMe* _followMe;
QGCPositionManager* _qgcPositionManager; QGCPositionManager* _qgcPositionManager;
VideoManager* _videoManager; VideoManager* _videoManager;
MavlinkLogManager* _mavlinkLogManager; MAVLinkLogManager* _mavlinkLogManager;
friend class QGCApplication; friend class QGCApplication;
}; };
......
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
Q_PROPERTY(QGCPositionManager* qgcPositionManger READ qgcPositionManger CONSTANT) Q_PROPERTY(QGCPositionManager* qgcPositionManger READ qgcPositionManger CONSTANT)
Q_PROPERTY(MissionCommandTree* missionCommandTree READ missionCommandTree CONSTANT) Q_PROPERTY(MissionCommandTree* missionCommandTree READ missionCommandTree CONSTANT)
Q_PROPERTY(VideoManager* videoManager READ videoManager CONSTANT) Q_PROPERTY(VideoManager* videoManager READ videoManager CONSTANT)
Q_PROPERTY(MavlinkLogManager* mavlinkLogManager READ mavlinkLogManager CONSTANT) Q_PROPERTY(MAVLinkLogManager* mavlinkLogManager READ mavlinkLogManager CONSTANT)
Q_PROPERTY(qreal zOrderTopMost READ zOrderTopMost CONSTANT) ///< z order for top most items, toolbar, main window sub view Q_PROPERTY(qreal zOrderTopMost READ zOrderTopMost CONSTANT) ///< z order for top most items, toolbar, main window sub view
Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss
...@@ -167,7 +167,7 @@ public: ...@@ -167,7 +167,7 @@ public:
QGCPositionManager* qgcPositionManger () { return _qgcPositionManager; } QGCPositionManager* qgcPositionManger () { return _qgcPositionManager; }
MissionCommandTree* missionCommandTree () { return _missionCommandTree; } MissionCommandTree* missionCommandTree () { return _missionCommandTree; }
VideoManager* videoManager () { return _videoManager; } VideoManager* videoManager () { return _videoManager; }
MavlinkLogManager* mavlinkLogManager () { return _mavlinkLogManager; } MAVLinkLogManager* mavlinkLogManager () { return _mavlinkLogManager; }
qreal zOrderTopMost () { return 1000; } qreal zOrderTopMost () { return 1000; }
qreal zOrderWidgets () { return 100; } qreal zOrderWidgets () { return 100; }
...@@ -239,7 +239,7 @@ private: ...@@ -239,7 +239,7 @@ private:
QGCPositionManager* _qgcPositionManager; QGCPositionManager* _qgcPositionManager;
MissionCommandTree* _missionCommandTree; MissionCommandTree* _missionCommandTree;
VideoManager* _videoManager; VideoManager* _videoManager;
MavlinkLogManager* _mavlinkLogManager; MAVLinkLogManager* _mavlinkLogManager;
bool _virtualTabletJoystick; bool _virtualTabletJoystick;
qreal _baseFontPointSize; qreal _baseFontPointSize;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
****************************************************************************/ ****************************************************************************/
#include "MavlinkLogManager.h" #include "MAVLinkLogManager.h"
#include "QGCApplication.h" #include "QGCApplication.h"
#include <QQmlContext> #include <QQmlContext>
#include <QQmlProperty> #include <QQmlProperty>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define kTimeOutMilliseconds 1000 #define kTimeOutMilliseconds 1000
QGC_LOGGING_CATEGORY(MavlinkLogManagerLog, "MavlinkLogManagerLog") QGC_LOGGING_CATEGORY(MAVLinkLogManagerLog, "MAVLinkLogManagerLog")
static const char* kEmailAddressKey = "MAVLinkLogEmail"; static const char* kEmailAddressKey = "MAVLinkLogEmail";
static const char* kDescriptionsKey = "MAVLinkLogDescription"; static const char* kDescriptionsKey = "MAVLinkLogDescription";
...@@ -35,7 +35,7 @@ static const char* kUlogExtension = ".ulg"; ...@@ -35,7 +35,7 @@ static const char* kUlogExtension = ".ulg";
static const char* kSidecarExtension = ".uploaded"; static const char* kSidecarExtension = ".uploaded";
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MavlinkLogFiles::MavlinkLogFiles(MavlinkLogManager* manager, const QString& filePath, bool newFile) MAVLinkLogFiles::MAVLinkLogFiles(MAVLinkLogManager* manager, const QString& filePath, bool newFile)
: _manager(manager) : _manager(manager)
, _size(0) , _size(0)
, _selected(false) , _selected(false)
...@@ -57,7 +57,7 @@ MavlinkLogFiles::MavlinkLogFiles(MavlinkLogManager* manager, const QString& file ...@@ -57,7 +57,7 @@ MavlinkLogFiles::MavlinkLogFiles(MavlinkLogManager* manager, const QString& file
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setSize(quint32 size) MAVLinkLogFiles::setSize(quint32 size)
{ {
_size = size; _size = size;
emit sizeChanged(); emit sizeChanged();
...@@ -65,7 +65,7 @@ MavlinkLogFiles::setSize(quint32 size) ...@@ -65,7 +65,7 @@ MavlinkLogFiles::setSize(quint32 size)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setSelected(bool selected) MAVLinkLogFiles::setSelected(bool selected)
{ {
_selected = selected; _selected = selected;
emit selectedChanged(); emit selectedChanged();
...@@ -74,7 +74,7 @@ MavlinkLogFiles::setSelected(bool selected) ...@@ -74,7 +74,7 @@ MavlinkLogFiles::setSelected(bool selected)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setUploading(bool uploading) MAVLinkLogFiles::setUploading(bool uploading)
{ {
_uploading = uploading; _uploading = uploading;
emit uploadingChanged(); emit uploadingChanged();
...@@ -82,7 +82,7 @@ MavlinkLogFiles::setUploading(bool uploading) ...@@ -82,7 +82,7 @@ MavlinkLogFiles::setUploading(bool uploading)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setProgress(qreal progress) MAVLinkLogFiles::setProgress(qreal progress)
{ {
_progress = progress; _progress = progress;
emit progressChanged(); emit progressChanged();
...@@ -90,7 +90,7 @@ MavlinkLogFiles::setProgress(qreal progress) ...@@ -90,7 +90,7 @@ MavlinkLogFiles::setProgress(qreal progress)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setWriting(bool writing) MAVLinkLogFiles::setWriting(bool writing)
{ {
_writing = writing; _writing = writing;
emit writingChanged(); emit writingChanged();
...@@ -98,7 +98,7 @@ MavlinkLogFiles::setWriting(bool writing) ...@@ -98,7 +98,7 @@ MavlinkLogFiles::setWriting(bool writing)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogFiles::setUploaded(bool uploaded) MAVLinkLogFiles::setUploaded(bool uploaded)
{ {
_uploaded = uploaded; _uploaded = uploaded;
emit uploadedChanged(); emit uploadedChanged();
...@@ -106,7 +106,7 @@ MavlinkLogFiles::setUploaded(bool uploaded) ...@@ -106,7 +106,7 @@ MavlinkLogFiles::setUploaded(bool uploaded)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MavlinkLogProcessor::MavlinkLogProcessor() MAVLinkLogProcessor::MAVLinkLogProcessor()
: _fd(NULL) : _fd(NULL)
, _written(0) , _written(0)
, _sequence(-1) , _sequence(-1)
...@@ -118,14 +118,14 @@ MavlinkLogProcessor::MavlinkLogProcessor() ...@@ -118,14 +118,14 @@ MavlinkLogProcessor::MavlinkLogProcessor()
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MavlinkLogProcessor::~MavlinkLogProcessor() MAVLinkLogProcessor::~MAVLinkLogProcessor()
{ {
close(); close();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogProcessor::close() MAVLinkLogProcessor::close()
{ {
if(_fd) { if(_fd) {
fclose(_fd); fclose(_fd);
...@@ -135,14 +135,14 @@ MavlinkLogProcessor::close() ...@@ -135,14 +135,14 @@ MavlinkLogProcessor::close()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogProcessor::valid() MAVLinkLogProcessor::valid()
{ {
return (_fd != NULL) && (_record != NULL); return (_fd != NULL) && (_record != NULL);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogProcessor::create(MavlinkLogManager* manager, const QString path, uint8_t id) MAVLinkLogProcessor::create(MAVLinkLogManager* manager, const QString path, uint8_t id)
{ {
_fileName.sprintf("%s/%03d-%s%s", _fileName.sprintf("%s/%03d-%s%s",
path.toLatin1().data(), path.toLatin1().data(),
...@@ -151,7 +151,7 @@ MavlinkLogProcessor::create(MavlinkLogManager* manager, const QString path, uint ...@@ -151,7 +151,7 @@ MavlinkLogProcessor::create(MavlinkLogManager* manager, const QString path, uint
kUlogExtension); kUlogExtension);
_fd = fopen(_fileName.toLatin1().data(), "wb"); _fd = fopen(_fileName.toLatin1().data(), "wb");
if(_fd) { if(_fd) {
_record = new MavlinkLogFiles(manager, _fileName, true); _record = new MAVLinkLogFiles(manager, _fileName, true);
_record->setWriting(true); _record->setWriting(true);
_sequence = -1; _sequence = -1;
return true; return true;
...@@ -161,7 +161,7 @@ MavlinkLogProcessor::create(MavlinkLogManager* manager, const QString path, uint ...@@ -161,7 +161,7 @@ MavlinkLogProcessor::create(MavlinkLogManager* manager, const QString path, uint
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogProcessor::_checkSequence(uint16_t seq, int& num_drops) MAVLinkLogProcessor::_checkSequence(uint16_t seq, int& num_drops)
{ {
num_drops = 0; num_drops = 0;
//-- Check if a sequence is newer than the one previously received and if //-- Check if a sequence is newer than the one previously received and if
...@@ -195,7 +195,7 @@ MavlinkLogProcessor::_checkSequence(uint16_t seq, int& num_drops) ...@@ -195,7 +195,7 @@ MavlinkLogProcessor::_checkSequence(uint16_t seq, int& num_drops)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogProcessor::_writeData(void* data, int len) MAVLinkLogProcessor::_writeData(void* data, int len)
{ {
if(!_error) { if(!_error) {
_error = fwrite(data, 1, len, _fd) != (size_t)len; _error = fwrite(data, 1, len, _fd) != (size_t)len;
...@@ -205,14 +205,14 @@ MavlinkLogProcessor::_writeData(void* data, int len) ...@@ -205,14 +205,14 @@ MavlinkLogProcessor::_writeData(void* data, int len)
_record->setSize(_written); _record->setSize(_written);
} }
} else { } else {
qCDebug(MavlinkLogManagerLog) << "File IO error:" << len << "bytes into" << _fileName; qCDebug(MAVLinkLogManagerLog) << "File IO error:" << len << "bytes into" << _fileName;
} }
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QByteArray QByteArray
MavlinkLogProcessor::_writeUlogMessage(QByteArray& data) MAVLinkLogProcessor::_writeUlogMessage(QByteArray& data)
{ {
//-- Write ulog data w/o integrity checking, assuming data starts with a //-- Write ulog data w/o integrity checking, assuming data starts with a
// valid ulog message. returns the remaining data at the end. // valid ulog message. returns the remaining data at the end.
...@@ -230,7 +230,7 @@ MavlinkLogProcessor::_writeUlogMessage(QByteArray& data) ...@@ -230,7 +230,7 @@ MavlinkLogProcessor::_writeUlogMessage(QByteArray& data)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message, QByteArray data) MAVLinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message, QByteArray data)
{ {
int num_drops = 0; int num_drops = 0;
_error = false; _error = false;
...@@ -239,7 +239,7 @@ MavlinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message, ...@@ -239,7 +239,7 @@ MavlinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message,
if(!_gotHeader) { if(!_gotHeader) {
if(data.size() < 16) { if(data.size() < 16) {
//-- Shouldn't happen but if it does, we might as well close shop. //-- Shouldn't happen but if it does, we might as well close shop.
qCCritical(MavlinkLogManagerLog) << "Corrupt log header. Canceling log download."; qCCritical(MAVLinkLogManagerLog) << "Corrupt log header. Canceling log download.";
return false; return false;
} }
//-- Write header //-- Write header
...@@ -291,7 +291,7 @@ MavlinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message, ...@@ -291,7 +291,7 @@ MavlinkLogProcessor::processStreamData(uint16_t sequence, uint8_t first_message,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MavlinkLogManager::MavlinkLogManager(QGCApplication* app) MAVLinkLogManager::MAVLinkLogManager(QGCApplication* app)
: QGCTool(app) : QGCTool(app)
, _enableAutoUpload(true) , _enableAutoUpload(true)
, _enableAutoStart(true) , _enableAutoStart(true)
...@@ -314,10 +314,10 @@ MavlinkLogManager::MavlinkLogManager(QGCApplication* app) ...@@ -314,10 +314,10 @@ MavlinkLogManager::MavlinkLogManager(QGCApplication* app)
setDeleteAfterUpload(settings.value(kEnableDeletetKey, false).toBool()); setDeleteAfterUpload(settings.value(kEnableDeletetKey, false).toBool());
//-- Logging location //-- Logging location
_logPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); _logPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
_logPath += "/MavlinkLogs"; _logPath += "/MAVLinkLogs";
if(!QDir(_logPath).exists()) { if(!QDir(_logPath).exists()) {
if(!QDir().mkpath(_logPath)) { if(!QDir().mkpath(_logPath)) {
qCCritical(MavlinkLogManagerLog) << "Could not create Mavlink log download path:" << _logPath; qCCritical(MAVLinkLogManagerLog) << "Could not create MAVLink log download path:" << _logPath;
_loggingDisabled = true; _loggingDisabled = true;
} }
} }
...@@ -327,34 +327,34 @@ MavlinkLogManager::MavlinkLogManager(QGCApplication* app) ...@@ -327,34 +327,34 @@ MavlinkLogManager::MavlinkLogManager(QGCApplication* app)
filter += kUlogExtension; filter += kUlogExtension;
QDirIterator it(_logPath, QStringList() << filter, QDir::Files); QDirIterator it(_logPath, QStringList() << filter, QDir::Files);
while(it.hasNext()) { while(it.hasNext()) {
_insertNewLog(new MavlinkLogFiles(this, it.next())); _insertNewLog(new MAVLinkLogFiles(this, it.next()));
} }
qCDebug(MavlinkLogManagerLog) << "MAVLink logs directory:" << _logPath; qCDebug(MAVLinkLogManagerLog) << "MAVLink logs directory:" << _logPath;
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
MavlinkLogManager::~MavlinkLogManager() MAVLinkLogManager::~MAVLinkLogManager()
{ {
_logFiles.clear(); _logFiles.clear();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setToolbox(QGCToolbox* toolbox) MAVLinkLogManager::setToolbox(QGCToolbox* toolbox)
{ {
QGCTool::setToolbox(toolbox); QGCTool::setToolbox(toolbox);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<MavlinkLogManager>("QGroundControl.MavlinkLogManager", 1, 0, "MavlinkLogManager", "Reference only"); qmlRegisterUncreatableType<MAVLinkLogManager>("QGroundControl.MAVLinkLogManager", 1, 0, "MAVLinkLogManager", "Reference only");
if(!_loggingDisabled) { if(!_loggingDisabled) {
connect(toolbox->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &MavlinkLogManager::_activeVehicleChanged); connect(toolbox->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &MAVLinkLogManager::_activeVehicleChanged);
connect(&_ackTimer, &QTimer::timeout, this, &MavlinkLogManager::_processCmdAck); connect(&_ackTimer, &QTimer::timeout, this, &MAVLinkLogManager::_processCmdAck);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setEmailAddress(QString email) MAVLinkLogManager::setEmailAddress(QString email)
{ {
_emailAddress = email; _emailAddress = email;
QSettings settings; QSettings settings;
...@@ -364,7 +364,7 @@ MavlinkLogManager::setEmailAddress(QString email) ...@@ -364,7 +364,7 @@ MavlinkLogManager::setEmailAddress(QString email)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setDescription(QString description) MAVLinkLogManager::setDescription(QString description)
{ {
_description = description; _description = description;
QSettings settings; QSettings settings;
...@@ -374,7 +374,7 @@ MavlinkLogManager::setDescription(QString description) ...@@ -374,7 +374,7 @@ MavlinkLogManager::setDescription(QString description)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setUploadURL(QString url) MAVLinkLogManager::setUploadURL(QString url)
{ {
_uploadURL = url; _uploadURL = url;
if(_uploadURL.isEmpty()) { if(_uploadURL.isEmpty()) {
...@@ -387,7 +387,7 @@ MavlinkLogManager::setUploadURL(QString url) ...@@ -387,7 +387,7 @@ MavlinkLogManager::setUploadURL(QString url)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setEnableAutoUpload(bool enable) MAVLinkLogManager::setEnableAutoUpload(bool enable)
{ {
_enableAutoUpload = enable; _enableAutoUpload = enable;
QSettings settings; QSettings settings;
...@@ -397,7 +397,7 @@ MavlinkLogManager::setEnableAutoUpload(bool enable) ...@@ -397,7 +397,7 @@ MavlinkLogManager::setEnableAutoUpload(bool enable)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setEnableAutoStart(bool enable) MAVLinkLogManager::setEnableAutoStart(bool enable)
{ {
_enableAutoStart = enable; _enableAutoStart = enable;
QSettings settings; QSettings settings;
...@@ -407,7 +407,7 @@ MavlinkLogManager::setEnableAutoStart(bool enable) ...@@ -407,7 +407,7 @@ MavlinkLogManager::setEnableAutoStart(bool enable)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::setDeleteAfterUpload(bool enable) MAVLinkLogManager::setDeleteAfterUpload(bool enable)
{ {
_deleteAfterUpload = enable; _deleteAfterUpload = enable;
QSettings settings; QSettings settings;
...@@ -417,20 +417,20 @@ MavlinkLogManager::setDeleteAfterUpload(bool enable) ...@@ -417,20 +417,20 @@ MavlinkLogManager::setDeleteAfterUpload(bool enable)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogManager::uploading() MAVLinkLogManager::uploading()
{ {
return _currentLogfile != NULL; return _currentLogfile != NULL;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::uploadLog() MAVLinkLogManager::uploadLog()
{ {
if(_currentLogfile) { if(_currentLogfile) {
_currentLogfile->setUploading(false); _currentLogfile->setUploading(false);
} }
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
_currentLogfile = qobject_cast<MavlinkLogFiles*>(_logFiles.get(i)); _currentLogfile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(_currentLogfile); Q_ASSERT(_currentLogfile);
if(_currentLogfile->selected()) { if(_currentLogfile->selected()) {
_currentLogfile->setSelected(false); _currentLogfile->setSelected(false);
...@@ -450,7 +450,7 @@ MavlinkLogManager::uploadLog() ...@@ -450,7 +450,7 @@ MavlinkLogManager::uploadLog()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_insertNewLog(MavlinkLogFiles* newLog) MAVLinkLogManager::_insertNewLog(MAVLinkLogFiles* newLog)
{ {
//-- Simpler than trying to sort this thing //-- Simpler than trying to sort this thing
int count = _logFiles.count(); int count = _logFiles.count();
...@@ -458,7 +458,7 @@ MavlinkLogManager::_insertNewLog(MavlinkLogFiles* newLog) ...@@ -458,7 +458,7 @@ MavlinkLogManager::_insertNewLog(MavlinkLogFiles* newLog)
_logFiles.append(newLog); _logFiles.append(newLog);
} else { } else {
for(int i = 0; i < count; i++) { for(int i = 0; i < count; i++) {
MavlinkLogFiles* f = qobject_cast<MavlinkLogFiles*>(_logFiles.get(i)); MAVLinkLogFiles* f = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
if(newLog->name() < f->name()) { if(newLog->name() < f->name()) {
_logFiles.insert(i, newLog); _logFiles.insert(i, newLog);
return; return;
...@@ -470,10 +470,10 @@ MavlinkLogManager::_insertNewLog(MavlinkLogFiles* newLog) ...@@ -470,10 +470,10 @@ MavlinkLogManager::_insertNewLog(MavlinkLogFiles* newLog)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int int
MavlinkLogManager::_getFirstSelected() MAVLinkLogManager::_getFirstSelected()
{ {
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
MavlinkLogFiles* f = qobject_cast<MavlinkLogFiles*>(_logFiles.get(i)); MAVLinkLogFiles* f = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(f); Q_ASSERT(f);
if(f->selected()) { if(f->selected()) {
return i; return i;
...@@ -484,26 +484,26 @@ MavlinkLogManager::_getFirstSelected() ...@@ -484,26 +484,26 @@ MavlinkLogManager::_getFirstSelected()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::deleteLog() MAVLinkLogManager::deleteLog()
{ {
while (true) { while (true) {
int idx = _getFirstSelected(); int idx = _getFirstSelected();
if(idx < 0) { if(idx < 0) {
break; break;
} }
MavlinkLogFiles* log = qobject_cast<MavlinkLogFiles*>(_logFiles.get(idx)); MAVLinkLogFiles* log = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(idx));
_deleteLog(log); _deleteLog(log);
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_deleteLog(MavlinkLogFiles* log) MAVLinkLogManager::_deleteLog(MAVLinkLogFiles* log)
{ {
QString filePath = _makeFilename(log->name()); QString filePath = _makeFilename(log->name());
QFile gone(filePath); QFile gone(filePath);
if(!gone.remove()) { if(!gone.remove()) {
qCWarning(MavlinkLogManagerLog) << "Could not delete Mavlink log file:" << _logPath; qCWarning(MAVLinkLogManagerLog) << "Could not delete MAVLink log file:" << _logPath;
} }
//-- Remove sidecar file (if any) //-- Remove sidecar file (if any)
filePath.replace(kUlogExtension, kSidecarExtension); filePath.replace(kUlogExtension, kSidecarExtension);
...@@ -519,10 +519,10 @@ MavlinkLogManager::_deleteLog(MavlinkLogFiles* log) ...@@ -519,10 +519,10 @@ MavlinkLogManager::_deleteLog(MavlinkLogFiles* log)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::cancelUpload() MAVLinkLogManager::cancelUpload()
{ {
for(int i = 0; i < _logFiles.count(); i++) { for(int i = 0; i < _logFiles.count(); i++) {
MavlinkLogFiles* pLogFile = qobject_cast<MavlinkLogFiles*>(_logFiles.get(i)); MAVLinkLogFiles* pLogFile = qobject_cast<MAVLinkLogFiles*>(_logFiles.get(i));
Q_ASSERT(pLogFile); Q_ASSERT(pLogFile);
if(pLogFile->selected() && pLogFile != _currentLogfile) { if(pLogFile->selected() && pLogFile != _currentLogfile) {
pLogFile->setSelected(false); pLogFile->setSelected(false);
...@@ -535,7 +535,7 @@ MavlinkLogManager::cancelUpload() ...@@ -535,7 +535,7 @@ MavlinkLogManager::cancelUpload()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::startLogging() MAVLinkLogManager::startLogging()
{ {
if(_vehicle) { if(_vehicle) {
if(_createNewLog()) { if(_createNewLog()) {
...@@ -550,7 +550,7 @@ MavlinkLogManager::startLogging() ...@@ -550,7 +550,7 @@ MavlinkLogManager::startLogging()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::stopLogging() MAVLinkLogManager::stopLogging()
{ {
if(_vehicle) { if(_vehicle) {
//-- Tell vehicle to stop sending logs //-- Tell vehicle to stop sending logs
...@@ -592,24 +592,24 @@ create_form_part(const QString& name, const QString& value) ...@@ -592,24 +592,24 @@ create_form_part(const QString& name, const QString& value)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogManager::_sendLog(const QString& logFile) MAVLinkLogManager::_sendLog(const QString& logFile)
{ {
QString defaultDescription = _description; QString defaultDescription = _description;
if(_description.isEmpty()) { if(_description.isEmpty()) {
qCWarning(MavlinkLogManagerLog) << "Log description missing. Using defaults."; qCWarning(MAVLinkLogManagerLog) << "Log description missing. Using defaults.";
defaultDescription = kDefaultDescr; defaultDescription = kDefaultDescr;
} }
if(_emailAddress.isEmpty()) { if(_emailAddress.isEmpty()) {
qCCritical(MavlinkLogManagerLog) << "User email missing."; qCCritical(MAVLinkLogManagerLog) << "User email missing.";
return false; return false;
} }
if(_uploadURL.isEmpty()) { if(_uploadURL.isEmpty()) {
qCCritical(MavlinkLogManagerLog) << "Upload URL missing."; qCCritical(MAVLinkLogManagerLog) << "Upload URL missing.";
return false; return false;
} }
QFileInfo fi(logFile); QFileInfo fi(logFile);
if(!fi.exists()) { if(!fi.exists()) {
qCCritical(MavlinkLogManagerLog) << "Log file missing:" << logFile; qCCritical(MAVLinkLogManagerLog) << "Log file missing:" << logFile;
return false; return false;
} }
QFile* file = new QFile(logFile); QFile* file = new QFile(logFile);
...@@ -617,7 +617,7 @@ MavlinkLogManager::_sendLog(const QString& logFile) ...@@ -617,7 +617,7 @@ MavlinkLogManager::_sendLog(const QString& logFile)
if(file) { if(file) {
delete file; delete file;
} }
qCCritical(MavlinkLogManagerLog) << "Could not open log file:" << logFile; qCCritical(MAVLinkLogManagerLog) << "Could not open log file:" << logFile;
return false; return false;
} }
if(!_nam) { if(!_nam) {
...@@ -649,40 +649,40 @@ MavlinkLogManager::_sendLog(const QString& logFile) ...@@ -649,40 +649,40 @@ MavlinkLogManager::_sendLog(const QString& logFile)
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
#endif #endif
QNetworkReply* reply = _nam->post(request, multiPart); QNetworkReply* reply = _nam->post(request, multiPart);
connect(reply, &QNetworkReply::finished, this, &MavlinkLogManager::_uploadFinished); connect(reply, &QNetworkReply::finished, this, &MAVLinkLogManager::_uploadFinished);
connect(this, &MavlinkLogManager::abortUpload, reply, &QNetworkReply::abort); connect(this, &MAVLinkLogManager::abortUpload, reply, &QNetworkReply::abort);
//connect(reply, &QNetworkReply::readyRead, this, &MavlinkLogManager::_dataAvailable); //connect(reply, &QNetworkReply::readyRead, this, &MAVLinkLogManager::_dataAvailable);
connect(reply, &QNetworkReply::uploadProgress, this, &MavlinkLogManager::_uploadProgress); connect(reply, &QNetworkReply::uploadProgress, this, &MAVLinkLogManager::_uploadProgress);
multiPart->setParent(reply); multiPart->setParent(reply);
qCDebug(MavlinkLogManagerLog) << "Log" << fi.baseName() << "Uploading." << fi.size() << "bytes."; qCDebug(MAVLinkLogManagerLog) << "Log" << fi.baseName() << "Uploading." << fi.size() << "bytes.";
_nam->setProxy(savedProxy); _nam->setProxy(savedProxy);
return true; return true;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogManager::_processUploadResponse(int http_code, QByteArray& data) MAVLinkLogManager::_processUploadResponse(int http_code, QByteArray& data)
{ {
qCDebug(MavlinkLogManagerLog) << "Uploaded response:" << QString::fromUtf8(data); qCDebug(MAVLinkLogManagerLog) << "Uploaded response:" << QString::fromUtf8(data);
emit readyRead(data); emit readyRead(data);
return http_code == 200; return http_code == 200;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_dataAvailable() MAVLinkLogManager::_dataAvailable()
{ {
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if(!reply) { if(!reply) {
return; return;
} }
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
qCDebug(MavlinkLogManagerLog) << "Uploaded response data:" << QString::fromUtf8(data); qCDebug(MAVLinkLogManagerLog) << "Uploaded response data:" << QString::fromUtf8(data);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_uploadFinished() MAVLinkLogManager::_uploadFinished()
{ {
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
if(!reply) { if(!reply) {
...@@ -691,7 +691,7 @@ MavlinkLogManager::_uploadFinished() ...@@ -691,7 +691,7 @@ MavlinkLogManager::_uploadFinished()
const int http_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); const int http_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
if(_processUploadResponse(http_code, data)) { if(_processUploadResponse(http_code, data)) {
qCDebug(MavlinkLogManagerLog) << "Log uploaded."; qCDebug(MAVLinkLogManagerLog) << "Log uploaded.";
emit succeed(); emit succeed();
if(_deleteAfterUpload) { if(_deleteAfterUpload) {
if(_currentLogfile) { if(_currentLogfile) {
...@@ -711,7 +711,7 @@ MavlinkLogManager::_uploadFinished() ...@@ -711,7 +711,7 @@ MavlinkLogManager::_uploadFinished()
} }
} }
} else { } else {
qCWarning(MavlinkLogManagerLog) << QString("Log Upload Error: %1 status: %2").arg(reply->errorString(), reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString()); qCWarning(MAVLinkLogManagerLog) << QString("Log Upload Error: %1 status: %2").arg(reply->errorString(), reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString());
emit failed(); emit failed();
} }
reply->deleteLater(); reply->deleteLater();
...@@ -721,7 +721,7 @@ MavlinkLogManager::_uploadFinished() ...@@ -721,7 +721,7 @@ MavlinkLogManager::_uploadFinished()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_uploadProgress(qint64 bytesSent, qint64 bytesTotal) MAVLinkLogManager::_uploadProgress(qint64 bytesSent, qint64 bytesTotal)
{ {
if(bytesTotal) { if(bytesTotal) {
qreal progress = (qreal)bytesSent / (qreal)bytesTotal; qreal progress = (qreal)bytesSent / (qreal)bytesTotal;
...@@ -729,12 +729,12 @@ MavlinkLogManager::_uploadProgress(qint64 bytesSent, qint64 bytesTotal) ...@@ -729,12 +729,12 @@ MavlinkLogManager::_uploadProgress(qint64 bytesSent, qint64 bytesTotal)
_currentLogfile->setProgress(progress); _currentLogfile->setProgress(progress);
} }
} }
qCDebug(MavlinkLogManagerLog) << bytesSent << "of" << bytesTotal; qCDebug(MAVLinkLogManagerLog) << bytesSent << "of" << bytesTotal;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle) MAVLinkLogManager::_activeVehicleChanged(Vehicle* vehicle)
{ {
//-- TODO: This is not quite right. This is being used to detect when a vehicle //-- TODO: This is not quite right. This is being used to detect when a vehicle
// connects/disconnects. In reality, if QGC is connected to multiple vehicles, // connects/disconnects. In reality, if QGC is connected to multiple vehicles,
...@@ -743,9 +743,9 @@ MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle) ...@@ -743,9 +743,9 @@ MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle)
// For now, we only handle one log download at a time. // For now, we only handle one log download at a time.
// Disconnect the previous one (if any) // Disconnect the previous one (if any)
if(_vehicle) { if(_vehicle) {
disconnect(_vehicle, &Vehicle::armedChanged, this, &MavlinkLogManager::_armedChanged); disconnect(_vehicle, &Vehicle::armedChanged, this, &MAVLinkLogManager::_armedChanged);
disconnect(_vehicle, &Vehicle::mavlinkLogData, this, &MavlinkLogManager::_mavlinkLogData); disconnect(_vehicle, &Vehicle::mavlinkLogData, this, &MAVLinkLogManager::_mavlinkLogData);
disconnect(_vehicle, &Vehicle::commandLongAck, this, &MavlinkLogManager::_commandLongAck); disconnect(_vehicle, &Vehicle::commandLongAck, this, &MAVLinkLogManager::_commandLongAck);
_vehicle = NULL; _vehicle = NULL;
//-- Stop logging (if that's the case) //-- Stop logging (if that's the case)
stopLogging(); stopLogging();
...@@ -754,34 +754,34 @@ MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle) ...@@ -754,34 +754,34 @@ MavlinkLogManager::_activeVehicleChanged(Vehicle* vehicle)
// Connect new system // Connect new system
if(vehicle) { if(vehicle) {
_vehicle = vehicle; _vehicle = vehicle;
connect(_vehicle, &Vehicle::armedChanged, this, &MavlinkLogManager::_armedChanged); connect(_vehicle, &Vehicle::armedChanged, this, &MAVLinkLogManager::_armedChanged);
connect(_vehicle, &Vehicle::mavlinkLogData, this, &MavlinkLogManager::_mavlinkLogData); connect(_vehicle, &Vehicle::mavlinkLogData, this, &MAVLinkLogManager::_mavlinkLogData);
connect(_vehicle, &Vehicle::commandLongAck, this, &MavlinkLogManager::_commandLongAck); connect(_vehicle, &Vehicle::commandLongAck, this, &MAVLinkLogManager::_commandLongAck);
emit canStartLogChanged(); emit canStartLogChanged();
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_processCmdAck() MAVLinkLogManager::_processCmdAck()
{ {
if(_loggingCmdTryCount++ > 3) { if(_loggingCmdTryCount++ > 3) {
_ackTimer.stop(); _ackTimer.stop();
//-- Give up //-- Give up
if(_logRunning) { if(_logRunning) {
qCWarning(MavlinkLogManagerLog) << "Start MAVLink log command had no response."; qCWarning(MAVLinkLogManagerLog) << "Start MAVLink log command had no response.";
_discardLog(); _discardLog();
} else { } else {
qCWarning(MavlinkLogManagerLog) << "Stop MAVLink log command had no response."; qCWarning(MAVLinkLogManagerLog) << "Stop MAVLink log command had no response.";
} }
} else { } else {
if(_vehicle) { if(_vehicle) {
if(_logRunning) { if(_logRunning) {
_vehicle->startMavlinkLog(); _vehicle->startMavlinkLog();
qCWarning(MavlinkLogManagerLog) << "Start MAVLink log command sent again."; qCWarning(MAVLinkLogManagerLog) << "Start MAVLink log command sent again.";
} else { } else {
_vehicle->stopMavlinkLog(); _vehicle->stopMavlinkLog();
qCWarning(MavlinkLogManagerLog) << "Stop MAVLink log command sent again."; qCWarning(MAVLinkLogManagerLog) << "Stop MAVLink log command sent again.";
} }
_ackTimer.start(kTimeOutMilliseconds); _ackTimer.start(kTimeOutMilliseconds);
} else { } else {
...@@ -793,7 +793,7 @@ MavlinkLogManager::_processCmdAck() ...@@ -793,7 +793,7 @@ MavlinkLogManager::_processCmdAck()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system*/, uint8_t /*target_component*/, uint16_t sequence, uint8_t first_message, QByteArray data, bool /*acked*/) MAVLinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system*/, uint8_t /*target_component*/, uint16_t sequence, uint8_t first_message, QByteArray data, bool /*acked*/)
{ {
//-- Disable timer if we got a message before an ACK for the start command //-- Disable timer if we got a message before an ACK for the start command
if(_logRunning) { if(_logRunning) {
...@@ -801,7 +801,7 @@ MavlinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system ...@@ -801,7 +801,7 @@ MavlinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system
} }
if(_logProcessor && _logProcessor->valid()) { if(_logProcessor && _logProcessor->valid()) {
if(!_logProcessor->processStreamData(sequence, first_message, data)) { if(!_logProcessor->processStreamData(sequence, first_message, data)) {
qCCritical(MavlinkLogManagerLog) << "Error writing Mavlink log file:" << _logProcessor->fileName(); qCCritical(MAVLinkLogManagerLog) << "Error writing MAVLink log file:" << _logProcessor->fileName();
delete _logProcessor; delete _logProcessor;
_logProcessor = NULL; _logProcessor = NULL;
_logRunning = false; _logRunning = false;
...@@ -809,13 +809,13 @@ MavlinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system ...@@ -809,13 +809,13 @@ MavlinkLogManager::_mavlinkLogData(Vehicle* /*vehicle*/, uint8_t /*target_system
emit logRunningChanged(); emit logRunningChanged();
} }
} else { } else {
qCWarning(MavlinkLogManagerLog) << "MAVLink log data received when not expected."; qCWarning(MAVLinkLogManagerLog) << "MAVLink log data received when not expected.";
} }
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t result) MAVLinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t result)
{ {
if(command == MAV_CMD_LOGGING_START || command == MAV_CMD_LOGGING_STOP) { if(command == MAV_CMD_LOGGING_START || command == MAV_CMD_LOGGING_STOP) {
_ackTimer.stop(); _ackTimer.stop();
...@@ -823,10 +823,10 @@ MavlinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t ...@@ -823,10 +823,10 @@ MavlinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t
if(result) { if(result) {
if(command == MAV_CMD_LOGGING_STOP) { if(command == MAV_CMD_LOGGING_STOP) {
//-- Not that it could happen but... //-- Not that it could happen but...
qCWarning(MavlinkLogManagerLog) << "Stop MAVLink log command failed."; qCWarning(MAVLinkLogManagerLog) << "Stop MAVLink log command failed.";
} else { } else {
//-- Could not start logging for some reason. //-- Could not start logging for some reason.
qCWarning(MavlinkLogManagerLog) << "Start MAVLink log command failed."; qCWarning(MAVLinkLogManagerLog) << "Start MAVLink log command failed.";
_discardLog(); _discardLog();
} }
} }
...@@ -835,7 +835,7 @@ MavlinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t ...@@ -835,7 +835,7 @@ MavlinkLogManager::_commandLongAck(uint8_t /*compID*/, uint16_t command, uint8_t
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_discardLog() MAVLinkLogManager::_discardLog()
{ {
//-- Delete (empty) log file (and record) //-- Delete (empty) log file (and record)
if(_logProcessor) { if(_logProcessor) {
...@@ -852,18 +852,18 @@ MavlinkLogManager::_discardLog() ...@@ -852,18 +852,18 @@ MavlinkLogManager::_discardLog()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool bool
MavlinkLogManager::_createNewLog() MAVLinkLogManager::_createNewLog()
{ {
if(_logProcessor) { if(_logProcessor) {
delete _logProcessor; delete _logProcessor;
_logProcessor = NULL; _logProcessor = NULL;
} }
_logProcessor = new MavlinkLogProcessor; _logProcessor = new MAVLinkLogProcessor;
if(_logProcessor->create(this, _logPath, _vehicle->id())) { if(_logProcessor->create(this, _logPath, _vehicle->id())) {
_insertNewLog(_logProcessor->record()); _insertNewLog(_logProcessor->record());
emit logFilesChanged(); emit logFilesChanged();
} else { } else {
qCCritical(MavlinkLogManagerLog) << "Could not create Mavlink log file:" << _logProcessor->fileName(); qCCritical(MAVLinkLogManagerLog) << "Could not create MAVLink log file:" << _logProcessor->fileName();
delete _logProcessor; delete _logProcessor;
_logProcessor = NULL; _logProcessor = NULL;
} }
...@@ -872,7 +872,7 @@ MavlinkLogManager::_createNewLog() ...@@ -872,7 +872,7 @@ MavlinkLogManager::_createNewLog()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
MavlinkLogManager::_armedChanged(bool armed) MAVLinkLogManager::_armedChanged(bool armed)
{ {
if(_vehicle) { if(_vehicle) {
if(armed) { if(armed) {
...@@ -889,7 +889,7 @@ MavlinkLogManager::_armedChanged(bool armed) ...@@ -889,7 +889,7 @@ MavlinkLogManager::_armedChanged(bool armed)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QString QString
MavlinkLogManager::_makeFilename(const QString& baseName) MAVLinkLogManager::_makeFilename(const QString& baseName)
{ {
QString filePath = _logPath; QString filePath = _logPath;
filePath += "/"; filePath += "/";
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
****************************************************************************/ ****************************************************************************/
#ifndef MavlinkLogManager_H #ifndef MAVLinkLogManager_H
#define MavlinkLogManager_H #define MAVLinkLogManager_H
#include <QObject> #include <QObject>
...@@ -18,17 +18,17 @@ ...@@ -18,17 +18,17 @@
#include "QGCToolbox.h" #include "QGCToolbox.h"
#include "Vehicle.h" #include "Vehicle.h"
Q_DECLARE_LOGGING_CATEGORY(MavlinkLogManagerLog) Q_DECLARE_LOGGING_CATEGORY(MAVLinkLogManagerLog)
class QNetworkAccessManager; class QNetworkAccessManager;
class MavlinkLogManager; class MAVLinkLogManager;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class MavlinkLogFiles : public QObject class MAVLinkLogFiles : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
MavlinkLogFiles (MavlinkLogManager* manager, const QString& filePath, bool newFile = false); MAVLinkLogFiles (MAVLinkLogManager* manager, const QString& filePath, bool newFile = false);
Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(quint32 size READ size NOTIFY sizeChanged) Q_PROPERTY(quint32 size READ size NOTIFY sizeChanged)
...@@ -62,7 +62,7 @@ signals: ...@@ -62,7 +62,7 @@ signals:
void uploadedChanged (); void uploadedChanged ();
private: private:
MavlinkLogManager* _manager; MAVLinkLogManager* _manager;
QString _name; QString _name;
quint32 _size; quint32 _size;
bool _selected; bool _selected;
...@@ -73,15 +73,15 @@ private: ...@@ -73,15 +73,15 @@ private:
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class MavlinkLogProcessor class MAVLinkLogProcessor
{ {
public: public:
MavlinkLogProcessor(); MAVLinkLogProcessor();
~MavlinkLogProcessor(); ~MAVLinkLogProcessor();
void close (); void close ();
bool valid (); bool valid ();
bool create (MavlinkLogManager *manager, const QString path, uint8_t id); bool create (MAVLinkLogManager *manager, const QString path, uint8_t id);
MavlinkLogFiles* record () { return _record; } MAVLinkLogFiles* record () { return _record; }
QString fileName () { return _fileName; } QString fileName () { return _fileName; }
bool processStreamData(uint16_t _sequence, uint8_t first_message, QByteArray data); bool processStreamData(uint16_t _sequence, uint8_t first_message, QByteArray data);
private: private:
...@@ -97,17 +97,17 @@ private: ...@@ -97,17 +97,17 @@ private:
bool _error; bool _error;
QByteArray _ulogMessage; QByteArray _ulogMessage;
QString _fileName; QString _fileName;
MavlinkLogFiles* _record; MAVLinkLogFiles* _record;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class MavlinkLogManager : public QGCTool class MAVLinkLogManager : public QGCTool
{ {
Q_OBJECT Q_OBJECT
public: public:
MavlinkLogManager (QGCApplication* app); MAVLinkLogManager (QGCApplication* app);
~MavlinkLogManager (); ~MAVLinkLogManager ();
Q_PROPERTY(QString emailAddress READ emailAddress WRITE setEmailAddress NOTIFY emailAddressChanged) Q_PROPERTY(QString emailAddress READ emailAddress WRITE setEmailAddress NOTIFY emailAddressChanged)
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
...@@ -180,8 +180,8 @@ private: ...@@ -180,8 +180,8 @@ private:
bool _processUploadResponse (int http_code, QByteArray &data); bool _processUploadResponse (int http_code, QByteArray &data);
bool _createNewLog (); bool _createNewLog ();
int _getFirstSelected (); int _getFirstSelected ();
void _insertNewLog (MavlinkLogFiles* newLog); void _insertNewLog (MAVLinkLogFiles* newLog);
void _deleteLog (MavlinkLogFiles* log); void _deleteLog (MAVLinkLogFiles* log);
void _discardLog (); void _discardLog ();
QString _makeFilename (const QString& baseName); QString _makeFilename (const QString& baseName);
...@@ -194,11 +194,11 @@ private: ...@@ -194,11 +194,11 @@ private:
bool _enableAutoStart; bool _enableAutoStart;
QNetworkAccessManager* _nam; QNetworkAccessManager* _nam;
QmlObjectListModel _logFiles; QmlObjectListModel _logFiles;
MavlinkLogFiles* _currentLogfile; MAVLinkLogFiles* _currentLogfile;
Vehicle* _vehicle; Vehicle* _vehicle;
bool _logRunning; bool _logRunning;
bool _loggingDisabled; bool _loggingDisabled;
MavlinkLogProcessor* _logProcessor; MAVLinkLogProcessor* _logProcessor;
bool _deleteAfterUpload; bool _deleteAfterUpload;
int _loggingCmdTryCount; int _loggingCmdTryCount;
QTimer _ackTimer; QTimer _ackTimer;
......
...@@ -144,7 +144,7 @@ Rectangle { ...@@ -144,7 +144,7 @@ Rectangle {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { QGCLabel {
id: mavlogLabel id: mavlogLabel
text: qsTr("Vehicle Mavlink Logging") text: qsTr("Vehicle MAVLink Logging")
font.family: ScreenTools.demiboldFontFamily font.family: ScreenTools.demiboldFontFamily
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment