mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Merge remote-tracking branch 'origin/next' into laurent/OP-1337_French_translations_updates
This commit is contained in:
commit
c67310509e
@ -52,11 +52,13 @@ class FieldTreeItem : public TreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
FieldTreeItem(int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_index(index) {}
|
||||
FieldTreeItem(int index, const QList<QVariant> &data, UAVObjectField *field, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_index(index), m_field(field)
|
||||
{}
|
||||
|
||||
FieldTreeItem(int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_index(index) {}
|
||||
FieldTreeItem(int index, const QVariant &data, UAVObjectField *field, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_index(index), m_field(field)
|
||||
{}
|
||||
|
||||
bool isEditable()
|
||||
{
|
||||
@ -67,19 +69,27 @@ public:
|
||||
virtual QVariant getEditorValue(QWidget *editor) = 0;
|
||||
virtual void setEditorValue(QWidget *editor, QVariant value) = 0;
|
||||
virtual void apply() {}
|
||||
virtual bool isKnown()
|
||||
{
|
||||
return parent()->isKnown();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
int m_index;
|
||||
UAVObjectField *m_field;
|
||||
};
|
||||
|
||||
class EnumFieldTreeItem : public FieldTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EnumFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_enumOptions(field->getOptions()), m_field(field) {}
|
||||
FieldTreeItem(index, data, field, parent), m_enumOptions(field->getOptions())
|
||||
{}
|
||||
|
||||
EnumFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_enumOptions(field->getOptions()), m_field(field) {}
|
||||
FieldTreeItem(index, data, field, parent), m_enumOptions(field->getOptions())
|
||||
{}
|
||||
|
||||
void setData(QVariant value, int column)
|
||||
{
|
||||
@ -148,20 +158,19 @@ public:
|
||||
|
||||
private:
|
||||
QStringList m_enumOptions;
|
||||
UAVObjectField *m_field;
|
||||
};
|
||||
|
||||
class IntFieldTreeItem : public FieldTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
IntFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{
|
||||
setMinMaxValues();
|
||||
}
|
||||
|
||||
IntFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{
|
||||
setMinMaxValues();
|
||||
}
|
||||
@ -246,7 +255,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
int m_minValue;
|
||||
int m_maxValue;
|
||||
};
|
||||
@ -255,10 +263,10 @@ class FloatFieldTreeItem : public FieldTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, bool scientific = false, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific) {}
|
||||
FieldTreeItem(index, data, field, parent), m_useScientificNotation(scientific) {}
|
||||
|
||||
FloatFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, bool scientific = false, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field), m_useScientificNotation(scientific) {}
|
||||
FieldTreeItem(index, data, field, parent), m_useScientificNotation(scientific) {}
|
||||
|
||||
void setData(QVariant value, int column)
|
||||
{
|
||||
@ -324,7 +332,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
bool m_useScientificNotation;
|
||||
};
|
||||
|
||||
@ -332,11 +339,11 @@ class HexFieldTreeItem : public FieldTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
HexFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{}
|
||||
|
||||
HexFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{}
|
||||
|
||||
QWidget *createEditor(QWidget *parent)
|
||||
@ -385,8 +392,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
|
||||
QVariant toHexString(QVariant value)
|
||||
{
|
||||
QString str;
|
||||
@ -407,11 +412,11 @@ class CharFieldTreeItem : public FieldTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CharFieldTreeItem(UAVObjectField *field, int index, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{}
|
||||
|
||||
CharFieldTreeItem(UAVObjectField *field, int index, const QVariant &data, TreeItem *parent = 0) :
|
||||
FieldTreeItem(index, data, parent), m_field(field)
|
||||
FieldTreeItem(index, data, field, parent)
|
||||
{}
|
||||
|
||||
QWidget *createEditor(QWidget *parent)
|
||||
@ -460,8 +465,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
|
||||
QVariant toChar(QVariant value)
|
||||
{
|
||||
return value.toChar();
|
||||
|
@ -88,6 +88,9 @@ private:
|
||||
class TreeItem : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const int TITLE_COLUMN = 0;
|
||||
static const int DATA_COLUMN = 1;
|
||||
|
||||
TreeItem(const QList<QVariant> &data, TreeItem *parent = 0);
|
||||
TreeItem(const QVariant &data, TreeItem *parent = 0);
|
||||
virtual ~TreeItem();
|
||||
@ -205,14 +208,31 @@ public:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void updateIsKnown(bool isKnown)
|
||||
{
|
||||
if (isKnown != this->isKnown()) {
|
||||
m_changed = false;
|
||||
foreach(TreeItem * child, m_children) {
|
||||
child->updateIsKnown(isKnown);
|
||||
}
|
||||
emit updateIsKnown(this);
|
||||
}
|
||||
}
|
||||
virtual bool isKnown()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
signals:
|
||||
void updateHighlight(TreeItem *);
|
||||
void updateHighlight(TreeItem *item);
|
||||
void updateIsKnown(TreeItem *item);
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
static int m_highlightTimeMs;
|
||||
QList<TreeItem *> m_children;
|
||||
|
||||
// m_data contains: [0] property name, [1] value, [2] unit
|
||||
QList<QVariant> m_data;
|
||||
QString m_description;
|
||||
@ -221,9 +241,6 @@ private:
|
||||
bool m_changed;
|
||||
QTime m_highlightExpires;
|
||||
HighLightManager *m_highlightManager;
|
||||
static int m_highlightTimeMs;
|
||||
public:
|
||||
static const int dataColumn = 1;
|
||||
};
|
||||
|
||||
class DataObjectTreeItem;
|
||||
@ -265,18 +282,25 @@ private:
|
||||
class ObjectTreeItem : public TreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ObjectTreeItem(const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_obj(0) {}
|
||||
ObjectTreeItem(const QVariant &data, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_obj(0) {}
|
||||
void setObject(UAVObject *obj)
|
||||
ObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_obj(object)
|
||||
{
|
||||
m_obj = obj; setDescription(obj->getDescription());
|
||||
setDescription(m_obj->getDescription());
|
||||
}
|
||||
ObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parent = 0) :
|
||||
TreeItem(data, parent), m_obj(object)
|
||||
{
|
||||
setDescription(m_obj->getDescription());
|
||||
}
|
||||
inline UAVObject *object()
|
||||
{
|
||||
return m_obj;
|
||||
}
|
||||
bool isKnown()
|
||||
{
|
||||
return !m_obj->isSettingsObject() || m_obj->isKnown();
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObject *m_obj;
|
||||
};
|
||||
@ -284,25 +308,27 @@ private:
|
||||
class MetaObjectTreeItem : public ObjectTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetaObjectTreeItem(UAVObject *obj, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, parent)
|
||||
MetaObjectTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, object, parent)
|
||||
{}
|
||||
MetaObjectTreeItem(UAVObject *object, const QVariant &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, object, parent)
|
||||
{}
|
||||
|
||||
bool isKnown()
|
||||
{
|
||||
setObject(obj);
|
||||
}
|
||||
MetaObjectTreeItem(UAVObject *obj, const QVariant &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, parent)
|
||||
{
|
||||
setObject(obj);
|
||||
return parent()->isKnown();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class DataObjectTreeItem : public ObjectTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataObjectTreeItem(const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, parent) {}
|
||||
DataObjectTreeItem(const QVariant &data, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, parent) {}
|
||||
DataObjectTreeItem(const QList<QVariant> &data, UAVObject *object, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, object, parent) {}
|
||||
DataObjectTreeItem(const QVariant &data, UAVObject *object, TreeItem *parent = 0) :
|
||||
ObjectTreeItem(data, object, parent) {}
|
||||
virtual void apply()
|
||||
{
|
||||
foreach(TreeItem * child, treeChildren()) {
|
||||
@ -328,16 +354,12 @@ public:
|
||||
class InstanceTreeItem : public DataObjectTreeItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InstanceTreeItem(UAVObject *obj, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
DataObjectTreeItem(data, parent)
|
||||
{
|
||||
setObject(obj);
|
||||
}
|
||||
InstanceTreeItem(UAVObject *obj, const QVariant &data, TreeItem *parent = 0) :
|
||||
DataObjectTreeItem(data, parent)
|
||||
{
|
||||
setObject(obj);
|
||||
}
|
||||
InstanceTreeItem(UAVObject *object, const QList<QVariant> &data, TreeItem *parent = 0) :
|
||||
DataObjectTreeItem(data, object, parent)
|
||||
{}
|
||||
InstanceTreeItem(UAVObject *object, const QVariant &data, TreeItem *parent = 0) :
|
||||
DataObjectTreeItem(data, object, parent)
|
||||
{}
|
||||
virtual void apply()
|
||||
{
|
||||
TreeItem::apply();
|
||||
@ -356,6 +378,10 @@ public:
|
||||
ArrayFieldTreeItem(UAVObjectField *field, const QVariant &data, TreeItem *parent = 0) : TreeItem(data, parent), m_field(field)
|
||||
{}
|
||||
QVariant data(int column) const;
|
||||
bool isKnown()
|
||||
{
|
||||
return parent()->isKnown();
|
||||
}
|
||||
|
||||
private:
|
||||
UAVObjectField *m_field;
|
||||
|
@ -46,6 +46,7 @@ void UAVObjectBrowser::loadConfiguration(IUAVGadgetConfiguration *config)
|
||||
UAVObjectBrowserConfiguration *m = qobject_cast<UAVObjectBrowserConfiguration *>(config);
|
||||
|
||||
m_config = m;
|
||||
m_widget->setUnknownObjectColor(m->unknownObjectColor());
|
||||
m_widget->setRecentlyUpdatedColor(m->recentlyUpdatedColor());
|
||||
m_widget->setManuallyChangedColor(m->manuallyChangedColor());
|
||||
m_widget->setRecentlyUpdatedTimeout(m->recentlyUpdatedTimeout());
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_unknownObjectColor(QColor(Qt::gray)),
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
m_manuallyChangedColor(QColor(230, 230, 255)),
|
||||
m_onlyHilightChangedValues(false),
|
||||
@ -40,6 +41,7 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QS
|
||||
{
|
||||
// if a saved configuration exists load it
|
||||
if (qSettings != 0) {
|
||||
m_unknownObjectColor = qSettings->value("unknownObjectColor", QVariant(QColor(Qt::gray))).value<QColor>();
|
||||
m_useCategorizedView = qSettings->value("CategorizedView").toBool();
|
||||
m_useScientificView = qSettings->value("ScientificView").toBool();
|
||||
m_showMetaData = qSettings->value("showMetaData").toBool();
|
||||
@ -64,6 +66,7 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
|
||||
m->m_useScientificView = m_useScientificView;
|
||||
m->m_splitterState = m_splitterState;
|
||||
m->m_showMetaData = m_showMetaData;
|
||||
m->m_unknownObjectColor = m_unknownObjectColor;
|
||||
m->m_showDescription = m_showDescription;
|
||||
return m;
|
||||
}
|
||||
@ -74,6 +77,7 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
|
||||
*/
|
||||
void UAVObjectBrowserConfiguration::saveConfig(QSettings *qSettings) const
|
||||
{
|
||||
qSettings->setValue("unknownObjectColor", m_unknownObjectColor);
|
||||
qSettings->setValue("recentlyUpdatedColor", m_recentlyUpdatedColor);
|
||||
qSettings->setValue("manuallyChangedColor", m_manuallyChangedColor);
|
||||
qSettings->setValue("recentlyUpdatedTimeout", m_recentlyUpdatedTimeout);
|
||||
|
@ -34,7 +34,8 @@
|
||||
using namespace Core;
|
||||
|
||||
class UAVObjectBrowserConfiguration : public IUAVGadgetConfiguration {
|
||||
Q_OBJECT Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRecentlyUpdatedColor)
|
||||
Q_OBJECT Q_PROPERTY(QColor m_unknownObjectColor READ unknownObjectColor WRITE setUnknownObjectColor)
|
||||
Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRecentlyUpdatedColor)
|
||||
Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor)
|
||||
Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout)
|
||||
Q_PROPERTY(bool m_onlyHilightChangedValues READ onlyHighlightChangedValues WRITE setOnlyHighlightChangedValues)
|
||||
@ -49,6 +50,10 @@ public:
|
||||
void saveConfig(QSettings *settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
QColor unknownObjectColor() const
|
||||
{
|
||||
return m_unknownObjectColor;
|
||||
}
|
||||
QColor recentlyUpdatedColor() const
|
||||
{
|
||||
return m_recentlyUpdatedColor;
|
||||
@ -90,6 +95,10 @@ public:
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void setUnknownObjectColor(QColor color)
|
||||
{
|
||||
m_unknownObjectColor = color;
|
||||
}
|
||||
void setRecentlyUpdatedColor(QColor color)
|
||||
{
|
||||
m_recentlyUpdatedColor = color;
|
||||
@ -129,6 +138,7 @@ public slots:
|
||||
}
|
||||
|
||||
private:
|
||||
QColor m_unknownObjectColor;
|
||||
QColor m_recentlyUpdatedColor;
|
||||
QColor m_manuallyChangedColor;
|
||||
bool m_onlyHilightChangedValues;
|
||||
|
@ -50,6 +50,7 @@ QWidget *UAVObjectBrowserOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
m_page->recentlyUpdatedButton->setColor(m_config->recentlyUpdatedColor());
|
||||
m_page->manuallyChangedButton->setColor(m_config->manuallyChangedColor());
|
||||
m_page->unknownButton->setColor(m_config->unknownObjectColor());
|
||||
m_page->recentlyUpdatedTimeoutSpinBox->setValue(m_config->recentlyUpdatedTimeout());
|
||||
m_page->hilightBox->setChecked(m_config->onlyHighlightChangedValues());
|
||||
|
||||
@ -58,6 +59,7 @@ QWidget *UAVObjectBrowserOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
void UAVObjectBrowserOptionsPage::apply()
|
||||
{
|
||||
m_config->setUnknownObjectColor(m_page->unknownButton->color());
|
||||
m_config->setRecentlyUpdatedColor(m_page->recentlyUpdatedButton->color());
|
||||
m_config->setManuallyChangedColor(m_page->manuallyChangedButton->color());
|
||||
m_config->setRecentlyUpdatedTimeout(m_page->recentlyUpdatedTimeoutSpinBox->value());
|
||||
|
@ -14,7 +14,16 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -33,12 +42,21 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>194</height>
|
||||
<width>507</width>
|
||||
<height>178</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
@ -48,6 +66,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Utils::QtColorButton" name="recentlyUpdatedButton">
|
||||
<property name="sizePolicy">
|
||||
@ -67,10 +111,33 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Manually changed color:</string>
|
||||
<string>Recently updated timeout (ms):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="hilightBox">
|
||||
<property name="text">
|
||||
<string>Only highlight nodes when value actually changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="recentlyUpdatedTimeoutSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -93,61 +160,38 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Recently updated timeout (ms):</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="recentlyUpdatedTimeoutSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>100</number>
|
||||
<string>Manually changed color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="hilightBox">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Only highlight nodes when value actually changes</string>
|
||||
<string>Unknown object color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<item row="3" column="1">
|
||||
<widget class="Utils::QtColorButton" name="unknownButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>64</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -162,6 +206,14 @@
|
||||
<header>utils/qtcolorbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>recentlyUpdatedButton</tabstop>
|
||||
<tabstop>manuallyChangedButton</tabstop>
|
||||
<tabstop>unknownButton</tabstop>
|
||||
<tabstop>recentlyUpdatedTimeoutSpinBox</tabstop>
|
||||
<tabstop>hilightBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -51,11 +51,11 @@ UAVObjectBrowserWidget::UAVObjectBrowserWidget(QWidget *parent) : QWidget(parent
|
||||
m_model = new UAVObjectTreeModel();
|
||||
m_browser->treeView->setModel(m_model);
|
||||
m_browser->treeView->setColumnWidth(0, 300);
|
||||
|
||||
BrowserItemDelegate *m_delegate = new BrowserItemDelegate();
|
||||
m_browser->treeView->setItemDelegate(m_delegate);
|
||||
m_browser->treeView->setEditTriggers(QAbstractItemView::AllEditTriggers);
|
||||
m_browser->treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
m_browser->splitter->setChildrenCollapsible(false);
|
||||
m_mustacheTemplate = loadFileIntoString(QString(":/uavobjectbrowser/resources/uavodescription.mustache"));
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
showDescription(m_viewoptions->cbDescription->isChecked());
|
||||
@ -119,6 +119,7 @@ void UAVObjectBrowserWidget::categorize(bool categorize)
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
m_model->setOnlyHilightChangedValues(m_onlyHilightChangedValues);
|
||||
m_model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
m_browser->treeView->setModel(m_model);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
@ -134,6 +135,7 @@ void UAVObjectBrowserWidget::useScientificNotation(bool scientific)
|
||||
m_model->setRecentlyUpdatedColor(m_recentlyUpdatedColor);
|
||||
m_model->setManuallyChangedColor(m_manuallyChangedColor);
|
||||
m_model->setRecentlyUpdatedTimeout(m_recentlyUpdatedTimeout);
|
||||
m_model->setUnknowObjectColor(m_unknownObjectColor);
|
||||
m_browser->treeView->setModel(m_model);
|
||||
showMetaData(m_viewoptions->cbMetaData->isChecked());
|
||||
connect(m_browser->treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
|
||||
|
@ -44,21 +44,31 @@ class UAVObjectBrowserWidget : public QWidget {
|
||||
public:
|
||||
UAVObjectBrowserWidget(QWidget *parent = 0);
|
||||
~UAVObjectBrowserWidget();
|
||||
|
||||
void setUnknownObjectColor(QColor color)
|
||||
{
|
||||
m_unknownObjectColor = color;
|
||||
m_model->setUnknowObjectColor(color);
|
||||
}
|
||||
void setRecentlyUpdatedColor(QColor color)
|
||||
{
|
||||
m_recentlyUpdatedColor = color; m_model->setRecentlyUpdatedColor(color);
|
||||
m_recentlyUpdatedColor = color;
|
||||
m_model->setRecentlyUpdatedColor(color);
|
||||
}
|
||||
void setManuallyChangedColor(QColor color)
|
||||
{
|
||||
m_manuallyChangedColor = color; m_model->setManuallyChangedColor(color);
|
||||
m_manuallyChangedColor = color;
|
||||
m_model->setManuallyChangedColor(color);
|
||||
}
|
||||
void setRecentlyUpdatedTimeout(int timeout)
|
||||
{
|
||||
m_recentlyUpdatedTimeout = timeout; m_model->setRecentlyUpdatedTimeout(timeout);
|
||||
m_recentlyUpdatedTimeout = timeout;
|
||||
m_model->setRecentlyUpdatedTimeout(timeout);
|
||||
}
|
||||
void setOnlyHilightChangedValues(bool hilight)
|
||||
{
|
||||
m_onlyHilightChangedValues = hilight; m_model->setOnlyHilightChangedValues(hilight);
|
||||
m_onlyHilightChangedValues = hilight;
|
||||
m_model->setOnlyHilightChangedValues(hilight);
|
||||
}
|
||||
void setViewOptions(bool categorized, bool scientific, bool metadata, bool description);
|
||||
void setSplitterState(QByteArray state);
|
||||
@ -91,6 +101,7 @@ private:
|
||||
UAVObjectTreeModel *m_model;
|
||||
|
||||
int m_recentlyUpdatedTimeout;
|
||||
QColor m_unknownObjectColor;
|
||||
QColor m_recentlyUpdatedColor;
|
||||
QColor m_manuallyChangedColor;
|
||||
bool m_onlyHilightChangedValues;
|
||||
|
@ -43,11 +43,14 @@ UAVObjectTreeModel::UAVObjectTreeModel(QObject *parent, bool categorize, bool us
|
||||
m_categorize(categorize),
|
||||
m_recentlyUpdatedTimeout(500), // ms
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
m_manuallyChangedColor(QColor(230, 230, 255))
|
||||
m_manuallyChangedColor(QColor(230, 230, 255)),
|
||||
m_unknownObjectColor(QColor(Qt::gray))
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
Q_ASSERT(objManager);
|
||||
|
||||
// Create highlight manager, let it run every 300 ms.
|
||||
m_highlightManager = new HighLightManager(300);
|
||||
connect(objManager, SIGNAL(newObject(UAVObject *)), this, SLOT(newObject(UAVObject *)));
|
||||
@ -112,9 +115,10 @@ void UAVObjectTreeModel::addDataObject(UAVDataObject *obj)
|
||||
if (existing) {
|
||||
addInstance(obj, existing);
|
||||
} else {
|
||||
DataObjectTreeItem *dataTreeItem = new DataObjectTreeItem(obj->getName() + " (" + QString::number(obj->getNumBytes()) + " bytes)");
|
||||
DataObjectTreeItem *dataTreeItem = new DataObjectTreeItem(obj->getName(), obj);
|
||||
dataTreeItem->setHighlightManager(m_highlightManager);
|
||||
connect(dataTreeItem, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
|
||||
connect(dataTreeItem, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
|
||||
parent->insertChild(dataTreeItem);
|
||||
root->addObjectTreeItem(obj->getObjID(), dataTreeItem);
|
||||
UAVMetaObject *meta = obj->getMetaObject();
|
||||
@ -165,16 +169,18 @@ MetaObjectTreeItem *UAVObjectTreeModel::addMetaObject(UAVMetaObject *obj, TreeIt
|
||||
void UAVObjectTreeModel::addInstance(UAVObject *obj, TreeItem *parent)
|
||||
{
|
||||
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(highlightUpdatedObject(UAVObject *)));
|
||||
connect(obj, SIGNAL(isKnownChanged(UAVObject *, bool)), this, SLOT(isKnownChanged(UAVObject *, bool)));
|
||||
TreeItem *item;
|
||||
if (obj->isSingleInstance()) {
|
||||
item = parent;
|
||||
DataObjectTreeItem *p = static_cast<DataObjectTreeItem *>(parent);
|
||||
p->setObject(obj);
|
||||
DataObjectTreeItem *objectItem = static_cast<DataObjectTreeItem *>(parent);
|
||||
connect(objectItem, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
|
||||
} else {
|
||||
QString name = tr("Instance") + " " + QString::number(obj->getInstID());
|
||||
item = new InstanceTreeItem(obj, name);
|
||||
item->setHighlightManager(m_highlightManager);
|
||||
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
|
||||
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
|
||||
parent->appendChild(item);
|
||||
}
|
||||
foreach(UAVObjectField * field, obj->getFields()) {
|
||||
@ -192,6 +198,7 @@ void UAVObjectTreeModel::addArrayField(UAVObjectField *field, TreeItem *parent)
|
||||
|
||||
item->setHighlightManager(m_highlightManager);
|
||||
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
|
||||
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
|
||||
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||
addSingleField(i, field, item);
|
||||
}
|
||||
@ -247,6 +254,7 @@ void UAVObjectTreeModel::addSingleField(int index, UAVObjectField *field, TreeIt
|
||||
item->setHighlightManager(m_highlightManager);
|
||||
item->setDescription(field->getDescription());
|
||||
connect(item, SIGNAL(updateHighlight(TreeItem *)), this, SLOT(updateHighlight(TreeItem *)));
|
||||
connect(item, SIGNAL(updateIsKnown(TreeItem *)), this, SLOT(updateIsKnown(TreeItem *)));
|
||||
parent->appendChild(item);
|
||||
}
|
||||
|
||||
@ -353,17 +361,21 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (index.column() == TreeItem::dataColumn && role == Qt::EditRole) {
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
|
||||
if (index.column() == TreeItem::DATA_COLUMN && role == Qt::EditRole) {
|
||||
return item->data(index.column());
|
||||
}
|
||||
|
||||
if (role == Qt::ToolTipRole) {
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
return item->description();
|
||||
}
|
||||
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
if (role == Qt::ForegroundRole) {
|
||||
if (!dynamic_cast<TopTreeItem *>(item) && !item->isKnown()) {
|
||||
return QVariant(m_unknownObjectColor);
|
||||
}
|
||||
}
|
||||
|
||||
if (index.column() == 0 && role == Qt::BackgroundRole) {
|
||||
if (!dynamic_cast<TopTreeItem *>(item) && item->highlighted()) {
|
||||
@ -371,7 +383,7 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
if (index.column() == TreeItem::dataColumn && role == Qt::BackgroundRole) {
|
||||
if (index.column() == TreeItem::DATA_COLUMN && role == Qt::BackgroundRole) {
|
||||
FieldTreeItem *fieldItem = dynamic_cast<FieldTreeItem *>(item);
|
||||
if (fieldItem && fieldItem->highlighted()) {
|
||||
return QVariant(m_recentlyUpdatedColor);
|
||||
@ -386,7 +398,7 @@ QVariant UAVObjectTreeModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (index.column() == TreeItem::dataColumn) {
|
||||
if (index.column() == TreeItem::DATA_COLUMN) {
|
||||
EnumFieldTreeItem *fieldItem = dynamic_cast<EnumFieldTreeItem *>(item);
|
||||
if (fieldItem) {
|
||||
int enumIndex = fieldItem->data(index.column()).toInt();
|
||||
@ -412,7 +424,7 @@ Qt::ItemFlags UAVObjectTreeModel::flags(const QModelIndex &index) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (index.column() == TreeItem::dataColumn) {
|
||||
if (index.column() == TreeItem::DATA_COLUMN) {
|
||||
TreeItem *item = static_cast<TreeItem *>(index.internalPointer());
|
||||
if (item->isEditable()) {
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||
@ -483,5 +495,22 @@ void UAVObjectTreeModel::updateHighlight(TreeItem *item)
|
||||
QModelIndex itemIndex = index(item);
|
||||
|
||||
Q_ASSERT(itemIndex != QModelIndex());
|
||||
emit dataChanged(itemIndex, itemIndex.sibling(itemIndex.row(), TreeItem::dataColumn));
|
||||
emit dataChanged(itemIndex, itemIndex.sibling(itemIndex.row(), TreeItem::DATA_COLUMN));
|
||||
}
|
||||
|
||||
void UAVObjectTreeModel::updateIsKnown(TreeItem *item)
|
||||
{
|
||||
QModelIndex itemIndex = index(item);
|
||||
|
||||
Q_ASSERT(itemIndex != QModelIndex());
|
||||
emit dataChanged(itemIndex, itemIndex.sibling(itemIndex.row(), TreeItem::TITLE_COLUMN));
|
||||
}
|
||||
|
||||
void UAVObjectTreeModel::isKnownChanged(UAVObject *object, bool isKnown)
|
||||
{
|
||||
Q_UNUSED(isKnown);
|
||||
ObjectTreeItem *item = findObjectTreeItem(object);
|
||||
if (item) {
|
||||
item->updateIsKnown(isKnown);
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,10 @@ public:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
void setUnknowObjectColor(QColor color)
|
||||
{
|
||||
m_unknownObjectColor = color;
|
||||
}
|
||||
void setRecentlyUpdatedColor(QColor color)
|
||||
{
|
||||
m_recentlyUpdatedColor = color;
|
||||
@ -88,8 +92,10 @@ public slots:
|
||||
void newObject(UAVObject *obj);
|
||||
|
||||
private slots:
|
||||
void updateHighlight(TreeItem *item);
|
||||
void updateIsKnown(TreeItem *item);
|
||||
void highlightUpdatedObject(UAVObject *obj);
|
||||
void updateHighlight(TreeItem *);
|
||||
void isKnownChanged(UAVObject *object, bool isKnown);
|
||||
|
||||
private:
|
||||
void setupModelData(UAVObjectManager *objManager);
|
||||
@ -115,6 +121,7 @@ private:
|
||||
int m_recentlyUpdatedTimeout;
|
||||
QColor m_recentlyUpdatedColor;
|
||||
QColor m_manuallyChangedColor;
|
||||
QColor m_unknownObjectColor;
|
||||
bool m_onlyHilightChangedValues;
|
||||
|
||||
// Highlight manager to handle highlighting of tree items.
|
||||
|
@ -38,7 +38,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbDescription">
|
||||
<property name="text">
|
||||
<string>Show description</string>
|
||||
<string>Show Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -63,6 +63,7 @@ UAVObject::UAVObject(quint32 objID, bool isSingleInst, const QString & name)
|
||||
this->data = 0;
|
||||
this->numBytes = 0;
|
||||
this->mutex = new QMutex(QMutex::Recursive);
|
||||
m_isKnown = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -603,6 +604,25 @@ void UAVObject::emitNewInstance(UAVObject *obj)
|
||||
emit newInstance(obj);
|
||||
}
|
||||
|
||||
bool UAVObject::isKnown() const
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
return m_isKnown;
|
||||
}
|
||||
|
||||
void UAVObject::setIsKnown(bool isKnown)
|
||||
{
|
||||
lock();
|
||||
bool changed = m_isKnown != isKnown;
|
||||
m_isKnown = isKnown;
|
||||
unlock();
|
||||
|
||||
if (changed) {
|
||||
emit isKnownChanged(this, isKnown);
|
||||
}
|
||||
}
|
||||
|
||||
bool UAVObject::isSettingsObject()
|
||||
{
|
||||
return false;
|
||||
|
@ -142,6 +142,9 @@ public:
|
||||
void emitTransactionCompleted(bool success);
|
||||
void emitNewInstance(UAVObject *);
|
||||
|
||||
bool isKnown() const;
|
||||
void setIsKnown(bool isKnown);
|
||||
|
||||
virtual bool isSettingsObject();
|
||||
virtual bool isDataObject();
|
||||
virtual bool isMetaDataObject();
|
||||
@ -178,9 +181,7 @@ signals:
|
||||
void updateRequested(UAVObject *obj, bool all = false);
|
||||
void transactionCompleted(UAVObject *obj, bool success);
|
||||
void newInstance(UAVObject *obj);
|
||||
|
||||
private slots:
|
||||
void fieldUpdated(UAVObjectField *field);
|
||||
void isKnownChanged(UAVObject *obj, bool isKnown);
|
||||
|
||||
protected:
|
||||
quint32 objID;
|
||||
@ -197,6 +198,12 @@ protected:
|
||||
void initializeFields(QList<UAVObjectField *> & fields, quint8 *data, quint32 numBytes);
|
||||
void setDescription(const QString & description);
|
||||
void setCategory(const QString & category);
|
||||
|
||||
private:
|
||||
bool m_isKnown;
|
||||
|
||||
private slots:
|
||||
void fieldUpdated(UAVObjectField *field);
|
||||
};
|
||||
|
||||
#endif // UAVOBJECT_H
|
||||
|
@ -41,10 +41,13 @@ Telemetry::Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMng
|
||||
mutex = new QMutex(QMutex::Recursive);
|
||||
|
||||
// Register all objects in the list
|
||||
QList< QList<UAVObject *> > objs = objMngr->getObjects();
|
||||
for (int objidx = 0; objidx < objs.length(); ++objidx) {
|
||||
foreach(QList<UAVObject *> instances, objMngr->getObjects()) {
|
||||
foreach(UAVObject * object, instances) {
|
||||
// make sure we 'forget' all objects before we request it from the flight side
|
||||
object->setIsKnown(false);
|
||||
}
|
||||
// we only need to register one instance per object type
|
||||
registerObject(objs[objidx][0]);
|
||||
registerObject(instances.first());
|
||||
}
|
||||
|
||||
// Listen to new object creations
|
||||
@ -74,6 +77,12 @@ Telemetry::Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr) : objMngr(objMng
|
||||
Telemetry::~Telemetry()
|
||||
{
|
||||
closeAllTransactions();
|
||||
foreach(QList<UAVObject *> instances, objMngr->getObjects()) {
|
||||
foreach(UAVObject * object, instances) {
|
||||
// make sure we 'forget' all objects before we request it from the flight side
|
||||
object->setIsKnown(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,10 +244,14 @@ void Telemetry::transactionCompleted(UAVObject *obj, bool success)
|
||||
|
||||
if (transInfo) {
|
||||
if (success) {
|
||||
// We now know tat the flight side knows of this object.
|
||||
obj->setIsKnown(true);
|
||||
|
||||
#ifdef VERBOSE_TELEMETRY
|
||||
qDebug() << "Telemetry - transaction successful for object" << obj->toStringBrief();
|
||||
#endif
|
||||
} else {
|
||||
obj->setIsKnown(false);
|
||||
qWarning() << "Telemetry - !!! transaction failed for object" << obj->toStringBrief();
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,6 @@ public:
|
||||
void resetStats();
|
||||
void transactionTimeout(ObjectTransactionInfo *info);
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
// Constants
|
||||
static const int REQ_TIMEOUT_MS = 250;
|
||||
|
@ -26,16 +26,18 @@
|
||||
*/
|
||||
|
||||
#include "telemetrymanager.h"
|
||||
#include "telemetry.h"
|
||||
#include "telemetrymonitor.h"
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/threadmanager.h>
|
||||
|
||||
TelemetryManager::TelemetryManager() : autopilotConnected(false)
|
||||
TelemetryManager::TelemetryManager() : m_isAutopilotConnected(false)
|
||||
{
|
||||
moveToThread(Core::ICore::instance()->threadManager()->getRealTimeThread());
|
||||
// Get UAVObjectManager instance
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
objMngr = pm->getObject<UAVObjectManager>();
|
||||
m_uavobjectManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
// connect to start stop signals
|
||||
connect(this, SIGNAL(myStart()), this, SLOT(onStart()), Qt::QueuedConnection);
|
||||
@ -47,24 +49,24 @@ TelemetryManager::~TelemetryManager()
|
||||
|
||||
bool TelemetryManager::isConnected()
|
||||
{
|
||||
return autopilotConnected;
|
||||
return m_isAutopilotConnected;
|
||||
}
|
||||
|
||||
void TelemetryManager::start(QIODevice *dev)
|
||||
{
|
||||
device = dev;
|
||||
m_telemetryDevice = dev;
|
||||
// OP-1383
|
||||
// take ownership of the device by moving it to the TelemetryManager thread (see TelemetryManager constructor)
|
||||
// this removes the following runtime Qt warning and incidentally fixes GCS crashes:
|
||||
// QObject: Cannot create children for a parent that is in a different thread.
|
||||
// (Parent is QSerialPort(0x56af73f8), parent's thread is QThread(0x23f69ae8), current thread is QThread(0x2649cfd8)
|
||||
device->moveToThread(thread());
|
||||
m_telemetryDevice->moveToThread(thread());
|
||||
emit myStart();
|
||||
}
|
||||
|
||||
void TelemetryManager::onStart()
|
||||
{
|
||||
utalk = new UAVTalk(device, objMngr);
|
||||
m_uavTalk = new UAVTalk(m_telemetryDevice, m_uavobjectManager);
|
||||
if (false) {
|
||||
// UAVTalk must be thread safe and for that:
|
||||
// 1- all public methods must lock a mutex
|
||||
@ -73,25 +75,25 @@ void TelemetryManager::onStart()
|
||||
// It is assumed that the UAVObjectManager is thread safe
|
||||
|
||||
// Create the reader and move it to the reader thread
|
||||
IODeviceReader *reader = new IODeviceReader(utalk);
|
||||
reader->moveToThread(&readerThread);
|
||||
IODeviceReader *reader = new IODeviceReader(m_uavTalk);
|
||||
reader->moveToThread(&m_telemetryReaderThread);
|
||||
// The reader will be deleted (later) when the thread finishes
|
||||
connect(&readerThread, &QThread::finished, reader, &QObject::deleteLater);
|
||||
connect(&m_telemetryReaderThread, &QThread::finished, reader, &QObject::deleteLater);
|
||||
// Connect IO device to reader
|
||||
connect(device, SIGNAL(readyRead()), reader, SLOT(read()));
|
||||
connect(m_telemetryDevice, SIGNAL(readyRead()), reader, SLOT(read()));
|
||||
// start the reader thread
|
||||
readerThread.start();
|
||||
m_telemetryReaderThread.start();
|
||||
} else {
|
||||
// Connect IO device to reader
|
||||
connect(device, SIGNAL(readyRead()), utalk, SLOT(processInputStream()));
|
||||
connect(m_telemetryDevice, SIGNAL(readyRead()), m_uavTalk, SLOT(processInputStream()));
|
||||
}
|
||||
|
||||
telemetry = new Telemetry(utalk, objMngr);
|
||||
telemetryMon = new TelemetryMonitor(objMngr, telemetry);
|
||||
m_telemetry = new Telemetry(m_uavTalk, m_uavobjectManager);
|
||||
m_telemetryMonitor = new TelemetryMonitor(m_uavobjectManager, m_telemetry);
|
||||
|
||||
connect(telemetryMon, SIGNAL(connected()), this, SLOT(onConnect()));
|
||||
connect(telemetryMon, SIGNAL(disconnected()), this, SLOT(onDisconnect()));
|
||||
connect(telemetryMon, SIGNAL(telemetryUpdated(double, double)), this, SLOT(onTelemetryUpdate(double, double)));
|
||||
connect(m_telemetryMonitor, SIGNAL(connected()), this, SLOT(onConnect()));
|
||||
connect(m_telemetryMonitor, SIGNAL(disconnected()), this, SLOT(onDisconnect()));
|
||||
connect(m_telemetryMonitor, SIGNAL(telemetryUpdated(double, double)), this, SLOT(onTelemetryUpdate(double, double)));
|
||||
}
|
||||
|
||||
void TelemetryManager::stop()
|
||||
@ -99,29 +101,29 @@ void TelemetryManager::stop()
|
||||
emit myStop();
|
||||
|
||||
if (false) {
|
||||
readerThread.quit();
|
||||
readerThread.wait();
|
||||
m_telemetryReaderThread.quit();
|
||||
m_telemetryReaderThread.wait();
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetryManager::onStop()
|
||||
{
|
||||
telemetryMon->disconnect(this);
|
||||
delete telemetryMon;
|
||||
delete telemetry;
|
||||
delete utalk;
|
||||
m_telemetryMonitor->disconnect(this);
|
||||
delete m_telemetryMonitor;
|
||||
delete m_telemetry;
|
||||
delete m_uavTalk;
|
||||
onDisconnect();
|
||||
}
|
||||
|
||||
void TelemetryManager::onConnect()
|
||||
{
|
||||
autopilotConnected = true;
|
||||
m_isAutopilotConnected = true;
|
||||
emit connected();
|
||||
}
|
||||
|
||||
void TelemetryManager::onDisconnect()
|
||||
{
|
||||
autopilotConnected = false;
|
||||
m_isAutopilotConnected = false;
|
||||
emit disconnected();
|
||||
}
|
||||
|
||||
@ -130,10 +132,10 @@ void TelemetryManager::onTelemetryUpdate(double txRate, double rxRate)
|
||||
emit telemetryUpdated(txRate, rxRate);
|
||||
}
|
||||
|
||||
IODeviceReader::IODeviceReader(UAVTalk *uavTalk) : uavTalk(uavTalk)
|
||||
IODeviceReader::IODeviceReader(UAVTalk *uavTalk) : m_uavTalk(uavTalk)
|
||||
{}
|
||||
|
||||
void IODeviceReader::read()
|
||||
{
|
||||
uavTalk->processInputStream();
|
||||
m_uavTalk->processInputStream();
|
||||
}
|
||||
|
@ -29,13 +29,14 @@
|
||||
#define TELEMETRYMANAGER_H
|
||||
|
||||
#include "uavtalk_global.h"
|
||||
#include "telemetrymonitor.h"
|
||||
#include "telemetry.h"
|
||||
#include "uavtalk.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include <QIODevice>
|
||||
#include <QObject>
|
||||
|
||||
class Telemetry;
|
||||
class TelemetryMonitor;
|
||||
|
||||
class UAVTALK_EXPORT TelemetryManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -62,13 +63,13 @@ private slots:
|
||||
void onStop();
|
||||
|
||||
private:
|
||||
UAVObjectManager *objMngr;
|
||||
UAVTalk *utalk;
|
||||
Telemetry *telemetry;
|
||||
TelemetryMonitor *telemetryMon;
|
||||
QIODevice *device;
|
||||
bool autopilotConnected;
|
||||
QThread readerThread;
|
||||
UAVObjectManager *m_uavobjectManager;
|
||||
UAVTalk *m_uavTalk;
|
||||
Telemetry *m_telemetry;
|
||||
TelemetryMonitor *m_telemetryMonitor;
|
||||
QIODevice *m_telemetryDevice;
|
||||
bool m_isAutopilotConnected;
|
||||
QThread m_telemetryReaderThread;
|
||||
};
|
||||
|
||||
|
||||
@ -77,7 +78,7 @@ class IODeviceReader : public QObject {
|
||||
public:
|
||||
IODeviceReader(UAVTalk *uavTalk);
|
||||
|
||||
UAVTalk *uavTalk;
|
||||
UAVTalk *m_uavTalk;
|
||||
|
||||
public slots:
|
||||
void read();
|
||||
|
@ -48,9 +48,6 @@ bool UAVTalkPlugin::initialize(const QStringList & arguments, QString *errorStri
|
||||
// Done
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorString);
|
||||
// Get UAVObjectManager instance
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
objMngr = pm->getObject<UAVObjectManager>();
|
||||
|
||||
// Create TelemetryManager
|
||||
telMngr = new TelemetryManager();
|
||||
|
@ -30,11 +30,8 @@
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <QtPlugin>
|
||||
#include "telemetrymonitor.h"
|
||||
#include "telemetry.h"
|
||||
#include "uavtalk.h"
|
||||
#include "telemetrymanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
class UAVTALK_EXPORT UAVTalkPlugin : public ExtensionSystem::IPlugin {
|
||||
Q_OBJECT
|
||||
@ -53,7 +50,6 @@ protected slots:
|
||||
void onDeviceDisconnect();
|
||||
|
||||
private:
|
||||
UAVObjectManager *objMngr;
|
||||
TelemetryManager *telMngr;
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
defaultvalue="Attitude,Attitude,AxisLock,Manual"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
@ -22,7 +22,7 @@
|
||||
defaultvalue="Attitude,Attitude,Rate,Manual"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
@ -33,7 +33,7 @@
|
||||
defaultvalue="Rate,Rate,Rate,Manual"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
@ -44,7 +44,7 @@
|
||||
defaultvalue="Attitude,Attitude,AxisLock,CruiseControl"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
@ -55,7 +55,7 @@
|
||||
defaultvalue="Attitude,Attitude,Rate,CruiseControl"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
@ -66,7 +66,7 @@
|
||||
defaultvalue="Rate,Rate,Rate,CruiseControl"
|
||||
limits="%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl; \
|
||||
%NE:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario:CruiseControl:Attitude:Rattitude:Acro+:WeakLeveling:VirtualBar; \
|
||||
%NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude,\
|
||||
%0401NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario,\
|
||||
%0402NE:Rate:Attitude:AxisLock:WeakLeveling:VirtualBar:Acro+:Rattitude:RelayRate:RelayAttitude:AltitudeHold:AltitudeVario;"
|
||||
|
@ -6,7 +6,7 @@
|
||||
<field name="MaxPDOP" units="" type="float" elements="1" defaultvalue="3.5"/>
|
||||
<!-- Ubx self configuration. Enable to allow the flight board to auto configure ubx GPS options,
|
||||
store does AutoConfig and save GPS settings (i.e. to prevent issues if gps is power cycled) -->
|
||||
<field name="UbxAutoConfig" units="" type="enum" elements="1" options="Disabled,Configure,ConfigureAndStore" defaultvalue="Disabled"/>
|
||||
<field name="UbxAutoConfig" units="" type="enum" elements="1" options="Disabled,Configure,ConfigureAndStore" defaultvalue="Configure"/>
|
||||
<!-- Ubx position update rate, -1 for auto -->
|
||||
<field name="UbxRate" units="Hz" type="int8" elements="1" defaultvalue="5" />
|
||||
<!-- Ubx dynamic model, see UBX datasheet for more details -->
|
||||
|
Loading…
Reference in New Issue
Block a user