Files
EJM_Display/Pages/P11_IsolationPage.cpp.bak
2025-10-20 22:28:37 +08:00

76 lines
3.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "P11_IsolationPage.h"
#include "ui_P11_IsolationPage.h"
#include <QTimer>
#include <QDebug>
#include <GlobalDefinitions/Variable.h>
P11_IsolationPage::P11_IsolationPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::P11_IsolationPage)
{
ui->setupUi(this);
QTimer::singleShot(10, this, &P11_IsolationPage::WinInit);
}
P11_IsolationPage::~P11_IsolationPage()
{
delete ui;
}
void P11_IsolationPage::WinInit()
{
//所用定时器初始化
QTimer* UIRefresh_Timer = new QTimer(this);
connect(UIRefresh_Timer, &QTimer::timeout, this, &P11_IsolationPage::UIRefreshTimeOut);
UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒1 秒)
UIRefresh_Timer->start();
}
void P11_IsolationPage::SetStyleStr(QLabel *L,bool Status,QString TStr,QString FStr){
if(L == nullptr) return;
QString Style = "";
if(Status){
Style = TStr;
}else{
Style = FStr;
}
if(L->styleSheet() != Style)
L->setStyleSheet(Style);
}
void P11_IsolationPage::Refresh(const QString Dev,const uint8_t DevIndex,const uint32_t Status,const uint8_t Q_Index,const uint8_t I_Index,const uint8_t G_Index){
uint32_t TmpValue = gOPC_NodeValue["ns=6;s=::AsGlobalPV:HMI_LC_"+Dev] .toUInt();
uint16_t ET = static_cast<uint16_t>(TmpValue >> 16); // 漏电检测消耗的时间高16位
uint16_t WaitET = static_cast<uint16_t>(TmpValue & 0xFFFF);// 漏电检测等待的时间低16位
QLabel* Label2 = findChild<QLabel*>(QString("La_2_%1").arg(DevIndex));
if (Label2) Label2->setText(QString::number(ET) + "");
QLabel* Label3 = findChild<QLabel*>(QString("La_3_%1").arg(DevIndex));
if (Label3) Label3->setText(QString::number(WaitET) + "");
QLabel* Label4 = findChild<QLabel*>(QString("La_Q_%1").arg(DevIndex));
if (Label4) SetStyleStr(Label4,getBitOf32Data(Status, Q_Index,false),"border-image: url(:/Icos/Icos/LED2_Green.png);","border-image: url(:/Icos/Icos/LED3_Rad (2).png);");
QLabel* Label5 = findChild<QLabel*>(QString("La_I_%1").arg(DevIndex));
if (Label5) SetStyleStr(Label5,getBitOf32Data(Status, I_Index,false),"border-image: url(:/Icos/Icos/LED1_Green.png);","border-image: url(:/Icos/Icos/LED1_Rad.png);");
QLabel* Label6 = findChild<QLabel*>(QString("La_4_%1").arg(DevIndex));
if (Label6){
SetStyleStr(Label6,getBitOf32Data(Status, G_Index,false),"color: rgb(0, 255, 0);","color: rgb(255, 0, 0);");
Label6->setText(getBitOf32Data(Status, G_Index,false) ? "正常":"异常");
}
}
void P11_IsolationPage::UIRefreshTimeOut()
{
if(gPageIndexStr != "P11")
return;
uint32_t Status = gOPC_NodeValue["ns=6;s=::AsGlobalPV:HMI_LC_Status"] .toUInt();
/************************************* 电机基本信息 *************************************/
Refresh("Cut" ,1,Status,0,8 ,16);
Refresh("Pump" ,2,Status,1,9 ,17);
Refresh("Transport" ,3,Status,2,10,18);
Refresh("Loader" ,4,Status,3,11,19);
Refresh("Standby" ,5,Status,4,12,20);
/**************************************************************************************/
}