10 connect(objMngr, SIGNAL(newInstance(
UAVObject *)),
this, SLOT(newInstance(
UAVObject *)));
13 obj1 =
new ExampleObject1();
14 connect(obj1, SIGNAL(objectUpdated(
UAVObject *)),
this, SLOT(objectUpdated(
UAVObject *)));
15 connect(obj1, SIGNAL(objectUpdatedAuto(
UAVObject *)),
this,
17 connect(obj1, SIGNAL(objectUpdatedManual(
UAVObject *)),
this,
19 connect(obj1, SIGNAL(objectUnpacked(
UAVObject *)),
this, SLOT(objectUnpacked(
UAVObject *)));
20 connect(obj1, SIGNAL(updateRequested(
UAVObject *)),
this, SLOT(updateRequested(
UAVObject *)));
25 connect(timer, SIGNAL(timeout()),
this, SLOT(runTest()));
29 void UAVObjectsTest::objectUpdated(
UAVObject *obj)
31 sout << QString(
"[Object Updated]\n%1").arg(obj->
toString());
34 void UAVObjectsTest::objectUpdatedAuto(
UAVObject *obj)
36 sout << QString(
"[Object Updated AUTO]\n%1").arg(obj->
toString());
39 void UAVObjectsTest::objectUpdatedManual(
UAVObject *obj)
41 sout << QString(
"[Object Updated MANUAL]\n%1").arg(obj->
toString());
44 void UAVObjectsTest::objectUnpacked(
UAVObject *obj)
46 sout << QString(
"[Object Updated UNPACKED]\n%1").arg(obj->
toString());
49 void UAVObjectsTest::updateRequested(
UAVObject *obj)
51 sout << QString(
"[Object Update Requested]\n%1").arg(obj->
toString());
54 void UAVObjectsTest::newObject(
UAVObject *obj)
56 sout << QString(
"[New object]\n%1").arg(obj->
toString());
59 void UAVObjectsTest::newInstance(
UAVObject *obj)
61 sout << QString(
"[New instance]\n%1").arg(obj->
toString());
64 void UAVObjectsTest::runTest()
68 ExampleObject1 *obj2 =
new ExampleObject1();
72 ExampleObject1::DataFields
data = obj1->getData();
82 UAVObject::Metadata mdata = obj1->getMetadata();
83 mdata.gcsTelemetryUpdatePeriod = 123;
84 obj1->setMetadata(mdata);
86 sout <<
"[Meta of obj1]\n";
87 sout << obj1->getMetaObject()->toString();
88 sout <<
"[Meta of obj2]\n";
89 sout << obj2->getMetaObject()->toString();
96 quint8 *buf =
new quint8[obj1->getNumBytes()];
101 data.Field4[0] = 40.1;
102 data.Field4[1] = 40.2;
103 data.Field4[2] = 40.3;
112 data.Field4[0] = 40.1;
113 data.Field4[1] = 40.2;
114 data.Field4[2] = 40.3;
120 for (
int n = 0;
n < objs.length(); ++
n) {
121 sout <<
"[Printing object instances]\n";
122 sout << objs[
n]->toString();
126 QString objname(
"ExampleObject1");
130 UAVObjectFieldInt8 *fieldint8 =
dynamic_cast<UAVObjectFieldInt8 *
>(fields[0]);
131 if (fieldint8 != NULL) {
132 fieldint8->setValue(10);
133 qint8 value = fieldint8->getValue();
137 UAVObjectFieldEnum *fieldenum =
dynamic_cast<UAVObjectFieldEnum *
>(fields[7]);
138 if (fieldenum != NULL) {
139 QStringList options = fieldenum->getOptions();
140 fieldenum->setSelected(options[1]);
141 QString selected = fieldenum->getSelected();
bool registerObject(UAVDataObject *obj)
QList< UAVObjectField * > getFields()
virtual UAVDataObject * clone(quint32 instID=0)=0
UAVObject * getObject(const QString &name, quint32 instId=0)