fix loss data

This commit is contained in:
hm
2020-08-11 16:48:15 +08:00
parent 965750b7bc
commit 10a1e3eb11
17 changed files with 143 additions and 74 deletions
+39 -1
View File
@@ -1,4 +1,4 @@
#include "CharInputter.h"
#include "CharInputter.h"
#include "ui_CharInputter.h"
CharInputter::CharInputter(QWidget *parent) :
@@ -27,10 +27,28 @@ CharInputter::CharInputter(QWidget *parent) :
setLower();
DoubleClickTimer = new QTimer(this);
DoubleClickTimer->setInterval(200);//0.2s之内再点击,那就相当于双击
connect(DoubleClickTimer,SIGNAL(timeout()),
this,SLOT(DoubleClickTimeout()));
}
CharInputter::~CharInputter()
{
if(DoubleClickTimer)
{
if(DoubleClickTimer->isActive())
{
DoubleClickTimer->stop();
}
delete DoubleClickTimer;
}
delete ui;
}
@@ -61,6 +79,11 @@ void CharInputter::on_Clicked(QString str)
ui->lineEdit->setText(curentStr);
}
void CharInputter::DoubleClickTimeout()
{
DoubleClickTimer->stop();
}
void CharInputter::on_pushButton_1_clicked()
{
@@ -441,6 +464,21 @@ void CharInputter::on_pushButton_Delete_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 CharInputter::on_pushButton_Space_clicked()
+6 -1
View File
@@ -1,4 +1,4 @@
#ifndef CHARINPUTTER_H
#ifndef CHARINPUTTER_H
#define CHARINPUTTER_H
#include <QWidget>
@@ -7,6 +7,8 @@
#include "QTextStream"
#include <QCommonStyle>
#include "QStyle"
#include "QTimer"
namespace Ui {
class CharInputter;
@@ -37,6 +39,8 @@ protected:
private slots:
void DoubleClickTimeout();
void setUpper(void);
void setLower(void);
@@ -127,6 +131,7 @@ private slots:
private:
Ui::CharInputter *ui;
QTimer *DoubleClickTimer = nullptr;
bool isCapsLock = false;
+12 -4
View File
@@ -25,17 +25,25 @@ Inputter::Inputter(QWidget *parent) :
DoubleClickTimer = new QTimer(this);
DoubleClickTimer->setInterval(300);//0.5s之内再点击,那就相当于双击
DoubleClickTimer->setInterval(200);//0.2s之内再点击,那就相当于双击
connect(DoubleClickTimer,SIGNAL(timeout()),
this,SLOT(DoubleClickTimeout()));
}
Inputter::~Inputter()
{
if(DoubleClickTimer)
{
if(DoubleClickTimer->isActive())
{
DoubleClickTimer->stop();
}
delete DoubleClickTimer;
}
delete ui;
}
+1 -11
View File
@@ -56,11 +56,6 @@ Scope::Scope(QWidget *parent) :
connect(updateTimer,SIGNAL(timeout()),
this,SLOT(timeout()));
updateTimer->start(50);//20hz刷新
//不要轻易使用singleShot,容易引起内存超限
//QTimer::singleShot(10,this,SLOT(timeout()));
}
Scope::~Scope()
@@ -80,16 +75,12 @@ void Scope::mouseReleaseEvent(QMouseEvent *e)
{
qDebug() << "Scope release" << e;
isPress = false;
//setCursor(Qt::ArrowCursor);
}
void Scope::mousePressEvent(QMouseEvent *e)
{
qDebug() << "Scope press" << e;
isPress = true;
//setCursor(Qt::ClosedHandCursor);
}
void Scope::mouseDoubleClickEvent(QMouseEvent *e)
@@ -174,7 +165,6 @@ void Scope::timeout(void)//100Hz
{
timeseries += 0.01;
chartUpdate();
QTimer::singleShot(10,this,SLOT(timeout()));
}
@@ -422,7 +412,7 @@ void Scope::on_pushButton_Close_clicked()
{
// delete ui;
emit willcloase();
emit willclose();
this->hide();
// this->deleteLater();
// this->close();
+1 -1
View File
@@ -69,7 +69,7 @@ protected:
signals:
void clearall(void);
void willcloase(void);
void willclose(void);
public slots:
void setUseOpenGL(const bool &value);
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -990,12 +990,12 @@
<message>
<location filename="mainwindow.cpp" line="600"/>
<source>ARM</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="603"/>
<source>DISARM</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="626"/>
+9
View File
@@ -62,6 +62,15 @@ MenuBarUI::MenuBarUI(QWidget *parent) :
MenuBarUI::~MenuBarUI()
{
if(MessageTimer)
{
if(MessageTimer->isActive())
{
MessageTimer->stop();
}
delete MessageTimer;
}
delete ui;
}
@@ -34,10 +34,7 @@ ParameterInspector::ParameterInspector(QWidget *parent) :
flushTimer = new QTimer(this);
connect(flushTimer,SIGNAL(timeout()),
this,SLOT(mReflush()));
flushTimer->start(1000);
//不要轻易使用这个,容易引起超限
//QTimer::singleShot(1000,this,SLOT(mReflush()));
flushTimer->start(50);
}
ParameterInspector::~ParameterInspector()
@@ -59,11 +56,6 @@ void ParameterInspector::mReflush()
refreshView();
}
if(TimerRunningFlag == true)
{
QTimer::singleShot(10,this,SLOT(mReflush()));
}
}
@@ -37,24 +37,8 @@ MAVLinkInspector::MAVLinkInspector(const QString& title, QAction* action,QWidget
ui->treeWidget->header()->setStretchLastSection(true);
//ui->treeWidget->header()->resizeSection();
// Connect the UI
/*
connect(ui->systemComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MAVLinkInspector::selectDropDownMenuSystem);
connect(ui->componentComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MAVLinkInspector::selectDropDownMenuComponent);
*/
connect(ui->clearButton, &QPushButton::clicked, this, &MAVLinkInspector::clearView);
// Connect external connections
//connect(qApp()->toolbox()->multiVehicleManager(), &MAVLinkInspector::vehicleAdded, this, &QGCMAVLinkInspector::_vehicleAdded);
//connect(protocol, &MAVLinkInspector::messageReceived, this, &MAVLinkInspector::receiveMessage);
// Attach the UI's refresh rate to a timer.
connect(&updateTimer, &QTimer::timeout, this, &MAVLinkInspector::refreshView);
updateTimer.start(updateInterval);
@@ -112,13 +96,12 @@ void MAVLinkInspector::on_pushButton_system_clicked()
ui->pushButton_system->hide();
ui->clearButton->hide();
if(!scope)
{
scope = new Scope(this);
connect(scope,SIGNAL(willcloase()),
connect(scope,SIGNAL(willclose()),
this,SLOT(ScopeClose()));
connect(scope,SIGNAL(clearall()),
@@ -132,9 +115,6 @@ void MAVLinkInspector::on_pushButton_system_clicked()
{
scope->show();
}
}
void MAVLinkInspector::ScopeClose(void)//可能有点问题
@@ -336,8 +316,6 @@ void MAVLinkInspector::addUAStoTree(int sysId)
{
if(!uasTreeWidgetItems.contains(sysId))
{
// Add the UAS to the main tree after it has been created
//Vehicle* vehicle = qgcApp()->toolbox()->multiVehicleManager()->getVehicleById(sysId);
if (1)//vehicle)
{
//UASInterface* uas = vehicle->uas();
@@ -757,7 +735,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));
}
}
}
+3 -5
View File
@@ -7,8 +7,7 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
{
//setGeometry();
//检测qml文件夹,如果不存在,那么就新建一个,这里存着所有的qml文件
@@ -414,6 +413,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) //键盘按下事件
bool MainWindow::event(QEvent *event)
{
/*
switch (event->type()) {
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
@@ -448,6 +448,7 @@ bool MainWindow::event(QEvent *event)
default:
break;
}
*/
return QWidget::event(event);
}
@@ -701,9 +702,6 @@ void MainWindow::updateUI()//事件驱动式更新数据
dlink->mavlinknode->vehicle.compid,
dlink->mavlinknode->vehicle.attitude.yaw * 57.3);
//QTimer::singleShot
if(MainIndex == 3)//飞行界面
{
+2 -2
View File
@@ -76,7 +76,7 @@ protected slots:
void resizeEvent(QResizeEvent *event);
void mousePressEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent *event);
//void mouseMoveEvent();
private slots:
void onTabIndexChanged(const int &index);
@@ -112,7 +112,7 @@ protected:
QQuickWidget *quick = nullptr;
QTimer *updateTimer;
QTimer *updateTimer = nullptr;
};
+6 -6
View File
@@ -25,14 +25,14 @@ VS_VERSION_INFO VERSIONINFO
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "CompanyName", "...公司\0"
VALUE "FileDescription", "...\0"
VALUE "CompanyName", "xxx\0"
VALUE "FileDescription", "无人机地面站系统\0"
VALUE "FileVersion", "1.0.0.0\0"
VALUE "ProductVersion", "1.0.0.0\0"
VALUE "LegalCopyright", "版权所有 (C)...公司\0"
VALUE "LegalTrademarks", "...公司\0"
VALUE "ProductVersion", "0.0.0.1\0"
VALUE "LegalCopyright", "xxx\0"
VALUE "LegalTrademarks", "xxx\0"
VALUE "OriginalFilename", "Version.exe\0"
VALUE "ProductName", "...查看系统\0"
VALUE "ProductName", "GCS\0"
VALUE "InternalName", "Version.exe\0"
END
END
+2 -2
View File
@@ -60,10 +60,10 @@ Cockpit::Cockpit(QWidget *parent): QWidget(parent)
//初始化完成后打开定时器开始计数刷新
UpdateTimer = new QTimer;
UpdateTimer = new QTimer(this);
connect(UpdateTimer,SIGNAL(timeout()),
this,SLOT(UpdateTimeout()));
UpdateTimer->start(50);//50Hz
UpdateTimer->start(100);//10Hz
}
+19 -3
View File
@@ -276,6 +276,7 @@ QByteArray MavLinkNode::readbuff(quint32 src)
void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
{
static int count = 0;
mavlink_message_t msg;
mavlink_status_t status;
@@ -283,10 +284,25 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
{
if(MAVLINK_FRAMING_OK == mavlink_parse_char(src,*i,&msg,&status))
{
if(msg.compid != Current_CompID) //过滤地面站发过来的数据
//qDebug() << "fifo parse:" << count << msg.msgid;
count++;
if(msg.compid == Current_CompID) //过滤地面站发过来的数据
{
emit recievemsg(msg); //将信息广播出去
//不能使用这种方法过滤,不正确
//qDebug() << msg.msgid << "msg come from groundstation";
}
//if(msg.compid != Current_CompID) //过滤地面站发过来的数据
{
MAVLinkRcv_Handler(msg); //接收完一帧数据并处理
//QThread::sleep(5);
//qDebug() << "msg.sysid" <<msg.sysid << "msg.compid" << msg.compid << "fifo parse:" << count << msg.msgid;
emit recievemsg(msg); //将信息广播出去
}
}
else
@@ -350,7 +366,7 @@ void MavLinkNode::Mavlinkparse(quint32 src,QByteArray datagram)
void MavLinkNode::MAVLinkRcv_Handler(mavlink_message_t msg)
{
//用于给参数添加设备,便于读取
//qDebug() << "msg.sysid" <<msg.sysid << "msg.compid" << msg.compid;
CheckVehicle(msg.sysid,msg.compid);
vehicle.sysid = msg.sysid;
+37 -2
View File
@@ -263,9 +263,23 @@ bool DLink::setupClient(const QHostAddress &local_addr,int local_port,const QHos
void DLink::readPendingDatagramsSerialPort(void)
{
static int count = 0;
QByteArray datagram = serialPort->readAll();
mavlinknode->setbuff(SourceType::s_port,datagram);
mavlink_message_t msg;
mavlink_status_t status;
for (QByteArray::const_iterator i = datagram.cbegin(); i != datagram.cend(); ++i)
{
if(MAVLINK_FRAMING_OK == mavlink_parse_char(3,*i,&msg,&status))
{
//qDebug() << "direct parse:" << count << msg.msgid;
count++;
}
}
/*
QString num;
for (int i = 0; i < datagram.size(); ++i) {
@@ -275,21 +289,42 @@ void DLink::readPendingDatagramsSerialPort(void)
qDebug() << num;
*/
qDebug() << "port recieve";
//qDebug() << "port recieve";
}
void DLink::readPendingDatagramsClient(void)
{
static int count = 0;
//轮番查询
while (Clientsock->hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(Clientsock->pendingDatagramSize());
Clientsock->readDatagram(datagram.data(), datagram.size());
mavlinknode->setbuff(SourceType::c_sock,datagram);
mavlink_message_t msg;
mavlink_status_t status;
for (QByteArray::const_iterator i = datagram.cbegin(); i != datagram.cend(); ++i)
{
if(MAVLINK_FRAMING_OK == mavlink_parse_char(2,*i,&msg,&status))
{
//qDebug() << "direct parse:" << count << msg.msgid;
count++;
}
}
}
qDebug() << "client recieve";
//qDebug() << "client recieve";
}
+1 -1
View File
@@ -90,7 +90,7 @@ OPMapWidget::OPMapWidget(QWidget *parent, Configuration *config) : QGraphicsView
altitudeitem->hide();
NoOperationTimer = new QTimer();
NoOperationTimer = new QTimer(this);
connect(NoOperationTimer,SIGNAL(timeout()),
this,SLOT(NOPTimeout()));
NoOperationTimer->start(20000);//20s不操作