线程问题
This commit is contained in:
@@ -93,11 +93,20 @@ void ServoSystem::setBUMState(mavlink_bmustate_t *t)
|
||||
ui->label_onBoard_56V_Current->setText(QString::number((float)((int16_t)t->BAT2_group_current_dA) *0.1f,'f',1));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ServoSystem::setServoState(mavlink_servo_output_raw_t *t)
|
||||
{
|
||||
ui->label_rud_curr->setText(QString::number(t->servo1_raw));
|
||||
ui->label_ele_l_curr->setText(QString::number(t->servo2_raw));
|
||||
ui->label_ele_r_curr->setText(QString::number(t->servo3_raw));
|
||||
ui->label_ail_l_curr->setText(QString::number(t->servo4_raw));
|
||||
ui->label_ail_r_curr->setText(QString::number(t->servo5_raw));
|
||||
|
||||
ui->label_rud_cmd->setText(QString::number(t->servo6_raw));
|
||||
ui->label_ele_l_cmd->setText(QString::number(t->servo7_raw));
|
||||
ui->label_ele_r_cmd->setText(QString::number(t->servo8_raw));
|
||||
ui->label_ail_l_cmd->setText(QString::number(t->servo9_raw));
|
||||
ui->label_ail_r_cmd->setText(QString::number(t->servo10_raw));
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public slots:
|
||||
void setValue(QLabel *w,QString s);
|
||||
|
||||
void setBUMState(mavlink_bmustate_t *t);
|
||||
|
||||
void setServoState(mavlink_servo_output_raw_t *t);
|
||||
|
||||
private:
|
||||
QWidget *m_parent;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_24">
|
||||
<widget class="QLabel" name="label_ail_l_curr">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -107,7 +107,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_21">
|
||||
<widget class="QLabel" name="label_ail_l_cmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@@ -161,7 +161,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<widget class="QLabel" name="label_ele_r_curr">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@@ -211,7 +211,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<widget class="QLabel" name="label_ele_r_cmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -309,7 +309,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_28">
|
||||
<widget class="QLabel" name="label_ail_r_cmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@@ -366,7 +366,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_31">
|
||||
<widget class="QLabel" name="label_ail_r_curr">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -507,7 +507,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<widget class="QLabel" name="label_ele_l_cmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
@@ -564,7 +564,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_38">
|
||||
<widget class="QLabel" name="label_ele_l_curr">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -662,7 +662,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<widget class="QLabel" name="label_rud_cmd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
@@ -687,7 +687,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<widget class="QLabel" name="label_rud_curr">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
|
||||
+3
-2
@@ -676,9 +676,8 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
|
||||
|
||||
static qint64 frq_time = 0;
|
||||
if((QDateTime::currentMSecsSinceEpoch() - frq_time) <= 100)
|
||||
if((QDateTime::currentMSecsSinceEpoch() - frq_time) <= 200)
|
||||
{
|
||||
qDebug() << "10hz";
|
||||
return;
|
||||
}
|
||||
frq_time = QDateTime::currentMSecsSinceEpoch();
|
||||
@@ -940,6 +939,8 @@ void MainWindow::updateUI()//事件驱动式更新数据
|
||||
toolsui->powersystem->setTurbineState(&dlink->mavlinknode->vehicle.turbinstate);
|
||||
|
||||
toolsui->servosystem->setBUMState(&dlink->mavlinknode->vehicle.bmustate);
|
||||
toolsui->servosystem->setServoState(&dlink->mavlinknode->vehicle.servo_output_raw);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -236,12 +236,6 @@ void MavLinkNode::stop()
|
||||
//这里一直在解码,一直检查双缓冲里面是否有数据,有就解码,没有就休息
|
||||
void MavLinkNode::process()//线程函数
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t count = 0;
|
||||
QByteArray datagram = nullptr;
|
||||
while (running_flag)
|
||||
@@ -275,7 +269,11 @@ void MavLinkNode::process()//线程函数
|
||||
//退出线程
|
||||
disconnect(thread, nullptr, nullptr, nullptr);
|
||||
thread->quit();
|
||||
thread->wait();
|
||||
//thread->wait();
|
||||
|
||||
thread->deleteLater();
|
||||
thread = nullptr;
|
||||
|
||||
}
|
||||
|
||||
void MavLinkNode::TimerOut(void)
|
||||
|
||||
@@ -213,6 +213,9 @@ void Replay::process()//线程函数
|
||||
disconnect(thread, nullptr, nullptr, nullptr);
|
||||
thread->quit();
|
||||
thread->wait();
|
||||
thread->deleteLater();
|
||||
thread = nullptr;
|
||||
|
||||
}
|
||||
|
||||
//类相关函数
|
||||
|
||||
+4
-3
@@ -216,17 +216,18 @@ bool DLink::setupClient(const QHostAddress &local_addr,int local_port,const QHos
|
||||
{
|
||||
if(Clientsock)
|
||||
{
|
||||
Clientsock->disconnect();
|
||||
delete Clientsock;
|
||||
Clientsock = nullptr;
|
||||
}
|
||||
|
||||
bool isSuccess = false;
|
||||
Clientsock = new QUdpSocket(this);
|
||||
if (Clientsock->bind(QHostAddress::AnyIPv4, local_port, QUdpSocket::ShareAddress))
|
||||
if (Clientsock->bind(QHostAddress::AnyIPv4, local_port, QUdpSocket::ShareAddress|QUdpSocket::ReuseAddressHint))
|
||||
{
|
||||
Clientsock->joinMulticastGroup(remote_addr);
|
||||
//Clientsock->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,1024*1024*8);
|
||||
//Clientsock->setSocketOption(QAbstractSocket::MulticastTtlOption, 3);
|
||||
Clientsock->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption,1024*1024*8);
|
||||
Clientsock->setSocketOption(QAbstractSocket::MulticastTtlOption, 3);
|
||||
|
||||
if(Clientsock->open(QIODevice::ReadWrite))
|
||||
//if(Clientsock->joinMulticastGroup(remote_addr))
|
||||
|
||||
Reference in New Issue
Block a user