You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
6.8 KiB
C++

1 year ago
#include "mainpage_jfparameter.h"
mainpage_JfParameter::mainpage_JfParameter(QWidget *parent) : QWidget(parent)
{
label_cspz_2_1=new QLabel(this);//局放参数
label_cspz_2_2=new QLabel(this);
label_cspz_2_3=new QLabel(this);
label_cspz_2_4=new QLabel(this);
label_cspz_2_5=new QLabel(this);
label_cspz_2_6=new QLabel(this);
label_cspz_2_7=new QLabel(this);
label_cspz_2_8=new QLabel(this);
label_cspz_2_9=new QLabel(this);
label_cspz_2_10=new QLabel(this);
label_disconnect_jufang=new QLabel(this);
label_disconnect_jufang->setGeometry(30,10,740,150);
label_disconnect_jufang->setAlignment(Qt::AlignCenter);
label_disconnect_jufang->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(240, 0, 0)");
label_cspz_2_1->setGeometry(170,10,200,20);
label_cspz_2_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_2->setGeometry(170,40,200,20);
label_cspz_2_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_3->setGeometry(170,70,200,20);
label_cspz_2_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_4->setGeometry(170,100,200,20);
label_cspz_2_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_5->setGeometry(170,130,200,20);
label_cspz_2_5->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_6->setGeometry(470,10,250,20);
label_cspz_2_6->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_7->setGeometry(470,40,250,20);
label_cspz_2_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_8->setGeometry(470,70,250,20);
label_cspz_2_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_9->setGeometry(470,100,250,20);
label_cspz_2_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_cspz_2_10->setGeometry(470,130,250,20);
label_cspz_2_10->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
}
void mainpage_JfParameter::onPageSevenDataUpdate()
{
DisplayMsg_cspz();
label_cspz_2_1->setText("TEV峰值"+QString::number(Cspz_TevTop_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_2->setText("TEV频次"+QString::number(Cspz_TevFreq_data1,'f',1));//10进制转字符串
label_cspz_2_3->setText("TEV噪声水平值"+QString::number(TevTop_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_4->setText("TEV噪声均值"+QString::number(Cspz_TevAve_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_5->setText("TEV脉冲周期数"+QString::number(Cspz_Tevperiodicity_data1,'f',1));//10进制转字符串
label_cspz_2_6->setText("超声波峰值:"+QString::number(Cspz_UltTop_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_7->setText("超声波频次:"+QString::number(Cspz_UltFreq_data1,'f',1));//10进制转字符串
label_cspz_2_8->setText("超声波噪声水平值:"+QString::number(Cspz_UltLevel_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_9->setText("超声波均值:"+QString::number(Cspz_UltAve_data1,'f',1)+"dB");//10进制转字符串
label_cspz_2_10->setText("超声波有效值:"+QString::number(Cspz_UltEffective_data1,'f',1)+"dB");//10进制转字符串
}
void mainpage_JfParameter::onJuFangStateCheck()
{
bool state = false;
QFile file_read("/home/data/JF_state.txt");
if(file_read.open(QIODevice::ReadOnly | QIODevice::Text))
{
QTextStream in(&file_read);//创建一个对象让它去读文件
if(in.readLine()=="1")//局放未连接
{
state=true;
label_disconnect_jufang->setText("局放未连接!");
label_disconnect_jufang->show();
label_disconnect_jufang->raise();
}
else
{
state=false;
label_disconnect_jufang->hide();
}
}
file_read.close();
emit sigDispJuFangAlarm(state);
}
void mainpage_JfParameter::DisplayMsg_cspz()//参数显示实时更新
{
bool ok;
QString Cspz_TevTop_data = SEC.TevTop.toHex();
Cspz_TevTop_data1 = Qchange(Cspz_TevTop_data);
QString Cspz_TevFreq_data = SEC.TevFreq.toHex();
Cspz_TevFreq_data1 = Cspz_TevFreq_data.toInt(&ok,16);//16进制转十进制
QString TevTop_data = SEC.TevLevel.toHex();
TevTop_data1 = Qchange(TevTop_data);
QString Cspz_TevAve_data = SEC.TevAve.toHex();
Cspz_TevAve_data1 = Qchange(Cspz_TevAve_data);
QString Cspz_Tevperiodicity_data = SEC.Tevperiodicity.toHex();
Cspz_Tevperiodicity_data1 = Cspz_Tevperiodicity_data.toInt(&ok,16);//16进制转十进制
QString Cspz_UltTop_data = SEC.UltTop.toHex();
Cspz_UltTop_data1 = Qchange2(Cspz_UltTop_data);
QString Cspz_UltFreq_data = SEC.UltFreq.toHex();
Cspz_UltFreq_data1 = Cspz_UltFreq_data.toInt(&ok,16);//16进制转十进制
QString Cspz_UltLevel_data = SEC.UltLevel.toHex();
Cspz_UltLevel_data1 = Qchange2(Cspz_UltLevel_data);
QString Cspz_UltAve_data = SEC.UltAve.toHex();
Cspz_UltAve_data1 = Qchange2(Cspz_UltAve_data);
QString Cspz_UltEffective_data = SEC.UltEffective.toHex();
Cspz_UltEffective_data1 = Qchange2(Cspz_UltEffective_data);
}
float mainpage_JfParameter::Qchange(QString asend)
{
bool ok;
float aaa;
int Cspz_TevTop_data2 = asend.toInt(&ok,16);
if (Cspz_TevTop_data2 > 32767){
Cspz_TevTop_data2 = Cspz_TevTop_data2 & 0x7FFF; //清除符号位
Cspz_TevTop_data2 = ~Cspz_TevTop_data2; //反码
Cspz_TevTop_data2 = Cspz_TevTop_data2 & 0x7FFF; //清除左边多余位
Cspz_TevTop_data2 = Cspz_TevTop_data2 + 1; //加1
Cspz_TevTop_data2 = Cspz_TevTop_data2*-1; //符号位
aaa = Cspz_TevTop_data2*1.0/10;//16进制转十进制
}else{
aaa = asend.toInt(&ok,16)*1.0/10;
}
return aaa;
}
float mainpage_JfParameter::Qchange2(QString asend2)
{
bool ok;
float aaa;
int Cspz_TevTop_data2 = asend2.toInt(&ok,16);
if (Cspz_TevTop_data2 > 32767){
Cspz_TevTop_data2 = Cspz_TevTop_data2 & 0x7FFF; //清除符号位
Cspz_TevTop_data2 = ~Cspz_TevTop_data2; //反码
Cspz_TevTop_data2 = Cspz_TevTop_data2 & 0x7FFF; //清除左边多余位
Cspz_TevTop_data2 = Cspz_TevTop_data2 + 1; //加1
Cspz_TevTop_data2 = Cspz_TevTop_data2*-1; //符号位
aaa = Cspz_TevTop_data2*1.0/100;//16进制转十进制
}else{
aaa = asend2.toInt(&ok,16)*1.0/100;
}
return aaa;
}