1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1245 Changed the code that saves the logging metadata for all objects and DebugLogSettings object.

This commit is contained in:
m_thread 2014-03-20 22:58:09 +01:00
parent 786d3c97a1
commit 77f9294548
2 changed files with 22 additions and 16 deletions

View File

@ -56,6 +56,9 @@ FlightLogManager::FlightLogManager(QObject *parent) :
m_telemtryManager = pluginManager->getObject<TelemetryManager>();
Q_ASSERT(m_telemtryManager);
m_objectUtilManager = pluginManager->getObject<UAVObjectUtilManager>();
Q_ASSERT(m_objectUtilManager);
m_flightLogControl = DebugLogControl::GetInstance(m_objectManager);
Q_ASSERT(m_flightLogControl);
@ -493,8 +496,8 @@ void FlightLogManager::resetSettings(bool clear)
void FlightLogManager::saveSettingsToBoard()
{
m_flightLogSettings->setLoggingEnabled(m_loggingEnabled);
m_flightLogSettings->updated();
saveUAVObjectToFlash(m_flightLogSettings);
foreach(UAVOLogSettingsWrapper * wrapper, m_uavoEntries) {
@ -502,6 +505,9 @@ void FlightLogManager::saveSettingsToBoard()
UAVObject::Metadata meta = wrapper->object()->getMetadata();
wrapper->object()->SetLoggingUpdateMode(meta, wrapper->settingAsUpdateMode());
meta.loggingUpdatePeriod = wrapper->period();
// As metadata are set up to update via telemetry on change
// this call will send the update to the board.
wrapper->object()->setMetadata(meta);
if (saveUAVObjectToFlash(wrapper->object()->getMetaObject())) {
@ -513,18 +519,8 @@ void FlightLogManager::saveSettingsToBoard()
bool FlightLogManager::saveUAVObjectToFlash(UAVObject *object)
{
UAVObjectUpdaterHelper helper;
if (helper.doObjectAndWait(object, 3000) == UAVObjectUpdaterHelper::SUCCESS) {
ObjectPersistence::DataFields data;
data.Operation = ObjectPersistence::OPERATION_SAVE;
data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT;
data.ObjectID = object->getObjID();
data.InstanceID = object->getInstID();
m_objectPersistence->setData(data);
return (helper.doObjectAndWait(m_objectPersistence, 3000) == UAVObjectUpdaterHelper::SUCCESS);
}
return false;
m_objectUtilManager->saveObjectToSD(object);
return true;
}
void FlightLogManager::updateFlightEntries(quint16 currentFlight)
@ -680,9 +676,17 @@ UAVOLogSettingsWrapper::~UAVOLogSettingsWrapper()
void UAVOLogSettingsWrapper::reset(bool clear)
{
setSetting(clear ? 0 : m_object->GetLoggingUpdateMode(m_object->getMetadata()));
setPeriod(clear ? 0 : m_object->getMetadata().loggingUpdatePeriod);
setDirty(false);
setSetting(m_object->GetLoggingUpdateMode(m_object->getMetadata()));
setPeriod(m_object->getMetadata().loggingUpdatePeriod);
if (clear) {
int oldSetting = setting();
int oldPeriod = period();
setSetting(0);
setPeriod(0);
setDirty(oldSetting != setting() || oldPeriod != period());
} else {
setDirty(false);
}
}
UAVObject::UpdateMode UAVOLogSettingsWrapper::settingAsUpdateMode()

View File

@ -37,6 +37,7 @@
#include <QTextStream>
#include "uavobjectmanager.h"
#include "uavobjectutilmanager.h"
#include "debuglogentry.h"
#include "debuglogstatus.h"
#include "debuglogsettings.h"
@ -316,6 +317,7 @@ private slots:
private:
UAVObjectManager *m_objectManager;
UAVObjectUtilManager *m_objectUtilManager;
TelemetryManager *m_telemtryManager;
DebugLogControl *m_flightLogControl;
DebugLogStatus *m_flightLogStatus;