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

OP-4 Flight/ObjectPersistance Implemented saving/loading of individual objects from the SD card

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@580 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-05-04 02:11:16 +00:00 committed by vassilis
parent e22aaa939e
commit 7ca10bf5d7
2 changed files with 49 additions and 11 deletions

View File

@ -120,6 +120,7 @@ static void systemTask(void* parameters)
static void objectUpdatedCb(UAVObjEvent* ev)
{
ObjectPersistenceData objper;
UAVObjHandle obj;
// If the object updated was the ObjectPersistence execute requested action
if ( ev->obj == ObjectPersistenceHandle() )
@ -130,33 +131,66 @@ static void objectUpdatedCb(UAVObjEvent* ev)
// Execute action
if ( objper.Operation == OBJECTPERSISTENCE_OPERATION_LOAD)
{
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_SETTINGS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_SINGLEOBJECT )
{
// Get selected object
obj = UAVObjGetByID(objper.ObjectID);
if ( obj == 0)
{
return;
}
// Load selected instance
UAVObjLoad(obj, objper.InstanceID);
}
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLSETTINGS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjLoadSettings();
}
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_METAOBJECTS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLMETAOBJECTS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjLoadMetaobjects();
}
}
else if ( objper.Operation == OBJECTPERSISTENCE_OPERATION_SAVE)
{
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_SETTINGS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_SINGLEOBJECT )
{
// Get selected object
obj = UAVObjGetByID(objper.ObjectID);
if ( obj == 0)
{
return;
}
// Save selected instance
UAVObjSave(obj, objper.InstanceID);
}
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLSETTINGS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjSaveSettings();
}
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_METAOBJECTS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLMETAOBJECTS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjSaveMetaobjects();
}
}
else if ( objper.Operation == OBJECTPERSISTENCE_OPERATION_DELETE)
{
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_SETTINGS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_SINGLEOBJECT )
{
// Get selected object
obj = UAVObjGetByID(objper.ObjectID);
if ( obj == 0)
{
return;
}
// Delete selected instance
UAVObjDelete(obj, objper.InstanceID);
}
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLSETTINGS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjDeleteSettings();
}
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_METAOBJECTS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
else if ( objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLMETAOBJECTS || objper.Selection == OBJECTPERSISTENCE_SELECTION_ALLOBJECTS)
{
UAVObjDeleteMetaobjects();
}

View File

@ -33,7 +33,7 @@
#define OBJECTPERSISTENCE_H
// Object constants
#define OBJECTPERSISTENCE_OBJID 2407027612U
#define OBJECTPERSISTENCE_OBJID 572614706U
#define OBJECTPERSISTENCE_NAME "ObjectPersistence"
#define OBJECTPERSISTENCE_METANAME "ObjectPersistenceMeta"
#define OBJECTPERSISTENCE_ISSINGLEINST 1
@ -58,7 +58,9 @@
// Object data
typedef struct {
uint8_t Operation;
uint8_t Objects;
uint8_t Selection;
uint32_t ObjectID;
uint32_t InstanceID;
} __attribute__((packed)) ObjectPersistenceData;
@ -66,9 +68,11 @@ typedef struct {
// Field Operation information
/* Enumeration options for field Operation */
typedef enum { OBJECTPERSISTENCE_OPERATION_LOAD=0, OBJECTPERSISTENCE_OPERATION_SAVE=1, OBJECTPERSISTENCE_OPERATION_DELETE=2, } ObjectPersistenceOperationOptions;
// Field Objects information
/* Enumeration options for field Objects */
typedef enum { OBJECTPERSISTENCE_OBJECTS_ALL=0, OBJECTPERSISTENCE_OBJECTS_SETTINGS=1, OBJECTPERSISTENCE_OBJECTS_METAOBJECTS=2, } ObjectPersistenceObjectsOptions;
// Field Selection information
/* Enumeration options for field Selection */
typedef enum { OBJECTPERSISTENCE_SELECTION_SINGLEOBJECT=0, OBJECTPERSISTENCE_SELECTION_ALLSETTINGS=1, OBJECTPERSISTENCE_SELECTION_ALLMETAOBJECTS=2, OBJECTPERSISTENCE_SELECTION_ALLOBJECTS=3, } ObjectPersistenceSelectionOptions;
// Field ObjectID information
// Field InstanceID information
// Generic interface functions