This commit is contained in:
hm
2021-04-29 17:02:45 +08:00
parent 9ca80d96f4
commit 35098e2a5c
5 changed files with 92 additions and 510 deletions
-245
View File
@@ -9,65 +9,6 @@ CommandBox::CommandBox(QWidget *parent) :
this->setTop(true); this->setTop(true);
ui->comboBox_Full->addItem("基准档",0x85);
ui->comboBox_Full->addItem("1档",0x16);
ui->comboBox_Full->addItem("2档",0x26);
ui->comboBox_Full->addItem("3档",0x36);
ui->comboBox_Full->addItem("4档",0x46);
ui->comboBox_Full->addItem("5档",0x56);
ui->comboBox_Full->addItem("6档",0x66);
ui->comboBox_Full->addItem("7档",0x76);
ui->comboBox_Full->addItem("8档",0x86);
ui->comboBox_Full->addItem("9档",0x96);
ui->comboBox_Full->setCurrentIndex(0);
ui->comboBox_Half->addItem("基准档",0x75);
ui->comboBox_Half->addItem("1档",0x1c);
ui->comboBox_Half->addItem("2档",0x2c);
ui->comboBox_Half->addItem("3档",0x3c);
ui->comboBox_Half->addItem("4档",0x4c);
ui->comboBox_Half->addItem("5档",0x5c);
ui->comboBox_Half->addItem("6档",0x6c);
ui->comboBox_Half->addItem("7档",0x7c);
ui->comboBox_Half->addItem("8档",0x8c);
ui->comboBox_Half->addItem("9档",0x9c);
ui->comboBox_Half->setCurrentIndex(0);
ui->comboBox_rate->addItem("10000",10000);
ui->comboBox_rate->addItem("13700",13700);
ui->comboBox_rate->addItem("15000",15000);
ui->comboBox_rate->addItem("20000",20000);
ui->comboBox_rate->addItem("25000",25000);
ui->comboBox_rate->addItem("30000",30000);
ui->comboBox_rate->addItem("35000",35000);
ui->comboBox_rate->addItem("40000",40000);
ui->comboBox_rate->addItem("46000",46000);
ui->comboBox_rate->setEditable(true);
ui->comboBox_rate->setCurrentIndex(-1);
ui->comboBox_TestPoint->addItem("核心机主燃油泵",0x19);
ui->comboBox_TestPoint->addItem("加力主燃油泵",0x29);
ui->comboBox_TestPoint->addItem("加力点火燃油泵",0x49);
ui->comboBox_TestPoint->addItem("尾喷口舵机",0x79);
ui->comboBox_TestPoint->addItem("点火器",0x89);
ui->comboBox_TestPoint->addItem("起动控制1",0xb9);
ui->comboBox_TestPoint->addItem("起动控制2",0xd9);
ui->comboBox_TestPoint->addItem("核心机点火油阀",0x1a);
ui->comboBox_TestPoint->addItem("核心机优先油阀",0x2a);
ui->comboBox_TestPoint->addItem("核心机轻吹油阀",0x4a);
ui->comboBox_TestPoint->addItem("核心机起动气阀",0x7a);
ui->comboBox_TestPoint->addItem("核心机主油阀",0x8a);
ui->comboBox_TestPoint->addItem("加力主油阀",0xba);
ui->comboBox_TestPoint->addItem("加力轻吹阀",0xda);
ui->comboBox_TestPoint->addItem("加力点火快速阀",0xea);
ui->comboBox_TestPoint->addItem("手动转速控制",0xd5);
ui->comboBox_TestPoint->setCurrentIndex(-1);
ui->comboBox_TestValue->show();
ui->comboBox_TestValue->setCurrentIndex(-1);
//use_ext_ins参数名称 //use_ext_ins参数名称
ui->comboBox_IMU->addItem("内置惯导",0); ui->comboBox_IMU->addItem("内置惯导",0);
@@ -272,72 +213,6 @@ void CommandBox::commandAccepted(bool flag,uint16_t command,uint8_t result)
} }
void CommandBox::on_comboBox_TestPoint_currentIndexChanged(int index)
{
switch (index) {
case 0:
case 1:
case 2:
case 3:
case 15:
ui->label_TestValue->show();
ui->label_TestValue->setText("转速");
ui->comboBox_TestValue->show();
ui->comboBox_TestValue->clear();
ui->comboBox_TestValue->addItem("10000",10000);
if(index == 2)
{
ui->comboBox_TestValue->addItem("13700",13700);
}
ui->comboBox_TestValue->addItem("15000",15000);
ui->comboBox_TestValue->addItem("20000",20000);
ui->comboBox_TestValue->addItem("25000",25000);
ui->comboBox_TestValue->addItem("30000",30000);
ui->comboBox_TestValue->addItem("35000",35000);
ui->comboBox_TestValue->addItem("40000",40000);
if(index != 3)
{
ui->comboBox_TestValue->addItem("45000",45000);
}
ui->comboBox_TestValue->setCurrentIndex(0);
break;
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
ui->label_TestValue->show();
ui->label_TestValue->setText("电平");
ui->comboBox_TestValue->show();
ui->comboBox_TestValue->clear();
ui->comboBox_TestValue->addItem("低电平",0);
ui->comboBox_TestValue->addItem("高电平",1);
ui->comboBox_TestValue->setEditable(true);
ui->comboBox_TestValue->setCurrentIndex(1);
break;
case 4:
ui->label_TestValue->hide();
ui->comboBox_TestValue->hide();
break;
}
}
//二次确认 //二次确认
void CommandBox::setSecondConfirm(QVariant value) void CommandBox::setSecondConfirm(QVariant value)
{ {
@@ -442,58 +317,6 @@ void CommandBox::on_paramClicked(uint8_t sysid, uint8_t compid , QString id, uin
} }
//测试指令
void CommandBox::on_pushButton_SendTest_clicked()
{
//判断 两个 内容是否是空,
float testPoint = 0;
float testValue = 0;
if(!ui->comboBox_TestValue->isHidden())//如果显示
{
testPoint = ui->comboBox_TestPoint->currentData(Qt::UserRole).toFloat();
testValue = ui->comboBox_TestValue->currentData(Qt::UserRole).toFloat();
if((ui->comboBox_TestPoint->currentIndex() != -1)&&(ui->comboBox_TestValue->currentIndex() != -1))
{
on_commandClicked(ui->comboBox_TestPoint->currentText() + " " + ui->comboBox_TestValue->currentText() ,
103,testPoint,testValue,0,0,0,0,180,0);
}
else
{
QMessageBox *box = new QMessageBox(this);
box->setWindowTitle(tr("警告"));
box->setText(tr("请选择测试项和测试点"));
box->show();
}
}
else
{
if(ui->comboBox_TestPoint->currentIndex() != -1)
{
testPoint = ui->comboBox_TestPoint->currentData(Qt::UserRole).toFloat();
on_commandClicked(ui->comboBox_TestPoint->currentText(),
103,testPoint,0,0,0,0,0,180,0);
}
else
{
QMessageBox *box = new QMessageBox(this);
box->setWindowTitle(tr("警告"));
box->setText(tr("请选择测试项和测试点"));
box->show();
}
}
}
@@ -519,74 +342,6 @@ void CommandBox::on_pushButton_Servo_Work_clicked()
} }
void CommandBox::on_pushButton_coldrun_clicked()
{
on_commandClicked(ui->pushButton_coldrun->text(),
103,0x13,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_groundstartup_clicked()
{
on_commandClicked(ui->pushButton_groundstartup->text(),
103,0x15,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_off_clicked()
{
on_commandClicked(ui->pushButton_Afterburner_off->text(),
103,0xb5,20000,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_stop_clicked()
{
on_commandClicked(ui->pushButton_stop->text(),
103,0x43,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_EmergencyStop_clicked()
{
on_commandClicked(ui->pushButton_EmergencyStop->text(),
103,0x73,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_on_clicked()
{
//根据档位选择
float Level = ui->comboBox_Full->currentData(Qt::UserRole).toFloat();
on_commandClicked(ui->pushButton_Afterburner_on->text() + " " + ui->comboBox_Full->currentText(),
103,Level,46000,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_half_clicked()
{
float Level = ui->comboBox_Half->currentData(Qt::UserRole).toFloat();
on_commandClicked(ui->pushButton_Afterburner_half->text() + " " + ui->comboBox_Half->currentText(),
103,Level,46000,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_setRPM_clicked()
{
if(ui->comboBox_rate->currentIndex() != -1)
{
float rpm = ui->comboBox_rate->currentData(Qt::UserRole).toFloat();
on_commandClicked(ui->pushButton_setRPM->text() + " " + ui->comboBox_rate->currentText(),
103,0x45,rpm,0,0,0,0,180,0);
}
else
{
QMessageBox *box = new QMessageBox(this);
box->setWindowTitle(tr("警告"));
box->setText(tr("请设定给定转速"));
box->show();
}
}
void CommandBox::on_pushButton_IMU_clicked() void CommandBox::on_pushButton_IMU_clicked()
{ {
if((ui->comboBox_IMU->currentIndex() != -1)&&(ui->comboBox_sys->currentIndex() != -1)) if((ui->comboBox_IMU->currentIndex() != -1)&&(ui->comboBox_sys->currentIndex() != -1))
-18
View File
@@ -39,9 +39,6 @@ public slots:
void commandAccepted(bool flag,uint16_t command,uint8_t result); void commandAccepted(bool flag,uint16_t command,uint8_t result);
void on_comboBox_TestPoint_currentIndexChanged(int index);
void on_pushButton_SendTest_clicked();
void setSecondConfirm(QVariant value); void setSecondConfirm(QVariant value);
void on_commandClicked(QString name, void on_commandClicked(QString name,
float param1, float param2, float param3, float param4, float param1, float param2, float param3, float param4,
@@ -68,21 +65,6 @@ private slots:
void on_pushButton_AirHeatOn_clicked(); void on_pushButton_AirHeatOn_clicked();
void on_pushButton_coldrun_clicked();
void on_pushButton_groundstartup_clicked();
void on_pushButton_Afterburner_off_clicked();
void on_pushButton_stop_clicked();
void on_pushButton_EmergencyStop_clicked();
void on_pushButton_Afterburner_on_clicked();
void on_pushButton_Afterburner_half_clicked();
void on_pushButton_setRPM_clicked();
void on_pushButton_SendCommand_clicked(); void on_pushButton_SendCommand_clicked();
+68 -233
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>794</width> <width>768</width>
<height>876</height> <height>489</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -345,172 +345,87 @@
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_6"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0"> <item row="3" column="0">
<widget class="QGroupBox" name="groupBox"> <spacer name="verticalSpacer_3">
<property name="title"> <property name="orientation">
<string>发动机指令</string> <enum>Qt::Vertical</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>参数设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="spacing">
<number>12</number>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_sys"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox_Engine_Ctrl"> <widget class="QLabel" name="label_5">
<property name="title"> <property name="text">
<string>控制指令</string> <string>无人机#</string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignCenter</set> </item>
<item row="2" column="4">
<widget class="QPushButton" name="pushButton_IAS_SEL_2">
<property name="text">
<string>外置大气机</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="spacing">
<number>12</number>
</property>
<item row="3" column="3">
<widget class="QPushButton" name="pushButton_EmergencyStop">
<property name="text">
<string>紧急停车</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="pushButton_stop">
<property name="text">
<string>停车</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_coldrun">
<property name="text">
<string>冷运转</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_Afterburner_off">
<property name="text">
<string>关加力</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_55">
<property name="text">
<string>全加力档</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_56">
<property name="text">
<string>半加力档</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_Afterburner_half">
<property name="text">
<string>半加力</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_Full"/>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_Half"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_Afterburner_on">
<property name="text">
<string>全加力</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButton_setRPM">
<property name="text">
<string>给定转速</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBox_rate"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_57">
<property name="text">
<string>给定转速</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_groundstartup">
<property name="text">
<string>地面起动</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="groupBox_Engine_Test"> <widget class="QLabel" name="label_2">
<property name="styleSheet"> <property name="text">
<string notr="true"/> <string>选择惯导</string>
</property> </property>
<property name="title"> </widget>
<string>测试指令</string> </item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_IMU"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_IMU">
<property name="text">
<string>选择</string>
</property> </property>
<property name="alignment"> </widget>
<set>Qt::AlignCenter</set> </item>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>IAS_SEL</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_IAS_SEL_0">
<property name="text">
<string>地速算空速</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_IAS_SEL_1">
<property name="text">
<string>内置大气机</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="spacing">
<number>12</number>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_TestPoint"/>
</item>
<item row="1" column="3">
<widget class="QFrame" name="framex">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_SendTest">
<property name="text">
<string>测试</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_58">
<property name="text">
<string>测试项</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_TestValue">
<property name="text">
<string>测试值</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_TestValue"/>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="groupBox_5"> <widget class="QGroupBox" name="groupBox_5">
<property name="title"> <property name="title">
<string>舵机指令</string> <string>舵机指令</string>
@@ -592,87 +507,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<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"> <item row="2" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>参数设置</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<property name="spacing">
<number>12</number>
</property>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_sys"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>无人机#</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QPushButton" name="pushButton_IAS_SEL_2">
<property name="text">
<string>外置大气机</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>选择惯导</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_IMU"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_IMU">
<property name="text">
<string>选择</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>IAS_SEL</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton_IAS_SEL_0">
<property name="text">
<string>地速算空速</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_IAS_SEL_1">
<property name="text">
<string>内置大气机</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="groupBox_3"> <widget class="QGroupBox" name="groupBox_3">
<property name="title"> <property name="title">
<string>油量校准</string> <string>油量校准</string>
+1 -1
View File
@@ -385,7 +385,7 @@ void MavLinkNode::stop()
if(RC->isActive()) if(RC->isActive())
{ {
RC->stop(); RC->stop();
delete RC; delete RC;
RC = nullptr; RC = nullptr;
} }
} }
+23 -13
View File
@@ -50,9 +50,6 @@ void rcprocess::setID(int m_sysid,int m_compid)
void rcprocess::Send(mavlink_message_t msg) void rcprocess::Send(mavlink_message_t msg)
{ {
uint8_t buff[MAVLINK_MAX_PACKET_LEN+sizeof(quint64)]; uint8_t buff[MAVLINK_MAX_PACKET_LEN+sizeof(quint64)];
//quint64 currentTimestamp = ((quint64)QDateTime::currentMSecsSinceEpoch()) * 1000;
//qToBigEndian(currentTimestamp, buff);
//uint16_t len = mavlink_msg_to_send_buffer(buff + sizeof(quint64), &msg);
uint16_t len = mavlink_msg_to_send_buffer(buff, &msg); uint16_t len = mavlink_msg_to_send_buffer(buff, &msg);
emit SendMessageTo(0,buff, len);//使用信号和槽 emit SendMessageTo(0,buff, len);//使用信号和槽
} }
@@ -94,21 +91,31 @@ void rcprocess::start()
void rcprocess::stop() void rcprocess::stop()
{ {
if(thread->isRunning()) if(thread)
{ {
running_flag = false; if(!thread->isFinished())
{
running_flag = false;
disconnect(thread, nullptr, nullptr, nullptr); disconnect(thread, nullptr, nullptr, nullptr);
thread->quit();
thread->deleteLater();
thread = nullptr; thread->quit();
} thread->deleteLater();
else
{ thread = nullptr;
qDebug() << "thread is not running";
}
else
{
qDebug() << "thread is not running";
}
qDebug() << "thread ";
} }
} }
//这里一直在解码,一直检查双缓冲里面是否有数据,有就解码,没有就休息 //这里一直在解码,一直检查双缓冲里面是否有数据,有就解码,没有就休息
@@ -150,6 +157,8 @@ void rcprocess::process()//线程函数
update15Hz(); update15Hz();
} }
} }
} }
@@ -286,6 +295,7 @@ void rcprocess::update15Hz(void)
{ {
if ((isRCActive != 0) || rcin_cnt > 0) if ((isRCActive != 0) || rcin_cnt > 0)
{ {
//qDebug() << "active";
rcin_cnt--; rcin_cnt--;
mavlink_rc_channels_override_t command; mavlink_rc_channels_override_t command;
command.chan1_raw = rcin[0]; command.chan1_raw = rcin[0];