diff --git a/ground/src/libs/uavobjgenerator/uavobjectgenerator.cpp b/ground/src/libs/uavobjgenerator/uavobjectgenerator.cpp index f02bf9216..52541b1da 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectgenerator.cpp +++ b/ground/src/libs/uavobjgenerator/uavobjectgenerator.cpp @@ -173,7 +173,7 @@ bool UAVObjectGenerator::processAll() // Update strings for the object initialization objInc.append("#include \"" + namelc + ".h\"\n"); flightObjInit.append(" " + name + "Initialize();\n"); - gcsObjInit.append(" objMngr->registerObject( new " + name + "() );"); + gcsObjInit.append(" objMngr->registerObject( new " + name + "() );\n"); } } diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp index 5965c045b..4ffb1b3e1 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp @@ -188,7 +188,7 @@ void UAVObjectParser::calculateID(ObjectInfo* info) // Hash object name quint32 hash = updateHash(info->name, 0); // Hash object attributes - hash = updateHash(info->type, hash); + hash = updateHash(info->isSettings, hash); hash = updateHash(info->isSingleInst, hash); // Hash field information for (int n = 0; n < info->fields.length(); ++n) @@ -413,27 +413,32 @@ QString UAVObjectParser::processObjectAttributes(QDomNode& node, ObjectInfo* inf return QString("Object:singleinstance attribute value is invalid"); } } - // Get type attribute - attr = attributes.namedItem("type"); + // Get settings attribute + attr = attributes.namedItem("settings"); if ( attr.isNull() ) { - return QString("Object:type attribute is missing"); + return QString("Object:settings attribute is missing"); } else { - if ( attr.nodeValue().compare(QString("data")) == 0 ) + if ( attr.nodeValue().compare(QString("true")) == 0 ) { - info->type = OBJTYPE_DATA; + info->isSettings = true; } - else if ( attr.nodeValue().compare(QString("settings")) == 0 ) + else if ( attr.nodeValue().compare(QString("false")) == 0 ) { - info->type = OBJTYPE_SETTINGS; + info->isSettings = false; } else { - return QString("Object:type attribute value is invalid"); + return QString("Object:settings attribute value is invalid"); } } + // Settings objects can only have a single instance + if ( info->isSettings && !info->isSingleInst ) + { + return QString("Object: Settings objects can not have multiple instances"); + } // Done return QString(); } @@ -455,9 +460,12 @@ void UAVObjectParser::replaceCommonTags(QString& out, ObjectInfo* info) out.replace(QString("$(NAMEUC)"), info->name.toUpper()); // Replace $(OBJID) tag out.replace(QString("$(OBJID)"), QString().setNum(info->id)); - // Replace $(SINGLEINST) tag + // Replace $(ISSINGLEINST) tag value = boolToString( info->isSingleInst ); - out.replace(QString("$(SINGLEINST)"), value); + out.replace(QString("$(ISSINGLEINST)"), value); + // Replace $(ISSETTINGS) tag + value = boolToString( info->isSettings ); + out.replace(QString("$(ISSETTINGS)"), value); // Replace $(FLIGHTTELEM_ACKED) tag value = boolToString( info->flightTelemetryAcked ); out.replace(QString("$(FLIGHTTELEM_ACKED)"), value); diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.h b/ground/src/libs/uavobjgenerator/uavobjectparser.h index cb322439e..caeeb7e30 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.h +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.h @@ -37,11 +37,6 @@ class UAVObjectParser { public: // Types - typedef enum { - OBJTYPE_DATA = 0, - OBJTYPE_SETTINGS - } ObjectType; - typedef enum { FIELDTYPE_INT8 = 0, FIELDTYPE_INT16, @@ -70,8 +65,8 @@ public: typedef struct { QString name; quint32 id; - ObjectType type; bool isSingleInst; + bool isSettings; bool flightTelemetryAcked; UpdateMode flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */ int flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */ diff --git a/ground/src/shared/uavobjectdefinition/exampleobject.xml b/ground/src/shared/uavobjectdefinition/exampleobject.xml index 4eb11d6ed..2221f109d 100644 --- a/ground/src/shared/uavobjectdefinition/exampleobject.xml +++ b/ground/src/shared/uavobjectdefinition/exampleobject.xml @@ -1,5 +1,5 @@ - + diff --git a/ground/src/shared/uavobjectdefinition/examplesettings.xml b/ground/src/shared/uavobjectdefinition/examplesettings.xml new file mode 100644 index 000000000..d454ef8a7 --- /dev/null +++ b/ground/src/shared/uavobjectdefinition/examplesettings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file