1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Flight/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@561 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-04-30 02:28:16 +00:00 committed by vassilis
parent fe29624590
commit 0999c1ce58
17 changed files with 552 additions and 365 deletions

View File

@ -135,7 +135,7 @@ SRC += $(OPUAVOBJ)/eventdispatcher.c
SRC += $(OPUAVOBJ)/exampleobject1.c
SRC += $(OPUAVOBJ)/exampleobject2.c
SRC += $(OPUAVOBJ)/examplesettings.c
SRC += $(OPUAVOBJ)/settingspersistence.c
SRC += $(OPUAVOBJ)/objectpersistence.c
SRC += $(OPUAVOBJ)/gpsobject.c
SRC += $(OPUAVOBJ)/gcstelemetrystats.c
SRC += $(OPUAVOBJ)/flighttelemetrystats.c

View File

@ -26,7 +26,7 @@
#include "openpilot.h"
#include "systemmod.h"
#include "settingspersistence.h"
#include "objectpersistence.h"
#include "systemstats.h"
// Private constants
@ -85,7 +85,7 @@ static void systemTask(void* parameters)
lastSysTime = xTaskGetTickCount();
// Listen for SettingPersistance object updates, connect a callback function
SettingsPersistenceConnectCallback(&objectUpdatedCb);
ObjectPersistenceConnectCallback(&objectUpdatedCb);
// Main system loop
while (1)
@ -119,23 +119,37 @@ static void systemTask(void* parameters)
*/
static void objectUpdatedCb(UAVObjEvent* ev)
{
SettingsPersistenceData setper;
ObjectPersistenceData objper;
// If the object updated was the SettingsPersistence execute requested action
if ( ev->obj == SettingsPersistenceHandle() )
// If the object updated was the ObjectPersistence execute requested action
if ( ev->obj == ObjectPersistenceHandle() )
{
// Get object data
SettingsPersistenceGet(&setper);
ObjectPersistenceGet(&objper);
// Execute action
if ( setper.Operation == SETTINGSPERSISTENCE_OPERATION_LOAD)
if ( objper.Operation == OBJECTPERSISTENCE_OPERATION_LOAD)
{
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_SETTINGS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
{
UAVObjLoadSettings();
}
else if ( setper.Operation == SETTINGSPERSISTENCE_OPERATION_SAVE)
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_METAOBJECTS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
{
UAVObjLoadMetaobjects();
}
}
else if ( objper.Operation == OBJECTPERSISTENCE_OPERATION_SAVE)
{
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_SETTINGS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
{
UAVObjSaveSettings();
}
if ( objper.Objects == OBJECTPERSISTENCE_OBJECTS_METAOBJECTS || objper.Objects == OBJECTPERSISTENCE_OBJECTS_ALL)
{
UAVObjSaveMetaobjects();
}
}
}
}

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t ExampleObject1Initialize()
{
// Register object with the object manager
handle = UAVObjRegister(EXAMPLEOBJECT1_OBJID, EXAMPLEOBJECT1_NAME, EXAMPLEOBJECT1_METANAME, 0,
EXAMPLEOBJECT1_ISSINGLEINST, EXAMPLEOBJECT1_ISSETTINGS, EXAMPLEOBJECT1_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
ExampleObject1Data data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(EXAMPLEOBJECT1_OBJID, EXAMPLEOBJECT1_NAME, 0, EXAMPLEOBJECT1_ISSINGLEINST, EXAMPLEOBJECT1_ISSETTINGS, EXAMPLEOBJECT1_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(ExampleObject1Data));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
metadata.telemetryUpdatePeriod = 0;
@ -60,27 +85,7 @@ int32_t ExampleObject1Initialize()
metadata.gcsTelemetryUpdatePeriod = 200;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
ExampleObject1Data data;
ExampleObject1Get(&data);
memset(&data, 0, sizeof(ExampleObject1Data));
ExampleObject1Set(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t ExampleObject2Initialize()
{
// Register object with the object manager
handle = UAVObjRegister(EXAMPLEOBJECT2_OBJID, EXAMPLEOBJECT2_NAME, EXAMPLEOBJECT2_METANAME, 0,
EXAMPLEOBJECT2_ISSINGLEINST, EXAMPLEOBJECT2_ISSETTINGS, EXAMPLEOBJECT2_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
ExampleObject2Data data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(EXAMPLEOBJECT2_OBJID, EXAMPLEOBJECT2_NAME, 0, EXAMPLEOBJECT2_ISSINGLEINST, EXAMPLEOBJECT2_ISSETTINGS, EXAMPLEOBJECT2_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(ExampleObject2Data));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 100;
@ -60,27 +85,7 @@ int32_t ExampleObject2Initialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
ExampleObject2Data data;
ExampleObject2Get(&data);
memset(&data, 0, sizeof(ExampleObject2Data));
ExampleObject2Set(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,41 @@ static void setDefaultFieldValues();
*/
int32_t ExampleSettingsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(EXAMPLESETTINGS_OBJID, EXAMPLESETTINGS_NAME, EXAMPLESETTINGS_METANAME, 0,
EXAMPLESETTINGS_ISSINGLEINST, EXAMPLESETTINGS_ISSETTINGS, EXAMPLESETTINGS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
ExampleSettingsData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(EXAMPLESETTINGS_OBJID, EXAMPLESETTINGS_NAME, 0, EXAMPLESETTINGS_ISSINGLEINST, EXAMPLESETTINGS_ISSETTINGS, EXAMPLESETTINGS_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(ExampleSettingsData));
data.UpdatePeriod = 10;
data.StepSize = 1;
data.StepDirection = 0;
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
metadata.telemetryUpdatePeriod = 0;
@ -60,30 +88,7 @@ int32_t ExampleSettingsInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
ExampleSettingsData data;
ExampleSettingsGet(&data);
memset(&data, 0, sizeof(ExampleSettingsData));
data.UpdatePeriod = 10;
data.StepSize = 1;
data.StepDirection = 0;
ExampleSettingsSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t FlightTelemetryStatsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(FLIGHTTELEMETRYSTATS_OBJID, FLIGHTTELEMETRYSTATS_NAME, FLIGHTTELEMETRYSTATS_METANAME, 0,
FLIGHTTELEMETRYSTATS_ISSINGLEINST, FLIGHTTELEMETRYSTATS_ISSETTINGS, FLIGHTTELEMETRYSTATS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
FlightTelemetryStatsData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(FLIGHTTELEMETRYSTATS_OBJID, FLIGHTTELEMETRYSTATS_NAME, 0, FLIGHTTELEMETRYSTATS_ISSINGLEINST, FLIGHTTELEMETRYSTATS_ISSETTINGS, FLIGHTTELEMETRYSTATS_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(FlightTelemetryStatsData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 5000;
@ -60,27 +85,7 @@ int32_t FlightTelemetryStatsInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 5000;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
FlightTelemetryStatsData data;
FlightTelemetryStatsGet(&data);
memset(&data, 0, sizeof(FlightTelemetryStatsData));
FlightTelemetryStatsSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t GCSTelemetryStatsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(GCSTELEMETRYSTATS_OBJID, GCSTELEMETRYSTATS_NAME, GCSTELEMETRYSTATS_METANAME, 0,
GCSTELEMETRYSTATS_ISSINGLEINST, GCSTELEMETRYSTATS_ISSETTINGS, GCSTELEMETRYSTATS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
GCSTelemetryStatsData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(GCSTELEMETRYSTATS_OBJID, GCSTELEMETRYSTATS_NAME, 0, GCSTELEMETRYSTATS_ISSINGLEINST, GCSTELEMETRYSTATS_ISSETTINGS, GCSTELEMETRYSTATS_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(GCSTelemetryStatsData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_NEVER;
metadata.telemetryUpdatePeriod = 0;
@ -60,27 +85,7 @@ int32_t GCSTelemetryStatsInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
GCSTelemetryStatsData data;
GCSTelemetryStatsGet(&data);
memset(&data, 0, sizeof(GCSTelemetryStatsData));
GCSTelemetryStatsSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t GpsObjectInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(GPSOBJECT_OBJID, GPSOBJECT_NAME, GPSOBJECT_METANAME, 0,
GPSOBJECT_ISSINGLEINST, GPSOBJECT_ISSETTINGS, GPSOBJECT_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
GpsObjectData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(GPSOBJECT_OBJID, GPSOBJECT_NAME, 0, GPSOBJECT_ISSINGLEINST, GPSOBJECT_ISSETTINGS, GPSOBJECT_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(GpsObjectData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 1000;
@ -60,27 +85,7 @@ int32_t GpsObjectInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 1000;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
GpsObjectData data;
GpsObjectGet(&data);
memset(&data, 0, sizeof(GpsObjectData));
GpsObjectSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -0,0 +1,78 @@
/**
******************************************************************************
*
* @file objectpersistence.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the ObjectPersistence object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: objectpersistence.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef OBJECTPERSISTENCE_H
#define OBJECTPERSISTENCE_H
// Object constants
#define OBJECTPERSISTENCE_OBJID 2407027612U
#define OBJECTPERSISTENCE_NAME "ObjectPersistence"
#define OBJECTPERSISTENCE_METANAME "ObjectPersistenceMeta"
#define OBJECTPERSISTENCE_ISSINGLEINST 1
#define OBJECTPERSISTENCE_ISSETTINGS 0
#define OBJECTPERSISTENCE_NUMBYTES sizeof(ObjectPersistenceData)
// Object access macros
#define ObjectPersistenceGet(dataOut) UAVObjGetData(ObjectPersistenceHandle(), dataOut)
#define ObjectPersistenceSet(dataIn) UAVObjSetData(ObjectPersistenceHandle(), dataIn)
#define ObjectPersistenceInstGet(instId, dataOut) UAVObjGetInstanceData(ObjectPersistenceHandle(), instId, dataOut)
#define ObjectPersistenceInstSet(instId, dataIn) UAVObjSetInstanceData(ObjectPersistenceHandle(), instId, dataIn)
#define ObjectPersistenceConnectQueue(queue) UAVObjConnectQueue(ObjectPersistenceHandle(), queue, EV_MASK_ALL_UPDATES)
#define ObjectPersistenceConnectCallback(cb) UAVObjConnectCallback(ObjectPersistenceHandle(), cb, EV_MASK_ALL_UPDATES)
#define ObjectPersistenceCreateInstance() UAVObjCreateInstance(ObjectPersistenceHandle())
#define ObjectPersistenceRequestUpdate() UAVObjRequestUpdate(ObjectPersistenceHandle())
#define ObjectPersistenceRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(ObjectPersistenceHandle(), instId)
#define ObjectPersistenceUpdated() UAVObjUpdated(ObjectPersistenceHandle())
#define ObjectPersistenceInstUpdated(instId) UAVObjUpdated(ObjectPersistenceHandle(), instId)
#define ObjectPersistenceGetMetadata(dataOut) UAVObjGetMetadata(ObjectPersistenceHandle(), dataOut)
#define ObjectPersistenceSetMetadata(dataIn) UAVObjSetMetadata(ObjectPersistenceHandle(), dataIn)
// Object data
typedef struct {
uint8_t Operation;
uint8_t Objects;
} __attribute__((packed)) ObjectPersistenceData;
// Field information
// Field Operation information
/* Enumeration options for field Operation */
typedef enum { OBJECTPERSISTENCE_OPERATION_LOAD=0, OBJECTPERSISTENCE_OPERATION_SAVE=1, } ObjectPersistenceOperationOptions;
// Field Objects information
/* Enumeration options for field Objects */
typedef enum { OBJECTPERSISTENCE_OBJECTS_ALL=0, OBJECTPERSISTENCE_OBJECTS_SETTINGS=1, OBJECTPERSISTENCE_OBJECTS_METAOBJECTS=2, } ObjectPersistenceObjectsOptions;
// Generic interface functions
int32_t ObjectPersistenceInitialize();
UAVObjHandle ObjectPersistenceHandle();
#endif // OBJECTPERSISTENCE_H

View File

@ -1,74 +0,0 @@
/**
******************************************************************************
*
* @file settingspersistence.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the SettingsPersistence object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: settingspersistence.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* 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
// Object constants
#define SETTINGSPERSISTENCE_OBJID 3652432370U
#define SETTINGSPERSISTENCE_NAME "SettingsPersistence"
#define SETTINGSPERSISTENCE_METANAME "SettingsPersistenceMeta"
#define SETTINGSPERSISTENCE_ISSINGLEINST 1
#define SETTINGSPERSISTENCE_ISSETTINGS 0
#define SETTINGSPERSISTENCE_NUMBYTES sizeof(SettingsPersistenceData)
// Object access macros
#define SettingsPersistenceGet(dataOut) UAVObjGetData(SettingsPersistenceHandle(), dataOut)
#define SettingsPersistenceSet(dataIn) UAVObjSetData(SettingsPersistenceHandle(), dataIn)
#define SettingsPersistenceInstGet(instId, dataOut) UAVObjGetInstanceData(SettingsPersistenceHandle(), instId, dataOut)
#define SettingsPersistenceInstSet(instId, dataIn) UAVObjSetInstanceData(SettingsPersistenceHandle(), instId, dataIn)
#define SettingsPersistenceConnectQueue(queue) UAVObjConnectQueue(SettingsPersistenceHandle(), queue, EV_MASK_ALL_UPDATES)
#define SettingsPersistenceConnectCallback(cb) UAVObjConnectCallback(SettingsPersistenceHandle(), cb, EV_MASK_ALL_UPDATES)
#define SettingsPersistenceCreateInstance() UAVObjCreateInstance(SettingsPersistenceHandle())
#define SettingsPersistenceRequestUpdate() UAVObjRequestUpdate(SettingsPersistenceHandle())
#define SettingsPersistenceRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(SettingsPersistenceHandle(), instId)
#define SettingsPersistenceUpdated() UAVObjUpdated(SettingsPersistenceHandle())
#define SettingsPersistenceInstUpdated(instId) UAVObjUpdated(SettingsPersistenceHandle(), instId)
#define SettingsPersistenceGetMetadata(dataOut) UAVObjGetMetadata(SettingsPersistenceHandle(), dataOut)
#define SettingsPersistenceSetMetadata(dataIn) UAVObjSetMetadata(SettingsPersistenceHandle(), dataIn)
// Object data
typedef struct {
uint8_t Operation;
} __attribute__((packed)) SettingsPersistenceData;
// Field information
// Field Operation information
/* Enumeration options for field Operation */
typedef enum { SETTINGSPERSISTENCE_OPERATION_LOAD=0, SETTINGSPERSISTENCE_OPERATION_SAVE=1, } SettingsPersistenceOperationOptions;
// Generic interface functions
int32_t SettingsPersistenceInitialize();
UAVObjHandle SettingsPersistenceHandle();
#endif // SETTINGSPERSISTENCE_H

View File

@ -88,6 +88,11 @@ typedef struct {
*/
typedef void (*UAVObjEventCallback)(UAVObjEvent* ev);
/**
* Callback used to initialize the object fields to their default values.
*/
typedef void (*UAVObjInitializeCallback)(UAVObjHandle obj, uint16_t instId);
/**
* Event manager statistics
*/
@ -98,8 +103,8 @@ typedef struct {
int32_t UAVObjInitialize();
void UAVObjGetStats(UAVObjStats* statsOut);
void UAVObjClearStats();
UAVObjHandle UAVObjRegister(uint32_t id, const char* name, int32_t isMetaobject, int32_t isSingleInstance,
int32_t isSettings, uint32_t numBytes);
UAVObjHandle UAVObjRegister(uint32_t id, const char* name, const char* metaName, int32_t isMetaobject,
int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes, UAVObjInitializeCallback initCb);
UAVObjHandle UAVObjGetByID(uint32_t id);
UAVObjHandle UAVObjGetByName(char* name);
uint32_t UAVObjGetID(UAVObjHandle obj);
@ -119,6 +124,8 @@ int32_t UAVObjSaveToFile(UAVObjHandle obj, uint16_t instId, FILEINFO* file);
UAVObjHandle UAVObjLoadFromFile(FILEINFO* file);
int32_t UAVObjSaveSettings();
int32_t UAVObjLoadSettings();
int32_t UAVObjSaveMetaobjects();
int32_t UAVObjLoadMetaobjects();
int32_t UAVObjSetData(UAVObjHandle obj, const void* dataIn);
int32_t UAVObjGetData(UAVObjHandle obj, void* dataOut);
int32_t UAVObjSetInstanceData(UAVObjHandle obj, uint16_t instId, const void* dataIn);

View File

@ -1,12 +1,12 @@
/**
******************************************************************************
*
* @file settingspersistence.c
* @file objectpersistence.c
* @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.
*
@ -30,28 +30,53 @@
*/
#include "openpilot.h"
#include "settingspersistence.h"
#include "objectpersistence.h"
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
* \return 0 Success
* \return -1 Failure
*/
int32_t SettingsPersistenceInitialize()
int32_t ObjectPersistenceInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(OBJECTPERSISTENCE_OBJID, OBJECTPERSISTENCE_NAME, OBJECTPERSISTENCE_METANAME, 0,
OBJECTPERSISTENCE_ISSINGLEINST, OBJECTPERSISTENCE_ISSETTINGS, OBJECTPERSISTENCE_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
ObjectPersistenceData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(SETTINGSPERSISTENCE_OBJID, SETTINGSPERSISTENCE_NAME, 0, SETTINGSPERSISTENCE_ISSINGLEINST, SETTINGSPERSISTENCE_ISSETTINGS, SETTINGSPERSISTENCE_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(ObjectPersistenceData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_MANUAL;
metadata.telemetryUpdatePeriod = 0;
@ -60,33 +85,13 @@ int32_t SettingsPersistenceInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
SettingsPersistenceData data;
SettingsPersistenceGet(&data);
memset(&data, 0, sizeof(SettingsPersistenceData));
SettingsPersistenceSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**
* Get object handle
*/
UAVObjHandle SettingsPersistenceHandle()
UAVObjHandle ObjectPersistenceHandle()
{
return handle;
}

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t SystemAlarmsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(SYSTEMALARMS_OBJID, SYSTEMALARMS_NAME, SYSTEMALARMS_METANAME, 0,
SYSTEMALARMS_ISSINGLEINST, SYSTEMALARMS_ISSETTINGS, SYSTEMALARMS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
SystemAlarmsData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(SYSTEMALARMS_OBJID, SYSTEMALARMS_NAME, 0, SYSTEMALARMS_ISSINGLEINST, SYSTEMALARMS_ISSETTINGS, SYSTEMALARMS_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(SystemAlarmsData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 4000;
@ -60,27 +85,7 @@ int32_t SystemAlarmsInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 1000;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
SystemAlarmsData data;
SystemAlarmsGet(&data);
memset(&data, 0, sizeof(SystemAlarmsData));
SystemAlarmsSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t SystemStatsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(SYSTEMSTATS_OBJID, SYSTEMSTATS_NAME, SYSTEMSTATS_METANAME, 0,
SYSTEMSTATS_ISSINGLEINST, SYSTEMSTATS_ISSETTINGS, SYSTEMSTATS_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
SystemStatsData data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister(SYSTEMSTATS_OBJID, SYSTEMSTATS_NAME, 0, SYSTEMSTATS_ISSINGLEINST, SYSTEMSTATS_ISSETTINGS, SYSTEMSTATS_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(SystemStatsData));
// Initialize metadata
UAVObjSetInstanceData(obj, instId, &data);
// Initialize object metadata to their default values
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 1000;
@ -60,27 +85,7 @@ int32_t SystemStatsInitialize()
metadata.gcsTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
metadata.loggingUpdatePeriod = 1000;
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
SystemStatsData data;
SystemStatsGet(&data);
memset(&data, 0, sizeof(SystemStatsData));
SystemStatsSet(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**

View File

@ -62,6 +62,7 @@ struct ObjectListStruct {
int8_t isSettings; /** Set to 1 if this object is a settings object */
uint16_t numBytes; /** Number of data bytes contained in the object (for a single instance) */
uint16_t numInstances; /** Number of instances */
UAVObjInitializeCallback initCb; /** Object field and metadata initialization callback */
struct ObjectListStruct* linkedObj; /** Linked object, for regular objects this is the metaobject and for metaobjects it is the parent object */
ObjectInstList* instances; /** List of object instances, instance 0 always exists */
ObjectEventList* events; /** Event queues registered on the object */
@ -75,6 +76,8 @@ static ObjectInstList* createInstance(ObjectList* obj, uint16_t instId);
static ObjectInstList* getInstance(ObjectList* obj, uint16_t instId);
static int32_t connectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCallback cb, int32_t eventMask);
static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCallback cb);
static void objectFilename(ObjectList* obj, uint8_t* filename);
static void customSPrintf(uint8_t* buffer, uint8_t* format, ...);
// Private variables
static ObjectList* objList;
@ -137,15 +140,17 @@ void UAVObjClearStats()
* Register and new object in the object manager.
* \param[in] id Unique object ID
* \param[in] name Object name
* \param[in] nameName Metaobject name
* \param[in] isMetaobject Is this a metaobject (1:true, 0:false)
* \param[in] isSingleInstance Is this a single instance or multi-instance object
* \param[in] isSettings Is this a settings object
* \param[in] numBytes Number of bytes of object data (for one instance)
* \param[in] initCb Default field and metadata initialization function
* \return Object handle, or 0 if failure.
* \return
*/
UAVObjHandle UAVObjRegister(uint32_t id, const char* name, int32_t isMetaobject,
int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes)
UAVObjHandle UAVObjRegister(uint32_t id, const char* name, const char* metaName, int32_t isMetaobject,
int32_t isSingleInstance, int32_t isSettings, uint32_t numBytes, UAVObjInitializeCallback initCb)
{
ObjectList* objEntry;
ObjectInstList* instEntry;
@ -180,12 +185,13 @@ UAVObjHandle UAVObjRegister(uint32_t id, const char* name, int32_t isMetaobject,
objEntry->numBytes = numBytes;
objEntry->events = NULL;
objEntry->numInstances = 0;
objEntry->initCb = initCb;
objEntry->instances = NULL;
objEntry->linkedObj = NULL; // will be set later
LL_APPEND(objList, objEntry);
// Create instance zero
instEntry = createInstance(objEntry, objEntry->numInstances);
instEntry = createInstance(objEntry, 0);
if ( instEntry == NULL )
{
xSemaphoreGiveRecursive(mutex);
@ -200,13 +206,25 @@ UAVObjHandle UAVObjRegister(uint32_t id, const char* name, int32_t isMetaobject,
else
{
// Create metaobject
metaObj = (ObjectList*)UAVObjRegister(id+1, NULL, 1, 1, 0, sizeof(UAVObjMetadata));
metaObj = (ObjectList*)UAVObjRegister(id+1, metaName, NULL, 1, 1, 0, sizeof(UAVObjMetadata), NULL);
// Link two objects
objEntry->linkedObj = metaObj;
metaObj->linkedObj = objEntry;
}
// If this is a settings object attempt to load its data from the file system
// Initialize object fields and metadata to default values
if ( objEntry->initCb != NULL )
{
objEntry->initCb((UAVObjHandle)objEntry, 0);
}
// Attempt to load object's metadata from the SD card (not done directly on the metaobject, but through the object)
if ( !objEntry->isMetaobject )
{
UAVObjLoad( (UAVObjHandle)objEntry->linkedObj, 0 );
}
// If this is a settings object, attempt to load from SD card
if ( objEntry->isSettings )
{
UAVObjLoad( (UAVObjHandle)objEntry, 0 );
@ -353,6 +371,12 @@ uint16_t UAVObjCreateInstance(UAVObjHandle obj)
return -1;
}
// Initialize instance data
if ( objEntry->initCb != NULL )
{
objEntry->initCb(obj, instEntry->instId);
}
// Unlock
xSemaphoreGiveRecursive(mutex);
return instEntry->instId;
@ -538,6 +562,7 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId)
{
FILEINFO file;
ObjectList* objEntry;
uint8_t filename[14];
// Check for file system availability
if ( POIS_SDCARD_IsMounted() == 0 )
@ -551,8 +576,11 @@ int32_t UAVObjSave(UAVObjHandle obj, uint16_t instId)
// Cast to object
objEntry = (ObjectList*)obj;
// Get filename
objectFilename(objEntry, filename);
// Open file
if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)objEntry->name, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK )
if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)filename, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK )
{
xSemaphoreGiveRecursive(mutex);
return -1;
@ -666,6 +694,7 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
ObjectList* objEntry;
UAVObjHandle loadedObj;
ObjectList* loadedObjEntry;
uint8_t filename[14];
// Check for file system availability
if ( POIS_SDCARD_IsMounted() == 0 )
@ -679,8 +708,11 @@ int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
// Cast to object
objEntry = (ObjectList*)obj;
// Get filename
objectFilename(objEntry, filename);
// Open file
if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)objEntry->name, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK )
if ( DFS_OpenFile(&PIOS_SDCARD_VolInfo, (uint8_t *)filename, DFS_WRITE, PIOS_SDCARD_Sector, &file) != DFS_OK )
{
xSemaphoreGiveRecursive(mutex);
return -1;
@ -772,6 +804,68 @@ int32_t UAVObjLoadSettings()
return 0;
}
/**
* Save all metaobjects to the SD card.
* @return 0 if success or -1 if failure
*/
int32_t UAVObjSaveMetaobjects()
{
ObjectList* objEntry;
// Get lock
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
// Save all settings objects
LL_FOREACH(objList, objEntry)
{
// Check if this is a settings object
if ( objEntry->isMetaobject )
{
// Save object
if ( UAVObjSave( (UAVObjHandle)objEntry, 0 ) == -1 )
{
xSemaphoreGiveRecursive(mutex);
return -1;
}
}
}
// Done
xSemaphoreGiveRecursive(mutex);
return 0;
}
/**
* Load all metaobjects from the SD card.
* @return 0 if success or -1 if failure
*/
int32_t UAVObjLoadMetaobjects()
{
ObjectList* objEntry;
// Get lock
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
// Load all settings objects
LL_FOREACH(objList, objEntry)
{
// Check if this is a settings object
if ( objEntry->isMetaobject )
{
// Load object
if ( UAVObjLoad( (UAVObjHandle)objEntry, 0 ) == -1 )
{
xSemaphoreGiveRecursive(mutex);
return -1;
}
}
}
// Done
xSemaphoreGiveRecursive(mutex);
return 0;
}
/**
* Set the object data
* \param[in] obj The object handle
@ -1236,6 +1330,24 @@ static int32_t disconnectObj(UAVObjHandle obj, xQueueHandle queue, UAVObjEventCa
return -1;
}
/**
* Wrapper for the sprintf function
*/
static void customSPrintf(uint8_t* buffer, uint8_t* format, ...)
{
va_list args;
va_start(args, format);
vsprintf((char *)buffer, (char *)format, args);
}
/**
* Get an 8 character (plus extension) filename for the object.
*/
static void objectFilename(ObjectList* obj, uint8_t* filename)
{
customSPrintf(filename, (uint8_t*)"%X.obj", obj->id);
}

View File

@ -34,7 +34,7 @@
#include "flighttelemetrystats.h"
#include "gcstelemetrystats.h"
#include "gpsobject.h"
#include "settingspersistence.h"
#include "objectpersistence.h"
#include "systemalarms.h"
#include "systemstats.h"
@ -51,7 +51,7 @@ void UAVObjectsInitializeAll()
FlightTelemetryStatsInitialize();
GCSTelemetryStatsInitialize();
GpsObjectInitialize();
SettingsPersistenceInitialize();
ObjectPersistenceInitialize();
SystemAlarmsInitialize();
SystemStatsInitialize();

View File

@ -36,7 +36,7 @@
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
static void setDefaults(UAVObjHandle obj, uint16_t instId);
/**
* Initialize object.
@ -45,13 +45,38 @@ static void setDefaultFieldValues();
*/
int32_t $(NAME)Initialize()
{
// Register object with the object manager
handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, $(NAMEUC)_METANAME, 0,
$(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES, &setDefaults);
// Done
if (handle != 0)
{
return 0;
}
else
{
return -1;
}
}
/**
* Initialize object fields and metadata with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaults(UAVObjHandle obj, uint16_t instId)
{
$(NAME)Data data;
UAVObjMetadata metadata;
// Register object with the object manager
handle = UAVObjRegister($(NAMEUC)_OBJID, $(NAMEUC)_NAME, 0, $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES);
if (handle == 0) return -1;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof($(NAME)Data));
$(INITFIELDS)
UAVObjSetInstanceData(obj, instId, &data);
// Initialize metadata
// Initialize object metadata to their default values
metadata.telemetryAcked = $(FLIGHTTELEM_ACKED);
metadata.telemetryUpdateMode = $(FLIGHTTELEM_UPDATEMODE);
metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD);
@ -60,27 +85,7 @@ int32_t $(NAME)Initialize()
metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
metadata.loggingUpdateMode = $(LOGGING_UPDATEMODE);
metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD);
UAVObjSetMetadata(handle, &metadata);
// Initialize field values
setDefaultFieldValues();
// Done
return 0;
}
/**
* Initialize object fields with the default values.
* If a default value is not specified the object fields
* will be initialized to zero.
*/
static void setDefaultFieldValues()
{
$(NAME)Data data;
$(NAME)Get(&data);
memset(&data, 0, sizeof($(NAME)Data));
$(INITFIELDS)
$(NAME)Set(&data);
UAVObjSetMetadata(obj, &metadata);
}
/**