dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
uavmetaobject.cpp
Go to the documentation of this file.
1 
16 /*
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful, but
23  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25  * for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with this program; if not, see <http://www.gnu.org/licenses/>
29  *
30  * Additional note on redistribution: The copyright and license notices above
31  * must be maintained in each individual source file that is a derivative work
32  * of this source file; otherwise redistribution is prohibited.
33  */
34 
35 #include "uavmetaobject.h"
36 #include "uavobjectfield.h"
37 
41 UAVMetaObject::UAVMetaObject(quint32 objID, const QString &name, UAVObject *parent)
42  : UAVObject(objID, true, name)
43 {
44  this->parent = parent;
45  // Setup default metadata of metaobject (can not be changed)
46  UAVObject::MetadataInitialize(ownMetadata);
47  // Setup fields
48  QStringList modesBitField;
49  modesBitField << tr("FlightReadOnly") << tr("GCSReadOnly") << tr("FlightTelemetryAcked")
50  << tr("GCSTelemetryAcked") << tr("FlightUpdatePeriodic")
51  << tr("FlightUpdateOnChange") << tr("GCSUpdatePeriodic")
52  << tr("GCSUpdateOnChange");
54  fields.append(new UAVObjectField(tr("Modes"), tr("boolean"), UAVObjectField::BITFIELD,
55  modesBitField, QStringList(), QList<int>()));
56  fields.append(new UAVObjectField(tr("Flight Telemetry Update Period"), tr("ms"),
57  UAVObjectField::UINT16, 1, QStringList(), QList<int>()));
58  fields.append(new UAVObjectField(tr("GCS Telemetry Update Period"), tr("ms"),
59  UAVObjectField::UINT16, 1, QStringList(), QList<int>()));
60  fields.append(new UAVObjectField(tr("Logging Update Period"), tr("ms"), UAVObjectField::UINT16,
61  1, QStringList(), QList<int>()));
62  // Initialize parent
64  UAVObject::initializeFields(fields, reinterpret_cast<quint8 *>(&parentMetadata),
65  sizeof(Metadata));
66  // Setup metadata of parent
67  parentMetadata = parent->getDefaultMetadata();
68 }
69 
74 {
75  return parent;
76 }
77 
82 void UAVMetaObject::setMetadata(const Metadata &mdata)
83 {
84  Q_UNUSED(mdata);
85  return; // can not update metaobject's metadata
86 }
87 
91 UAVObject::Metadata UAVMetaObject::getMetadata()
92 {
93  return ownMetadata;
94 }
95 
99 UAVObject::Metadata UAVMetaObject::getDefaultMetadata()
100 {
101  return ownMetadata;
102 }
103 
107 void UAVMetaObject::setData(const Metadata &mdata)
108 {
109  parentMetadata = mdata;
110  emit objectUpdatedAuto(this); // trigger object updated event
111  emit objectUpdated(this);
112 }
113 
117 UAVObject::Metadata UAVMetaObject::getData()
118 {
119  return parentMetadata;
120 }
void initializeFields(QList< UAVObjectField * > &fields, quint8 *data, quint32 numBytes)
Definition: uavobject.cpp:82
virtual Metadata getDefaultMetadata()=0
void objectUpdatedAuto(UAVObject *obj)
objectUpdatedAuto: triggered on "setData" only (Object data updated by changing the data structure) ...
UAVObject * getParentObject()
void setData(const Metadata &mdata)
QList< UAVObjectField * > fields
Definition: uavobject.h:253
Metadata getMetadata()
void objectUpdated(UAVObject *obj)
Signal sent whenever any field of the object is updated.
Metadata getDefaultMetadata()
void initialize(quint32 instID)
Definition: uavobject.cpp:71
UAVMetaObject(quint32 objID, const QString &name, UAVObject *parent)
void setMetadata(const Metadata &mdata)
Metadata getData()
static void MetadataInitialize(Metadata &meta)
Definition: uavobject.cpp:360