1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-22 12: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:
vassilis 2010-04-30 02:27:37 +00:00 committed by vassilis
parent c9ef6dcfeb
commit fe29624590
7 changed files with 48 additions and 35 deletions

View File

@ -113,23 +113,24 @@ ObjectTreeItem *UAVObjectBrowserWidget::findCurrentObjectTreeItem()
void UAVObjectBrowserWidget::saveSettings() void UAVObjectBrowserWidget::saveSettings()
{ {
updateSettings(SettingsPersistence::OPERATION_SAVE); updateSettings(ObjectPersistence::OPERATION_SAVE);
} }
void UAVObjectBrowserWidget::readSettings() 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(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); 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) if (obj != NULL)
{ {
SettingsPersistence::DataFields data; ObjectPersistence::DataFields data;
data.Operation = op; data.Operation = op;
data.Objects = ObjectPersistence::OBJECTS_ALL;
obj->setData(data); obj->setData(data);
obj->updated(); obj->updated();
} }

View File

@ -30,7 +30,7 @@
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include "uavobjects/settingspersistence.h" #include "uavobjects/objectpersistence.h"
#include "uavobjecttreemodel.h" #include "uavobjecttreemodel.h"
class QPushButton; class QPushButton;
@ -65,7 +65,7 @@ private:
Ui_UAVObjectBrowser *m_browser; Ui_UAVObjectBrowser *m_browser;
UAVObjectTreeModel *m_model; UAVObjectTreeModel *m_model;
void updateSettings(SettingsPersistence::OperationOptions op); void updateSettings(ObjectPersistence::OperationOptions op);
void enableSendRequest(bool enable); void enableSendRequest(bool enable);
ObjectTreeItem *findCurrentObjectTreeItem(); ObjectTreeItem *findCurrentObjectTreeItem();
}; };

View File

@ -1,12 +1,12 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file settingspersistence.cpp * @file objectpersistence.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @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. * automatically generated by the UAVObjectGenerator.
* *
* @note Object definition file: settingspersistence.xml. * @note Object definition file: objectpersistence.xml.
* This is an automatically generated file. * This is an automatically generated file.
* DO NOT modify manually. * DO NOT modify manually.
* *
@ -28,15 +28,15 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "settingspersistence.h" #include "objectpersistence.h"
#include "uavobjectfields.h" #include "uavobjectfields.h"
const QString SettingsPersistence::NAME = QString("SettingsPersistence"); const QString ObjectPersistence::NAME = QString("ObjectPersistence");
/** /**
* Constructor * Constructor
*/ */
SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) ObjectPersistence::ObjectPersistence(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{ {
// Create fields // Create fields
QList<UAVObjectField*> fields; QList<UAVObjectField*> fields;
@ -46,6 +46,13 @@ SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, I
OperationEnumOptions.append("Load"); OperationEnumOptions.append("Load");
OperationEnumOptions.append("Save"); OperationEnumOptions.append("Save");
fields.append(new UAVObjectFieldEnum(QString("Operation"), QString(""), OperationElemNames, OperationEnumOptions)); 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 // Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES); initializeFields(fields, (quint8*)&data, NUMBYTES);
@ -56,7 +63,7 @@ SettingsPersistence::SettingsPersistence(): UAVDataObject(OBJID, ISSINGLEINST, I
/** /**
* Get the default metadata for this object * Get the default metadata for this object
*/ */
UAVObject::Metadata SettingsPersistence::getDefaultMetadata() UAVObject::Metadata ObjectPersistence::getDefaultMetadata()
{ {
UAVObject::Metadata metadata; UAVObject::Metadata metadata;
metadata.gcsTelemetryAcked = 1; metadata.gcsTelemetryAcked = 1;
@ -75,7 +82,7 @@ UAVObject::Metadata SettingsPersistence::getDefaultMetadata()
* If a default value is not specified the object fields * If a default value is not specified the object fields
* will be initialized to zero. * will be initialized to zero.
*/ */
void SettingsPersistence::setDefaultFieldValues() void ObjectPersistence::setDefaultFieldValues()
{ {
} }
@ -83,7 +90,7 @@ void SettingsPersistence::setDefaultFieldValues()
/** /**
* Get the object data fields * Get the object data fields
*/ */
SettingsPersistence::DataFields SettingsPersistence::getData() ObjectPersistence::DataFields ObjectPersistence::getData()
{ {
QMutexLocker locker(mutex); QMutexLocker locker(mutex);
return data; return data;
@ -92,7 +99,7 @@ SettingsPersistence::DataFields SettingsPersistence::getData()
/** /**
* Set the object data fields * Set the object data fields
*/ */
void SettingsPersistence::setData(const DataFields& data) void ObjectPersistence::setData(const DataFields& data)
{ {
QMutexLocker locker(mutex); QMutexLocker locker(mutex);
this->data = data; this->data = data;
@ -105,9 +112,9 @@ void SettingsPersistence::setData(const DataFields& data)
* Do not use this function directly to create new instances, the * Do not use this function directly to create new instances, the
* UAVObjectManager should be used instead. * 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()); obj->initialize(instID, this->getMetaObject());
return obj; return obj;
} }

View File

@ -1,12 +1,12 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file settingspersistence.h * @file objectpersistence.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @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. * automatically generated by the UAVObjectGenerator.
* *
* @note Object definition file: settingspersistence.xml. * @note Object definition file: objectpersistence.xml.
* This is an automatically generated file. * This is an automatically generated file.
* DO NOT modify manually. * DO NOT modify manually.
* *
@ -28,12 +28,12 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef SETTINGSPERSISTENCE_H #ifndef OBJECTPERSISTENCE_H
#define SETTINGSPERSISTENCE_H #define OBJECTPERSISTENCE_H
#include "uavdataobject.h" #include "uavdataobject.h"
class UAVOBJECTS_EXPORT SettingsPersistence: public UAVDataObject class UAVOBJECTS_EXPORT ObjectPersistence: public UAVDataObject
{ {
Q_OBJECT Q_OBJECT
@ -41,6 +41,7 @@ public:
// Field structure // Field structure
typedef struct { typedef struct {
quint8 Operation; quint8 Operation;
quint8 Objects;
} __attribute__((packed)) DataFields; } __attribute__((packed)) DataFields;
@ -48,17 +49,20 @@ public:
// Field Operation information // Field Operation information
/* Enumeration options for field Operation */ /* Enumeration options for field Operation */
typedef enum { OPERATION_LOAD=0, OPERATION_SAVE=1, } OperationOptions; 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 // Constants
static const quint32 OBJID = 3652432370U; static const quint32 OBJID = 2407027612U;
static const QString NAME; static const QString NAME;
static const bool ISSINGLEINST = 1; static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0; static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields); static const quint32 NUMBYTES = sizeof(DataFields);
// Functions // Functions
SettingsPersistence(); ObjectPersistence();
DataFields getData(); DataFields getData();
void setData(const DataFields& data); void setData(const DataFields& data);
@ -72,4 +76,4 @@ private:
}; };
#endif // SETTINGSPERSISTENCE_H #endif // OBJECTPERSISTENCE_H

View File

@ -23,12 +23,12 @@ HEADERS += uavobjects_global.h \
uavobjectfielduint16.h \ uavobjectfielduint16.h \
uavobjectfielduint32.h \ uavobjectfielduint32.h \
uavobjectfields.h \ uavobjectfields.h \
settingspersistence.h \
gpsobject.h \ gpsobject.h \
gcstelemetrystats.h \ gcstelemetrystats.h \
flighttelemetrystats.h \ flighttelemetrystats.h \
systemstats.h \ systemstats.h \
systemalarms.h systemalarms.h \
objectpersistence.h
SOURCES += uavobject.cpp \ SOURCES += uavobject.cpp \
uavmetaobject.cpp \ uavmetaobject.cpp \
uavobjectmanager.cpp \ uavobjectmanager.cpp \
@ -48,11 +48,11 @@ SOURCES += uavobject.cpp \
uavobjectfielduint8.cpp \ uavobjectfielduint8.cpp \
uavobjectfielduint16.cpp \ uavobjectfielduint16.cpp \
uavobjectfielduint32.cpp \ uavobjectfielduint32.cpp \
settingspersistence.cpp \
gpsobject.cpp \ gpsobject.cpp \
gcstelemetrystats.cpp \ gcstelemetrystats.cpp \
flighttelemetrystats.cpp \ flighttelemetrystats.cpp \
systemstats.cpp \ systemstats.cpp \
systemalarms.cpp systemalarms.cpp \
objectpersistence.cpp
DEFINES += UAVOBJECTS_LIBRARY DEFINES += UAVOBJECTS_LIBRARY
OTHER_FILES += UAVObjects.pluginspec OTHER_FILES += UAVObjects.pluginspec

View File

@ -36,7 +36,7 @@
#include "flighttelemetrystats.h" #include "flighttelemetrystats.h"
#include "gcstelemetrystats.h" #include "gcstelemetrystats.h"
#include "gpsobject.h" #include "gpsobject.h"
#include "settingspersistence.h" #include "objectpersistence.h"
#include "systemalarms.h" #include "systemalarms.h"
#include "systemstats.h" #include "systemstats.h"
@ -53,7 +53,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new FlightTelemetryStats() ); objMngr->registerObject( new FlightTelemetryStats() );
objMngr->registerObject( new GCSTelemetryStats() ); objMngr->registerObject( new GCSTelemetryStats() );
objMngr->registerObject( new GpsObject() ); objMngr->registerObject( new GpsObject() );
objMngr->registerObject( new SettingsPersistence() ); objMngr->registerObject( new ObjectPersistence() );
objMngr->registerObject( new SystemAlarms() ); objMngr->registerObject( new SystemAlarms() );
objMngr->registerObject( new SystemStats() ); objMngr->registerObject( new SystemStats() );

View File

@ -1,6 +1,7 @@
<xml> <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="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"/> <telemetrygcs acked="true" updatemode="manual" period="0"/>
<telemetryflight acked="true" updatemode="manual" period="0"/> <telemetryflight acked="true" updatemode="manual" period="0"/>
<logging updatemode="never" period="0"/> <logging updatemode="never" period="0"/>