b
This commit is contained in:
@@ -12,7 +12,6 @@ ParameterInspector::ParameterInspector(QWidget *parent) :
|
||||
// Make sure "All" is an option for both the system and components
|
||||
ui->systemComboBox->addItem(tr("All"), 0);
|
||||
ui->componentComboBox->addItem(tr("All"), 0);
|
||||
ui->ReadcomboBox->addItem(tr("All"),0);
|
||||
|
||||
// Set up the column headers for the message listing
|
||||
QStringList header;
|
||||
@@ -23,6 +22,8 @@ ParameterInspector::ParameterInspector(QWidget *parent) :
|
||||
|
||||
//ui->treeWidget->SelectedClicked
|
||||
|
||||
|
||||
QTimer::singleShot(500,this,SLOT(mReflush()));
|
||||
}
|
||||
|
||||
ParameterInspector::~ParameterInspector()
|
||||
@@ -30,6 +31,25 @@ ParameterInspector::~ParameterInspector()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ParameterInspector::mReflush()
|
||||
{
|
||||
if(isReflush == true)
|
||||
{
|
||||
isReflush = false;
|
||||
|
||||
ui->progressBar->setValue(currentpersent);
|
||||
|
||||
refreshView();
|
||||
|
||||
//qDebug() << "reflush the view";
|
||||
}
|
||||
|
||||
|
||||
QTimer::singleShot(500,this,SLOT(mReflush()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ParameterInspector::resizeEvent(QResizeEvent * event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
@@ -38,64 +58,95 @@ void ParameterInspector::resizeEvent(QResizeEvent * event)
|
||||
}
|
||||
|
||||
|
||||
//添加一个设备,
|
||||
void ParameterInspector::addVehicles(uint16_t id)
|
||||
{
|
||||
if(!vehicles.keys().contains(id))
|
||||
{
|
||||
//如果还没有这个设备,就添加一个
|
||||
QMap<int, mavlink_param_value_t> param;
|
||||
vehicles.insert(id,param);
|
||||
|
||||
//同时检查combox有没有,没有就添加
|
||||
if(ui->systemComboBox->findText(tr("Vehicle %1").arg(id)) == (-1))
|
||||
{
|
||||
ui->systemComboBox->addItem(tr("Vehicle %1").arg(id), id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//直接接受整个msg,这个函数传来的只有param_value这一帧,因此不需要识别
|
||||
void ParameterInspector::appendParameter(mavlink_message_t msg)
|
||||
{
|
||||
|
||||
//查找这个消息归属的设备和部件
|
||||
|
||||
if(!systems.values().contains(msg.sysid))//如果不包含,那么新建
|
||||
if(!vehicles.keys().contains(msg.sysid))
|
||||
{
|
||||
systems.insert(msg.sysid,msg.sysid);
|
||||
//如果还没有这个设备,就添加一个
|
||||
QMap<int, mavlink_param_value_t> param;
|
||||
vehicles.insert(msg.sysid,param);
|
||||
|
||||
//同时检查combox有没有,没有就添加
|
||||
if(ui->systemComboBox->findText(tr("Vehicle %1").arg(msg.sysid)) == (-1))
|
||||
{
|
||||
ui->systemComboBox->addItem(tr("Vehicle %1").arg(msg.sysid), msg.sysid);
|
||||
}
|
||||
}
|
||||
|
||||
//解码
|
||||
|
||||
mavlink_param_value_t param_value;//
|
||||
mavlink_msg_param_value_decode(&msg,¶m_value);
|
||||
|
||||
|
||||
//如果当前是航点0,那么设置状态条
|
||||
if(param_value.param_index == 0)
|
||||
{
|
||||
ui->progressBar->setMaximum(0);
|
||||
ui->progressBar->setMaximum(param_value.param_count - 1);
|
||||
}
|
||||
|
||||
//这里可能有bug,程序会死机
|
||||
//ui->progressBar->setValue((int)param_value.param_index);
|
||||
|
||||
currentpersent = param_value.param_index;
|
||||
|
||||
|
||||
//qDebug() << QThread::currentThreadId();
|
||||
|
||||
//检查是否包含了该参数,如果没有,那么添加
|
||||
if(ParameterStorage.keys().contains(param_value.param_index))
|
||||
{
|
||||
//如果已经存在,那么覆盖
|
||||
ParameterStorage.value(param_value.param_index) = param_value.param_value;//这个value需要转换
|
||||
}
|
||||
else
|
||||
{
|
||||
ParameterStorage.insert(param_value.param_index,¶m_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QMap<int, mavlink_param_value_t> ParameterStorage;
|
||||
ParameterStorage = vehicles.value(msg.sysid);
|
||||
|
||||
ParameterStorage.insert(param_value.param_index,param_value);
|
||||
vehicles.insert(msg.sysid,ParameterStorage);
|
||||
|
||||
|
||||
//需要刷新一次
|
||||
isReflush = true;
|
||||
|
||||
}
|
||||
void ParameterInspector::refreshView()
|
||||
void ParameterInspector::refreshView()//来一个参数更新一次
|
||||
{
|
||||
|
||||
//查看当前选择的uav,下面的参数
|
||||
QMap<int,QMap<int,mavlink_param_value_t>>::key_iterator ite;
|
||||
|
||||
for(ite=vehicles.keyBegin(); ite!=vehicles.keyBegin();++ite)//每一个key下面都是一个设备的所有参数
|
||||
{
|
||||
|
||||
//查找当前设备下的所有参数并显示
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QMap<int, mavlink_message_t* >::const_iterator ite;
|
||||
|
||||
|
||||
for(ite=uasMessageStorage.constBegin(); ite!=uasMessageStorage.constEnd();++ite)
|
||||
{
|
||||
mavlink_message_t* msg = ite.value();
|
||||
@@ -111,7 +162,48 @@ void ParameterInspector::refreshView()
|
||||
|
||||
// Update the message frenquency
|
||||
|
||||
// Get the previous frequency for low-pass filtering
|
||||
float msgHz = 0.0f;
|
||||
QMap<int, QMap<int, float>* >::const_iterator iteHz = uasMessageHz.find(msg->sysid);
|
||||
QMap<int, float>* uasMsgHz = iteHz.value();
|
||||
|
||||
while((iteHz != uasMessageHz.end()) && (iteHz.key() == msg->sysid))
|
||||
{
|
||||
if(iteHz.value()->contains(msg->msgid))
|
||||
{
|
||||
uasMsgHz = iteHz.value();
|
||||
msgHz = iteHz.value()->value(msg->msgid);
|
||||
break;
|
||||
}
|
||||
++iteHz;
|
||||
}
|
||||
|
||||
// Get the number of message received
|
||||
float msgCount = 0;
|
||||
QMap<int, QMap<int, unsigned int> * >::const_iterator iter = uasMessageCount.find(msg->sysid);
|
||||
QMap<int, unsigned int>* uasMsgCount = iter.value();
|
||||
|
||||
while((iter != uasMessageCount.end()) && (iter.key()==msg->sysid))
|
||||
{
|
||||
if(iter.value()->contains(msg->msgid))
|
||||
{
|
||||
msgCount = (float) iter.value()->value(msg->msgid);
|
||||
uasMsgCount = iter.value();
|
||||
break;
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
|
||||
// Compute the new low-pass filtered frequency and update the message count
|
||||
msgHz = (1.0f-updateHzLowpass)* msgHz + updateHzLowpass*msgCount/((float)updateInterval/1000.0f);
|
||||
uasMsgHz->insert(msg->msgid,msgHz);
|
||||
uasMsgCount->insert(msg->msgid,(unsigned int) 0);
|
||||
|
||||
// Update the tree view
|
||||
QString messageName("%1 (%2 Hz, #%3)");
|
||||
messageName = messageName.arg(msgInfo->name).arg(msgHz, 3, 'f', 1).arg(msg->msgid);
|
||||
|
||||
addUAStoTree(msg->sysid);
|
||||
|
||||
// Look for the tree for the UAS sysid
|
||||
QMap<int, QTreeWidgetItem*>* msgTreeItems = uasMsgTreeItems.value(msg->sysid);
|
||||
@@ -146,60 +238,27 @@ void ParameterInspector::refreshView()
|
||||
message->setData(0, Qt::DisplayRole, QVariant(messageName));
|
||||
for (unsigned int i = 0; i < msgInfo->num_fields; ++i)
|
||||
{
|
||||
updateField(msg, msgInfo, i, message->child(i));
|
||||
// updateField(msg, msgInfo, i, message->child(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ParameterInspector::addItem(void)//添加
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ParameterInspector::on_ReadButton_clicked()
|
||||
{
|
||||
uint8_t m_sysid = 0;
|
||||
uint8_t m_compid = 1;
|
||||
uint8_t m_type = 0;
|
||||
|
||||
m_sysid = ui->systemComboBox->currentData().toInt();
|
||||
|
||||
qDebug() << "m_sysid" << m_sysid;
|
||||
|
||||
emit ReadCmd(m_sysid,m_compid,m_type);
|
||||
}
|
||||
|
||||
void ParameterInspector::delItem(void)//删除
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ParameterInspector::insItem(void)//插入
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
QStandardItem *ParameterInspector::getItem(QStandardItemModel *model, QString s)
|
||||
{
|
||||
|
||||
QStandardItem *getitem = nullptr;
|
||||
|
||||
|
||||
|
||||
return getitem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
QStandardItem *ParameterInspector::getItem(QStandardItem *item, QString s)
|
||||
{
|
||||
|
||||
if(item == nullptr)
|
||||
return nullptr;
|
||||
qDebug() << tr("fine %1").arg(item->text());
|
||||
QStandardItem *getitem = nullptr;
|
||||
return getitem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
#include "QThread"
|
||||
#include "QPushButton"
|
||||
#include "QTreeView"
|
||||
#include "QDebug"
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "QMap"
|
||||
#include <QList>
|
||||
#include "QStandardItemModel"
|
||||
|
||||
#include "QTimer"
|
||||
|
||||
|
||||
|
||||
@@ -108,41 +108,56 @@ public:
|
||||
|
||||
|
||||
void refreshView();
|
||||
void addItem(void);
|
||||
void delItem(void);
|
||||
void insItem(void);
|
||||
|
||||
|
||||
|
||||
QStandardItem * getItem(QStandardItemModel *model, QString s);
|
||||
QStandardItem * getItem(QStandardItem *item, QString s);
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void ReadCmd(uint8_t m_sysid, uint8_t m_compid, uint8_t type);
|
||||
void WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count);
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
void addVehicles(uint16_t id);
|
||||
|
||||
void appendParameter(mavlink_message_t msg);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
void mReflush();
|
||||
|
||||
|
||||
void on_ReadButton_clicked();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int selectedSystemID; ///< Currently selected system
|
||||
int selectedComponentID; ///< Currently selected component
|
||||
QMap<int, int> systems; ///< Already observed systems
|
||||
bool isReflush = false;
|
||||
uint16_t currentpersent;
|
||||
|
||||
|
||||
|
||||
|
||||
int selectedSystemID; ///< Currently selected system
|
||||
int selectedComponentID; ///< Currently selected component
|
||||
QMap<int, int> systems; ///< Already observed systems
|
||||
QMap<int, int> components; ///< Already observed components
|
||||
|
||||
QMap<int, QTreeWidgetItem* > uasTreeWidgetItems; ///< Tree of available uas with their widget
|
||||
QMap<int, QMap<int, QTreeWidgetItem*>* > uasMsgTreeItems; ///< Stores the widget of the received message for each UAS
|
||||
|
||||
QMap<int, mavlink_param_value_t* > ParameterStorage; ///< Stores the parameter for every UAS
|
||||
|
||||
|
||||
//QMap<int, mavlink_param_value_t* > ParameterStorage; ///< Stores the parameter for every UAS
|
||||
|
||||
|
||||
QMap<int,QMap<int,QMap<int,mavlink_param_value_t*>*>> vehicles;
|
||||
|
||||
QMap<int,QMap<int,mavlink_param_value_t>> vehicles;
|
||||
|
||||
|
||||
Ui::ParameterInspector *ui;
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
#ifndef PARAMETERINSPECTOR_H
|
||||
#define PARAMETERINSPECTOR_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
|
||||
#include "QPushButton"
|
||||
#include "QTreeView"
|
||||
#include "QDebug"
|
||||
|
||||
#include "QMap"
|
||||
#include <QList>
|
||||
#include "QStandardItemModel"
|
||||
|
||||
|
||||
|
||||
|
||||
#include "QDateTime"
|
||||
|
||||
#include "mavlink.h"
|
||||
#include "mavlink_get_info.h"
|
||||
|
||||
|
||||
#include "QHeaderView"
|
||||
|
||||
|
||||
|
||||
#include "QTreeWidgetItem"
|
||||
|
||||
#ifdef QtMavlinkNode
|
||||
#include <mavlinknodeglobal.h>
|
||||
namespace Ui {
|
||||
class ParameterInspector;
|
||||
}
|
||||
|
||||
class MAVLINKNODESHARED_EXPORT ParameterInspector : public QWidget{
|
||||
#else
|
||||
namespace Ui {
|
||||
class ParameterInspector;
|
||||
}
|
||||
|
||||
class ParameterInspector : public QWidget
|
||||
{
|
||||
#endif
|
||||
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ParameterInspector(QWidget *parent = nullptr);
|
||||
~ParameterInspector();
|
||||
|
||||
void resizeEvent(QResizeEvent * event);
|
||||
|
||||
|
||||
const QHash<int, QString> _mavlinkCompIdHash {
|
||||
{ MAV_COMP_ID_CAMERA, "Camera1" },
|
||||
{ MAV_COMP_ID_CAMERA2, "Camera2" },
|
||||
{ MAV_COMP_ID_CAMERA3, "Camera3" },
|
||||
{ MAV_COMP_ID_CAMERA4, "Camera4" },
|
||||
{ MAV_COMP_ID_CAMERA5, "Camera5" },
|
||||
{ MAV_COMP_ID_CAMERA6, "Camera6" },
|
||||
{ MAV_COMP_ID_SERVO1, "Servo1" },
|
||||
{ MAV_COMP_ID_SERVO2, "Servo2" },
|
||||
{ MAV_COMP_ID_SERVO3, "Servo3" },
|
||||
{ MAV_COMP_ID_SERVO4, "Servo4" },
|
||||
{ MAV_COMP_ID_SERVO5, "Servo5" },
|
||||
{ MAV_COMP_ID_SERVO6, "Servo6" },
|
||||
{ MAV_COMP_ID_SERVO7, "Servo7" },
|
||||
{ MAV_COMP_ID_SERVO8, "Servo8" },
|
||||
{ MAV_COMP_ID_SERVO9, "Servo9" },
|
||||
{ MAV_COMP_ID_SERVO10, "Servo10" },
|
||||
{ MAV_COMP_ID_SERVO11, "Servo11" },
|
||||
{ MAV_COMP_ID_SERVO12, "Servo12" },
|
||||
{ MAV_COMP_ID_SERVO13, "Servo13" },
|
||||
{ MAV_COMP_ID_SERVO14, "Servo14" },
|
||||
{ MAV_COMP_ID_GIMBAL, "Gimbal1" },
|
||||
{ MAV_COMP_ID_ADSB, "ADSB" },
|
||||
{ MAV_COMP_ID_OSD, "OSD" },
|
||||
{ MAV_COMP_ID_FLARM, "FLARM" },
|
||||
{ MAV_COMP_ID_IMU, "IMU1" },
|
||||
{ MAV_COMP_ID_IMU_2, "IMU2" },
|
||||
{ MAV_COMP_ID_IMU_3, "IMU3" },
|
||||
{ MAV_COMP_ID_GPS, "GPS1" },
|
||||
{ MAV_COMP_ID_GPS2, "GPS2" }
|
||||
};
|
||||
|
||||
|
||||
typedef struct{
|
||||
char name[16];
|
||||
union{
|
||||
double *d;
|
||||
float *s;
|
||||
uint32_t *I;
|
||||
int32_t *i;
|
||||
uint16_t *H;
|
||||
int16_t *h;
|
||||
uint8_t *B;
|
||||
int8_t *b;
|
||||
} val_ptr;
|
||||
MAV_PARAM_TYPE typ;
|
||||
} _param_props;
|
||||
|
||||
_param_props param_props;
|
||||
|
||||
|
||||
void refreshView();
|
||||
void addItem(void);
|
||||
void delItem(void);
|
||||
void insItem(void);
|
||||
|
||||
|
||||
|
||||
QStandardItem * getItem(QStandardItemModel *model, QString s);
|
||||
QStandardItem * getItem(QStandardItem *item, QString s);
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void appendParameter(mavlink_message_t msg);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int selectedSystemID; ///< Currently selected system
|
||||
int selectedComponentID; ///< Currently selected component
|
||||
QMap<int, int> systems; ///< Already observed systems
|
||||
QMap<int, int> components; ///< Already observed components
|
||||
|
||||
QMap<int, QTreeWidgetItem* > uasTreeWidgetItems; ///< Tree of available uas with their widget
|
||||
QMap<int, QMap<int, QTreeWidgetItem*>* > uasMsgTreeItems; ///< Stores the widget of the received message for each UAS
|
||||
|
||||
QMap<int, mavlink_param_value_t* > ParameterStorage; ///< Stores the parameter for every UAS
|
||||
|
||||
|
||||
|
||||
|
||||
QMap<int,QMap<int,mavlink_param_value_t*>*> vehicles;
|
||||
|
||||
|
||||
|
||||
Ui::ParameterInspector *ui;
|
||||
};
|
||||
|
||||
#endif // PARAMETERINSPECTOR_H
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>531</width>
|
||||
<height>421</height>
|
||||
<width>627</width>
|
||||
<height>416</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -35,7 +35,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="systemComboBox"/>
|
||||
<widget class="QComboBox" name="systemComboBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
@@ -54,6 +61,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ReadButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>read</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@@ -82,15 +115,14 @@
|
||||
</item>
|
||||
<item row="0" column="1" rowspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="ReadButton">
|
||||
<property name="text">
|
||||
<string>read</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="WriteButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>write</string>
|
||||
</property>
|
||||
@@ -98,6 +130,12 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="SearchButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>search</string>
|
||||
</property>
|
||||
@@ -105,6 +143,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>95</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>id</string>
|
||||
</property>
|
||||
@@ -115,19 +159,22 @@
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>95</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="ReadcomboBox"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<width>180</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user