94 lines
3.7 KiB
C++
94 lines
3.7 KiB
C++
#include "P11_IsolationPage.h"
|
||
#include "ui_P11_IsolationPage.h"
|
||
#include <QTimer>
|
||
#include <QDebug>
|
||
#include <GlobalDefinitions/Variable.h>
|
||
#include <PublicFunctions/BitMaps.h>
|
||
#include <PublicFunctions/Basic.h>
|
||
|
||
|
||
P11_IsolationPage::P11_IsolationPage(QWidget *parent) :
|
||
QWidget(parent),
|
||
ui(new Ui::P11_IsolationPage)
|
||
{
|
||
ui->setupUi(this);
|
||
QTimer::singleShot(1000, 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 = 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位)
|
||
|
||
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;
|
||
|
||
// 使用多核心管理器异步处理数据获取和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");
|
||
}
|