mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
GCS/Objects Metaobjects are now also stored in CF and retrieved on power-up. At this time settings and meta objects are automatically loaded on startup if they have been saved in the CF card (to test use Save button in the object browser), if a file is not found in the CF card then the defaults specified in the XML file will be used.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@560 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c9ef6dcfeb
commit
fe29624590
@ -113,23 +113,24 @@ ObjectTreeItem *UAVObjectBrowserWidget::findCurrentObjectTreeItem()
|
||||
|
||||
void UAVObjectBrowserWidget::saveSettings()
|
||||
{
|
||||
updateSettings(SettingsPersistence::OPERATION_SAVE);
|
||||
updateSettings(ObjectPersistence::OPERATION_SAVE);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::readSettings()
|
||||
{
|
||||
updateSettings(SettingsPersistence::OPERATION_LOAD);
|
||||
updateSettings(ObjectPersistence::OPERATION_LOAD);
|
||||
}
|
||||
|
||||
void UAVObjectBrowserWidget::updateSettings(SettingsPersistence::OperationOptions op)
|
||||
void UAVObjectBrowserWidget::updateSettings(ObjectPersistence::OperationOptions op)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
SettingsPersistence* obj = dynamic_cast<SettingsPersistence*>( objManager->getObject(SettingsPersistence::NAME) );
|
||||
ObjectPersistence* obj = dynamic_cast<ObjectPersistence*>( objManager->getObject(ObjectPersistence::NAME) );
|
||||
if (obj != NULL)
|
||||
{
|
||||
SettingsPersistence::DataFields data;
|
||||
ObjectPersistence::DataFields data;
|
||||
data.Operation = op;
|
||||
data.Objects = ObjectPersistence::OBJECTS_ALL;
|
||||
obj->setData(data);
|
||||
obj->updated();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTreeView>
|
||||
#include "uavobjects/settingspersistence.h"
|
||||
#include "uavobjects/objectpersistence.h"
|
||||
#include "uavobjecttreemodel.h"
|
||||
|
||||
class QPushButton;
|
||||
@ -65,7 +65,7 @@ private:
|
||||
Ui_UAVObjectBrowser *m_browser;
|
||||
UAVObjectTreeModel *m_model;
|
||||
|
||||
void updateSettings(SettingsPersistence::OperationOptions op);
|
||||
void updateSettings(ObjectPersistence::OperationOptions op);
|
||||
void enableSendRequest(bool enable);
|
||||
ObjectTreeItem *findCurrentObjectTreeItem();
|
||||
};
|
||||
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file settingspersistence.cpp
|
||||
* @file objectpersistence.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SettingsPersistence object. This file has been
|
||||
* @brief Implementation of the ObjectPersistence object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: settingspersistence.xml.
|
||||
* @note Object definition file: objectpersistence.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
@ -28,15 +28,15 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "settingspersistence.h"
|
||||
#include "objectpersistence.h"
|
||||
#include "uavobjectfields.h"
|
||||
|
||||
const QString SettingsPersistence::NAME = QString("SettingsPersistence");
|
||||
const QString ObjectPersistence::NAME = QString("ObjectPersistence");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
ObjectPersistence::ObjectPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
@ -46,6 +46,13 @@ SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, I
|
||||
OperationEnumOptions.append("Load");
|
||||
OperationEnumOptions.append("Save");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Operation"), QString(""), OperationElemNames, OperationEnumOptions));
|
||||
QStringList ObjectsElemNames;
|
||||
ObjectsElemNames.append("0");
|
||||
QStringList ObjectsEnumOptions;
|
||||
ObjectsEnumOptions.append("All");
|
||||
ObjectsEnumOptions.append("Settings");
|
||||
ObjectsEnumOptions.append("MetaObjects");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Objects"), QString(""), ObjectsElemNames, ObjectsEnumOptions));
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
@ -56,7 +63,7 @@ SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, I
|
||||
/**
|
||||
* Get the default metadata for this object
|
||||
*/
|
||||
UAVObject::Metadata SettingsPersistence::getDefaultMetadata()
|
||||
UAVObject::Metadata ObjectPersistence::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
@ -75,7 +82,7 @@ UAVObject::Metadata SettingsPersistence::getDefaultMetadata()
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
void SettingsPersistence::setDefaultFieldValues()
|
||||
void ObjectPersistence::setDefaultFieldValues()
|
||||
{
|
||||
|
||||
}
|
||||
@ -83,7 +90,7 @@ void SettingsPersistence::setDefaultFieldValues()
|
||||
/**
|
||||
* Get the object data fields
|
||||
*/
|
||||
SettingsPersistence::DataFields SettingsPersistence::getData()
|
||||
ObjectPersistence::DataFields ObjectPersistence::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
@ -92,7 +99,7 @@ SettingsPersistence::DataFields SettingsPersistence::getData()
|
||||
/**
|
||||
* Set the object data fields
|
||||
*/
|
||||
void SettingsPersistence::setData(const DataFields& data)
|
||||
void ObjectPersistence::setData(const DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
this->data = data;
|
||||
@ -105,9 +112,9 @@ void SettingsPersistence::setData(const DataFields& data)
|
||||
* Do not use this function directly to create new instances, the
|
||||
* UAVObjectManager should be used instead.
|
||||
*/
|
||||
UAVDataObject* SettingsPersistence::clone(quint32 instID)
|
||||
UAVDataObject* ObjectPersistence::clone(quint32 instID)
|
||||
{
|
||||
SettingsPersistence* obj = new SettingsPersistence();
|
||||
ObjectPersistence* obj = new ObjectPersistence();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file settingspersistence.h
|
||||
* @file objectpersistence.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the SettingsPersistence object. This file has been
|
||||
* @brief Implementation of the ObjectPersistence object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: settingspersistence.xml.
|
||||
* @note Object definition file: objectpersistence.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
@ -28,12 +28,12 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef SETTINGSPERSISTENCE_H
|
||||
#define SETTINGSPERSISTENCE_H
|
||||
#ifndef OBJECTPERSISTENCE_H
|
||||
#define OBJECTPERSISTENCE_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT SettingsPersistence: public UAVDataObject
|
||||
class UAVOBJECTS_EXPORT ObjectPersistence: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -41,6 +41,7 @@ public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Operation;
|
||||
quint8 Objects;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
@ -48,17 +49,20 @@ public:
|
||||
// Field Operation information
|
||||
/* Enumeration options for field Operation */
|
||||
typedef enum { OPERATION_LOAD=0, OPERATION_SAVE=1, } OperationOptions;
|
||||
// Field Objects information
|
||||
/* Enumeration options for field Objects */
|
||||
typedef enum { OBJECTS_ALL=0, OBJECTS_SETTINGS=1, OBJECTS_METAOBJECTS=2, } ObjectsOptions;
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 3652432370U;
|
||||
static const quint32 OBJID = 2407027612U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
SettingsPersistence();
|
||||
ObjectPersistence();
|
||||
|
||||
DataFields getData();
|
||||
void setData(const DataFields& data);
|
||||
@ -72,4 +76,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif // SETTINGSPERSISTENCE_H
|
||||
#endif // OBJECTPERSISTENCE_H
|
@ -23,12 +23,12 @@ HEADERS += uavobjects_global.h \
|
||||
uavobjectfielduint16.h \
|
||||
uavobjectfielduint32.h \
|
||||
uavobjectfields.h \
|
||||
settingspersistence.h \
|
||||
gpsobject.h \
|
||||
gcstelemetrystats.h \
|
||||
flighttelemetrystats.h \
|
||||
systemstats.h \
|
||||
systemalarms.h
|
||||
systemalarms.h \
|
||||
objectpersistence.h
|
||||
SOURCES += uavobject.cpp \
|
||||
uavmetaobject.cpp \
|
||||
uavobjectmanager.cpp \
|
||||
@ -48,11 +48,11 @@ SOURCES += uavobject.cpp \
|
||||
uavobjectfielduint8.cpp \
|
||||
uavobjectfielduint16.cpp \
|
||||
uavobjectfielduint32.cpp \
|
||||
settingspersistence.cpp \
|
||||
gpsobject.cpp \
|
||||
gcstelemetrystats.cpp \
|
||||
flighttelemetrystats.cpp \
|
||||
systemstats.cpp \
|
||||
systemalarms.cpp
|
||||
systemalarms.cpp \
|
||||
objectpersistence.cpp
|
||||
DEFINES += UAVOBJECTS_LIBRARY
|
||||
OTHER_FILES += UAVObjects.pluginspec
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "gpsobject.h"
|
||||
#include "settingspersistence.h"
|
||||
#include "objectpersistence.h"
|
||||
#include "systemalarms.h"
|
||||
#include "systemstats.h"
|
||||
|
||||
@ -53,7 +53,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new FlightTelemetryStats() );
|
||||
objMngr->registerObject( new GCSTelemetryStats() );
|
||||
objMngr->registerObject( new GpsObject() );
|
||||
objMngr->registerObject( new SettingsPersistence() );
|
||||
objMngr->registerObject( new ObjectPersistence() );
|
||||
objMngr->registerObject( new SystemAlarms() );
|
||||
objMngr->registerObject( new SystemStats() );
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<xml>
|
||||
<object name="SettingsPersistence" singleinstance="true" settings="false">
|
||||
<object name="ObjectPersistence" singleinstance="true" settings="false">
|
||||
<field name="Operation" units="" type="enum" elements="1" options="Load,Save"/>
|
||||
<field name="Objects" units="" type="enum" elements="1" options="All,Settings,MetaObjects"/>
|
||||
<telemetrygcs acked="true" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="manual" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
Loading…
x
Reference in New Issue
Block a user