make version 1.0

This commit is contained in:
hm
2020-08-10 22:42:59 +08:00
parent 02041fcf85
commit 965750b7bc
18 changed files with 330 additions and 192 deletions
+42 -11
View File
@@ -199,7 +199,6 @@ void CommandUI::on_commandClicked()
}
//找到id或者名字一样的按键,找到参数,发出去
QString _name = info.toObject().find(_TextJsonKey).value().toString();
QString _text = btn->text();
@@ -219,6 +218,9 @@ void CommandUI::on_commandClicked()
//如果confirm 不为0,那么弹出确认对话框
if(confirm != 0)
{
//根据这个comfirm 确定要输入的参数
Confirm *confirmor = new Confirm(this);
confirmor->setGeometry(0,0,this->width(),this->height());
@@ -261,10 +263,10 @@ void CommandUI::on_commandClicked()
void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
{
bool isFundSender = false;
QString string;
//找到消息的发送者
QObjectList list = ui->groupBox_Command->children();
for(QJsonValue info: CMD_infoArray) {
if (!info.isObject()) {
return;
@@ -272,6 +274,8 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
if(command == info.toObject().find(_commandJsonKey).value().toInt())
{
isFundSender = true;
foreach (QObject *obj, list)
{
QPushButton *btn = qobject_cast<QPushButton *>(obj);
@@ -279,10 +283,9 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
{
QString btn_name = btn->text();
if(btn_name == info.toObject().find(_TextJsonKey).value().toString())
{
QString string;
if(flag)
{
btn->setProperty("state",state::success);
@@ -318,17 +321,45 @@ void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
btn->style()->unpolish(btn);
btn->style()->polish(btn);
}
}
}
}
}
if(isFundSender == false)
{
switch (result) {
case MAV_RESULT_ACCEPTED:
string.append(tr("%1 accepted and executed").arg(command));
break;
case MAV_RESULT_TEMPORARILY_REJECTED:
string.append(tr("%1 rejected").arg(command));
break;
case MAV_RESULT_DENIED:
string.append(tr("%1 permanently denied").arg(command));
break;
case MAV_RESULT_UNSUPPORTED:
string.append(tr("%1 unsupported").arg(command));
break;
case MAV_RESULT_FAILED:
string.append(tr("%1 failed").arg(command));
break;
case MAV_RESULT_IN_PROGRESS:
string.append(tr("%1 being executed").arg(command));
break;
default:
break;
}
}
QTextToSpeech *tts = new QTextToSpeech();
tts->say(string);
}
}
}
}
}
}
+123 -8
View File
@@ -1,4 +1,4 @@
#include "Inputter.h"
#include "Inputter.h"
#include "ui_Inputter.h"
Inputter::Inputter(QWidget *parent) :
@@ -17,12 +17,21 @@ Inputter::Inputter(QWidget *parent) :
curentStr = "";
currentValue = 0;
inputType = 0;
inputType = type::Normal;
DecimalPlaces = -1;
ui->lineEdit->setText(curentStr);
ui->lineEdit->setReadOnly(true);
DoubleClickTimer = new QTimer(this);
DoubleClickTimer->setInterval(300);//0.5s之内再点击,那就相当于双击
connect(DoubleClickTimer,SIGNAL(timeout()),
this,SLOT(DoubleClickTimeout()));
}
Inputter::~Inputter()
@@ -41,7 +50,17 @@ bool Inputter::event(QEvent *event)
void Inputter::setInputType(int Type)
{
inputType = Type;
switch (Type) {
default:
case 0:
inputType = type::Normal;
break;
case 1:
inputType = type::MAC;
ui->pushButton_nan->setEnabled(false);
ui->pushButton_minus->setEnabled(false);
break;
}
}
void Inputter::setInitValue(QVariant value)
@@ -56,11 +75,60 @@ void Inputter::setDecimalPlaces(int value)
}
void Inputter::on_NumberClicked(QString str)
{
if((!curentStr.contains('n'))&&(!curentStr.contains('a')))
{
if(inputType == type::Normal)
{
curentStr.append(str);
ui->lineEdit->setText(curentStr);
}
else//检查当前释放点和点连在一起,是否点之间数字大于255
{
QString mac = curentStr;
int index;
if(mac.contains('.'))
{
index = mac.lastIndexOf('.')+1;
}
else
{
index = 0;
}
mac = mac.mid(index);
mac.append(str);
if(mac.toInt() <= 255)
{
//如果上一个是0,这个也是0,那么就不用连接
if(mac != 0)
{
curentStr.append(str);
ui->lineEdit->setText(curentStr);
}
}
else
{
if(curentStr.count('.') < 3)
{
curentStr.append('.');
curentStr.append(str);
ui->lineEdit->setText(curentStr);
}
}
}
}
}
void Inputter::DoubleClickTimeout()
{
DoubleClickTimer->stop();
}
void Inputter::on_pushButton_1_clicked()
{
@@ -109,7 +177,7 @@ void Inputter::on_pushButton_9_clicked()
void Inputter::on_pushButton_point_clicked()
{
if(inputType == 0)
if(inputType == type::Normal)
{
if(curentStr.size()>0)
{
@@ -131,10 +199,20 @@ void Inputter::on_pushButton_point_clicked()
}
}
else
{
if(curentStr.size()>0)
{
if((curentStr.data()[curentStr.size() -1]!= '.')&&(curentStr.count('.')<3))//数量小于3
{
on_NumberClicked(ui->pushButton_point->text());
}
}
else
{
qDebug() << "point can't be set in first char";
}
}
}
void Inputter::on_pushButton_0_clicked()
{
@@ -143,7 +221,9 @@ void Inputter::on_pushButton_0_clicked()
void Inputter::on_pushButton_minus_clicked()
{
if(inputType == 0)
if(inputType == type::Normal)
{
if((!curentStr.contains('n'))&&(!curentStr.contains('a')))
{
if(curentStr.at(0) == '-')
{
@@ -153,6 +233,7 @@ void Inputter::on_pushButton_minus_clicked()
{
curentStr.insert(0,'-');
}
}
ui->lineEdit->setText(curentStr);
}
@@ -163,6 +244,20 @@ void Inputter::on_pushButton_del_clicked()
{
curentStr = curentStr.mid(0,curentStr.size() - 1);
ui->lineEdit->setText(curentStr);
if(DoubleClickTimer)
{
if(DoubleClickTimer->isActive())
{
curentStr.clear();
ui->lineEdit->clear();
DoubleClickTimer->stop();
}
else
{
DoubleClickTimer->start();
}
}
}
void Inputter::on_pushButton_cancel_clicked()
@@ -172,7 +267,7 @@ void Inputter::on_pushButton_cancel_clicked()
void Inputter::on_pushButton_ok_clicked()
{
if(inputType == 0)
if(inputType == type::Normal)
{
while(curentStr.at(0) == '0')
{
@@ -219,7 +314,27 @@ void Inputter::on_pushButton_ok_clicked()
else
{
//mac模式
//点数不能超过3个,而且间隔的数字不能大于255
//检查是否填充完成,没有那么就填零,把格式填对
//curentStr
while(curentStr.count('.') < 3)//检查点,如果不够就进行编辑
{
if(curentStr.data()[curentStr.size()-1] == '.')
{
curentStr.append(QString::number(0));
}
else
{
curentStr.append('.');
}
if(curentStr.count('.') >= 3)
{
break;
}
}
}
+14 -2
View File
@@ -1,10 +1,10 @@
#ifndef INPUTTER_H
#ifndef INPUTTER_H
#define INPUTTER_H
#include <QWidget>
#include "QDebug" `
#include "QFile"
#include "QTimer"
namespace Ui {
class Inputter;
@@ -15,6 +15,12 @@ class Inputter : public QWidget
Q_OBJECT
public:
enum type{
Normal = 0,
MAC,
};
explicit Inputter(QWidget *parent = nullptr);
~Inputter();
@@ -34,6 +40,8 @@ protected:
bool event(QEvent *event);
private slots:
void DoubleClickTimeout();
void on_NumberClicked(QString str);
void on_pushButton_1_clicked();
@@ -71,6 +79,10 @@ private slots:
private:
Ui::Inputter *ui;
QTimer *DoubleClickTimer = nullptr;
int inputType = 0;
int DecimalPlaces;
+9 -26
View File
@@ -34,11 +34,8 @@ Scope::Scope(QWidget *parent) :
//chartView->setRubberBand(QChartView::RectangleRubberBand);
//chartView->chart()->setAcceptDrops(true);
QValueAxis *axisX = new QValueAxis();
axisX->setRange(0, 10);
axisX->setRange(-5, 5);
axisX->setTickCount(11);
axisX->setLabelFormat("%.2f");
chartView->chart()->addAxis(axisX, Qt::AlignBottom);
@@ -54,7 +51,14 @@ Scope::Scope(QWidget *parent) :
//默认不使用,因为使用显卡加速图形会闪
setUseOpenGL(false);
QTimer::singleShot(10,this,SLOT(timeout()));
updateTimer = new QTimer(this);
connect(updateTimer,SIGNAL(timeout()),
this,SLOT(timeout()));
updateTimer->start(50);//20hz刷新
//不要轻易使用singleShot,容易引起内存超限
//QTimer::singleShot(10,this,SLOT(timeout()));
}
@@ -180,27 +184,6 @@ void Scope::chartUpdate(void)
{
//读取新数据,如果没有,那就保持
//setSerieData("sin",sin(timeseries));
//setSerieData("cos",cos(timeseries));
//setSerieData("tan",tan(timeseries));
//setSerieData("acos",acos(timeseries));
//setSerieData("asin",asin(timeseries));
//setSerieData("atan",atan(timeseries));
//setSerieData("x1",1 * timeseries + 1);
//setSerieData("x2",timeseries * timeseries + 1);
//setSerieData("x3",timeseries * timeseries * timeseries + 1);
//setSerieData("sqrt",sqrt(timeseries));
//setSerieData("pow",pow(timeseries,2));
//setSerieData("log",log(timeseries + 1));
//setSerieData("log10",log10(timeseries));
//setSerieData("exp",exp(timeseries));
//setSerieData("tan+1",tan(timeseries + 1));
//setSerieData("log2",log2(timeseries));
//setSerieData("timeseries",timeseries);
//setSerieData("12",timeseries * log(timeseries));
//滚动显示器
//当到达最大时(0.95),开始滚动
+3 -1
View File
@@ -1,4 +1,4 @@
#ifndef SCOPE_H
#ifndef SCOPE_H
#define SCOPE_H
#include <QWidget>
@@ -102,6 +102,8 @@ private:
QChartView *chartView;
QLineSeries *series;
QTimer *updateTimer = nullptr;
qreal timeseries = 0;//时间基准,注意时间长度,可能会出现时间反转的情况
bool isOpenGL = false;
BIN
View File
Binary file not shown.
+78 -53
View File
@@ -335,35 +335,65 @@
<translation> </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="298"/>
<location filename="CommandUI/CommandUI.cpp" line="301"/>
<source>%1,%2 accepted and executed</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="301"/>
<location filename="CommandUI/CommandUI.cpp" line="304"/>
<source>%1,%2 rejected</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="304"/>
<location filename="CommandUI/CommandUI.cpp" line="307"/>
<source>%1,%2 permanently denied</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="307"/>
<location filename="CommandUI/CommandUI.cpp" line="310"/>
<source>%1,%2 unsupported</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="310"/>
<location filename="CommandUI/CommandUI.cpp" line="313"/>
<source>%1,%2 failed</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="313"/>
<location filename="CommandUI/CommandUI.cpp" line="316"/>
<source>%1,%2 being executed</source>
<translation>%1%2 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="336"/>
<source>%1 accepted and executed</source>
<translation>%1 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="339"/>
<source>%1 rejected</source>
<translation>%1 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="342"/>
<source>%1 permanently denied</source>
<translation>%1 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="345"/>
<source>%1 unsupported</source>
<translation>%1 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="348"/>
<source>%1 failed</source>
<translation>%1 </translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="351"/>
<source>%1 being executed</source>
<translation>%1 </translation>
</message>
<message>
<source>command %1,%2 success</source>
<translation type="vanished"> %1%2 </translation>
@@ -377,7 +407,7 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="CommandUI/CommandUI.cpp" line="243"/>
<location filename="CommandUI/CommandUI.cpp" line="245"/>
<source>clicked</source>
<translation></translation>
</message>
@@ -938,167 +968,162 @@
<translation type="vanished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="216"/>
<source>bugudp数字输入的.3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="565"/>
<location filename="mainwindow.cpp" line="564"/>
<source>%1D Fix</source>
<translation>%1D </translation>
</message>
<message>
<location filename="mainwindow.cpp" line="568"/>
<location filename="mainwindow.cpp" line="567"/>
<source>Fixed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="571"/>
<location filename="mainwindow.cpp" line="570"/>
<source>Float</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="574"/>
<location filename="mainwindow.cpp" line="573"/>
<source>gps err</source>
<translation>GPS错误</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="601"/>
<location filename="mainwindow.cpp" line="600"/>
<source>ARM</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="604"/>
<location filename="mainwindow.cpp" line="603"/>
<source>DISARM</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="627"/>
<location filename="mainwindow.cpp" line="626"/>
<source>MANUAL</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="630"/>
<location filename="mainwindow.cpp" line="629"/>
<source>ALTCTL</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="633"/>
<location filename="mainwindow.cpp" line="632"/>
<source>POSCTL</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="636"/>
<location filename="mainwindow.cpp" line="635"/>
<source>AUTO</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="639"/>
<location filename="mainwindow.cpp" line="638"/>
<source>ACRO</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="642"/>
<location filename="mainwindow.cpp" line="641"/>
<source>OFFBOARD</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="645"/>
<location filename="mainwindow.cpp" line="644"/>
<source>STABILIZED</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="648"/>
<location filename="mainwindow.cpp" line="647"/>
<source>RATTITUDE</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="651"/>
<location filename="mainwindow.cpp" line="650"/>
<source>AUTO_READY</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="654"/>
<location filename="mainwindow.cpp" line="653"/>
<source>AUTO_TAKEOFF</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="657"/>
<location filename="mainwindow.cpp" line="656"/>
<source>AUTO_LOITER</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="660"/>
<location filename="mainwindow.cpp" line="659"/>
<source>AUTO_MISSION</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="663"/>
<location filename="mainwindow.cpp" line="662"/>
<source>AUTO_RTL</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="666"/>
<location filename="mainwindow.cpp" line="665"/>
<source>AUTO_LAND</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="669"/>
<location filename="mainwindow.cpp" line="668"/>
<source>AUTO_RTGS</source>
<translation>RTGS</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="672"/>
<location filename="mainwindow.cpp" line="671"/>
<source>AUTO_FOLLOW_TARGET</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="675"/>
<location filename="mainwindow.cpp" line="674"/>
<source>unsported</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="689"/>
<location filename="mainwindow.cpp" line="688"/>
<source>flight mode</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="715"/>
<location filename="mainwindow.cpp" line="714"/>
<source>&lt;h6&gt;&lt;font color=red&gt;%1&lt;/font&gt; </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="716"/>
<location filename="mainwindow.cpp" line="715"/>
<source>&lt;font color=red&gt;%1&lt;/font&gt; </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="717"/>
<location filename="mainwindow.cpp" line="716"/>
<source>&lt;font color=red&gt;%1&lt;/font&gt;&lt;/h6&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="718"/>
<location filename="mainwindow.cpp" line="717"/>
<source>&lt;h6&gt;&lt;font color=red&gt;%1&lt;/font&gt;V </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="719"/>
<location filename="mainwindow.cpp" line="718"/>
<source>&lt;font color=red&gt;%1&lt;/font&gt;&lt;/h6&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="733"/>
<location filename="mainwindow.cpp" line="732"/>
<source>&lt;h6&gt;&lt;font color=red&gt;%1&lt;/font&gt; &lt;/h6&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="734"/>
<location filename="mainwindow.cpp" line="733"/>
<source>&lt;h6&gt;&lt;font color=red&gt;%1&lt;/font&gt; &lt;/h6&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="735"/>
<location filename="mainwindow.cpp" line="734"/>
<source>&lt;h6&gt;&lt;font color=red&gt;%1&lt;/font&gt; &lt;/h6&gt;</source>
<translation type="unfinished"></translation>
</message>
@@ -1255,10 +1280,10 @@
<translation></translation>
</message>
<message>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="86"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="187"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="201"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="544"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="93"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="194"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="208"/>
<location filename="Setting/Index1/ParameterInspector/ParameterInspector.cpp" line="551"/>
<source>Vehicle %1</source>
<translation> %1</translation>
</message>
@@ -1315,7 +1340,7 @@
</message>
<message>
<location filename="ComponentUI/Scope/Scope.ui" line="90"/>
<location filename="ComponentUI/Scope/Scope.cpp" line="401"/>
<location filename="ComponentUI/Scope/Scope.cpp" line="384"/>
<source>Pause</source>
<translation></translation>
</message>
@@ -1340,7 +1365,7 @@
<translation></translation>
</message>
<message>
<location filename="ComponentUI/Scope/Scope.cpp" line="397"/>
<location filename="ComponentUI/Scope/Scope.cpp" line="380"/>
<source>Scroll</source>
<translation></translation>
</message>
@@ -1561,7 +1586,7 @@
<translation></translation>
</message>
<message>
<location filename="MissionUI/propertyui.cpp" line="1567"/>
<location filename="MissionUI/propertyui.cpp" line="1568"/>
<source>click to clear all points</source>
<translation type="unfinished"></translation>
</message>
@@ -1616,8 +1641,8 @@
<translation>6</translation>
</message>
<message>
<location filename="MissionUI/propertyui.cpp" line="1541"/>
<location filename="MissionUI/propertyui.cpp" line="1580"/>
<location filename="MissionUI/propertyui.cpp" line="1542"/>
<location filename="MissionUI/propertyui.cpp" line="1581"/>
<source>Select Loading File...</source>
<translation>...</translation>
</message>
@@ -30,7 +30,14 @@ ParameterInspector::ParameterInspector(QWidget *parent) :
ui->WriteButton->setEnabled(false);
TimerRunningFlag = true;
QTimer::singleShot(1000,this,SLOT(mReflush()));
flushTimer = new QTimer(this);
connect(flushTimer,SIGNAL(timeout()),
this,SLOT(mReflush()));
flushTimer->start(1000);
//不要轻易使用这个,容易引起超限
//QTimer::singleShot(1000,this,SLOT(mReflush()));
}
ParameterInspector::~ParameterInspector()
@@ -214,6 +214,11 @@ private:
Ui::ParameterInspector *ui;
QTimer *flushTimer = nullptr;
};
#endif // PARAMETERINSPECTOR_H
@@ -757,7 +757,7 @@ void MAVLinkInspector::updateField(mavlink_message_t* msg, const mavlink_message
{
if(scope)
{
scope->setSerieData(item->data(0,Qt::DisplayRole).toString(),item->data(1,Qt::DisplayRole));
//scope->setSerieData(item->data(0,Qt::DisplayRole).toString(),item->data(1,Qt::DisplayRole));
}
}
}
+2 -2
View File
@@ -80,7 +80,7 @@ MainWindow::MainWindow(QWidget *parent)
//this ----- dlink
connect(dlink->mavlinknode,SIGNAL(beep()),
this,SLOT(beep()));
this,SLOT(beep()),Qt::DirectConnection);
//this ----- map
connect(map,SIGNAL(TotalDistanceUpdate(double)),
@@ -701,7 +701,7 @@ void MainWindow::updateUI()//事件驱动式更新数据
dlink->mavlinknode->vehicle.compid,
dlink->mavlinknode->vehicle.attitude.yaw * 57.3);
//QTimer::singleShot
+13 -13
View File
@@ -835,7 +835,7 @@ void Cockpit::drawLeftScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(15);
font.setPointSize(90);
font.setPixelSize(90);
font.setWeight(QFont::ExtraLight);
font.setFamily("Arial");//非衬线
@@ -877,7 +877,7 @@ void Cockpit::drawLeftScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(15);
font.setPointSize(90);
font.setPixelSize(90);
font.setFamily("Arial");//非衬线
painter->setPen(ePen);
@@ -1105,7 +1105,7 @@ void Cockpit::drawRightScale(QPainter *painter)
QFont font;
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(60);
font.setPixelSize(60);
font.setWeight(QFont::ExtraLight);
font.setFamily("Arial");//非衬线
@@ -1230,7 +1230,7 @@ void Cockpit::drawRightScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(90);
font.setPixelSize(90);
painter->setPen(ePen);
painter->setFont(font);
@@ -1264,7 +1264,7 @@ void Cockpit::drawRightScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(90);
font.setPixelSize(90);
painter->setPen(ePen);
painter->setFont(font);
painter->drawText(QRect(160,-50,90,100),Qt::AlignVCenter|Qt::AlignRight, thousandText);
@@ -1280,7 +1280,7 @@ void Cockpit::drawRightScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(70);
font.setPixelSize(70);
painter->setPen(ePen);
painter->setFont(font);
//写百位
@@ -1336,7 +1336,7 @@ void Cockpit::drawRightScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(70);
font.setPixelSize(70);
painter->setPen(ePen);
painter->setFont(font);
@@ -1426,7 +1426,7 @@ void Cockpit::drawVRate(QPainter *painter)
ePen.setWidth(8);
ePen.setColor(Qt::white);
font.setPointSize(50);
font.setPixelSize(50);
font.setWeight(QFont::ExtraLight);
font.setFamily("Arial");//非衬线
@@ -1518,7 +1518,7 @@ void Cockpit::drawVRate(QPainter *painter)
ePen.setWidth(8);
ePen.setColor(m_Color.TargetColor);
font.setPointSize(50);
font.setPixelSize(50);
font.setWeight(QFont::ExtraLight);
font.setFamily("Arial");//非衬线
@@ -1537,7 +1537,7 @@ void Cockpit::drawVRate(QPainter *painter)
ePen.setWidth(8);
ePen.setColor(m_Color.CurrentColor);
font.setPointSize(50);
font.setPixelSize(50);
font.setWeight(QFont::ExtraLight);
font.setFamily("Arial");//非衬线
@@ -1756,7 +1756,7 @@ void Cockpit::drawYawScale(QPainter *painter)
painter->drawPolygon(Rectpoints,4);
ePen.setColor(m_Color.CurrentColor);
font.setPointSize(60);
font.setPixelSize(60);
painter->setPen(ePen);
painter->setFont(font);
painter->drawText(QRect(-90,-625,180,80),Qt::AlignCenter,QString::number(m_State.yaw,'f',0));
@@ -1766,7 +1766,7 @@ void Cockpit::drawYawScale(QPainter *painter)
ePen.setColor(m_Color.CentreLineColor);
ePen.setWidth(10);
font.setPointSize(60);
font.setPixelSize(60);
painter->setPen(ePen);
painter->setFont(font);
@@ -1870,7 +1870,7 @@ void Cockpit::drawTopStatuts(QPainter *painter)
//画大字
ePen.setColor(m_Color.StatusColor);
ePen.setWidth(12);
font.setPointSize(60);
font.setPixelSize(60);
font.setFamily("Arial");//非衬线
painter->setPen(ePen);
+3 -3
View File
@@ -60,7 +60,7 @@ void commandprocess::process()//线程函数
while (running_flag)
{
count ++;
QThread::msleep(1000/running_frq);
QThread::msleep(1000.0/running_frq);
switch(status.m_Mode)
{
@@ -143,7 +143,7 @@ void commandprocess::WriteCmd_long(float param1, float param2, float param3, fl
//开启线程开始传输
status.m_Mode = TransmitMode;//发送模式
status.transmit.type = 1;
//start();//开启线程
start();//开启线程
}
@@ -173,7 +173,7 @@ void commandprocess::Parse(mavlink_message_t msg)
//break;//如果目标系统不是自己,那么就抛弃该指令
}
qDebug() << "command_ack.result" << command_ack.result;
//qDebug() << "command_ack.result" << command_ack.result;
if(command_ack.result == MAV_RESULT_ACCEPTED)
{
+4 -3
View File
@@ -103,9 +103,9 @@ void MavLinkNode::start()
//启动子线程
Mission->start();
Parameter->start();
Commander->start();
//Mission->start();
//Parameter->start();
//Commander->start();
}
else
@@ -425,6 +425,7 @@ void MavLinkNode::StatusParse(mavlink_message_t msg)
}break;
case MAVLINK_MSG_ID_HEARTBEAT: {
mavlink_msg_heartbeat_decode(&msg,&vehicle.heartbeat);
//qDebug() << "recieve heartbeat";
emit beep();
}break;
case MAVLINK_MSG_ID_PING: {
+4 -4
View File
@@ -3,7 +3,7 @@
MissionProcess::MissionProcess(QObject *parent) : QObject(parent)
{
setRunFrq(200);//默认200Hz频率运行
setRunFrq(50);//默认200Hz频率运行
}
@@ -56,7 +56,7 @@ void MissionProcess::process()//线程函数
while (running_flag)
{
count ++;
QThread::msleep(1000/running_frq);
QThread::msleep(1000.0/running_frq);
switch(mission_status.m_Mode)
{
@@ -118,7 +118,7 @@ void MissionProcess::ReadCmd(uint8_t m_sysid, uint8_t m_compid)
qDebug() << "read mission" << sysid << compid;
//start();//开启线程
start();//开启线程
}
void MissionProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count )
@@ -127,7 +127,7 @@ void MissionProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,uint32_t count
mission_status.transmit.count = count;
mission_status.m_Mode = TransmitMode;//发送模式
qDebug() << "write mission" << sysid << compid;
//start();//开启线程
start();//开启线程
}
+5 -25
View File
@@ -2,27 +2,7 @@
ParameterProcess::ParameterProcess(QObject *parent) : QObject(parent)
{
setRunFrq(200);
/* paramInspect = new ParameterInspector();
qRegisterMetaType<uint8_t>("uint8_t");
qRegisterMetaType<uint16_t>("uint16_t");
qRegisterMetaType<uint32_t>("uint32_t");
//开启线程之后signal失效
connect(paramInspect,SIGNAL(ReadCmd(uint8_t,uint8_t,uint8_t)),
this,SLOT(ReadCmd(uint8_t,uint8_t,uint8_t)),Qt::DirectConnection);//多线程连接方式
connect(paramInspect,SIGNAL(WriteCmd(uint8_t,uint8_t,const char*,uint8_t,float)),
this,SLOT(WriteCmd(uint8_t,uint8_t,const char*,uint8_t,float)),Qt::DirectConnection);
//隐藏
paramInspect->hide();
*/
setRunFrq(20);
}
void ParameterProcess::setRunFrq(uint32_t frq)
@@ -74,7 +54,7 @@ void ParameterProcess::process()//线程函数
while (running_flag)
{
count ++;
QThread::msleep(1000/running_frq);
QThread::msleep(1000.0/running_frq);
switch(status.m_Mode)
{
@@ -120,7 +100,7 @@ void ParameterProcess::ReadCmd(uint8_t m_sysid, uint8_t m_compid,uint8_t type)
<< "type" << status.recieve.type << endl
<< "start...";
//start();//开启线程
start();//开启线程
}
void ParameterProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,const char *id,uint8_t type,float value)
@@ -156,14 +136,14 @@ void ParameterProcess::WriteCmd(uint8_t m_sysid, uint8_t m_compid ,const char *i
<< "type" << status.recieve.type << endl
<< "start...";
//start();//开启线程
start();//开启线程
}
//这个函数类似中断,专门处理接收到的状态
void ParameterProcess::Parse(mavlink_message_t msg)
{
//qDebug() << "Parameter" << msg.msgid;
qDebug() << "Parameter" << msg.msgid;
switch (msg.msgid) {
case MAVLINK_MSG_ID_PARAM_SET:{
+9 -33
View File
@@ -22,9 +22,10 @@ DLink::DLink(QObject *parent) : QObject(parent)
mavlinknode->start();
/*
connect(this,&DLink::REVMessageTo1,
this,&DLink::SendMessageTo1);
*/
//其他协议节点。。。
}
@@ -52,9 +53,11 @@ int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
}
}
//这个地方有问题,会导致数据中断
emit REVMessageTo1(ch,msg,len);
if (DLink::serialPort)
{
qint64 flag = DLink::serialPort->write((const char *)msg,len);
qDebug() << "serialPort Send Msg";
}
return 0;
}
@@ -63,34 +66,7 @@ int DLink::SendMessageTo(quint8 ch, quint8 *msg, quint16 len)
int DLink::SendMessageTo1(quint8 ch, quint8 *msg, quint16 len)
{
if (DLink::serialPort)
{
/*
QString num;
for (int i = 0; i < len; ++i) {
num.append(QString::number(msg[i],16).toUpper());
num.append(" ");
}
qDebug() << num;
*/
//qDebug() << QThread::currentThread();
qint64 flag = DLink::serialPort->write((const char *)msg,len);
/*
if(flag != -1)
{
qDebug() << "serial send Success,Send " << flag << "bytes";
}
qDebug() << QThread::currentThread();
*/
qDebug() << "serialPort Send Msg";
}
return 0;
}
@@ -299,7 +275,7 @@ void DLink::readPendingDatagramsSerialPort(void)
qDebug() << num;
*/
//qDebug() << "reci";
qDebug() << "port recieve";
}
@@ -313,7 +289,7 @@ void DLink::readPendingDatagramsClient(void)
mavlinknode->setbuff(SourceType::c_sock,datagram);
}
//qDebug() << "client recieve";
qDebug() << "client recieve";
}
+1
View File
@@ -184,6 +184,7 @@ void OPMapWidget::addUAV(int sysid,int compid)
void OPMapWidget::NOPTimeout()
{
//qDebug() << "NOPTimeout";
//这个超限
if(isWPCreate == false)
{
isLNOP = true;