更新UI
This commit is contained in:
@@ -3,13 +3,16 @@
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <GlobalDefinitions/Variable.h>
|
||||
#include <PublicFunctions/BitMaps.h>
|
||||
#include <PublicFunctions/Basic.h>
|
||||
#include <Threads/MultiCoreManager.h>
|
||||
|
||||
P11_IsolationPage::P11_IsolationPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::P11_IsolationPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QTimer::singleShot(10, this, &P11_IsolationPage::WinInit);
|
||||
QTimer::singleShot(1000, this, &P11_IsolationPage::WinInit);
|
||||
}
|
||||
|
||||
P11_IsolationPage::~P11_IsolationPage()
|
||||
@@ -36,7 +39,7 @@ void P11_IsolationPage::SetStyleStr(QLabel *L,bool Status,QString TStr,QString F
|
||||
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();
|
||||
uint32_t TmpValue = getNodeValue("HMI_LC_"+Dev) .toUInt();
|
||||
uint16_t ET = static_cast<uint16_t>(TmpValue >> 16); // 漏电检测消耗的时间(高16位)
|
||||
uint16_t WaitET = static_cast<uint16_t>(TmpValue & 0xFFFF);// 漏电检测等待的时间(低16位)
|
||||
|
||||
@@ -54,7 +57,7 @@ void P11_IsolationPage::Refresh(const QString Dev,const uint8_t DevIndex,const u
|
||||
|
||||
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);");
|
||||
SetStyleStr(Label6,getBitOf32Data(Status, G_Index,false),"color: #22c55e","color: #ef4444");
|
||||
Label6->setText(getBitOf32Data(Status, G_Index,false) ? "正常":"异常");
|
||||
}
|
||||
|
||||
@@ -63,14 +66,28 @@ void P11_IsolationPage::UIRefreshTimeOut()
|
||||
{
|
||||
if(gPageIndexStr != "P11")
|
||||
return;
|
||||
uint32_t Status = gOPC_NodeValue["ns=6;s=::AsGlobalPV:HMI_LC_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);
|
||||
/**************************************************************************************/
|
||||
|
||||
// 使用多核心管理器异步处理数据获取和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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user