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.

125 lines
6.6 KiB
C++

1 year ago
#include "mainpage_data.h"
mainpage_Data::mainpage_Data(QWidget *parent) : QWidget(parent)
{
label_1_1=new QLabel(this);
label_1_2=new QLabel(this);
label_1_3=new QLabel(this);
label_1_4=new QLabel(this);
label_1_7=new QLabel(this);
label_1_8=new QLabel(this);
label_1_9=new QLabel(this);
label_1_10=new QLabel(this);
label_1_1->setGeometry(30,10,150,20);
label_1_1->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_1_1->setText("正向有功电量:");
label_1_2->setGeometry(30,30,750,20);
label_1_2->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_1_3->setGeometry(30,50,150,20);
label_1_3->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_1_3->setText("反向有功电量:");
label_1_4->setGeometry(30,70,750,20);
label_1_4->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_1_7->setGeometry(30,90,150,20);
label_1_7->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_1_7->setText("正向无功电量:");
label_1_8->setGeometry(30,110,750,20);
label_1_8->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
label_1_9->setGeometry(30,130,150,20);
label_1_9->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(255, 255, 255)");
label_1_9->setText("反向无功电量:");
label_1_10->setGeometry(30,150,750,20);
label_1_10->setStyleSheet("background: rgb(145, 145, 145);font: 12pt 黑体 bold;color: rgb(0, 0, 0)");
}
void mainpage_Data::onPageFourDataUpdate()
{
bool ok;
auto get_right_minus = [&](QByteArray &array,int q = 10)->float{
QString transition1 = array.toHex();
int transition2 = transition1.toUInt(&ok,16);
return (float)transition2*1.0/q;
};
auto get_right_minus_LL = [&](QByteArray &array,int q = 10)->float{
QString transition1 = array.toHex();
qlonglong transition2 = transition1.toULongLong(&ok,16);
return (float)transition2*1.0/q;
};
/*正向有功电量显示*/
float P_Power_zong3 = get_right_minus(SEC.SecWheelPositiveElectricEnergyzong);
ACC.P_Power_zong = P_Power_zong3;
float P_Power_jian3 = get_right_minus(SEC.SecWheelPositiveElectricEnergyjian);
ACC.P_Power_jian = P_Power_jian3;
float P_Power_feng3 = get_right_minus(SEC.SecWheelPositiveElectricEnergyfeng);
ACC.P_Power_feng = P_Power_feng3;
float P_Power_ping3 = get_right_minus(SEC.SecWheelPositiveElectricEnergyping);
ACC.P_Power_ping = P_Power_ping3;
float P_Power_gu2 = get_right_minus(SEC.SecWheelPositiveElectricEnergygu);
ACC.P_Power_gu = P_Power_gu2;
qDebug()<<"P_Power_zong3:"<<P_Power_zong3<<endl;
qDebug()<<"P_Power_jian3:"<<P_Power_jian3<<endl;
qDebug()<<"P_Power_feng3:"<<P_Power_feng3<<endl;
qDebug()<<"P_Power_ping3:"<<P_Power_ping3<<endl;
qDebug()<<"P_Power_gu2:"<<P_Power_gu2<<endl;
label_1_2->setText("总电量:"+QString::number(P_Power_zong3,'f',1)+"KWh 尖电量:"\
+QString::number(P_Power_jian3,'f',1)+"KWh 峰电量:"\
+QString::number(P_Power_feng3,'f',1)+"KWh 平电量:"\
+QString::number(P_Power_ping3,'f',1)+"KWh 谷电量:"\
+QString::number(P_Power_gu2,'f',1)+"KWh");//10进制转字符串
/*反向有功电量显示*/
float N_Power_zong3 = get_right_minus(SEC.SecWheelNegativeElectricEnergyzong);
float N_Power_jian3 = get_right_minus(SEC.SecWheelNegativeElectricEnergyjian);
float N_Power_feng3 = get_right_minus(SEC.SecWheelNegativeElectricEnergyfeng);
float N_Power_ping3 = get_right_minus(SEC.SecWheelNegativeElectricEnergyping);
float N_Power_gu2 = get_right_minus(SEC.SecWheelNegativeElectricEnergygu);
qDebug()<<"N_Power_zong3:"<<N_Power_zong3<<endl;
qDebug()<<"N_Power_jian3:"<<N_Power_jian3<<endl;
qDebug()<<"N_Power_feng3:"<<N_Power_feng3<<endl;
qDebug()<<"N_Power_ping3:"<<N_Power_ping3<<endl;
qDebug()<<"N_Power_gu2:"<<N_Power_gu2<<endl;
label_1_4->setText("总电量:"+QString::number(N_Power_zong3,'f',1)+"KWh 尖电量:"+QString::number(N_Power_jian3,'f',1)+"KWh 峰电量:"+QString::number(N_Power_feng3,'f',1)+"KWh 平电量:"+QString::number(N_Power_ping3,'f',1)+"KWh 谷电量:"+QString::number(N_Power_gu2,'f',1)+"KWh");//10进制转字符串
/*正向无功电量显示*/
float P_RePower_zong3 = get_right_minus_LL(SEC.PositiveReactivePowerzong,100);
float P_RePower_jian3 = get_right_minus_LL(SEC.PositiveReactivePowerjian,100);
float P_RePower_feng3 = get_right_minus_LL(SEC.PositiveReactivePowerfeng,100);
float P_RePower_ping3 = get_right_minus_LL(SEC.PositiveReactivePowerping,100);
float P_RePower_gu2 = get_right_minus_LL(SEC.PositiveReactivePowergu,100);
qDebug()<<"P_RePower_zong3:"<<P_RePower_zong3<<endl;
qDebug()<<"P_RePower_jian3:"<<P_RePower_jian3<<endl;
qDebug()<<"P_RePower_feng3:"<<P_RePower_feng3<<endl;
qDebug()<<"P_RePower_ping3:"<<P_RePower_ping3<<endl;
qDebug()<<"P_RePower_gu2:"<<P_RePower_gu2<<endl;
label_1_8->setText("总电量:"+QString::number(P_RePower_zong3,'f',1)+"KWh 尖电量:"+QString::number(P_RePower_jian3,'f',1)+"KWh 峰电量:"+QString::number(P_RePower_feng3,'f',1)+"KWh 平电量:"+QString::number(P_RePower_ping3,'f',1)+"KWh 谷电量:"+QString::number(P_RePower_gu2,'f',1)+"KWh");//10进制转字符串
/*反向无功电量显示*/
float N_RePower_zong3 = get_right_minus_LL(SEC.ReverseReactivePowerzong,100);
float N_RePower_jian3 = get_right_minus_LL(SEC.ReverseReactivePowerjian,100);
float N_RePower_feng3 = get_right_minus_LL(SEC.ReverseReactivePowerfeng,100);
float N_RePower_ping3 = get_right_minus_LL(SEC.ReverseReactivePowerping,100);
float N_RePower_gu2 = get_right_minus_LL(SEC.ReverseReactivePowergu,100);
qDebug()<<"N_RePower_zong3:"<<N_RePower_zong3<<endl;
qDebug()<<"N_RePower_jian3:"<<N_RePower_jian3<<endl;
qDebug()<<"N_RePower_feng3:"<<N_RePower_feng3<<endl;
qDebug()<<"N_RePower_ping3:"<<N_RePower_ping3<<endl;
qDebug()<<"N_RePower_gu2:"<<N_RePower_gu2<<endl;
label_1_10->setText("总电量:"+QString::number(N_RePower_zong3,'f',1)+"KWh 尖电量:"+QString::number(N_RePower_jian3,'f',1)+"KWh 峰电量:"+QString::number(N_RePower_feng3,'f',1)+"KWh 平电量:"+QString::number(N_RePower_ping3,'f',1)+"KWh 谷电量:"+QString::number(N_RePower_gu2,'f',1)+"KWh");//10进制转字符串
}