mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-1538 Added description to fields in the UAVObject description files.
Descriptions can be added to fields either as attributes or child nodes. Descriptions are not mandatory at this stage. The description shows up when hovering over objects and fields in the UAVObject browser. Added example descriptions to a few fields in the UAVO descriptor files.
This commit is contained in:
parent
9fd4fb26b9
commit
ef15064b26
@ -471,7 +471,6 @@ private:
|
||||
{
|
||||
return QVariant(str.toString().at(0).toLatin1());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // FIELDTREEITEM_H
|
||||
|
@ -250,7 +250,7 @@ QVariant ArrayFieldTreeItem::data(int column) const
|
||||
.arg(m_field->getValue(i).toUInt(&ok), TreeItem::maxHexStringLength(m_field->getType()),
|
||||
16, QChar('0')).toUpper());
|
||||
}
|
||||
QString data = QString("{%1}").arg(dataString);
|
||||
QString data = QString("{%1}").arg(dataString);
|
||||
return data;
|
||||
} else {
|
||||
return QVariant();
|
||||
|
@ -184,16 +184,22 @@ public:
|
||||
switch (type) {
|
||||
case UAVObjectField::INT8:
|
||||
return 2;
|
||||
|
||||
case UAVObjectField::INT16:
|
||||
return 4;
|
||||
|
||||
case UAVObjectField::INT32:
|
||||
return 8;
|
||||
|
||||
case UAVObjectField::UINT8:
|
||||
return 2;
|
||||
|
||||
case UAVObjectField::UINT16:
|
||||
return 4;
|
||||
|
||||
case UAVObjectField::UINT32:
|
||||
return 8;
|
||||
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
@ -352,7 +358,7 @@ public:
|
||||
QVariant data(int column) const;
|
||||
|
||||
private:
|
||||
UAVObjectField*m_field;
|
||||
UAVObjectField *m_field;
|
||||
};
|
||||
|
||||
#endif // TREEITEM_H
|
||||
|
@ -245,6 +245,7 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
item->setHighlightManager(m_highlightManager);
|
||||
item->setDescription(field->getDescription());
|
||||
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
|
||||
parent->appendChild(item);
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ UAVMetaObject::UAVMetaObject(quint32 objID, const QString & name, UAVObject *par
|
||||
QStringList modesBitField;
|
||||
modesBitField << tr("FlightReadOnly") << tr("GCSReadOnly") << tr("FlightTelemetryAcked") << tr("GCSTelemetryAcked") << tr("FlightUpdatePeriodic") << tr("FlightUpdateOnChange") << tr("GCSUpdatePeriodic") << tr("GCSUpdateOnChange") << tr("LoggingUpdatePeriodic") << tr("LoggingUpdateOnChange");
|
||||
QList<UAVObjectField *> fields;
|
||||
fields.append(new UAVObjectField(tr("Modes"), tr("boolean"), UAVObjectField::BITFIELD, modesBitField, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("Flight Telemetry Update Period"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("GCS Telemetry Update Period"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("Logging Update Period"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("Modes"), tr("Metadata modes"), tr("boolean"), UAVObjectField::BITFIELD, modesBitField, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("Flight Telemetry Update Period"), tr("This is how often flight side will update telemetry data"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("GCS Telemetry Update Period"), tr("This is how often GCS will update telemetry data"), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
fields.append(new UAVObjectField(tr("Logging Update Period"), tr("This is how often logging will be updated."), tr("ms"), UAVObjectField::UINT16, 1, QStringList()));
|
||||
// Initialize parent
|
||||
UAVObject::initialize(0);
|
||||
UAVObject::initializeFields(fields, (quint8 *)&parentMetadata, sizeof(Metadata));
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <QDebug>
|
||||
#include <QtWidgets>
|
||||
|
||||
UAVObjectField::UAVObjectField(const QString & name, const QString & units, FieldType type, quint32 numElements, const QStringList & options, const QString &limits)
|
||||
UAVObjectField::UAVObjectField(const QString & name, const QString & description, const QString & units, FieldType type, quint32 numElements, const QStringList & options, const QString &limits)
|
||||
{
|
||||
QStringList elementNames;
|
||||
|
||||
@ -39,18 +39,19 @@ UAVObjectField::UAVObjectField(const QString & name, const QString & units, Fiel
|
||||
elementNames.append(QString("%1").arg(n));
|
||||
}
|
||||
// Initialize
|
||||
constructorInitialize(name, units, type, elementNames, options, limits);
|
||||
constructorInitialize(name, description, units, type, elementNames, options, limits);
|
||||
}
|
||||
|
||||
UAVObjectField::UAVObjectField(const QString & name, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits)
|
||||
UAVObjectField::UAVObjectField(const QString & name, const QString & description, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits)
|
||||
{
|
||||
constructorInitialize(name, units, type, elementNames, options, limits);
|
||||
constructorInitialize(name, description, units, type, elementNames, options, limits);
|
||||
}
|
||||
|
||||
void UAVObjectField::constructorInitialize(const QString & name, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits)
|
||||
void UAVObjectField::constructorInitialize(const QString & name, const QString & description, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits)
|
||||
{
|
||||
// Copy params
|
||||
this->name = name;
|
||||
this->description = description;
|
||||
this->units = units;
|
||||
this->type = type;
|
||||
this->options = options;
|
||||
@ -609,6 +610,11 @@ QString UAVObjectField::getName()
|
||||
return name;
|
||||
}
|
||||
|
||||
QString UAVObjectField::getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
QString UAVObjectField::getUnits()
|
||||
{
|
||||
return units;
|
||||
|
@ -52,13 +52,14 @@ public:
|
||||
int board;
|
||||
} LimitStruct;
|
||||
|
||||
UAVObjectField(const QString & name, const QString & units, FieldType type, quint32 numElements, const QStringList & options, const QString & limits = QString());
|
||||
UAVObjectField(const QString & name, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString & limits = QString());
|
||||
UAVObjectField(const QString & name, const QString & description, const QString & units, FieldType type, quint32 numElements, const QStringList & options, const QString & limits = QString());
|
||||
UAVObjectField(const QString & name, const QString & description, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString & limits = QString());
|
||||
void initialize(quint8 *data, quint32 dataOffset, UAVObject *obj);
|
||||
UAVObject *getObject();
|
||||
FieldType getType();
|
||||
QString getTypeAsString();
|
||||
QString getName();
|
||||
QString getDescription();
|
||||
QString getUnits();
|
||||
quint32 getNumElements();
|
||||
QStringList getElementNames();
|
||||
@ -91,6 +92,7 @@ signals:
|
||||
|
||||
protected:
|
||||
QString name;
|
||||
QString description;
|
||||
QString units;
|
||||
FieldType type;
|
||||
QStringList elementNames;
|
||||
@ -102,7 +104,7 @@ protected:
|
||||
UAVObject *obj;
|
||||
QMap<quint32, QList<LimitStruct> > elementLimits;
|
||||
void clear();
|
||||
void constructorInitialize(const QString & name, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits);
|
||||
void constructorInitialize(const QString & name, const QString & description, const QString & units, FieldType type, const QStringList & elementNames, const QStringList & options, const QString &limits);
|
||||
void limitsInitialize(const QString &limits);
|
||||
};
|
||||
|
||||
|
@ -259,8 +259,9 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info)
|
||||
.arg(varOptionName)
|
||||
.arg(options[m]));
|
||||
}
|
||||
finit.append(QString(" fields.append( new UAVObjectField(QString(\"%1\"), QString(\"%2\"), UAVObjectField::ENUM, %3, %4, QString(\"%5\")));\n")
|
||||
finit.append(QString(" fields.append( new UAVObjectField(QString(\"%1\"), tr(\"%2\"), QString(\"%3\"), UAVObjectField::ENUM, %4, %5, QString(\"%6\")));\n")
|
||||
.arg(info->fields[n]->name)
|
||||
.arg(info->fields[n]->description)
|
||||
.arg(info->fields[n]->units)
|
||||
.arg(varElemName)
|
||||
.arg(varOptionName)
|
||||
@ -268,8 +269,9 @@ bool UAVObjectGeneratorGCS::process_object(ObjectInfo *info)
|
||||
}
|
||||
// For all other types
|
||||
else {
|
||||
finit.append(QString(" fields.append( new UAVObjectField(QString(\"%1\"), QString(\"%2\"), UAVObjectField::%3, %4, QStringList(), QString(\"%5\")));\n")
|
||||
finit.append(QString(" fields.append( new UAVObjectField(QString(\"%1\"), tr(\"%2\"), QString(\"%3\"), UAVObjectField::%4, %5, QStringList(), QString(\"%6\")));\n")
|
||||
.arg(info->fields[n]->name)
|
||||
.arg(info->fields[n]->description)
|
||||
.arg(info->fields[n]->units)
|
||||
.arg(fieldTypeStrCPPClass[info->fields[n]->type])
|
||||
.arg(varElemName)
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "uavobjectparser.h"
|
||||
|
||||
#include <QDebug>
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -441,6 +441,21 @@ QString UAVObjectParser::processObjectFields(QDomNode & childNode, ObjectInfo *i
|
||||
field->name = name;
|
||||
}
|
||||
|
||||
// Get description attribute if any
|
||||
elemAttr = elemAttributes.namedItem("description");
|
||||
if (!elemAttr.isNull()) {
|
||||
field->description = elemAttr.nodeValue();
|
||||
} else {
|
||||
// Look for a child description node
|
||||
QDomNode node = childNode.firstChildElement("description");
|
||||
if (!node.isNull()) {
|
||||
QDomNode description = node.firstChild();
|
||||
if (!description.isNull()) {
|
||||
field->description = description.nodeValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get units attribute
|
||||
elemAttr = elemAttributes.namedItem("units");
|
||||
if (elemAttr.isNull()) {
|
||||
@ -572,6 +587,7 @@ QString UAVObjectParser::processObjectFields(QDomNode & childNode, ObjectInfo *i
|
||||
}
|
||||
// Add field to object
|
||||
info->fields.append(field);
|
||||
qDebug() << "field added" << info->name << ", description" << field->description;
|
||||
// Done
|
||||
return QString();
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
QString name;
|
||||
QString description;
|
||||
QString units;
|
||||
FieldType type;
|
||||
int numElements;
|
||||
|
@ -1,7 +1,10 @@
|
||||
<xml>
|
||||
<object name="DebugLogSettings" singleinstance="true" settings="true" category="System">
|
||||
<description>Configure On Board Logging Facilities</description>
|
||||
<field name="LoggingEnabled" units="" type="enum" elements="1" options="Disabled,OnlyWhenArmed,Always" defaultvalue="Disabled" />
|
||||
|
||||
<field name="LoggingEnabled" units="" type="enum" elements="1" options="Disabled,OnlyWhenArmed,Always" defaultvalue="Disabled">
|
||||
<description>If set to OnlyWhenArmed logs will only be saved when craft is armed. Disabled turns logging off, and Always will always log.</description>
|
||||
</field>
|
||||
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<xml>
|
||||
<object name="DebugLogStatus" singleinstance="true" settings="false" category="System">
|
||||
<description>Log Status Object, contains log partition status information</description>
|
||||
<field name="Flight" units="" type="uint16" elements="1" />
|
||||
<field name="Entry" units="" type="uint16" elements="1" />
|
||||
<field name="UsedSlots" units="" type="uint16" elements="1" />
|
||||
<field name="FreeSlots" units="" type="uint16" elements="1" />
|
||||
<field name="Flight" units="" type="uint16" elements="1" description="The current flight number (logging session)"/>
|
||||
<field name="Entry" units="" type="uint16" elements="1" description="The current log entry id"/>
|
||||
<field name="UsedSlots" units="" type="uint16" elements="1" description="Holds the total log entries saved"/>
|
||||
<field name="FreeSlots" units="" type="uint16" elements="1" description="The number of free log slots available"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user