2010-03-10 23:36:47 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2010-03-27 04:22:43 +01:00
|
|
|
* @file $(NAMELC).cpp
|
2010-03-10 23:36:47 +01:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
2010-03-27 04:22:43 +01:00
|
|
|
* @brief Implementation of the $(NAME) object. This file has been
|
|
|
|
* automatically generated by the UAVObjectGenerator.
|
2010-03-10 23:36:47 +01:00
|
|
|
*
|
2010-03-27 04:22:43 +01:00
|
|
|
* @note Object definition file: $(XMLFILE).
|
|
|
|
* This is an automatically generated file.
|
|
|
|
* DO NOT modify manually.
|
|
|
|
*
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
2010-03-10 23:36:47 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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-03-27 04:22:43 +01:00
|
|
|
#include "$(NAMELC).h"
|
2010-05-07 03:49:38 +02:00
|
|
|
#include "uavobjectfield.h"
|
2010-03-27 04:22:43 +01:00
|
|
|
|
|
|
|
const QString $(NAME)::NAME = QString("$(NAME)");
|
|
|
|
|
2010-04-28 03:50:53 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
2010-03-29 00:22:19 +02:00
|
|
|
$(NAME)::$(NAME)(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
|
|
|
// Create fields
|
|
|
|
QList<UAVObjectField*> fields;
|
|
|
|
$(FIELDSINIT)
|
|
|
|
// 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-03-27 04:22:43 +01:00
|
|
|
UAVObject::Metadata $(NAME)::getDefaultMetadata()
|
|
|
|
{
|
|
|
|
UAVObject::Metadata metadata;
|
2010-05-20 03:01:01 +02:00
|
|
|
metadata.flightAccess = $(FLIGHTACCESS);
|
|
|
|
metadata.gcsAccess = $(GCSACCESS);
|
2010-03-27 04:22:43 +01:00
|
|
|
metadata.gcsTelemetryAcked = $(GCSTELEM_ACKED);
|
|
|
|
metadata.gcsTelemetryUpdateMode = UAVObject::$(GCSTELEM_UPDATEMODE);
|
|
|
|
metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD);
|
|
|
|
metadata.flightTelemetryAcked = $(FLIGHTTELEM_ACKED);
|
|
|
|
metadata.flightTelemetryUpdateMode = UAVObject::$(FLIGHTTELEM_UPDATEMODE);
|
|
|
|
metadata.flightTelemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD);
|
|
|
|
metadata.loggingUpdateMode = UAVObject::$(LOGGING_UPDATEMODE);
|
|
|
|
metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD);
|
|
|
|
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 $(NAME)::setDefaultFieldValues()
|
|
|
|
{
|
|
|
|
$(INITFIELDS)
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the object data fields
|
|
|
|
*/
|
2010-03-27 04:22:43 +01:00
|
|
|
$(NAME)::DataFields $(NAME)::getData()
|
|
|
|
{
|
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 $(NAME)::setData(const DataFields& data)
|
2010-03-27 04:22:43 +01:00
|
|
|
{
|
|
|
|
QMutexLocker locker(mutex);
|
2010-05-20 03:01:01 +02:00
|
|
|
// Get metadata
|
|
|
|
Metadata mdata = getMetadata();
|
|
|
|
// Update object if the access mode permits
|
|
|
|
if ( mdata.gcsAccess == ACCESS_READWRITE )
|
|
|
|
{
|
|
|
|
this->data = data;
|
|
|
|
emit objectUpdatedAuto(this); // trigger object updated event
|
|
|
|
emit objectUpdated(this);
|
|
|
|
}
|
2010-03-27 04:22:43 +01:00
|
|
|
}
|
|
|
|
|
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-03-27 04:22:43 +01:00
|
|
|
UAVDataObject* $(NAME)::clone(quint32 instID)
|
|
|
|
{
|
|
|
|
$(NAME)* obj = new $(NAME)();
|
|
|
|
obj->initialize(instID, this->getMetaObject());
|
|
|
|
return obj;
|
|
|
|
}
|
2010-05-04 03:31:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Static function to retrieve an instance of the object.
|
|
|
|
*/
|
|
|
|
$(NAME)* $(NAME)::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
|
|
|
{
|
|
|
|
return dynamic_cast<$(NAME)*>(objMngr->getObject($(NAME)::OBJID, instID));
|
|
|
|
}
|