1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-642 Changed from using an xml element for category to have it defined

as an attribute on the uav object definition. This attribute is
optional. If absent no category (empty string) is assigned to the uav
object type.
Added category attribute to a small selection of uavo definition files
to test parsing.
This commit is contained in:
Fredrik Arvidsson 2012-06-20 22:23:06 +02:00
parent 3c754af484
commit b73cde1787
5 changed files with 11 additions and 20 deletions

View File

@ -198,12 +198,6 @@ QString UAVObjectParser::parseXML(QString& xml, QString& filename)
descriptionFound = true;
}
else if ( childNode.nodeName().compare(QString("category")) == 0 ) {
QString status = processObjectCategory(childNode, &info->category);
if (!status.isNull())
return status;
}
else if (!childNode.isComment()) {
return QString("Unknown object element");
}
@ -505,6 +499,13 @@ QString UAVObjectParser::processObjectAttributes(QDomNode& node, ObjectInfo* inf
info->name = attr.nodeValue();
info->namelc = attr.nodeValue().toLower();
// Get category attribute if present
attr = attributes.namedItem("category");
if ( !attr.isNull() )
{
info->category = attr.nodeValue();
}
// Get singleinstance attribute
attr = attributes.namedItem("singleinstance");
if ( attr.isNull() )
@ -546,12 +547,3 @@ QString UAVObjectParser::processObjectDescription(QDomNode& childNode, QString *
description->append(childNode.firstChild().nodeValue());
return QString();
}
/**
* Process the category field from the XML file
*/
QString UAVObjectParser::processObjectCategory(QDomNode& childNode, QString * category)
{
category->append(childNode.firstChild().nodeValue());
return QString();
}

View File

@ -1,5 +1,5 @@
<xml>
<object name="BaroAltitude" singleinstance="true" settings="false">
<object name="BaroAltitude" singleinstance="true" settings="false" category="Sensors/Altitude">
<description>The raw data from the barometric sensor with pressure, temperature and altitude estimate.</description>
<field name="Altitude" units="m" type="float" elements="1"/>
<field name="Temperature" units="C" type="float" elements="1"/>

View File

@ -1,6 +1,5 @@
<xml>
<object name="Gyros" singleinstance="true" settings="false">
<category>Sensors</category>
<object name="Gyros" singleinstance="true" settings="false" category="Sensors">
<description>The gyro data.</description>
<field name="x" units="deg/s" type="float" elements="1"/>
<field name="y" units="deg/s" type="float" elements="1"/>

View File

@ -1,5 +1,5 @@
<xml>
<object name="Magnetometer" singleinstance="true" settings="false">
<object name="Magnetometer" singleinstance="true" settings="false" category="Sensors">
<description>The mag data.</description>
<field name="x" units="mGa" type="float" elements="1"/>
<field name="y" units="mGa" type="float" elements="1"/>

View File

@ -1,5 +1,5 @@
<xml>
<object name="SonarAltitude" singleinstance="true" settings="false">
<object name="SonarAltitude" singleinstance="true" settings="false" category="Sensors/Altitude">
<description>The raw data from the ultrasound sonar sensor with altitude estimate.</description>
<field name="Altitude" units="m" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>