1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Flight/UAVObjects Added support for default field values (used to initialize settings with defaults)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@558 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-04-28 01:54:24 +00:00 committed by vassilis
parent ce4aa6efc6
commit 99b67388bf
25 changed files with 226 additions and 22 deletions

View File

@ -97,12 +97,6 @@ static void ObjectUpdatedCb(UAVObjEvent* ev)
// Update settings with latest value
ExampleSettingsGet(&settings);
// TODO: Remove, this is temporary for testing (force settings)
// will remove when default setting values are implemented
settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP;
settings.StepSize = 1;
settings.UpdatePeriod = 100;
// Get the input object
ExampleObject1Get(&data1);

View File

@ -90,12 +90,6 @@ static void exampleTask(void* parameters)
// Update settings with latest value
ExampleSettingsGet(&settings);
// TODO: Remove, this is temporary for testing (force settings)
// will remove when default setting values are implemented
settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP;
settings.StepSize = 1;
settings.UpdatePeriod = 100;
// Get the object data
ExampleObject2Get(&data);

View File

@ -112,12 +112,6 @@ static void exampleTask(void* parameters)
// Update settings with latest value
ExampleSettingsGet(&settings);
// TODO: Remove, this is temporary for testing (force settings)
// will remove when default setting values are implemented
settings.StepDirection = EXAMPLESETTINGS_STEPDIRECTION_UP;
settings.StepSize = 1;
settings.UpdatePeriod = 100;
// Get the input object
ExampleObject1Get(&data1);

View File

@ -96,13 +96,13 @@ static void systemTask(void* parameters)
// Update the system alarms
updateSystemAlarms();
// Flash system alive the LED
// Flash the heartbeat LED
PIOS_LED_Toggle(LED1);
// Flash the error LED if an alarm is set
// Turn on the error LED if an alarm is set
if ( AlarmsHasWarnings() )
{
PIOS_LED_Toggle(LED2);
PIOS_LED_On(LED2);
}
else
{

View File

@ -55,7 +55,6 @@ int32_t AlarmsInitialize(void)
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
{
SystemAlarmsData alarms;
uint8_t changed;
// Check that this is a valid alarm
if (alarm >= SYSTEMALARMS_ALARM_NUMELEM)

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t ExampleObject1Initialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle ExampleObject1Handle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t ExampleObject2Initialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle ExampleObject2Handle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,30 @@ int32_t ExampleSettingsInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +95,4 @@ UAVObjHandle ExampleSettingsHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t FlightTelemetryStatsInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle FlightTelemetryStatsHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t GCSTelemetryStatsInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle GCSTelemetryStatsHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t GpsObjectInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle GpsObjectHandle()
}

View File

@ -35,6 +35,7 @@
// Object constants
#define EXAMPLEOBJECT1_OBJID 3852936276U
#define EXAMPLEOBJECT1_NAME "ExampleObject1"
#define EXAMPLEOBJECT1_METANAME "ExampleObject1Meta"
#define EXAMPLEOBJECT1_ISSINGLEINST 0
#define EXAMPLEOBJECT1_ISSETTINGS 0
#define EXAMPLEOBJECT1_NUMBYTES sizeof(ExampleObject1Data)

View File

@ -35,6 +35,7 @@
// Object constants
#define EXAMPLEOBJECT2_OBJID 2743296914U
#define EXAMPLEOBJECT2_NAME "ExampleObject2"
#define EXAMPLEOBJECT2_METANAME "ExampleObject2Meta"
#define EXAMPLEOBJECT2_ISSINGLEINST 0
#define EXAMPLEOBJECT2_ISSETTINGS 0
#define EXAMPLEOBJECT2_NUMBYTES sizeof(ExampleObject2Data)

View File

@ -35,6 +35,7 @@
// Object constants
#define EXAMPLESETTINGS_OBJID 1640607828U
#define EXAMPLESETTINGS_NAME "ExampleSettings"
#define EXAMPLESETTINGS_METANAME "ExampleSettingsMeta"
#define EXAMPLESETTINGS_ISSINGLEINST 1
#define EXAMPLESETTINGS_ISSETTINGS 1
#define EXAMPLESETTINGS_NUMBYTES sizeof(ExampleSettingsData)

View File

@ -35,6 +35,7 @@
// Object constants
#define FLIGHTTELEMETRYSTATS_OBJID 766280320U
#define FLIGHTTELEMETRYSTATS_NAME "FlightTelemetryStats"
#define FLIGHTTELEMETRYSTATS_METANAME "FlightTelemetryStatsMeta"
#define FLIGHTTELEMETRYSTATS_ISSINGLEINST 1
#define FLIGHTTELEMETRYSTATS_ISSETTINGS 0
#define FLIGHTTELEMETRYSTATS_NUMBYTES sizeof(FlightTelemetryStatsData)

View File

@ -35,6 +35,7 @@
// Object constants
#define GCSTELEMETRYSTATS_OBJID 607270704U
#define GCSTELEMETRYSTATS_NAME "GCSTelemetryStats"
#define GCSTELEMETRYSTATS_METANAME "GCSTelemetryStatsMeta"
#define GCSTELEMETRYSTATS_ISSINGLEINST 1
#define GCSTELEMETRYSTATS_ISSETTINGS 0
#define GCSTELEMETRYSTATS_NUMBYTES sizeof(GCSTelemetryStatsData)

View File

@ -35,6 +35,7 @@
// Object constants
#define GPSOBJECT_OBJID 4217926642U
#define GPSOBJECT_NAME "GpsObject"
#define GPSOBJECT_METANAME "GpsObjectMeta"
#define GPSOBJECT_ISSINGLEINST 1
#define GPSOBJECT_ISSETTINGS 0
#define GPSOBJECT_NUMBYTES sizeof(GpsObjectData)

View File

@ -35,6 +35,7 @@
// 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)

View File

@ -35,6 +35,7 @@
// Object constants
#define SYSTEMALARMS_OBJID 2311311458U
#define SYSTEMALARMS_NAME "SystemAlarms"
#define SYSTEMALARMS_METANAME "SystemAlarmsMeta"
#define SYSTEMALARMS_ISSINGLEINST 1
#define SYSTEMALARMS_ISSETTINGS 0
#define SYSTEMALARMS_NUMBYTES sizeof(SystemAlarmsData)

View File

@ -35,6 +35,7 @@
// Object constants
#define SYSTEMSTATS_OBJID 680908530U
#define SYSTEMSTATS_NAME "SystemStats"
#define SYSTEMSTATS_METANAME "SystemStatsMeta"
#define SYSTEMSTATS_ISSINGLEINST 1
#define SYSTEMSTATS_ISSETTINGS 0
#define SYSTEMSTATS_NUMBYTES sizeof(SystemStatsData)

View File

@ -35,6 +35,7 @@
// Object constants
#define $(NAMEUC)_OBJID $(OBJID)U
#define $(NAMEUC)_NAME "$(NAME)"
#define $(NAMEUC)_METANAME "$(NAME)Meta"
#define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST)
#define $(NAMEUC)_ISSETTINGS $(ISSETTINGS)
#define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data)

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t SettingsPersistenceInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle SettingsPersistenceHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t SystemAlarmsInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle SystemAlarmsHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t SystemStatsInitialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle SystemStatsHandle()
}

View File

@ -35,6 +35,9 @@
// Private variables
static UAVObjHandle handle;
// Private functions
static void setDefaultFieldValues();
/**
* Initialize object.
* \return 0 Success
@ -59,10 +62,27 @@ int32_t $(NAME)Initialize()
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);
}
/**
* Get object handle
*/
@ -72,3 +92,4 @@ UAVObjHandle $(NAME)Handle()
}