#include "P11_IsolationPage.h" #include "ui_P11_IsolationPage.h" #include #include #include 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(TmpValue >> 16); // 漏电检测消耗的时间(高16位) uint16_t WaitET = static_cast(TmpValue & 0xFFFF);// 漏电检测等待的时间(低16位) QLabel* Label2 = findChild(QString("La_2_%1").arg(DevIndex)); if (Label2) Label2->setText(QString::number(ET) + "秒"); QLabel* Label3 = findChild(QString("La_3_%1").arg(DevIndex)); if (Label3) Label3->setText(QString::number(WaitET) + "秒"); QLabel* Label4 = findChild(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(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(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); /**************************************************************************************/ }