Files
EJM_Display/Pages/P11_IsolationPage.cpp

106 lines
4.3 KiB
C++
Raw Normal View History

2025-08-20 23:06:28 +08:00
#include "P11_IsolationPage.h"
#include "ui_P11_IsolationPage.h"
2025-10-10 17:44:10 +08:00
#include <QTimer>
#include <QDebug>
#include <GlobalDefinitions/Variable.h>
2025-10-20 22:28:37 +08:00
#include <PublicFunctions/BitMaps.h>
#include <PublicFunctions/Basic.h>
#include <Threads/MultiCoreManager.h>
2025-08-20 23:06:28 +08:00
P11_IsolationPage::P11_IsolationPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::P11_IsolationPage)
{
ui->setupUi(this);
2025-10-20 22:28:37 +08:00
QTimer::singleShot(1000, this, &P11_IsolationPage::WinInit);
2025-08-20 23:06:28 +08:00
}
P11_IsolationPage::~P11_IsolationPage()
{
delete ui;
}
2025-10-10 17:44:10 +08:00
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){
2025-10-20 22:28:37 +08:00
uint32_t TmpValue = getNodeValue("HMI_LC_"+Dev) .toUInt();
2025-10-10 17:44:10 +08:00
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){
2025-10-20 22:28:37 +08:00
SetStyleStr(Label6,getBitOf32Data(Status, G_Index,false),"color: #22c55e","color: #ef4444");
2025-10-10 17:44:10 +08:00
Label6->setText(getBitOf32Data(Status, G_Index,false) ? "正常":"异常");
}
}
void P11_IsolationPage::UIRefreshTimeOut()
{
if(gPageIndexStr != "P11")
return;
<<<<<<< HEAD
=======
2025-10-16 17:40:00 +08:00
uint32_t Status = getNodeValue("HMI_LC_Status") .toUInt();
2025-10-10 17:44:10 +08:00
qDebug()<<Status;
/************************************* 电机基本信息 *************************************/
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);
/**************************************************************************************/
>>>>>>> f88b815723b08bbfe04dcdec05fc5555cef9352c
2025-10-10 17:44:10 +08:00
2025-10-20 22:28:37 +08:00
// 使用多核心管理器异步处理数据获取和UI更新
//MultiCoreManager::instance()->submitTask([this]() {
// 在工作线程中获取数据
uint32_t Status = getNodeValue("HMI_LC_Status").toUInt();
// 准备需要刷新的数据
QMap<QString, QVariant> refreshData;
refreshData["Status"] = Status;
// 在主线程中更新UI
QMetaObject::invokeMethod(this, [this, refreshData]() {
uint32_t Status = refreshData["Status"].toUInt();
qDebug() << Status;
/************************************* 电机基本信息 *************************************/
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);
/**************************************************************************************/
}, Qt::QueuedConnection);
//}, "isolation_page_data_processing");
2025-10-10 17:44:10 +08:00
}