#include "sysconf_page.h"
|
#include "ui_sysconf_page.h"
|
#include "IMEKeyBoard/keyboard_num.h"
|
#include "Common/mymessagebox.h"
|
|
Sysconf_Page::Sysconf_Page(QWidget *parent,Work_Thread *thread) :
|
customDialog(parent),
|
ui(new Ui::sysconf_page)
|
{
|
ui->setupUi(this);
|
work_thread = thread;
|
|
memset(&sysconf,0x00,sizeof(sysconf));
|
QString str = tr("单体来源:");
|
if(mon_use_type==0)
|
str+= "IO COM1";
|
else if(mon_use_type==1)
|
str+= "905 COM4";
|
else if(mon_use_type==2)
|
str+= "LORA COM4";
|
ui->label_mon->setText(str);
|
|
mashineTypeList<<tr("IDCE")<<tr("FBO")<<tr("FBI")<<tr("OTHER");
|
QPixmap pixmap(1, 50);
|
pixmap.fill(Qt::transparent);
|
QIcon icon(pixmap);
|
ui->cb_type->setIconSize(QSize(1, 50));
|
for(int i=0;i<mashineTypeList.count();i++)
|
{
|
ui->cb_type->addItem(icon,mashineTypeList.at(i));
|
}
|
if(sysconf.Mashine_Type < mashineTypeList.count())
|
{
|
ui->cb_type->setCurrentIndex(sysconf.Mashine_Type);
|
}
|
|
set_btn_beep(ui->ledit_intc,SIGNAL(custom_click()));
|
set_btn_beep(ui->ledit_extc,SIGNAL(custom_click()));
|
set_btn_beep(ui->ledit_stdc,SIGNAL(custom_click()));
|
set_btn_beep(ui->ledit_dcdc,SIGNAL(custom_click()));
|
set_btn_beep(ui->ledit_power,SIGNAL(custom_click()));
|
set_btn_beep(ui->cb_type,SIGNAL(activated(int)));
|
|
set_btn_beep(ui->btn_read,SIGNAL(pressed()));
|
set_btn_beep(ui->btn_set,SIGNAL(pressed()));
|
set_btn_beep(ui->pushButton_Exit,SIGNAL(pressed()));
|
|
connect(ui->ledit_intc,SIGNAL(custom_click()),this,SLOT(ledit_action()));
|
connect(ui->ledit_extc,SIGNAL(custom_click()),this,SLOT(ledit_action()));
|
connect(ui->ledit_stdc,SIGNAL(custom_click()),this,SLOT(ledit_action()));
|
connect(ui->ledit_dcdc,SIGNAL(custom_click()),this,SLOT(ledit_action()));
|
connect(ui->ledit_power,SIGNAL(custom_click()),this,SLOT(ledit_action()));
|
connect(ui->cb_type,SIGNAL(currentIndexChanged(int)),this,SLOT(Combox_Changed(int)));
|
|
connect(ui->btn_read,SIGNAL(released()),this,SLOT(BtnReleased()));
|
connect(ui->btn_set,SIGNAL(released()),this,SLOT(BtnReleased()));
|
connect(ui->pushButton_Exit,SIGNAL(released()),this,SLOT(BtnReleased()));
|
|
qRegisterMetaType<SYS_CONFIG>("SYS_CONFIG");
|
connect(this,SIGNAL(SendSysInfoConf(int,SYS_CONFIG)),work_thread,SLOT(RecvSysConfCMD(int,SYS_CONFIG)));
|
connect(work_thread,SIGNAL(SendSysconfInfo(SYS_CONFIG)),this,SLOT(RecvSysInfoConf(SYS_CONFIG)));
|
|
SysconfPageShow();
|
|
QTimer::singleShot(500,this,SLOT(TimerSlot()));
|
}
|
|
Sysconf_Page::~Sysconf_Page()
|
{
|
delete ui;
|
}
|
|
void Sysconf_Page::TimerSlot()
|
{
|
emit SendSysInfoConf(work_thread->CMD_ReadSysConfInfo, sysconf);
|
}
|
|
void Sysconf_Page::SysconfPageShow(void)
|
{
|
ui->ledit_intc->setText(QString::number(sysconf.InnerCurrRange));
|
ui->ledit_extc->setText(QString::number(sysconf.ExterCurrRange));
|
ui->ledit_stdc->setText(QString::number(sysconf.MashineCurr));
|
ui->ledit_dcdc->setText(QString::number(sysconf.DCDC_Count));
|
ui->ledit_power->setText(QString::number((float)sysconf.MashinePower/10,'f',1));
|
if(sysconf.Mashine_Type < mashineTypeList.count())
|
{
|
ui->cb_type->setCurrentIndex(sysconf.Mashine_Type);
|
}
|
if(sysconf.TKQenable){
|
ui->label_tkq->setText(tr("启用"));
|
}
|
else
|
ui->label_tkq->setText(tr("禁用"));
|
|
ui->ledit_intc->setStyleSheet("color:black");
|
ui->ledit_extc->setStyleSheet("color:black");
|
ui->ledit_stdc->setStyleSheet("color:black");
|
ui->ledit_dcdc->setStyleSheet("color:black");
|
ui->ledit_power->setStyleSheet("color:black");
|
// ui->label_tkq->setStyleSheet("color:black");
|
}
|
|
void Sysconf_Page::RecvSysInfoConf(SYS_CONFIG config)
|
{
|
sysconf = config;
|
|
SysconfPageShow();
|
|
qDebug("sys config read!");
|
}
|
|
void Sysconf_Page::ledit_action(void)
|
{
|
if((!work_thread->IF_J9Close)&&JT_VALUE)
|
{
|
QString msg = tr("设备处于紧急停止状态,请检查并断电重启!");
|
popBox(msg);
|
return;
|
}
|
Custom_LineEdit *le = dynamic_cast<Custom_LineEdit*>(sender());
|
|
if( le == ui->ledit_intc
|
|| le == ui->ledit_extc
|
|| le == ui->ledit_stdc
|
|| le == ui->ledit_dcdc
|
|| le == ui->ledit_power )
|
{
|
le->setStyleSheet("color:red");
|
|
KeyBoard_Num keyboard(this,INPUT_DATA,work_thread);
|
keyboard.setGeometry(400,60,300,350);
|
keyboard.execKeyboard();
|
|
DATA_KB_RTN kbdata = keyboard.get_kb_data();
|
|
if(kbdata.If_OK)
|
{
|
float tmpdata = kbdata.set_text.toFloat();
|
|
if(le == ui->ledit_intc)
|
{
|
if(tmpdata>=10 && tmpdata<=2000)
|
{
|
sysconf.InnerCurrRange = tmpdata;
|
le->setText(QString::number(sysconf.InnerCurrRange));
|
}
|
}
|
else if(le == ui->ledit_extc)
|
{
|
if(tmpdata>=10 && tmpdata<=2000)
|
{
|
sysconf.ExterCurrRange = tmpdata;
|
le->setText(QString::number(sysconf.ExterCurrRange));
|
}
|
}
|
else if(le == ui->ledit_stdc)
|
{
|
if(tmpdata>=1 && tmpdata<=2000)
|
{
|
sysconf.MashineCurr = tmpdata;
|
le->setText(QString::number(sysconf.MashineCurr));
|
}
|
}
|
else if(le == ui->ledit_dcdc)
|
{
|
if(tmpdata<=10)
|
{
|
sysconf.DCDC_Count = tmpdata;
|
le->setText(QString::number(sysconf.DCDC_Count));
|
}
|
}
|
else if(le == ui->ledit_power)
|
{
|
if(tmpdata>=1 && tmpdata<=100)
|
{
|
sysconf.MashinePower = tmpdata*10;
|
le->setText(QString::number(tmpdata,'f',1));
|
}
|
}
|
}
|
else
|
{
|
le->setStyleSheet("color:black");
|
}
|
}
|
}
|
|
void Sysconf_Page::BtnReleased()
|
{
|
QPushButton *pb = dynamic_cast<QPushButton*>(sender());
|
|
if(pb == ui->pushButton_Exit)
|
{
|
closeCustom(false);
|
}
|
else if(pb == ui->btn_read)
|
{
|
if((!work_thread->IF_J9Close)&&JT_VALUE)
|
{
|
QString msg = tr("设备处于紧急停止状态,请检查并断电重启!");
|
popBox(msg);
|
return;
|
}
|
emit SendSysInfoConf(work_thread->CMD_ReadSysConfInfo, sysconf);
|
}
|
else if(pb == ui->btn_set)
|
{
|
if((!work_thread->IF_J9Close)&&JT_VALUE)
|
{
|
QString msg = tr("设备处于紧急停止状态,请检查并断电重启!");
|
popBox(msg);
|
return;
|
}
|
emit SendSysInfoConf(work_thread->CMD_SetSysConfInfo, sysconf);
|
QTimer::singleShot(1000,this,SLOT(TimerSlot()));
|
}
|
}
|
|
void Sysconf_Page::Combox_Changed(int index)
|
{
|
switch(index)
|
{
|
case 0:
|
case 1:
|
case 2:
|
case 3: sysconf.Mashine_Type = index;
|
ui->cb_type->setCurrentIndex(sysconf.Mashine_Type);
|
break;
|
default:break;
|
}
|
}
|
|
void Sysconf_Page::popBox(QString msg)
|
{
|
MessageBox box( this, QMessageBox::Warning,MB_Caption, msg,
|
QMessageBox::Ok,
|
QMessageBox::Ok,
|
work_thread);
|
box.exec();
|
}
|