指令可以在线载入,语音播报高度速度
This commit is contained in:
+165
-11
@@ -15,6 +15,7 @@ const char* CommandUI::_CommandButtonJsonKey = "CommandButton";
|
||||
const char* CommandUI::_WidthJsonKey = "Width";
|
||||
const char* CommandUI::_HeightJsonKey = "Height";
|
||||
|
||||
const char* CommandUI::_dialogJsonKey = "Dialog";
|
||||
const char* CommandUI::_TextJsonKey = "Text";
|
||||
const char* CommandUI::_rowJsonKey = "row";
|
||||
const char* CommandUI::_columnJsonKey = "column";
|
||||
@@ -57,8 +58,7 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
|
||||
|
||||
//载入json
|
||||
//loadCommandJson(":/json/Command.json");
|
||||
loadCommandJson("./commands/Command.json");
|
||||
loadCommandJson(CommandFile);
|
||||
|
||||
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
|
||||
|
||||
@@ -90,6 +90,12 @@ CommandUI::CommandUI(QWidget *parent) :
|
||||
|
||||
}
|
||||
|
||||
|
||||
DoubleClickTimer = new QTimer(this);
|
||||
DoubleClickTimer->setInterval(200);//0.2s之内再点击,那就相当于双击
|
||||
connect(DoubleClickTimer,SIGNAL(timeout()),
|
||||
this,SLOT(DoubleClickTimeout()));
|
||||
|
||||
}
|
||||
|
||||
CommandUI::~CommandUI()
|
||||
@@ -120,6 +126,138 @@ void CommandUI::wheelEvent(QWheelEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void CommandUI::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
qDebug() << "clicked";
|
||||
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
QObjectList olist = ui->groupBox_Command->children();
|
||||
|
||||
foreach (QObject *obj, olist) {
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
disconnect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
delete btn;
|
||||
}
|
||||
|
||||
QLabel *lab = qobject_cast<QLabel *>(obj);
|
||||
if(lab)
|
||||
{
|
||||
delete lab;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadCommandJson(CommandFile);
|
||||
|
||||
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPushButton *btn = new QPushButton(ui->groupBox_Command);
|
||||
|
||||
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
|
||||
|
||||
//btn->setMinimumSize(CMDwidth,CMDheight);
|
||||
//btn->resize(CMDwidth,CMDheight);
|
||||
btn->setFixedSize(CMDwidth,CMDheight);
|
||||
|
||||
ui->gridLayout_Command->addWidget(btn,
|
||||
info.toObject().find(_rowJsonKey).value().toInt(),
|
||||
info.toObject().find(_columnJsonKey).value().toInt());
|
||||
|
||||
btn->setProperty("state",state::success);
|
||||
btn->style()->unpolish(btn);
|
||||
btn->style()->polish(btn);
|
||||
|
||||
connect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
}
|
||||
}
|
||||
else if (event->button() == Qt::RightButton)
|
||||
{
|
||||
|
||||
if(event->modifiers() == Qt::ControlModifier)
|
||||
{
|
||||
QFileDialog *dlg = new QFileDialog();
|
||||
|
||||
QString fileName = dlg->getOpenFileName(this, tr("Selete Command File..."),
|
||||
"./commands/",
|
||||
tr("command file (*.json)"));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
setCommandFile(fileName);
|
||||
}
|
||||
}
|
||||
else if(event->modifiers() == Qt::AltModifier)
|
||||
{
|
||||
CommandEditor *edit = new CommandEditor();
|
||||
edit->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandUI::setCommandFile(QString File)
|
||||
{
|
||||
CommandFile = File;
|
||||
|
||||
QObjectList olist = ui->groupBox_Command->children();
|
||||
|
||||
foreach (QObject *obj, olist) {
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
disconnect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
delete btn;
|
||||
}
|
||||
|
||||
QLabel *lab = qobject_cast<QLabel *>(obj);
|
||||
if(lab)
|
||||
{
|
||||
delete lab;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadCommandJson(CommandFile);
|
||||
|
||||
ui->groupBox_Command->setTitle(tr("Command Version:") + QString::number(CMD_version));
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPushButton *btn = new QPushButton(ui->groupBox_Command);
|
||||
|
||||
btn->setText(info.toObject().find(_TextJsonKey).value().toString());
|
||||
|
||||
//btn->setMinimumSize(CMDwidth,CMDheight);
|
||||
//btn->resize(CMDwidth,CMDheight);
|
||||
btn->setFixedSize(CMDwidth,CMDheight);
|
||||
|
||||
ui->gridLayout_Command->addWidget(btn,
|
||||
info.toObject().find(_rowJsonKey).value().toInt(),
|
||||
info.toObject().find(_columnJsonKey).value().toInt());
|
||||
|
||||
btn->setProperty("state",state::success);
|
||||
btn->style()->unpolish(btn);
|
||||
btn->style()->polish(btn);
|
||||
|
||||
connect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
{
|
||||
if (jsonFilename.isEmpty()) {
|
||||
@@ -148,6 +286,8 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
CMD_version = json.value(_versionJsonKey).toInt();
|
||||
qDebug() << "command version :" << CMD_version;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if (version != 1) {
|
||||
qWarning() << jsonFilename << "Invalid version" << version;
|
||||
@@ -166,11 +306,8 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate over MissionCommandUIInfo objects
|
||||
CMD_infoArray = jsonValue.toArray();
|
||||
|
||||
//qDebug() << CMD_infoArray;
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
qWarning() << jsonFilename << "mavCmdArray should contain objects";
|
||||
@@ -244,7 +381,7 @@ void CommandUI::on_commandClicked()
|
||||
m_confirm = info.toObject().find(_confirmJsonKey).value().toInt();
|
||||
|
||||
//如果confirm 不为0,那么弹出确认对话框
|
||||
if(m_confirm != 0)
|
||||
if(info.toObject().find(_dialogJsonKey).value().toInt() != 0)
|
||||
{
|
||||
|
||||
//根据这个comfirm 确定要输入的参数
|
||||
@@ -414,11 +551,28 @@ void CommandUI::missionConfirm(int seq)
|
||||
}
|
||||
|
||||
|
||||
void CommandUI::DoubleClickTimeout()
|
||||
{
|
||||
DoubleClickTimer->stop();
|
||||
}
|
||||
|
||||
|
||||
void CommandUI::on_groupBox_Command_clicked()
|
||||
{
|
||||
qDebug() << "clicked";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(DoubleClickTimer)
|
||||
{
|
||||
if(DoubleClickTimer->isActive())
|
||||
{
|
||||
//双击后的效果
|
||||
qDebug() << "double";
|
||||
DoubleClickTimer->stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "clicked";
|
||||
DoubleClickTimer->start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "QJsonParseError"
|
||||
|
||||
#include "QDir"
|
||||
#include "QFileDialog"
|
||||
|
||||
#include <QCommonStyle>
|
||||
#include "QStyle"
|
||||
@@ -22,6 +23,7 @@
|
||||
#include "Inputter.h"
|
||||
#include "CharInputter.h"
|
||||
#include "Confirm.h"
|
||||
#include "CommandEditor.h"
|
||||
|
||||
#include "QMouseEvent"
|
||||
|
||||
@@ -49,6 +51,7 @@ public:
|
||||
protected:
|
||||
|
||||
void wheelEvent(QWheelEvent *e);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -56,6 +59,8 @@ public slots:
|
||||
|
||||
void missionConfirm(int seq);
|
||||
|
||||
void setCommandFile(QString File);
|
||||
|
||||
signals:
|
||||
|
||||
void SetCurrentPoint(int seq);
|
||||
@@ -67,11 +72,14 @@ private slots:
|
||||
|
||||
void on_commandClicked();
|
||||
|
||||
void DoubleClickTimeout();
|
||||
|
||||
void setSecondConfirm(QVariant value);
|
||||
|
||||
void setCurrent(QVariant value);
|
||||
|
||||
void on_groupBox_Command_clicked();
|
||||
|
||||
protected:
|
||||
|
||||
void loadCommandJson(const QString& jsonFilename);
|
||||
@@ -85,7 +93,7 @@ private:
|
||||
|
||||
static const char* _WidthJsonKey;
|
||||
static const char* _HeightJsonKey;
|
||||
|
||||
static const char* _dialogJsonKey;
|
||||
static const char* _TextJsonKey;
|
||||
static const char* _rowJsonKey;
|
||||
static const char* _columnJsonKey;
|
||||
@@ -113,6 +121,11 @@ private:
|
||||
|
||||
Ui::CommandUI *ui;
|
||||
|
||||
QTimer *DoubleClickTimer = nullptr;
|
||||
|
||||
|
||||
QString CommandFile = "./commands/Command.json";
|
||||
|
||||
QString m_name = 0;
|
||||
|
||||
float m_param1 = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@ INCLUDEPATH += $$PWD/../ComponentUI/Inputter
|
||||
INCLUDEPATH += $$PWD/../ComponentUI/MultiSelector
|
||||
INCLUDEPATH += $$PWD/../ComponentUI/Selector
|
||||
INCLUDEPATH += $$PWD/../ComponentUI/Confirm
|
||||
|
||||
INCLUDEPATH += $$PWD/../ComponentUI/CommandEditor
|
||||
|
||||
|
||||
#添加mavlink目录
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "CommandEditor.h"
|
||||
#include "ui_CommandEditor.h"
|
||||
|
||||
CommandEditor::CommandEditor(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CommandEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QWidget::setAcceptDrops(true);
|
||||
}
|
||||
|
||||
CommandEditor::~CommandEditor()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void CommandEditor::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
|
||||
QDrag *drag = new QDrag(this);
|
||||
QMimeData *mimeData = new QMimeData;
|
||||
|
||||
mimeData->setText(ui->pushButton->text());
|
||||
|
||||
mimeData->setObjectName("pu");
|
||||
|
||||
drag->setMimeData(mimeData);
|
||||
//drag->setPixmap(iconPixmap);
|
||||
|
||||
Qt::DropAction dropAction = drag->exec();
|
||||
qDebug() << dropAction;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandEditor::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
qDebug() << event;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CommandEditor::dragLeaveEvent(QDragLeaveEvent *event)
|
||||
{
|
||||
qDebug() << event;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void CommandEditor::dragMoveEvent(QDragMoveEvent *event)
|
||||
{
|
||||
qDebug() << event;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef COMMANDEDITOR_H
|
||||
#define COMMANDEDITOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "QDebug"
|
||||
#include "QMouseEvent"
|
||||
#include "QDrag"
|
||||
#include "QDropEvent"
|
||||
#include "QMimeData"
|
||||
|
||||
namespace Ui {
|
||||
class CommandEditor;
|
||||
}
|
||||
|
||||
class CommandEditor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CommandEditor(QWidget *parent = nullptr);
|
||||
~CommandEditor();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
void dragMoveEvent(QDragMoveEvent *event);
|
||||
|
||||
private:
|
||||
Ui::CommandEditor *ui;
|
||||
};
|
||||
|
||||
#endif // COMMANDEDITOR_H
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/CommandEditor.qrc
|
||||
|
||||
FORMS += \
|
||||
$$PWD/CommandEditor.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/CommandEditor.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/CommandEditor.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qss">
|
||||
<file>CommandEditor.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,47 @@
|
||||
.QFrame {
|
||||
background-color: #FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
QListWidget {
|
||||
background-color: #F0FFFF;
|
||||
border-width: 2px;
|
||||
border-color: darkkhaki;
|
||||
border-style: solid;
|
||||
border-radius: 5;
|
||||
padding: 3px;
|
||||
font: 20px;
|
||||
}
|
||||
|
||||
QListWidget::Item {
|
||||
height: 60;
|
||||
}
|
||||
|
||||
|
||||
QScrollBar{
|
||||
width:60;
|
||||
background-color:palegoldenrod;
|
||||
}
|
||||
|
||||
.QPushButton {
|
||||
background-color: #FFFFFF;
|
||||
border-width: 2px;
|
||||
border-color: darkkhaki;
|
||||
border-style: solid;
|
||||
border-radius: 5;
|
||||
padding: 3px;
|
||||
font :15px;
|
||||
}
|
||||
|
||||
.QPushButton:pressed {
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #dadbde, stop: 1 #f6f7fa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CommandEditor</class>
|
||||
<widget class="QWidget" name="CommandEditor">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>767</width>
|
||||
<height>425</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QFrame" name="frame_2">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>80</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<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="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QFrame" name="frame_3">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -6,7 +6,7 @@ include(./Multiselector/Multiselector.pri)
|
||||
include(./Selector/Selector.pri)
|
||||
include(./Confirm/Confirm.pri)
|
||||
include(./Scope/Scope.pri)
|
||||
|
||||
include(./CommandEditor/CommandEditor.pri)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1538,20 +1538,16 @@ void propertyui::setLoad(QVariant value)
|
||||
qDebug() << "Loadvalue" << value;
|
||||
if(value.toBool() == true)
|
||||
{
|
||||
QFileDialog *dlg = new QFileDialog(this);
|
||||
dlg->setWindowTitle(tr("Select Loading File..."));
|
||||
dlg->show();
|
||||
QFileDialog *dlg = new QFileDialog();
|
||||
|
||||
QStringList sFileDir;
|
||||
|
||||
int ret = dlg->exec();
|
||||
if (QDialog::Accepted == ret)
|
||||
QString fileName = dlg->getOpenFileName(this, tr("Selete Way Point File..."),
|
||||
"./plan/",
|
||||
tr("plan file (*.plan)"));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
sFileDir = dlg->selectedFiles();
|
||||
|
||||
qDebug() << sFileDir.at(0);
|
||||
emit WPLoad(sFileDir.at(0));
|
||||
emit WPLoad(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1576,22 +1572,16 @@ void propertyui::on_pushButton_Load_clicked()
|
||||
|
||||
void propertyui::on_pushButton_Save_clicked()
|
||||
{
|
||||
QFileDialog *dlg = new QFileDialog(this);
|
||||
QFileDialog *dlg = new QFileDialog();
|
||||
|
||||
dlg->setWindowTitle(tr("Select Loading File..."));
|
||||
dlg->show();
|
||||
|
||||
QStringList sFileDir;
|
||||
|
||||
int ret = dlg->exec();
|
||||
if (QDialog::Accepted == ret)
|
||||
QString fileName = dlg->getSaveFileName(this, tr("Selete Way Point File..."),
|
||||
"./plan/",
|
||||
tr("plan file (*.plan)"));
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
sFileDir = dlg->selectedFiles();
|
||||
|
||||
qDebug() << sFileDir.at(0);
|
||||
|
||||
emit WPSave(sFileDir.at(0));
|
||||
emit WPSave(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void propertyui::on_pushButton_Upload_clicked()
|
||||
|
||||
@@ -46,6 +46,61 @@ ParameterInspector::~ParameterInspector()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void ParameterInspector::keyPressEvent(QKeyEvent *event) //键盘按下事件
|
||||
{
|
||||
qDebug() << "keyPressEvent" << event;
|
||||
}
|
||||
void ParameterInspector::keyReleaseEvent(QKeyEvent *event) //键盘松开事件
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Backspace:
|
||||
fineItem = fineItem.mid(0,fineItem.size() - 1);
|
||||
break;
|
||||
case Qt::Key_Delete:
|
||||
fineItem = fineItem.mid(0,fineItem.size() - 1);
|
||||
break;
|
||||
default:
|
||||
fineItem.append(event->text());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
qDebug() << fineItem;
|
||||
QTreeWidgetItemIterator I(ui->treeWidget);
|
||||
|
||||
//while(*Item)
|
||||
if(*I)
|
||||
{
|
||||
QTreeWidgetItem *item = *I;
|
||||
if(!item->parent())
|
||||
{
|
||||
qDebug() << "orphan" ;
|
||||
//找到最顶的项
|
||||
|
||||
QList<QTreeWidgetItem *> childList = item->takeChildren();
|
||||
|
||||
for(QTreeWidgetItem * child:childList)
|
||||
{
|
||||
qDebug() << child->text(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//QTreeWidgetItem *item;
|
||||
|
||||
//item = ui->treeWidget
|
||||
|
||||
//parentItem = item->parent()->data(0,Qt::DisplayRole).toString();
|
||||
|
||||
//currentSelectType = param_gettype(item->data(2,Qt::DisplayRole));
|
||||
|
||||
//触发一次查询
|
||||
}
|
||||
|
||||
|
||||
void ParameterInspector::mReflush()
|
||||
{
|
||||
if(isReflush == true)
|
||||
@@ -86,9 +141,6 @@ void ParameterInspector::addVehicles(int sysid, int compid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//直接接受整个msg,这个函数传来的只有param_value这一帧,因此不需要识别
|
||||
void ParameterInspector::appendParameter(mavlink_message_t msg)
|
||||
{
|
||||
@@ -109,14 +161,28 @@ void ParameterInspector::appendParameter(mavlink_message_t msg)
|
||||
//如果当前是航点0,那么设置状态条
|
||||
if(param_value.param_index == 0)
|
||||
{
|
||||
isNew = true;
|
||||
ui->progressBar->setMaximum(0);
|
||||
ui->progressBar->setMaximum(param_value.param_count - 1);
|
||||
}
|
||||
|
||||
|
||||
if(isNew)
|
||||
{
|
||||
currentpersent = param_value.param_index;
|
||||
}
|
||||
|
||||
|
||||
if(param_value.param_index == (param_value.param_count - 1))
|
||||
{
|
||||
isNew = false;
|
||||
}
|
||||
|
||||
|
||||
//这里可能有bug,程序会死机
|
||||
//ui->progressBar->setValue((int)param_value.param_index);
|
||||
|
||||
currentpersent = param_value.param_index;
|
||||
|
||||
|
||||
//检查是否包含了该参数,如果没有,那么添加
|
||||
QMap<int, mavlink_param_value_t> ParameterStorage;
|
||||
@@ -207,7 +273,10 @@ void ParameterInspector::refreshView()//来一个参数更新一次
|
||||
ui->treeWidget->addTopLevelItems(uasTopLevelItems.values());
|
||||
|
||||
ui->treeWidget->expandAll();
|
||||
ui->treeWidget->scrollToBottom();
|
||||
if(isNew)
|
||||
{
|
||||
ui->treeWidget->scrollToBottom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include "QPushButton"
|
||||
#include "QTreeView"
|
||||
#include "QDebug"
|
||||
|
||||
#include <QTreeWidgetItemIterator>
|
||||
#include "QMap"
|
||||
#include <QList>
|
||||
#include "QStandardItemModel"
|
||||
#include "QTimer"
|
||||
|
||||
#include "QKeyEvent"
|
||||
|
||||
|
||||
#include "QDateTime"
|
||||
@@ -127,8 +127,9 @@ public slots:
|
||||
void appendParameter(mavlink_message_t msg);
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
|
||||
|
||||
private slots:
|
||||
@@ -218,6 +219,11 @@ private:
|
||||
|
||||
QTimer *flushTimer = nullptr;
|
||||
|
||||
bool isNew = true;
|
||||
|
||||
QString fineItem;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -204,6 +204,9 @@
|
||||
<property name="textDirection">
|
||||
<enum>QProgressBar::BottomToTop</enum>
|
||||
</property>
|
||||
<property name="format">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -63,10 +63,10 @@
|
||||
<item row="14" column="1">
|
||||
<widget class="QProgressBar" name="progressBar_0_15">
|
||||
<property name="minimum">
|
||||
<number>800</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2200</number>
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
@@ -413,10 +413,10 @@
|
||||
<item row="13" column="1">
|
||||
<widget class="QProgressBar" name="progressBar_0_14">
|
||||
<property name="minimum">
|
||||
<number>800</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2200</number>
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1500</number>
|
||||
|
||||
@@ -215,6 +215,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(map,SIGNAL(WPProperty(float,float,float,float,int32_t,int32_t,float,uint16_t,uint16_t,uint16_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t)),
|
||||
dlink->mavlinknode->Mission,SLOT(transmitPoint(float,float,float,float,int32_t,int32_t,float,uint16_t,uint16_t,uint16_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
connect(dlink->mavlinknode->Mission,SIGNAL(clearWaypoint()),
|
||||
map,SLOT(WPDeleteAll()));
|
||||
|
||||
|
||||
connect(dlink->mavlinknode,SIGNAL(addVehicles(int,int)),
|
||||
map,SLOT(addUAV(int,int)));
|
||||
|
||||
@@ -555,6 +559,9 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
bool isCustomChanged = false;
|
||||
bool isStateChanged = false;
|
||||
|
||||
static quint64 lastTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
static int frq_count = 0;
|
||||
@@ -647,6 +654,24 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
switch (state) {
|
||||
case MAV_MODE_FLAG_SAFETY_ARMED:
|
||||
arm_str.append(tr("ARM"));
|
||||
|
||||
if(tts)
|
||||
{
|
||||
if((QDateTime::currentMSecsSinceEpoch() - lastTime) >= 5000)
|
||||
{
|
||||
lastTime = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
QString status;
|
||||
|
||||
status.append(tr("高度:%1").arg(QString::number(dlink->mavlinknode->vehicle.global_position_int.relative_alt * 0.001,'f',0)));
|
||||
status.append(tr("速度:%1").arg(QString::number(dlink->mavlinknode->vehicle.vfr_hud.airspeed,'f',0)));
|
||||
|
||||
tts->say(status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
break;
|
||||
case 0:
|
||||
arm_str.append(tr("DISARM"));
|
||||
@@ -741,6 +766,8 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//经纬度大于正常值,将舍弃
|
||||
|
||||
double lat = (double)(dlink->mavlinknode->vehicle.gps_raw_int.lat * 10e-8);
|
||||
|
||||
@@ -260,6 +260,11 @@ void MissionProcess::Parse(mavlink_message_t msg)
|
||||
|
||||
qDebug() << "recieve mission " << mission_item_int.seq;
|
||||
|
||||
if(mission_item_int.seq == 0)
|
||||
{
|
||||
emit clearWaypoint();
|
||||
}
|
||||
|
||||
//把航点发出去
|
||||
emit receivedPoint(mission_item_int.param1,mission_item_int.param2,mission_item_int.param3,mission_item_int.param4,
|
||||
mission_item_int.x,mission_item_int.y,mission_item_int.z,
|
||||
|
||||
@@ -142,6 +142,8 @@ private slots:
|
||||
|
||||
signals:
|
||||
|
||||
void clearWaypoint(void);
|
||||
|
||||
void readReady();
|
||||
|
||||
|
||||
|
||||
+69
-19
@@ -8,7 +8,7 @@ Replay::Replay(QObject *parent) : QObject(parent)
|
||||
thread = new QThread();
|
||||
this->moveToThread(thread);
|
||||
connect(thread, SIGNAL(started()), this, SLOT(process()));
|
||||
setRunFrq(20);//100
|
||||
setRunFrq(5);//100
|
||||
|
||||
logFile.clear();
|
||||
}
|
||||
@@ -97,24 +97,46 @@ void Replay::stop()
|
||||
void Replay::process()//线程函数
|
||||
{
|
||||
quint64 lastTimestamp = 0;
|
||||
quint64 currentTimestamp = 0;
|
||||
|
||||
quint64 timeStamp = 0;
|
||||
|
||||
while (running_flag)
|
||||
{
|
||||
//mutex.lock();
|
||||
if(isplaying)
|
||||
{
|
||||
if(!ispause)//不暂停
|
||||
{
|
||||
QThread::msleep(5);
|
||||
//读取数据放到缓存里面
|
||||
if(file)//已经有文件,那么可以读取
|
||||
{
|
||||
if(position <= file->size())
|
||||
{
|
||||
QByteArray raw;
|
||||
file->seek(position);
|
||||
raw = file->read(500);
|
||||
QByteArray time;
|
||||
|
||||
file->seek(position);
|
||||
|
||||
raw = file->read(MAVLINK_MAX_PACKET_LEN + sizeof(quint64));
|
||||
|
||||
if(raw.indexOf(0xFD) >= 8)
|
||||
{
|
||||
time = raw.mid(raw.indexOf(0xFD) - 8,8);
|
||||
}
|
||||
else
|
||||
{
|
||||
position -= 8 - raw.indexOf(0xFD);
|
||||
|
||||
file->seek(position);
|
||||
|
||||
raw = file->read(MAVLINK_MAX_PACKET_LEN + sizeof(quint64));
|
||||
|
||||
time = raw.mid(raw.indexOf(0xFD) - 8,8);
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << raw.indexOf(0xFD);
|
||||
|
||||
QByteArray time = raw.mid(raw.indexOf(0xFD) - 8,8);
|
||||
quint64 currentTimestamp = 0;
|
||||
|
||||
union {uint8_t B[8];uint64_t DW;}src;
|
||||
|
||||
@@ -129,35 +151,63 @@ void Replay::process()//线程函数
|
||||
|
||||
currentTimestamp = src.DW/1000;
|
||||
|
||||
QThread::msleep(currentTimestamp - lastTimestamp);
|
||||
if(lastTimestamp == 0)
|
||||
{
|
||||
lastTimestamp = currentTimestamp - 50;
|
||||
}
|
||||
|
||||
if(((currentTimestamp - lastTimestamp) >0)&&((currentTimestamp - lastTimestamp) < 5000))
|
||||
{
|
||||
timeStamp = currentTimestamp - lastTimestamp;
|
||||
}
|
||||
|
||||
if((currentTimestamp - lastTimestamp) >0)
|
||||
{
|
||||
QThread::msleep(timeStamp);
|
||||
}
|
||||
|
||||
position += (uint8_t)raw.at(raw.indexOf(0xFD)+1) + 20;
|
||||
|
||||
buff.clear();
|
||||
buff = raw.mid(raw.indexOf(0xFD),(uint8_t)raw.at(raw.indexOf(0xFD) +1) + 12);
|
||||
|
||||
//读取一帧数据
|
||||
//将百分比增加,或者位置增加
|
||||
percentage = (float)position / file->size();
|
||||
emit currentPercentage(percentage);
|
||||
emit readReady();
|
||||
|
||||
|
||||
/*
|
||||
qDebug() << position
|
||||
<< currentTimestamp
|
||||
<< lastTimestamp
|
||||
<< currentTimestamp - lastTimestamp;
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
lastTimestamp = currentTimestamp;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit replayComplete();
|
||||
isplaying = false;//换成另外的标志
|
||||
isplaying = false;
|
||||
}
|
||||
|
||||
//qDebug() << position << file->size() << percentage;
|
||||
//读取一帧数据
|
||||
//将百分比增加,或者位置增加
|
||||
percentage = (float)position / file->size();
|
||||
|
||||
emit currentPercentage(percentage);
|
||||
}
|
||||
//发送就绪信号
|
||||
emit readReady();
|
||||
}
|
||||
else
|
||||
{
|
||||
QThread::msleep(1000);//如果没有播放,那么每秒钟检测一下是否要播放
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QThread::msleep(1000);//如果没有播放,那么每秒钟检测一下是否要播放
|
||||
}
|
||||
//mutex.unlock();
|
||||
}
|
||||
//退出线程
|
||||
disconnect(thread, nullptr, nullptr, nullptr);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include "QThread"
|
||||
#include "QMutex"
|
||||
#include "QMessageBox"
|
||||
#include "QDebug"
|
||||
#include "QFile"
|
||||
@@ -68,6 +69,8 @@ protected:
|
||||
bool running_flag = false;
|
||||
bool isSleep = false;
|
||||
quint32 running_frq = 200;//200Hz
|
||||
QMutex mutex;
|
||||
|
||||
|
||||
QThread *thread = nullptr;
|
||||
QString logFile;
|
||||
@@ -79,6 +82,7 @@ protected:
|
||||
bool isplaying = false;//控制开始和结束
|
||||
QByteArray buff;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MAVLINKNODE_H
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
Reference in New Issue
Block a user