Commit 06244548 authored by lm's avatar lm

Switched to QTreeWidget for parameter view, receiving data works already

parent f64f15df
...@@ -147,7 +147,7 @@ void MAVLinkSimulationLink::mainloop() ...@@ -147,7 +147,7 @@ void MAVLinkSimulationLink::mainloop()
static float fullVoltage = 4.2 * 3; static float fullVoltage = 4.2 * 3;
static float emptyVoltage = 3.35 * 3; static float emptyVoltage = 3.35 * 3;
static float voltage = fullVoltage; static float voltage = fullVoltage;
static float drainRate = 0.0025; // x.xx% of the capacity is linearly drained per second static float drainRate = 0.025; // x.xx% of the capacity is linearly drained per second
attitude_t attitude; attitude_t attitude;
raw_aux_t rawAuxValues; raw_aux_t rawAuxValues;
...@@ -352,7 +352,7 @@ void MAVLinkSimulationLink::mainloop() ...@@ -352,7 +352,7 @@ void MAVLinkSimulationLink::mainloop()
} }
statusCounter++; statusCounter++;
status.vbat = voltage; status.vbat = voltage * 1000; // millivolts
// Pack message and get size of encoded byte string // Pack message and get size of encoded byte string
messageSize = message_sys_status_encode(systemId, componentId, &msg, &status); messageSize = message_sys_status_encode(systemId, componentId, &msg, &status);
......
...@@ -52,8 +52,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) : ...@@ -52,8 +52,8 @@ UAS::UAS(MAVLinkProtocol* protocol, int id) :
thrustSum(0), thrustSum(0),
thrustMax(10), thrustMax(10),
startVoltage(0), startVoltage(0),
currentVoltage(0.0f), currentVoltage(12.0f),
lpVoltage(0.0f), lpVoltage(12.0f),
mode(MAV_MODE_UNINIT), mode(MAV_MODE_UNINIT),
status(MAV_STATE_UNINIT), status(MAV_STATE_UNINIT),
onboardTimeOffset(0), onboardTimeOffset(0),
......
...@@ -16,12 +16,20 @@ ParameterInterface::ParameterInterface(QWidget *parent) : ...@@ -16,12 +16,20 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
tree = new ParamTreeModel(); tree = new ParamTreeModel();
treeView = new QTreeView(this); //treeView = new QTreeView(this);
treeView->setModel(tree); //treeView->setModel(tree);
treeWidget = new QTreeWidget(this);
QStringList headerItems;
headerItems.append("Parameter");
headerItems.append("Value");
treeWidget->setHeaderLabels(headerItems);
QStackedWidget* stack = m_ui->stackedWidget; QStackedWidget* stack = m_ui->stackedWidget;
stack->addWidget(treeView); //stack->addWidget(treeView);
stack->setCurrentWidget(treeView); //stack->setCurrentWidget(treeView);
stack->addWidget(treeWidget);
stack->setCurrentWidget(treeWidget);
} }
...@@ -56,6 +64,8 @@ void ParameterInterface::addUAS(UASInterface* uas) ...@@ -56,6 +64,8 @@ void ParameterInterface::addUAS(UASInterface* uas)
void ParameterInterface::requestParameterList() void ParameterInterface::requestParameterList()
{ {
mav->requestParameters(); mav->requestParameters();
// Clear view
treeWidget->clear();
} }
/** /**
...@@ -73,9 +83,11 @@ void ParameterInterface::receiveParameter(int uas, int component, QString parame ...@@ -73,9 +83,11 @@ void ParameterInterface::receiveParameter(int uas, int component, QString parame
{ {
Q_UNUSED(uas); Q_UNUSED(uas);
// Insert parameter into map // Insert parameter into map
tree->appendParam(component, parameterName, value); //tree->appendParam(component, parameterName, value);
// Refresh view QStringList list;
treeView->update(); list.append(parameterName);
list.append(QString::number(value));
treeWidget->addTopLevelItem(new QTreeWidgetItem(list));
} }
/** /**
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QTreeWidget>
#include "ui_ParameterInterface.h" #include "ui_ParameterInterface.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "ParamTreeModel.h" #include "ParamTreeModel.h"
...@@ -31,6 +32,7 @@ protected: ...@@ -31,6 +32,7 @@ protected:
UASInterface* mav; UASInterface* mav;
ParamTreeModel* tree; ParamTreeModel* tree;
QTreeView* treeView; QTreeView* treeView;
QTreeWidget* treeWidget;
private: private:
Ui::parameterWidget *m_ui; Ui::parameterWidget *m_ui;
......
...@@ -107,11 +107,16 @@ QVariant ParamTreeItem::data(int column) const ...@@ -107,11 +107,16 @@ QVariant ParamTreeItem::data(int column) const
} }
} }
ParamTreeItem *ParamTreeItem::parent() ParamTreeItem *ParamTreeItem::parent() const
{ {
return parentItem; return parentItem;
} }
const QList<ParamTreeItem*>* ParamTreeItem::children() const
{
return &childItems;
}
int ParamTreeItem::row() const int ParamTreeItem::row() const
{ {
if (parentItem) if (parentItem)
......
...@@ -53,7 +53,8 @@ public: ...@@ -53,7 +53,8 @@ public:
int columnCount() const; int columnCount() const;
QVariant data(int column) const; QVariant data(int column) const;
int row() const; int row() const;
ParamTreeItem *parent(); ParamTreeItem *parent() const;
const QList<ParamTreeItem*>* children() const;
protected: protected:
QString paramName; QString paramName;
......
...@@ -172,11 +172,11 @@ void ParamTreeModel::appendComponent(int componentId) ...@@ -172,11 +172,11 @@ void ParamTreeModel::appendComponent(int componentId)
ParamTreeItem* item = new ParamTreeItem(QString("Component #") + QString::number(componentId) + QString(""), 0, rootItem); ParamTreeItem* item = new ParamTreeItem(QString("Component #") + QString::number(componentId) + QString(""), 0, rootItem);
components.insert(componentId, item); components.insert(componentId, item);
} }
//emit dataChanged();
} }
void ParamTreeModel::appendParam(int componentId, QString name, float value) void ParamTreeModel::appendParam(int componentId, QString name, float value)
{ {
// If component does not exist yet // If component does not exist yet
if (!components.contains(componentId)) if (!components.contains(componentId))
{ {
...@@ -186,6 +186,7 @@ void ParamTreeModel::appendParam(int componentId, QString name, float value) ...@@ -186,6 +186,7 @@ void ParamTreeModel::appendParam(int componentId, QString name, float value)
// FIXME Children may be double here // FIXME Children may be double here
comp->appendChild(new ParamTreeItem(name, value, comp)); comp->appendChild(new ParamTreeItem(name, value, comp));
qDebug() << __FILE__ << __LINE__ << "Added param" << name << value << "for component" << comp->getParamName(); qDebug() << __FILE__ << __LINE__ << "Added param" << name << value << "for component" << comp->getParamName();
emit dataChanged(createIndex(0, 0, rootItem), createIndex(0, 0, rootItem));
} }
void ParamTreeModel::setupModelData(const QStringList &lines, ParamTreeItem *parent) void ParamTreeModel::setupModelData(const QStringList &lines, ParamTreeItem *parent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment