1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

GCS/UAVObjectGenerator: Added support for settings objects

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@406 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-03-28 22:19:32 +00:00 committed by vassilis
parent 9d7d297446
commit df573fdad5
5 changed files with 33 additions and 19 deletions

View File

@ -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");
}
}

View File

@ -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);

View File

@ -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) */

View File

@ -1,5 +1,5 @@
<xml>
<object name="ExampleObject" singleinstance="false" type="data">
<object name="ExampleObject" singleinstance="false" settings="false">
<field name="field1" units="unit1" type="int8" elements="1"/>
<field name="field2" units="unit2" type="int16" elements="1"/>
<field name="field3" units="unit3" type="float" elements="4"/>

View File

@ -0,0 +1,11 @@
<xml>
<object name="ExampleSettings" singleinstance="true" settings="true">
<field name="setting1" units="unit1" type="int8" elements="1"/>
<field name="setting2" units="unit2" type="int16" elements="1"/>
<field name="setting3" units="unit3" type="int8" elements="1"/>
<field name="setting4" units="unit4" type="int32" elements="1"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>
</object>
</xml>