2010-03-27 04:22:43 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2010-04-02 05:17:51 +02:00
|
|
|
* @file exampleobject1.cpp
|
2010-03-27 04:22:43 +01:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
2010-04-02 05:17:51 +02:00
|
|
|
* @brief Implementation of the ExampleObject1 object. This file has been
|
2010-03-27 04:22:43 +01:00
|
|
|
* automatically generated by the UAVObjectGenerator.
|
|
|
|
*
|
2010-04-02 05:17:51 +02:00
|
|
|
* @note Object definition file: exampleobject1.xml.
|
2010-03-27 04:22:43 +01:00
|
|
|
* 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
|
|
|
|
*/
|
2010-04-02 05:17:51 +02:00
|
|
|
#include "exampleobject1.h"
|
2010-04-07 05:11:13 +02:00
|
|
|
#include "uavobjectfields.h"
|
2010-03-27 04:22:43 +01:00
|
|
|
|
2010-04-02 05:17:51 +02:00
|
|
|
const QString ExampleObject1::NAME = QString("ExampleObject1");
|
2010-03-27 04:22:43 +01:00
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2010-04-02 05:17:51 +02:00
|
|
|
ExampleObject1::ExampleObject1(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
|
|
|
// Create fields
|
|
|
|
QList<UAVObjectField*> fields;
|
2010-04-21 04:50:51 +02:00
|
|
|
QStringList Field1ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field1ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldInt8(QString("Field1"), QString("unit1"), Field1ElemNames));
|
|
|
|
QStringList Field2ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field2ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldInt16(QString("Field2"), QString("unit2"), Field2ElemNames));
|
|
|
|
QStringList Field3ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field3ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldInt32(QString("Field3"), QString("unit3"), Field3ElemNames));
|
|
|
|
QStringList Field4ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field4ElemNames.append("0");
|
|
|
|
Field4ElemNames.append("1");
|
|
|
|
Field4ElemNames.append("2");
|
|
|
|
Field4ElemNames.append("3");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldFloat(QString("Field4"), QString("unit4"), Field4ElemNames));
|
|
|
|
QStringList Field5ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field5ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldUInt8(QString("Field5"), QString("unit5"), Field5ElemNames));
|
|
|
|
QStringList Field6ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field6ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldUInt16(QString("Field6"), QString("unit6"), Field6ElemNames));
|
|
|
|
QStringList Field7ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field7ElemNames.append("0");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldUInt32(QString("Field7"), QString("unit7"), Field7ElemNames));
|
|
|
|
QStringList Field8ElemNames;
|
2010-04-22 02:44:14 +02:00
|
|
|
Field8ElemNames.append("0");
|
2010-04-04 22:32:59 +02:00
|
|
|
QStringList Field8EnumOptions;
|
|
|
|
Field8EnumOptions.append("Option1");
|
|
|
|
Field8EnumOptions.append("Option2");
|
2010-04-21 04:50:51 +02:00
|
|
|
fields.append(new UAVObjectFieldEnum(QString("Field8"), QString("unit8"), Field8ElemNames, Field8EnumOptions));
|
2010-03-27 04:22:43 +01:00
|
|
|
|
|
|
|
// Initialize object
|
|
|
|
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
2010-04-28 03:50:53 +02:00
|
|
|
// Set the default field values
|
|
|
|
setDefaultFieldValues();
|
2010-03-27 04:22:43 +01:00
|
|
|
}
|
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Get the default metadata for this object
|
|
|
|
*/
|
2010-04-02 05:17:51 +02:00
|
|
|
UAVObject::Metadata ExampleObject1::getDefaultMetadata()
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
|
|
|
UAVObject::Metadata metadata;
|
|
|
|
metadata.gcsTelemetryAcked = 1;
|
2010-04-02 05:17:51 +02:00
|
|
|
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
|
|
|
metadata.gcsTelemetryUpdatePeriod = 200;
|
2010-03-27 04:22:43 +01:00
|
|
|
metadata.flightTelemetryAcked = 1;
|
|
|
|
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE;
|
2010-04-02 05:17:51 +02:00
|
|
|
metadata.flightTelemetryUpdatePeriod = 0;
|
2010-03-27 04:22:43 +01:00
|
|
|
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
|
|
|
metadata.loggingUpdatePeriod = 0;
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Initialize object fields with the default values.
|
|
|
|
* If a default value is not specified the object fields
|
|
|
|
* will be initialized to zero.
|
|
|
|
*/
|
|
|
|
void ExampleObject1::setDefaultFieldValues()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the object data fields
|
|
|
|
*/
|
2010-04-02 05:17:51 +02:00
|
|
|
ExampleObject1::DataFields ExampleObject1::getData()
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
2010-04-01 04:00:19 +02:00
|
|
|
QMutexLocker locker(mutex);
|
2010-03-27 04:22:43 +01:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Set the object data fields
|
|
|
|
*/
|
|
|
|
void ExampleObject1::setData(const DataFields& data)
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
|
|
|
QMutexLocker locker(mutex);
|
|
|
|
this->data = data;
|
|
|
|
emit objectUpdatedAuto(this); // trigger object updated event
|
|
|
|
emit objectUpdated(this);
|
|
|
|
}
|
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Create a clone of this object, a new instance ID must be specified.
|
|
|
|
* Do not use this function directly to create new instances, the
|
|
|
|
* UAVObjectManager should be used instead.
|
|
|
|
*/
|
2010-04-02 05:17:51 +02:00
|
|
|
UAVDataObject* ExampleObject1::clone(quint32 instID)
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
2010-04-02 05:17:51 +02:00
|
|
|
ExampleObject1* obj = new ExampleObject1();
|
2010-03-27 04:22:43 +01:00
|
|
|
obj->initialize(instID, this->getMetaObject());
|
|
|
|
return obj;
|
|
|
|
}
|