Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / plugins / uavobjects / uavmetaobject.cpp
blob985eaffe26ecc097b217b690fdad6436a97e89c4
1 /**
2 ******************************************************************************
4 * @file uavmetaobject.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @see The GNU Public License (GPL) Version 3
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup UAVObjectsPlugin UAVObjects Plugin
10 * @{
11 * @brief The UAVUObjects GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "uavmetaobject.h"
29 #include "uavobjectfield.h"
31 /**
32 * Constructor
34 UAVMetaObject::UAVMetaObject(quint32 objID, const QString & name, UAVObject *parent) :
35 UAVObject(objID, true, name)
37 this->parent = parent;
38 // Setup default metadata of metaobject (can not be changed)
39 UAVObject::MetadataInitialize(ownMetadata);
40 // Setup fields
41 QStringList modesBitField;
42 modesBitField << tr("FlightReadOnly") << tr("GCSReadOnly") << tr("FlightTelemetryAcked") << tr("GCSTelemetryAcked") << tr("FlightUpdatePeriodic") << tr("FlightUpdateOnChange") << tr("GCSUpdatePeriodic") << tr("GCSUpdateOnChange") << tr("LoggingUpdatePeriodic") << tr("LoggingUpdateOnChange");
43 QList<UAVObjectField *> fields;
44 fields.append(new UAVObjectField(tr("Modes"), tr("Metadata modes"), tr("boolean"), UAVObjectField::BITFIELD, modesBitField, QStringList()));
45 fields.append(new UAVObjectField(tr("Flight Telemetry Update Period"), tr("This is how often flight side will update telemetry data"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
46 fields.append(new UAVObjectField(tr("GCS Telemetry Update Period"), tr("This is how often GCS will update telemetry data"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
47 fields.append(new UAVObjectField(tr("Logging Update Period"), tr("This is how often logging will be updated."), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
48 // Initialize parent
49 UAVObject::initialize(0);
50 UAVObject::initializeFields(fields, (quint8 *)&parentMetadata, sizeof(Metadata));
51 // Setup metadata of parent
52 parentMetadata = parent->getDefaultMetadata();
55 /**
56 * Get the parent object
58 UAVObject *UAVMetaObject::getParentObject()
60 return parent;
63 /**
64 * Set the metadata of the metaobject, this function will
65 * do nothing since metaobjects have read-only metadata.
67 void UAVMetaObject::setMetadata(const Metadata & mdata)
69 Q_UNUSED(mdata);
70 // can not update metaobject's metadata
73 /**
74 * Get the metadata of the metaobject
76 UAVObject::Metadata UAVMetaObject::getMetadata()
78 return ownMetadata;
81 /**
82 * Get the default metadata
84 UAVObject::Metadata UAVMetaObject::getDefaultMetadata()
86 return ownMetadata;
89 /**
90 * Set the metadata held by the metaobject
92 void UAVMetaObject::setData(const Metadata & mdata)
94 QMutexLocker locker(mutex);
96 parentMetadata = mdata;
97 emit objectUpdatedAuto(this); // trigger object updated event
98 emit objectUpdated(this);
102 * Get the metadata held by the metaobject
104 UAVObject::Metadata UAVMetaObject::getData()
106 QMutexLocker locker(mutex);
108 return parentMetadata;
111 bool UAVMetaObject::isMetaDataObject()
113 return true;