2020-10-21 19:37:48 +08:00
|
|
|
#include "CommandBox.h"
|
2020-10-10 12:12:30 +08:00
|
|
|
#include "ui_CommandBox.h"
|
|
|
|
|
|
|
|
|
|
CommandBox::CommandBox(QWidget *parent) :
|
2021-01-07 10:55:02 +08:00
|
|
|
ToolsWidget(parent),
|
2020-10-10 12:12:30 +08:00
|
|
|
ui(new Ui::CommandBox)
|
|
|
|
|
{
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
2021-01-22 11:59:56 +08:00
|
|
|
this->setTop(true);
|
|
|
|
|
|
2020-10-11 19:10:57 +08:00
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
//use_ext_ins参数名称
|
2020-12-08 22:21:52 +08:00
|
|
|
ui->comboBox_IMU->addItem("内置惯导",0);
|
2021-06-13 17:44:46 +08:00
|
|
|
ui->comboBox_IMU->addItem("外置惯导",1);
|
2020-10-21 19:37:48 +08:00
|
|
|
ui->comboBox_IMU->setCurrentIndex(0);
|
|
|
|
|
|
2021-06-13 17:44:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->comboBox_ActuatorType->addItem("扫频试验",0);
|
|
|
|
|
ui->comboBox_ActuatorType->addItem("滞环试验",1);
|
|
|
|
|
ui->comboBox_ActuatorType->addItem("死区测试",2);
|
|
|
|
|
ui->comboBox_ActuatorType->addItem("阶跃测试",3);
|
|
|
|
|
ui->comboBox_ActuatorType->setCurrentIndex(0);
|
|
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
|
2020-11-17 15:30:22 +08:00
|
|
|
/*
|
|
|
|
|
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);
|
|
|
|
|
*/
|
2020-10-21 19:37:48 +08:00
|
|
|
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
//ui->pushButton_AirHeatOff->hide();
|
|
|
|
|
//ui->pushButton_AirHeatOn->hide();
|
|
|
|
|
//ui->pushButton_HeatOn3->hide();
|
|
|
|
|
//ui->pushButton_HeatOn4->hide();
|
2020-12-08 22:21:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-29 21:28:00 +08:00
|
|
|
m_ra = 0;
|
|
|
|
|
m_la = 0;
|
|
|
|
|
m_ru = 0;
|
|
|
|
|
m_re = 0;
|
|
|
|
|
m_le = 0;
|
|
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
QRegExp *reg = new QRegExp("^(-?\d+)(\.\d+)?$");
|
|
|
|
|
|
|
|
|
|
ui->lineEdit_msl_in->setValidator(QRegExpValidator(reg));
|
|
|
|
|
ui->lineEdit_Ma_in->setValidator(QRegExpValidator(reg));
|
|
|
|
|
ui->lineEdit_Ps_in->setValidator(QRegExpValidator(reg));
|
|
|
|
|
ui->lineEdit_qbar_in->setValidator(QRegExpValidator(reg));
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2020-10-10 12:12:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandBox::~CommandBox()
|
|
|
|
|
{
|
|
|
|
|
delete ui;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CommandBox::setFloatFlag(bool flag)
|
|
|
|
|
{
|
|
|
|
|
floatflag = flag;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-11 17:47:29 +08:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-14 21:28:47 +08:00
|
|
|
void CommandBox::commandAccepted(bool flag,uint16_t command,uint8_t result)
|
|
|
|
|
{
|
|
|
|
|
bool isFundSender = false;
|
|
|
|
|
QString string;
|
|
|
|
|
//找到消息的发送者
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QObjectList list = ui->frame->children();
|
|
|
|
|
|
2020-11-17 15:30:22 +08:00
|
|
|
// qDebug() << list;
|
2020-10-14 21:28:47 +08:00
|
|
|
|
|
|
|
|
//qDebug() << CommandBox.findChildren();
|
|
|
|
|
|
|
|
|
|
if(command == m_command)
|
|
|
|
|
{
|
2020-11-17 15:30:22 +08:00
|
|
|
isFundSender = true;
|
2020-10-14 21:28:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
|
case MAV_RESULT_ACCEPTED:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 accepted and executed").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
|
|
|
|
case MAV_RESULT_TEMPORARILY_REJECTED:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 rejected").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
|
|
|
|
case MAV_RESULT_DENIED:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 permanently denied").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
|
|
|
|
case MAV_RESULT_UNSUPPORTED:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 unsupported").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
|
|
|
|
case MAV_RESULT_FAILED:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 failed").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
|
|
|
|
case MAV_RESULT_IN_PROGRESS:
|
2020-11-17 15:30:22 +08:00
|
|
|
string.append(tr("%1,%2 being executed").arg(command).arg(m_name));
|
2020-10-14 21:28:47 +08:00
|
|
|
break;
|
2020-12-15 13:47:14 +08:00
|
|
|
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;
|
2020-10-14 21:28:47 +08:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-12-05 14:39:44 +08:00
|
|
|
|
2020-12-09 17:29:28 +08:00
|
|
|
ui->lineEdit_CommandName->clear();
|
2020-12-05 14:39:44 +08:00
|
|
|
m_name.clear();
|
2020-12-09 17:29:28 +08:00
|
|
|
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;
|
|
|
|
|
|
2020-10-14 21:28:47 +08:00
|
|
|
}
|
|
|
|
|
|
2020-10-15 22:21:38 +08:00
|
|
|
if(string.size() > 0)
|
|
|
|
|
{
|
2021-05-13 09:17:59 +08:00
|
|
|
QVariant flag;
|
|
|
|
|
Config *cfg = new Config();
|
|
|
|
|
|
|
|
|
|
cfg->getTTS(&flag);
|
|
|
|
|
|
|
|
|
|
if(flag.toBool())
|
|
|
|
|
{
|
|
|
|
|
QTextToSpeech *tts = new QTextToSpeech();
|
|
|
|
|
tts->say(string);
|
|
|
|
|
tts->deleteLater();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
emit showMessage(string);
|
|
|
|
|
|
2020-10-15 22:21:38 +08:00
|
|
|
}
|
2020-10-14 21:28:47 +08:00
|
|
|
}
|
|
|
|
|
|
2020-10-10 12:12:30 +08:00
|
|
|
|
2020-10-12 21:08:37 +08:00
|
|
|
//二次确认
|
|
|
|
|
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
|
|
|
|
|
{
|
2020-12-09 17:29:28 +08:00
|
|
|
ui->lineEdit_CommandName->clear();
|
|
|
|
|
m_name.clear();
|
2020-10-12 21:08:37 +08:00
|
|
|
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;
|
2020-12-09 17:29:28 +08:00
|
|
|
|
2020-10-12 21:08:37 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandBox::on_pushButton_SendCommand_clicked()
|
|
|
|
|
{
|
2020-12-08 22:21:52 +08:00
|
|
|
if(cmdType == 0)
|
2020-12-05 14:39:44 +08:00
|
|
|
{
|
2020-12-08 22:21:52 +08:00
|
|
|
if(m_command == 0)
|
|
|
|
|
{
|
|
|
|
|
emit showMessage(tr("please set command first ,command :%1").arg(m_command));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-05 14:39:44 +08:00
|
|
|
}
|
|
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
if(cmdType == 0)
|
|
|
|
|
{
|
2020-12-08 22:21:52 +08:00
|
|
|
emit showMessage(tr("发送指令 ") + QString::number(m_command) + " " + m_name,5000);
|
2020-10-21 19:37:48 +08:00
|
|
|
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)
|
|
|
|
|
{
|
2020-12-08 23:51:23 +08:00
|
|
|
|
2020-12-11 17:47:29 +08:00
|
|
|
emit showMessage(tr("修改参数 ") + " " + m_id.toLatin1().data() + " " + QString::number(m_value),5000);
|
2020-12-08 23:51:23 +08:00
|
|
|
|
|
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
emit WriteCmd(m_sysid,m_compid,m_id.toLatin1().data(),m_type,m_value);
|
2020-12-08 23:51:23 +08:00
|
|
|
//qDebug() << m_type << m_value;
|
2020-10-21 19:37:48 +08:00
|
|
|
}
|
2020-10-12 21:08:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandBox::on_pushButton_Cancel_clicked()
|
|
|
|
|
{
|
2020-12-09 17:29:28 +08:00
|
|
|
ui->lineEdit_CommandName->clear();
|
|
|
|
|
m_name.clear();
|
2020-10-12 21:08:37 +08:00
|
|
|
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);
|
2020-10-21 19:37:48 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2020-10-27 21:36:03 +08:00
|
|
|
ui->lineEdit_CommandName->setText(id + " " + QString::number(value));
|
2020-10-21 19:37:48 +08:00
|
|
|
|
|
|
|
|
cmdType = 1;
|
2020-10-12 21:08:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//舵机指令
|
2021-01-16 13:21:39 +08:00
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
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;
|
2020-12-08 22:21:52 +08:00
|
|
|
uint8_t type = MAV_PARAM_TYPE_INT8;
|
2020-10-21 19:37:48 +08:00
|
|
|
|
|
|
|
|
id.clear();
|
|
|
|
|
id.append("use_ext_ins");
|
|
|
|
|
|
2020-12-11 17:47:29 +08:00
|
|
|
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);
|
|
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
on_paramClicked(sysid,compid,id,type,value);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QMessageBox *box = new QMessageBox(this);
|
|
|
|
|
|
|
|
|
|
box->setWindowTitle(tr("警告"));
|
|
|
|
|
box->setText(tr("请设定目标"));
|
|
|
|
|
box->show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-12-11 17:47:29 +08:00
|
|
|
|
|
|
|
|
|
2020-10-21 19:37:48 +08:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 13:44:27 +08:00
|
|
|
void CommandBox::on_pushButton_setFuel_clicked()
|
|
|
|
|
{
|
2020-12-08 22:21:52 +08:00
|
|
|
double value = ui->doubleSpinBox_Fuel->value();
|
2020-11-05 13:44:27 +08:00
|
|
|
|
2020-12-08 22:21:52 +08:00
|
|
|
on_commandClicked(tr("%1 %2kg").arg(ui->pushButton_setFuel->text()).arg(QString::number(value)),
|
|
|
|
|
value,0,0,0,0,0,0,20009,0);
|
2020-11-05 13:44:27 +08:00
|
|
|
}
|
2020-11-07 10:54:30 +08:00
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
|
|
|
|
void CommandBox::on_pushButton_AngleZero_clicked()//动压归零
|
2020-11-07 10:54:30 +08:00
|
|
|
{
|
2020-12-18 09:35:41 +08:00
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_AngleZero->text()),
|
|
|
|
|
0,0,1,0,0,0,0,20005,0);
|
2020-11-07 10:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
|
|
|
|
void CommandBox::on_pushButton_ZeroComplete_clicked()
|
2020-11-07 10:54:30 +08:00
|
|
|
{
|
2020-12-18 09:35:41 +08:00
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_ZeroComplete->text()),
|
|
|
|
|
0,0,0,0,0,0,0,20005,0);
|
2020-11-07 10:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
2020-11-07 10:54:30 +08:00
|
|
|
void CommandBox::on_pushButton_HeatOn1_clicked()
|
|
|
|
|
{
|
|
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_HeatOn1->text()),
|
|
|
|
|
1,0,0,0,0,0,0,20005,0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
2020-11-07 10:54:30 +08:00
|
|
|
void CommandBox::on_pushButton_HeatOn2_clicked()
|
|
|
|
|
{
|
|
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_HeatOn2->text()),
|
|
|
|
|
0,1,0,0,0,0,0,20005,0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
//伺服指令
|
|
|
|
|
void CommandBox::on_pushButton_AirHeatOn_clicked()
|
2020-11-07 10:54:30 +08:00
|
|
|
{
|
2020-12-18 09:35:41 +08:00
|
|
|
on_commandClicked(ui->pushButton_AirHeatOn->text(),
|
|
|
|
|
1,1,0,0,0,0,0,20005,0);
|
2020-11-07 10:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
void CommandBox::on_pushButton_HeatOff_clicked()
|
2020-11-07 10:54:30 +08:00
|
|
|
{
|
2020-12-18 09:35:41 +08:00
|
|
|
on_commandClicked(ui->pushButton_HeatOff->text(),
|
|
|
|
|
0,0,0,0,0,0,0,20005,0);
|
2020-11-07 10:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
void CommandBox::on_pushButton_setStructSweepParameter_clicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
float msl_in = ui->lineEdit_msl_in->text().toDouble();
|
|
|
|
|
float ma_in = ui->lineEdit_Ma_in->text().toDouble();
|
|
|
|
|
float ps_in = ui->lineEdit_Ps_in->text().toDouble();
|
|
|
|
|
float qbar_in = ui->lineEdit_qbar_in->text().toDouble();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_setStructSweepParameter->text()),
|
|
|
|
|
msl_in,ma_in,ps_in,qbar_in,0,0,0,20014,0);
|
|
|
|
|
|
|
|
|
|
qDebug() << "StructSweep:" <<msl_in << ma_in << ps_in << qbar_in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-17 15:30:22 +08:00
|
|
|
void CommandBox::on_pushButton_test_cmd_clicked()
|
|
|
|
|
{
|
|
|
|
|
uint8_t ch = 0;
|
2022-08-16 20:35:36 +08:00
|
|
|
float Amp;
|
2020-11-17 15:30:22 +08:00
|
|
|
float start;
|
|
|
|
|
float stop;
|
|
|
|
|
float K;
|
2021-06-13 17:44:46 +08:00
|
|
|
float type;
|
2022-08-16 20:35:36 +08:00
|
|
|
float hlre;
|
2021-06-13 17:44:46 +08:00
|
|
|
|
2020-11-17 15:30:22 +08:00
|
|
|
|
2021-06-13 17:44:46 +08:00
|
|
|
type = ui->comboBox_ActuatorType->currentData().toFloat();
|
2020-11-17 15:30:22 +08:00
|
|
|
|
|
|
|
|
//ch = ui->comboBox_sel_ch->currentData(Qt::UserRole).toInt();
|
|
|
|
|
|
|
|
|
|
/* 1 ail
|
|
|
|
|
* 2 ele
|
|
|
|
|
* 4 rud
|
2022-08-16 20:35:36 +08:00
|
|
|
* 8 dsp
|
|
|
|
|
*
|
2020-11-17 15:30:22 +08:00
|
|
|
* */
|
|
|
|
|
|
|
|
|
|
ch |= ui->checkBox_ail->isChecked()?(1):(0);
|
|
|
|
|
ch |= ui->checkBox_ele->isChecked()?(2):(0);
|
|
|
|
|
ch |= ui->checkBox_rud->isChecked()?(4):(0);
|
2022-08-16 20:35:36 +08:00
|
|
|
ch |= ui->checkBox_dsp->isChecked()?(8):(0);
|
2020-11-17 15:30:22 +08:00
|
|
|
|
|
|
|
|
qDebug() << "ch" << ch;
|
|
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
Amp = ui->doubleSpinBox_A_deg->value();
|
2020-11-17 15:30:22 +08:00
|
|
|
start = ui->doubleSpinBox__Start_frq_Hz->value();
|
|
|
|
|
stop = ui->doubleSpinBox_Stop_frq_Hz->value();
|
|
|
|
|
K = ui->doubleSpinBox_K_frq_Hz->value();
|
|
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
quint16 hldn = ui->spinBox_hldn->value();
|
|
|
|
|
quint16 recn = ui->spinBox_recn->value();
|
|
|
|
|
|
|
|
|
|
hlre = ((quint16)recn << 8)|hldn;
|
|
|
|
|
|
2020-11-19 11:39:28 +08:00
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_test_cmd->text()),
|
2022-08-16 20:35:36 +08:00
|
|
|
ch,Amp,start,stop,K,type,hlre,20013,0);
|
2020-11-17 15:30:22 +08:00
|
|
|
|
|
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
qDebug() << "Servo Test:" <<ch << Amp << start << stop << K << type << hlre;
|
2020-11-17 15:30:22 +08:00
|
|
|
}
|
|
|
|
|
|
2022-08-16 20:35:36 +08:00
|
|
|
|
|
|
|
|
|
2020-11-17 15:30:22 +08:00
|
|
|
void CommandBox::on_pushButton_test_stop_clicked()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2020-11-19 11:39:28 +08:00
|
|
|
on_commandClicked(tr("设定 %1").arg(ui->pushButton_test_stop->text()),
|
2020-11-17 15:30:22 +08:00
|
|
|
0,0,0,0,0,0,0,20008,0);
|
|
|
|
|
}
|
2020-12-11 17:47:29 +08:00
|
|
|
|
|
|
|
|
|
2020-12-18 09:35:41 +08:00
|
|
|
|
|
|
|
|
|