1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-25: Initial GPS Object

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@512 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
sambas 2010-04-17 07:38:28 +00:00 committed by sambas
parent 17842c5c4c
commit 03a012c347
8 changed files with 318 additions and 2 deletions

View File

@ -0,0 +1,73 @@
/**
******************************************************************************
*
* @file gpsobject.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.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
*/
#include "gpsobject.h"
// Private variables
static UAVObjHandle handle;
/**
* Initialize object.
* \return 0 Success
* \return -1 Failure
*/
int32_t GpsObjectInitialize()
{
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 metadata
metadata.telemetryAcked = 1;
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
metadata.telemetryUpdatePeriod = 0;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.gcsTelemetryUpdatePeriod = 1000;
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(handle, &metadata);
// Done
return 0;
}
/**
* Get object handle
*/
UAVObjHandle GpsObjectHandle()
{
return handle;
}

View File

@ -0,0 +1,74 @@
/**
******************************************************************************
*
* @file gpsobject.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.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 GPSOBJECT_H
#define GPSOBJECT_H
#include "openpilot.h"
// Object constants
#define GPSOBJECT_OBJID 253092234U
#define GPSOBJECT_NAME "GpsObject"
#define GPSOBJECT_ISSINGLEINST 0
#define GPSOBJECT_ISSETTINGS 0
#define GPSOBJECT_NUMBYTES sizeof(GpsObjectData)
// Object access macros
#define GpsObjectGet(dataOut) UAVObjGetData(GpsObjectHandle(), dataOut)
#define GpsObjectSet(dataIn) UAVObjSetData(GpsObjectHandle(), dataIn)
#define GpsObjectInstGet(instId, dataOut) UAVObjGetInstanceData(GpsObjectHandle(), instId, dataOut)
#define GpsObjectInstSet(instId, dataIn) UAVObjSetInstanceData(GpsObjectHandle(), instId, dataIn)
#define GpsObjectConnectQueue(queue) UAVObjConnectQueue(GpsObjectHandle(), queue, EV_MASK_ALL_UPDATES)
#define GpsObjectConnectCallback(cb) UAVObjConnectCallback(GpsObjectHandle(), cb, EV_MASK_ALL_UPDATES)
#define GpsObjectCreateInstance() UAVObjCreateInstance(GpsObjectHandle())
#define GpsObjectRequestUpdate() UAVObjRequestUpdate(GpsObjectHandle())
#define GpsObjectRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(GpsObjectHandle(), instId)
#define GpsObjectUpdated() UAVObjUpdated(GpsObjectHandle())
#define GpsObjectInstUpdated(instId) UAVObjUpdated(GpsObjectHandle(), instId)
#define GpsObjectGetMetadata(dataOut) UAVObjGetMetadata(GpsObjectHandle(), dataOut)
#define GpsObjectSetMetadata(dataIn) UAVObjSetMetadata(GpsObjectHandle(), dataIn)
// Object data
typedef struct {
float Latitude;
float Longitude;
float Altitude;
} __attribute__((packed)) GpsObjectData;
// Enumeration types
// Generic interface functions
int32_t GpsObjectInitialize();
UAVObjHandle GpsObjectHandle();
#endif // GPSOBJECT_H

View File

@ -31,6 +31,7 @@
#include "exampleobject1.h"
#include "exampleobject2.h"
#include "examplesettings.h"
#include "gpsobject.h"
#include "settingspersistence.h"
@ -43,6 +44,7 @@ void UAVObjectsInitializeAll()
ExampleObject1Initialize();
ExampleObject2Initialize();
ExampleSettingsInitialize();
GpsObjectInitialize();
SettingsPersistenceInitialize();
}

View File

@ -0,0 +1,81 @@
/**
******************************************************************************
*
* @file gpsobject.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.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
*/
#include "gpsobject.h"
#include "uavobjectfields.h"
const QString GpsObject::NAME = QString("GpsObject");
GpsObject::GpsObject(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
fields.append(new UAVObjectFieldFloat(QString("Latitude"), QString("degrees"), 1));
fields.append(new UAVObjectFieldFloat(QString("Longitude"), QString("degrees"), 1));
fields.append(new UAVObjectFieldFloat(QString("Altitude"), QString("meters"), 1));
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
}
UAVObject::Metadata GpsObject::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.gcsTelemetryAcked = 1;
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.gcsTelemetryUpdatePeriod = 1000;
metadata.flightTelemetryAcked = 1;
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
metadata.flightTelemetryUpdatePeriod = 0;
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0;
return metadata;
}
GpsObject::DataFields GpsObject::getData()
{
QMutexLocker locker(mutex);
return data;
}
void GpsObject::setData(DataFields& data)
{
QMutexLocker locker(mutex);
this->data = data;
emit objectUpdatedAuto(this); // trigger object updated event
emit objectUpdated(this);
}
UAVDataObject* GpsObject::clone(quint32 instID)
{
GpsObject* obj = new GpsObject();
obj->initialize(instID, this->getMetaObject());
return obj;
}

View File

@ -0,0 +1,72 @@
/**
******************************************************************************
*
* @file gpsobject.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.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 GPSOBJECT_H
#define GPSOBJECT_H
#include "uavdataobject.h"
class UAVOBJECTS_EXPORT GpsObject: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
float Latitude;
float Longitude;
float Altitude;
} __attribute__((packed)) DataFields;
// Enumeration types
// Constants
static const quint32 OBJID = 253092234U;
static const QString NAME;
static const bool ISSINGLEINST = 0;
static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
GpsObject();
DataFields getData();
void setData(DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
private:
DataFields data;
};
#endif // GPSOBJECT_H

View File

@ -23,7 +23,8 @@ HEADERS += uavobjects_global.h \
uavobjectfielduint16.h \
uavobjectfielduint32.h \
uavobjectfields.h \
settingspersistence.h
settingspersistence.h \
gpsobject.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
uavobjectmanager.cpp \
@ -43,6 +44,7 @@ SOURCES += uavobject.cpp \
uavobjectfielduint8.cpp \
uavobjectfielduint16.cpp \
uavobjectfielduint32.cpp \
settingspersistence.cpp
settingspersistence.cpp \
gpsobject.cpp
DEFINES += UAVOBJECTS_LIBRARY
OTHER_FILES += UAVObjects.pluginspec

View File

@ -33,6 +33,7 @@
#include "exampleobject1.h"
#include "exampleobject2.h"
#include "examplesettings.h"
#include "gpsobject.h"
#include "settingspersistence.h"
@ -45,6 +46,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new ExampleObject1() );
objMngr->registerObject( new ExampleObject2() );
objMngr->registerObject( new ExampleSettings() );
objMngr->registerObject( new GpsObject() );
objMngr->registerObject( new SettingsPersistence() );
}

View File

@ -0,0 +1,10 @@
<xml>
<object name="GpsObject" singleinstance="false" settings="false">
<field name="Latitude" units="degrees" type="float" elements="1"/>
<field name="Longitude" units="degrees" type="float" elements="1"/>
<field name="Altitude" units="meters" type="float" elements="1"/>
<telemetrygcs acked="true" updatemode="periodic" period="1000"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>
</object>
</xml>