diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp index eef9b3cd5..932028163 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.cpp +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.cpp @@ -362,13 +362,14 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in } field->elementNames = names; field->numElements = names.length(); + field->defaultElementNames = false; } else { elemAttr = elemAttributes.namedItem("elements"); if ( elemAttr.isNull() ) { - return QString("Object:field:elements attribute is missing"); + return QString("Object:field:elements and Object:field:elementnames attribute is missing"); } else { @@ -377,6 +378,7 @@ QString UAVObjectParser::processObjectFields(QDomNode& childNode, ObjectInfo* in { field->elementNames.append(QString("%1").arg(n)); } + field->defaultElementNames = true; } } // Get options attribute (only if an enum type) @@ -596,7 +598,7 @@ bool UAVObjectParser::generateFlightObject(int objIndex, const QString& template .arg( info->fields[n]->name ) ); } // Generate element names (only if field has more than one element) - if (info->fields[n]->numElements > 1) + if (info->fields[n]->numElements > 1 && !info->fields[n]->defaultElementNames) { enums.append(QString("/* Array element names for field %1 */\n").arg(info->fields[n]->name)); enums.append("typedef enum { "); @@ -728,7 +730,7 @@ bool UAVObjectParser::generateGCSObject(int objIndex, const QString& templateInc .arg( info->fields[n]->name ) ); } // Generate element names (only if field has more than one element) - if (info->fields[n]->numElements > 1) + if (info->fields[n]->numElements > 1 && !info->fields[n]->defaultElementNames) { enums.append(QString(" /* Array element names for field %1 */\n").arg(info->fields[n]->name)); enums.append(" typedef enum { "); diff --git a/ground/src/libs/uavobjgenerator/uavobjectparser.h b/ground/src/libs/uavobjgenerator/uavobjectparser.h index 8e3cee810..f6f30ce4e 100644 --- a/ground/src/libs/uavobjgenerator/uavobjectparser.h +++ b/ground/src/libs/uavobjgenerator/uavobjectparser.h @@ -66,6 +66,7 @@ public: int numElements; QStringList elementNames; QStringList options; // for enums only + bool defaultElementNames; } FieldInfo; typedef struct { diff --git a/ground/src/plugins/uavobjects/exampleobject1.h b/ground/src/plugins/uavobjects/exampleobject1.h index af05df8f9..98068b570 100644 --- a/ground/src/plugins/uavobjects/exampleobject1.h +++ b/ground/src/plugins/uavobjects/exampleobject1.h @@ -52,8 +52,6 @@ public: } __attribute__((packed)) DataFields; // Enumeration types - /* Array element names for field Field4 */ - typedef enum { FIELD4_0=0, FIELD4_1=1, FIELD4_2=2, FIELD4_3=3, } Field4Elem; /* Enumeration options for field Field8 */ typedef enum { FIELD8_OPTION1=0, FIELD8_OPTION2=1, } Field8Options; diff --git a/ground/src/plugins/uavobjects/exampleobject2.h b/ground/src/plugins/uavobjects/exampleobject2.h index fd5f1d6f8..e7c1d7940 100644 --- a/ground/src/plugins/uavobjects/exampleobject2.h +++ b/ground/src/plugins/uavobjects/exampleobject2.h @@ -48,8 +48,6 @@ public: } __attribute__((packed)) DataFields; // Enumeration types - /* Array element names for field Field4 */ - typedef enum { FIELD4_0=0, FIELD4_1=1, FIELD4_2=2, FIELD4_3=3, } Field4Elem; // Constants