Files
gcs-nf/App/CommandBox/CommandBox.cpp
T

396 lines
11 KiB
C++

#include "CommandBox.h"
#include "ui_CommandBox.h"
CommandBox::CommandBox(QWidget *parent) :
QWidget(parent),
ui(new Ui::CommandBox)
{
ui->setupUi(this);
m_parent = parent;
ui->comboBox_Full->addItem("基准档",0);
ui->comboBox_Full->addItem("1档",1);
ui->comboBox_Full->addItem("2档",2);
ui->comboBox_Full->addItem("3档",3);
ui->comboBox_Full->addItem("4档",4);
ui->comboBox_Full->addItem("5档",5);
ui->comboBox_Full->addItem("6档",6);
ui->comboBox_Full->addItem("7档",7);
ui->comboBox_Full->addItem("8档",8);
ui->comboBox_Full->addItem("9档",9);
ui->comboBox_Full->setCurrentIndex(0);
ui->comboBox_Half->addItem("基准档",0);
ui->comboBox_Half->addItem("1档",1);
ui->comboBox_Half->addItem("2档",2);
ui->comboBox_Half->addItem("3档",3);
ui->comboBox_Half->addItem("4档",4);
ui->comboBox_Half->addItem("5档",5);
ui->comboBox_Half->addItem("6档",6);
ui->comboBox_Half->addItem("7档",7);
ui->comboBox_Half->addItem("8档",8);
ui->comboBox_Half->addItem("9档",9);
ui->comboBox_Half->setCurrentIndex(0);
ui->comboBox_rate->addItem("10000",10000);
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("45000",45000);
ui->comboBox_rate->setEditable(true);
ui->comboBox_rate->setCurrentIndex(-1);
ui->comboBox_TestPoint->addItem("核心机主燃油泵",0);
ui->comboBox_TestPoint->addItem("加力主燃油泵",1);
ui->comboBox_TestPoint->addItem("加力点火燃油泵",2);
ui->comboBox_TestPoint->addItem("尾喷口舵机",3);
ui->comboBox_TestPoint->addItem("点火器",4);
ui->comboBox_TestPoint->addItem("启动控制器1",5);
ui->comboBox_TestPoint->addItem("启动控制器2",6);
ui->comboBox_TestPoint->addItem("核心机点火油阀",7);
ui->comboBox_TestPoint->addItem("核心机优先油阀",8);
ui->comboBox_TestPoint->addItem("核心机轻吹油阀",9);
ui->comboBox_TestPoint->addItem("核心机启动气阀",10);
ui->comboBox_TestPoint->addItem("核心机主油阀",11);
ui->comboBox_TestPoint->addItem("加力主油阀",12);
ui->comboBox_TestPoint->addItem("加力轻吹阀",13);
ui->comboBox_TestPoint->addItem("加力点火快速阀",14);
ui->comboBox_TestPoint->addItem("手动转速控制",15);
ui->comboBox_TestPoint->setCurrentIndex(-1);
ui->comboBox_TestValue->show();
ui->comboBox_TestValue->setCurrentIndex(-1);
}
CommandBox::~CommandBox()
{
delete ui;
}
void CommandBox::closeEvent(QCloseEvent *event)
{
setFloat();
event->ignore();
}
void CommandBox::contextMenuEvent(QContextMenuEvent *event)
{
if(floatflag)
{
QMenu *menu = new QMenu(this);
QAction *pAction = new QAction("float",this);
connect(pAction,SIGNAL(triggered(bool)),
this,SLOT(setFloat()));
menu->addAction(pAction);
menu->move(cursor().pos());
menu->show();
}
}
void CommandBox::setFloat(void)
{
if(floatflag)
{
if(this->parent())
{
this->setParent(nullptr);
}
else
{
this->setParent(m_parent);
this->move(0,0);
}
this->show();
}
}
void CommandBox::setFloatFlag(bool flag)
{
floatflag = flag;
}
void CommandBox::on_comboBox_TestPoint_currentIndexChanged(int index)
{
switch (index) {
case 0:
case 1:
case 2:
case 15:
ui->label_TestValue->show();
ui->label_TestValue->setText("转速");
ui->comboBox_TestValue->show();
ui->comboBox_TestValue->clear();
ui->comboBox_TestValue->addItem("10000",10000);
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);
ui->comboBox_TestValue->addItem("45000",45000);
ui->comboBox_TestValue->setEditable(true);
ui->comboBox_TestValue->setCurrentIndex(0);
break;
case 3:
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
{
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()
{
emit cmd_long(m_param1,m_param2,m_param3,m_param4,m_param5,m_param6,m_param7,m_command,m_confirm);
}
void CommandBox::on_pushButton_Cancel_clicked()
{
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);
}
//测试指令
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();
}
else
{
testPoint = ui->comboBox_TestPoint->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() ,
102,0,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_AirHeatOn_clicked()
{
on_commandClicked(ui->pushButton_AirHeatOn->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_AirHeatOff_clicked()
{
on_commandClicked(ui->pushButton_AirHeatOff->text(),
102,0,0,0,0,0,0,180,0);
}
//舵机指令
void CommandBox::on_pushButton_Servo_Check_clicked()
{
on_commandClicked(ui->pushButton_Servo_Check->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Servo_Read_clicked()
{
on_commandClicked(ui->pushButton_Servo_Read->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Servo_Zero_clicked()
{
on_commandClicked(ui->pushButton_Servo_Zero->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Servo_Work_clicked()
{
on_commandClicked(ui->pushButton_Servo_Work->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_coldrun_clicked()
{
on_commandClicked(ui->pushButton_coldrun->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_groundstartup_clicked()
{
on_commandClicked(ui->pushButton_groundstartup->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_off_clicked()
{
on_commandClicked(ui->pushButton_Afterburner_off->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_stop_clicked()
{
on_commandClicked(ui->pushButton_stop->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_EmergencyStop_clicked()
{
on_commandClicked(ui->pushButton_EmergencyStop->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Hardware_off_clicked()
{
on_commandClicked(ui->pushButton_Hardware_off->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Hardware_on_clicked()
{
on_commandClicked(ui->pushButton_Hardware_on->text(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_on_clicked()
{
on_commandClicked(ui->pushButton_Afterburner_on->text() + " " + ui->comboBox_Full->currentText(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_Afterburner_half_clicked()
{
on_commandClicked(ui->pushButton_Afterburner_half->text() + " " + ui->comboBox_Half->currentText(),
102,0,0,0,0,0,0,180,0);
}
void CommandBox::on_pushButton_setRPM_clicked()
{
if(ui->comboBox_rate->currentIndex() != -1)
{
on_commandClicked(ui->pushButton_setRPM->text() + " " + ui->comboBox_rate->currentText(),
102,0,0,0,0,0,0,180,0);
}
else
{
QMessageBox *box = new QMessageBox(this);
box->setWindowTitle(tr("警告"));
box->setText(tr("请设定给定转速"));
box->show();
}
}