统一调用parse线程

This commit is contained in:
2022-08-16 22:13:55 +08:00
parent c96e464220
commit edd620c949
3 changed files with 112 additions and 26 deletions
+12 -22
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>391</width>
<height>896</height>
<width>473</width>
<height>1012</height>
</rect>
</property>
<property name="windowTitle">
@@ -366,26 +366,6 @@
<property name="spacing">
<number>12</number>
</property>
<item row="0" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>千克</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_Fuel">
<property name="specialValueText">
<string/>
</property>
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="stepType">
<enum>QAbstractSpinBox::DefaultStepType</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@@ -393,6 +373,13 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>千克</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_setFuel">
<property name="text">
@@ -400,6 +387,9 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_Fuel"/>
</item>
</layout>
</widget>
</item>
+96 -3
View File
@@ -1,4 +1,4 @@
#include "ToolsUI.h"
#include "ToolsUI.h"
#include "ui_ToolsUI.h"
@@ -28,6 +28,8 @@ ToolsUI::ToolsUI(QWidget *parent) :
ui->scrollArea->setFixedWidth(w);
ui->pushButton_ShowExtern->setFixedSize(w,h);
connect(this, &ToolsUI::recieveData, this, &ToolsUI::recieveDataSlot);
index0 = new Tools_Index0();
index1 = new Tools_Index1();
index2 = new Tools_Index2();
@@ -64,6 +66,7 @@ ToolsUI::ToolsUI(QWidget *parent) :
connect(this,SIGNAL(IndexChanged(int)),
this,SLOT(onTabIndexChanged(int)));
CurrentIndex = 0;
emit IndexChanged(CurrentIndex);
@@ -77,6 +80,25 @@ ToolsUI::ToolsUI(QWidget *parent) :
setPushButtonState(b,state::unSelected);
}
}
//测试
/*
connect(&timer, &QTimer::timeout,
this, [this]()
{
QByteArray array;
for(int i = 0; i < 100; ++i)
{
char ch = rand();
array.append(ch);
}
emit recieveData(1, array);
});
timer.start(1000);
*/
}
ToolsUI::~ToolsUI()
@@ -139,8 +161,8 @@ void ToolsUI::install(ToolsWidget *widget, QString name)
ToolsList.insert(ToolsList.size(),widget);
//接收到信号,每个界面自己解析,获取自己想要的信息
connect(this,&ToolsUI::recieveData,
widget,&ToolsWidget::recieveData);
// connect(this,&ToolsUI::recieveData,
// widget,&ToolsWidget::recieveData);
}
else
{
@@ -171,6 +193,77 @@ void ToolsUI::btnClicked()
}
}
void ToolsUI::recieveDataSlot(const int &id, const QByteArray &data)
{
Parse *parse = new Parse;
if(id == 0)
{
connect(parse,&Parse::INS_Info,
ins,&INS::INS_Info);
connect(parse,&Parse::NAV_Info,
ins,&INS::NAV_Info);
//sbg imu
connect(parse,&Parse::imu_info,
ins,&INS::imu);
//sbg euler
connect(parse,&Parse::euler_info,
ins,&INS::euler);
connect(parse,&Parse::gear_Info,
gear,&landinggear::gear_Info);
connect(parse,&Parse::actuator_info,
gear,&landinggear::actuator_info);
connect(parse,&Parse::actuator1_info,
gear,&landinggear::actuator1_info);
connect(parse,&Parse::actuator2_info,
gear,&landinggear::actuator2_info);
}
else if(id == 1)
{
connect(parse,&Parse::EADC_Info,
ecu,&ECU::EADC_Info);
connect(parse,&Parse::ECU_Info,
ecu,&ECU::ECU_Info);
connect(parse,&Parse::SSPC_Info,
ecu,&ECU::SSPC_Info);
connect(parse,&Parse::SSPC_Info_state,
ecu,&ECU::SSPC_Info_state);
connect(parse,&Parse::vel_info,
ins,&INS::vel);
//sbg pos
connect(parse,&Parse::pos_info,
ins,&INS::pos);
connect(parse,&Parse::actuator_info,
gear,&landinggear::actuator_info);
connect(parse,&Parse::actuator1_info,
gear,&landinggear::actuator1_info);
connect(parse,&Parse::actuator2_info,
gear,&landinggear::actuator2_info);
}
QThreadPool::globalInstance()->start(parse);
parse->parseData(id, data);
}
void ToolsUI::onTabIndexChanged(const int &index)//界面选择管理
{
+4 -1
View File
@@ -1,4 +1,4 @@
#ifndef TOOLSUI_H
#ifndef TOOLSUI_H
#define TOOLSUI_H
#include <QWidget>
@@ -71,10 +71,12 @@ private slots:
void onTabIndexChanged(const int &index);
void btnClicked();
void recieveDataSlot(int const &id, QByteArray const &data);
void on_pushButton_ShowExtern_clicked();
signals:
void IndexChanged(const int &index);
@@ -82,6 +84,7 @@ signals:
private:
// QTimer timer;
Ui::ToolsUI *ui;
int CurrentIndex = 0;