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:
parent
9d7d297446
commit
df573fdad5
@ -173,7 +173,7 @@ bool UAVObjectGenerator::processAll()
|
|||||||
// Update strings for the object initialization
|
// Update strings for the object initialization
|
||||||
objInc.append("#include \"" + namelc + ".h\"\n");
|
objInc.append("#include \"" + namelc + ".h\"\n");
|
||||||
flightObjInit.append(" " + name + "Initialize();\n");
|
flightObjInit.append(" " + name + "Initialize();\n");
|
||||||
gcsObjInit.append(" objMngr->registerObject( new " + name + "() );");
|
gcsObjInit.append(" objMngr->registerObject( new " + name + "() );\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ void UAVObjectParser::calculateID(ObjectInfo* info)
|
|||||||
// Hash object name
|
// Hash object name
|
||||||
quint32 hash = updateHash(info->name, 0);
|
quint32 hash = updateHash(info->name, 0);
|
||||||
// Hash object attributes
|
// Hash object attributes
|
||||||
hash = updateHash(info->type, hash);
|
hash = updateHash(info->isSettings, hash);
|
||||||
hash = updateHash(info->isSingleInst, hash);
|
hash = updateHash(info->isSingleInst, hash);
|
||||||
// Hash field information
|
// Hash field information
|
||||||
for (int n = 0; n < info->fields.length(); ++n)
|
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");
|
return QString("Object:singleinstance attribute value is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get type attribute
|
// Get settings attribute
|
||||||
attr = attributes.namedItem("type");
|
attr = attributes.namedItem("settings");
|
||||||
if ( attr.isNull() )
|
if ( attr.isNull() )
|
||||||
{
|
{
|
||||||
return QString("Object:type attribute is missing");
|
return QString("Object:settings attribute is missing");
|
||||||
}
|
}
|
||||||
else
|
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
|
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
|
// Done
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
@ -455,9 +460,12 @@ void UAVObjectParser::replaceCommonTags(QString& out, ObjectInfo* info)
|
|||||||
out.replace(QString("$(NAMEUC)"), info->name.toUpper());
|
out.replace(QString("$(NAMEUC)"), info->name.toUpper());
|
||||||
// Replace $(OBJID) tag
|
// Replace $(OBJID) tag
|
||||||
out.replace(QString("$(OBJID)"), QString().setNum(info->id));
|
out.replace(QString("$(OBJID)"), QString().setNum(info->id));
|
||||||
// Replace $(SINGLEINST) tag
|
// Replace $(ISSINGLEINST) tag
|
||||||
value = boolToString( info->isSingleInst );
|
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
|
// Replace $(FLIGHTTELEM_ACKED) tag
|
||||||
value = boolToString( info->flightTelemetryAcked );
|
value = boolToString( info->flightTelemetryAcked );
|
||||||
out.replace(QString("$(FLIGHTTELEM_ACKED)"), value);
|
out.replace(QString("$(FLIGHTTELEM_ACKED)"), value);
|
||||||
|
@ -37,11 +37,6 @@ class UAVObjectParser
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Types
|
// Types
|
||||||
typedef enum {
|
|
||||||
OBJTYPE_DATA = 0,
|
|
||||||
OBJTYPE_SETTINGS
|
|
||||||
} ObjectType;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FIELDTYPE_INT8 = 0,
|
FIELDTYPE_INT8 = 0,
|
||||||
FIELDTYPE_INT16,
|
FIELDTYPE_INT16,
|
||||||
@ -70,8 +65,8 @@ public:
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
QString name;
|
QString name;
|
||||||
quint32 id;
|
quint32 id;
|
||||||
ObjectType type;
|
|
||||||
bool isSingleInst;
|
bool isSingleInst;
|
||||||
|
bool isSettings;
|
||||||
bool flightTelemetryAcked;
|
bool flightTelemetryAcked;
|
||||||
UpdateMode flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */
|
UpdateMode flightTelemetryUpdateMode; /** Update mode used by the autopilot (UpdateMode) */
|
||||||
int flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */
|
int flightTelemetryUpdatePeriod; /** Update period used by the autopilot (only if telemetry mode is PERIODIC) */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<xml>
|
<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="field1" units="unit1" type="int8" elements="1"/>
|
||||||
<field name="field2" units="unit2" type="int16" elements="1"/>
|
<field name="field2" units="unit2" type="int16" elements="1"/>
|
||||||
<field name="field3" units="unit3" type="float" elements="4"/>
|
<field name="field3" units="unit3" type="float" elements="4"/>
|
||||||
|
11
ground/src/shared/uavobjectdefinition/examplesettings.xml
Normal file
11
ground/src/shared/uavobjectdefinition/examplesettings.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user