892 lines
24 KiB
C++
892 lines
24 KiB
C++
#include "CommandBox.h"
|
|
#include "ui_CommandBox.h"
|
|
|
|
CommandBox::CommandBox(QWidget *parent) :
|
|
ToolsWidget(parent),
|
|
ui(new Ui::CommandBox)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
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参数名称
|
|
ui->comboBox_IMU->addItem("内置惯导",0);
|
|
ui->comboBox_IMU->addItem("SBG",1);
|
|
ui->comboBox_IMU->setCurrentIndex(0);
|
|
|
|
ui->comboBox_ServoType->addItem("左副翼",0x01);
|
|
ui->comboBox_ServoType->addItem("右副翼",0x02);
|
|
ui->comboBox_ServoType->addItem("左升降",0x03);
|
|
ui->comboBox_ServoType->addItem("右升降",0x04);
|
|
ui->comboBox_ServoType->addItem("方向舵",0x05);
|
|
ui->comboBox_ServoType->setCurrentIndex(0);
|
|
|
|
/*
|
|
ui->comboBox_sel_ch->addItem("关闭",0x00);
|
|
ui->comboBox_sel_ch->addItem("左副翼",0x01);
|
|
ui->comboBox_sel_ch->addItem("右副翼",0x02);
|
|
ui->comboBox_sel_ch->addItem("左升降",0x03);
|
|
ui->comboBox_sel_ch->addItem("右升降",0x04);
|
|
ui->comboBox_sel_ch->addItem("方向舵",0x05);
|
|
ui->comboBox_sel_ch->setCurrentIndex(0);
|
|
*/
|
|
|
|
|
|
//ui->pushButton_AirHeatOff->hide();
|
|
//ui->pushButton_AirHeatOn->hide();
|
|
//ui->pushButton_HeatOn3->hide();
|
|
//ui->pushButton_HeatOn4->hide();
|
|
|
|
|
|
|
|
m_ra = 0;
|
|
m_la = 0;
|
|
m_ru = 0;
|
|
m_re = 0;
|
|
m_le = 0;
|
|
|
|
}
|
|
|
|
CommandBox::~CommandBox()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
|
|
void CommandBox::setFloatFlag(bool flag)
|
|
{
|
|
floatflag = flag;
|
|
}
|
|
|
|
float CommandBox::param_getvalue(QVariant param,uint8_t type)
|
|
{
|
|
float value;
|
|
union {
|
|
uint8_t u8[8];
|
|
int8_t i8[8];
|
|
uint16_t u16[4];
|
|
int16_t i16[4];
|
|
uint32_t u32[2];
|
|
int32_t i32[2];
|
|
uint64_t u64;
|
|
int64_t i64;
|
|
float f[2];
|
|
double d;
|
|
}src;
|
|
|
|
switch (type)
|
|
{
|
|
case MAV_PARAM_TYPE_UINT8:
|
|
{
|
|
src.u8[0] = param.toUInt();
|
|
((uint8_t *)&value)[0] = src.u8[0];
|
|
|
|
}break;
|
|
case MAV_PARAM_TYPE_INT8:
|
|
{
|
|
src.i8[0] = param.toUInt();
|
|
((int8_t *)&value)[0] = src.i8[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_UINT16:
|
|
{
|
|
src.u16[0] = param.toUInt();
|
|
((uint16_t *)&value)[0] = src.u16[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_INT16:
|
|
{
|
|
src.i16[0] = param.toUInt();
|
|
((int16_t *)&value)[0] = src.i16[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_UINT32:
|
|
{
|
|
src.u32[0] = param.toUInt();
|
|
((uint32_t *)&value)[0] = (uint32_t)src.u32[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_INT32:
|
|
{
|
|
src.i32[0] = param.toUInt();
|
|
((int32_t *)&value)[0] = (int32_t)src.i32[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_UINT64:
|
|
{
|
|
src.u64 = param.toUInt();
|
|
((uint64_t *)&value)[0] = (uint64_t )src.u64;
|
|
}break;
|
|
case MAV_PARAM_TYPE_INT64:
|
|
{
|
|
src.i64 = param.toUInt();
|
|
((int64_t *)&value)[0] = (int64_t)src.i64;
|
|
}break;
|
|
case MAV_PARAM_TYPE_REAL32:
|
|
{
|
|
src.f[0] = param.toFloat();
|
|
((float *)&value)[0] = (float)src.f[0];
|
|
}break;
|
|
case MAV_PARAM_TYPE_REAL64:
|
|
{
|
|
src.d = param.toDouble();
|
|
((double *)&value)[0]= (double)src.d;
|
|
}break;
|
|
default:
|
|
{
|
|
src.f[0] = param.toFloat();
|
|
((float *)&value)[0] = (float)src.i32[0];
|
|
}break;
|
|
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandBox::commandAccepted(bool flag,uint16_t command,uint8_t result)
|
|
{
|
|
bool isFundSender = false;
|
|
QString string;
|
|
//找到消息的发送者
|
|
|
|
|
|
QObjectList list = ui->frame->children();
|
|
|
|
// qDebug() << list;
|
|
|
|
//qDebug() << CommandBox.findChildren();
|
|
|
|
if(command == m_command)
|
|
{
|
|
isFundSender = true;
|
|
|
|
|
|
switch (result) {
|
|
case MAV_RESULT_ACCEPTED:
|
|
string.append(tr("%1,%2 accepted and executed").arg(command).arg(m_name));
|
|
break;
|
|
case MAV_RESULT_TEMPORARILY_REJECTED:
|
|
string.append(tr("%1,%2 rejected").arg(command).arg(m_name));
|
|
break;
|
|
case MAV_RESULT_DENIED:
|
|
string.append(tr("%1,%2 permanently denied").arg(command).arg(m_name));
|
|
break;
|
|
case MAV_RESULT_UNSUPPORTED:
|
|
string.append(tr("%1,%2 unsupported").arg(command).arg(m_name));
|
|
break;
|
|
case MAV_RESULT_FAILED:
|
|
string.append(tr("%1,%2 failed").arg(command).arg(m_name));
|
|
break;
|
|
case MAV_RESULT_IN_PROGRESS:
|
|
string.append(tr("%1,%2 being executed").arg(command).arg(m_name));
|
|
break;
|
|
case 0xFE:
|
|
string.append(tr("%1,%2 time out").arg(command).arg(m_name));
|
|
break;
|
|
case 0xFF:
|
|
string.append(tr("Please do not operate too fast, the last instruction has not been sent"));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
ui->lineEdit_CommandName->clear();
|
|
m_name.clear();
|
|
m_param1 = 0;
|
|
m_param2 = 0;
|
|
m_param3 = 0;
|
|
m_param4 = 0;
|
|
m_param5 = 0;
|
|
m_param6 = 0;
|
|
m_param7 = 0;
|
|
m_command = 0;
|
|
m_confirm = 0;
|
|
|
|
}
|
|
|
|
if(string.size() > 0)
|
|
{
|
|
QTextToSpeech *tts = new QTextToSpeech();
|
|
tts->say(string);
|
|
tts->deleteLater();
|
|
emit showMessage(string);
|
|
}
|
|
}
|
|
|
|
|
|
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)
|
|
{
|
|
if(value.toBool() == true)
|
|
{
|
|
emit cmd_long(m_param1,m_param2,m_param3,m_param4,m_param5,m_param6,m_param7,m_command,m_confirm);
|
|
}
|
|
else
|
|
{
|
|
ui->lineEdit_CommandName->clear();
|
|
m_name.clear();
|
|
m_param1 = 0;
|
|
m_param2 = 0;
|
|
m_param3 = 0;
|
|
m_param4 = 0;
|
|
m_param5 = 0;
|
|
m_param6 = 0;
|
|
m_param7 = 0;
|
|
m_command = 0;
|
|
m_confirm = 0;
|
|
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_SendCommand_clicked()
|
|
{
|
|
if(cmdType == 0)
|
|
{
|
|
if(m_command == 0)
|
|
{
|
|
emit showMessage(tr("please set command first ,command :%1").arg(m_command));
|
|
return;
|
|
}
|
|
}
|
|
|
|
if(cmdType == 0)
|
|
{
|
|
emit showMessage(tr("发送指令 ") + QString::number(m_command) + " " + m_name,5000);
|
|
emit cmd_long(m_param1,m_param2,m_param3,m_param4,m_param5,m_param6,m_param7,m_command,m_confirm);
|
|
}
|
|
else if(cmdType == 1)
|
|
{
|
|
|
|
emit showMessage(tr("修改参数 ") + " " + m_id.toLatin1().data() + " " + QString::number(m_value),5000);
|
|
|
|
|
|
emit WriteCmd(m_sysid,m_compid,m_id.toLatin1().data(),m_type,m_value);
|
|
//qDebug() << m_type << m_value;
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_Cancel_clicked()
|
|
{
|
|
ui->lineEdit_CommandName->clear();
|
|
m_name.clear();
|
|
m_param1 = 0;
|
|
m_param2 = 0;
|
|
m_param3 = 0;
|
|
m_param4 = 0;
|
|
m_param5 = 0;
|
|
m_param6 = 0;
|
|
m_param7 = 0;
|
|
m_command = 0;
|
|
m_confirm = 0;
|
|
}
|
|
|
|
|
|
void CommandBox::on_commandClicked(QString name,
|
|
float param1,float param2,float param3,float param4,
|
|
float param5,float param6,float param7,
|
|
uint16_t command,uint8_t confirmation)
|
|
{
|
|
|
|
m_name = name;
|
|
m_param1 = param1;
|
|
m_param2 = param2;
|
|
m_param3 = param3;
|
|
m_param4 = param4;
|
|
m_param5 = param5;
|
|
m_param6 = param6;
|
|
m_param7 = param7;
|
|
m_command = command;
|
|
m_confirm = confirmation;
|
|
|
|
ui->lineEdit_CommandName->setText(name);
|
|
|
|
cmdType = 0;
|
|
}
|
|
|
|
void CommandBox::on_paramClicked(uint8_t sysid, uint8_t compid , QString id, uint8_t type, float value)
|
|
{
|
|
|
|
m_sysid = sysid;
|
|
m_compid = compid;
|
|
m_id = id;
|
|
m_type = type;
|
|
m_value = value;
|
|
|
|
ui->lineEdit_CommandName->setText(id + " " + QString::number(value));
|
|
|
|
cmdType = 1;
|
|
}
|
|
|
|
|
|
//测试指令
|
|
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();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//舵机指令
|
|
|
|
|
|
void CommandBox::on_pushButton_Servo_Read_clicked()
|
|
{
|
|
on_commandClicked(ui->pushButton_Servo_Read->text(),
|
|
2,0,0,0,0,0,0,20004,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_Servo_Zero_clicked()
|
|
{
|
|
on_commandClicked(ui->pushButton_Servo_Zero->text(),
|
|
1,0,0,0,0,0,0,20004,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_Servo_Work_clicked()
|
|
{
|
|
on_commandClicked(ui->pushButton_Servo_Work->text(),
|
|
3,0,0,0,0,0,0,20004,0);
|
|
}
|
|
|
|
|
|
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()
|
|
{
|
|
if((ui->comboBox_IMU->currentIndex() != -1)&&(ui->comboBox_sys->currentIndex() != -1))
|
|
{
|
|
uint8_t sysid = ui->comboBox_sys->currentData(Qt::UserRole).toInt();
|
|
uint8_t compid = 1;
|
|
QString id;
|
|
uint8_t type = MAV_PARAM_TYPE_INT8;
|
|
|
|
id.clear();
|
|
id.append("use_ext_ins");
|
|
|
|
float value = param_getvalue(ui->comboBox_IMU->currentData(Qt::UserRole).toInt(),type);
|
|
|
|
on_paramClicked(sysid,compid,id,type,value);
|
|
|
|
}
|
|
else
|
|
{
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
box->setText(tr("请设定目标"));
|
|
box->show();
|
|
}
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_IAS_SEL_0_clicked()
|
|
{
|
|
if(ui->comboBox_sys->currentIndex() != -1)
|
|
{
|
|
|
|
uint8_t sysid = ui->comboBox_sys->currentData(Qt::UserRole).toInt();
|
|
uint8_t compid = 1;
|
|
QString id;
|
|
uint8_t type = MAV_PARAM_TYPE_UINT8;
|
|
|
|
id.clear();
|
|
id.append("IAS_SEL");
|
|
|
|
|
|
float value = param_getvalue(0,type);
|
|
|
|
on_paramClicked(sysid,compid,id,type,value);
|
|
|
|
}
|
|
else
|
|
{
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
box->setText(tr("请设定目标"));
|
|
box->show();
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_IAS_SEL_1_clicked()
|
|
{
|
|
if(ui->comboBox_sys->currentIndex() != -1)
|
|
{
|
|
|
|
uint8_t sysid = ui->comboBox_sys->currentData(Qt::UserRole).toInt();
|
|
uint8_t compid = 1;
|
|
QString id;
|
|
uint8_t type = MAV_PARAM_TYPE_UINT8;
|
|
|
|
id.clear();
|
|
id.append("IAS_SEL");
|
|
|
|
float value = param_getvalue(1,type);
|
|
|
|
on_paramClicked(sysid,compid,id,type,value);
|
|
|
|
}
|
|
else
|
|
{
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
box->setText(tr("请设定目标"));
|
|
box->show();
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_IAS_SEL_2_clicked()
|
|
{
|
|
if(ui->comboBox_sys->currentIndex() != -1)
|
|
{
|
|
uint8_t sysid = ui->comboBox_sys->currentData(Qt::UserRole).toInt();
|
|
uint8_t compid = 1;
|
|
QString id;
|
|
uint8_t type = MAV_PARAM_TYPE_UINT8;
|
|
|
|
id.clear();
|
|
id.append("IAS_SEL");
|
|
|
|
float value = param_getvalue(2,type);
|
|
|
|
on_paramClicked(sysid,compid,id,type,value);
|
|
|
|
}
|
|
else
|
|
{
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
box->setText(tr("请设定目标"));
|
|
box->show();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandBox::addVehicles(int sysid, int compid)
|
|
{
|
|
Q_UNUSED(compid)
|
|
|
|
if(ui->comboBox_sys->findData(sysid) == -1)
|
|
{
|
|
ui->comboBox_sys->addItem(QString::number(sysid),sysid);
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_ServoSet_clicked()
|
|
{
|
|
if(ui->comboBox_ServoType->currentIndex() != -1)
|
|
{
|
|
switch(ui->comboBox_ServoType->currentData(Qt::UserRole).toInt())
|
|
{
|
|
case 1:
|
|
{
|
|
m_la = ui->spinBox_Servo->value();
|
|
}break;
|
|
case 2:
|
|
{
|
|
m_ra = ui->spinBox_Servo->value();
|
|
}break;
|
|
case 3:
|
|
{
|
|
m_le = ui->spinBox_Servo->value();
|
|
}break;
|
|
case 4:
|
|
{
|
|
m_re = ui->spinBox_Servo->value();
|
|
}break;
|
|
case 5:
|
|
{
|
|
m_ru = ui->spinBox_Servo->value();
|
|
}break;
|
|
}
|
|
|
|
|
|
on_commandClicked(tr("设定舵机 %1 %2").arg(ui->comboBox_ServoType->currentText()).arg(ui->spinBox_Servo->value()),
|
|
106,m_la,m_le,m_ra,m_re,0,0,180,0);
|
|
|
|
//qDebug() << m_ra << m_re << m_ru << m_la << m_le;
|
|
|
|
}
|
|
else
|
|
{
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
box->setText(tr("请设定"));
|
|
box->show();
|
|
}
|
|
}
|
|
|
|
void CommandBox::on_pushButton_Zero_clicked()
|
|
{
|
|
m_ra = 0;
|
|
m_la = 0;
|
|
m_ru = 0;
|
|
m_re = 0;
|
|
m_le = 0;
|
|
|
|
on_commandClicked(tr("设定舵机归零 %1").arg(ui->pushButton_Zero->text()),
|
|
106,m_ra,m_re,m_ru,m_la,m_le,0,180,0);
|
|
|
|
}
|
|
|
|
void CommandBox::on_pushButton_setFuel_clicked()
|
|
{
|
|
double value = ui->doubleSpinBox_Fuel->value();
|
|
|
|
on_commandClicked(tr("%1 %2kg").arg(ui->pushButton_setFuel->text()).arg(QString::number(value)),
|
|
value,0,0,0,0,0,0,20009,0);
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_AngleZero_clicked()//动压归零
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_AngleZero->text()),
|
|
0,0,1,0,0,0,0,20005,0);
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_ZeroComplete_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_ZeroComplete->text()),
|
|
0,0,0,0,0,0,0,20005,0);
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_HeatOn1_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_HeatOn1->text()),
|
|
1,0,0,0,0,0,0,20005,0);
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_HeatOn2_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_HeatOn2->text()),
|
|
0,1,0,0,0,0,0,20005,0);
|
|
}
|
|
|
|
//伺服指令
|
|
void CommandBox::on_pushButton_AirHeatOn_clicked()
|
|
{
|
|
on_commandClicked(ui->pushButton_AirHeatOn->text(),
|
|
1,1,0,0,0,0,0,20005,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_HeatOff_clicked()
|
|
{
|
|
on_commandClicked(ui->pushButton_HeatOff->text(),
|
|
0,0,0,0,0,0,0,20005,0);
|
|
}
|
|
|
|
|
|
void CommandBox::on_pushButton_ServoTest_clicked()//IDLE
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_ServoTest->text()),
|
|
0,0,0,0,0,0,0,20007,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_StabilizeTest_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_StabilizeTest->text()),
|
|
1,0,0,0,0,0,0,20007,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_ManualTest_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_ManualTest->text()),
|
|
2,0,0,0,0,0,0,20007,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_swep_clicked()
|
|
{
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_swep->text()),
|
|
3,0,0,0,0,0,0,20007,0);
|
|
}
|
|
|
|
void CommandBox::on_pushButton_test_cmd_clicked()
|
|
{
|
|
uint8_t ch = 0;
|
|
float A;
|
|
float start;
|
|
float stop;
|
|
float K;
|
|
|
|
|
|
//ch = ui->comboBox_sel_ch->currentData(Qt::UserRole).toInt();
|
|
|
|
/* 1 ail
|
|
* 2 ele
|
|
* 4 rud
|
|
* */
|
|
|
|
ch |= ui->checkBox_ail->isChecked()?(1):(0);
|
|
ch |= ui->checkBox_ele->isChecked()?(2):(0);
|
|
ch |= ui->checkBox_rud->isChecked()?(4):(0);
|
|
|
|
qDebug() << "ch" << ch;
|
|
|
|
A = ui->doubleSpinBox_A_deg->value();
|
|
start = ui->doubleSpinBox__Start_frq_Hz->value();
|
|
stop = ui->doubleSpinBox_Stop_frq_Hz->value();
|
|
K = ui->doubleSpinBox_K_frq_Hz->value();
|
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_test_cmd->text()),
|
|
ch,A,start,stop,K,0,0,20009,0);
|
|
|
|
|
|
qDebug() << "Servo Test:" <<ch << A << start << stop << K;
|
|
}
|
|
|
|
void CommandBox::on_pushButton_test_stop_clicked()
|
|
{
|
|
|
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_test_stop->text()),
|
|
0,0,0,0,0,0,0,20008,0);
|
|
}
|
|
|
|
|
|
|
|
|