2025-10-14 20:05:38 +08:00
|
|
|
|
#include "P902_RemotePage.h"
|
|
|
|
|
|
#include "ui_P902_RemotePage.h"
|
2025-10-20 22:28:37 +08:00
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include <GlobalDefinitions/Variable.h>
|
|
|
|
|
|
#include <PublicFunctions/BitMaps.h>
|
|
|
|
|
|
#include <PublicFunctions/Basic.h>
|
|
|
|
|
|
#include <Threads/MultiCoreManager.h>
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
P902_RemotePage::P902_RemotePage(QWidget *parent) :
|
|
|
|
|
|
QWidget(parent),
|
|
|
|
|
|
ui(new Ui::P902_RemotePage)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
QTimer::singleShot(10, this, &P902_RemotePage::WinInit);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
P902_RemotePage::~P902_RemotePage()
|
|
|
|
|
|
{
|
|
|
|
|
|
delete ui;
|
|
|
|
|
|
}
|
|
|
|
|
|
void P902_RemotePage::WinInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
//所用定时器初始化
|
|
|
|
|
|
QTimer* UIRefresh_Timer = new QTimer(this);
|
|
|
|
|
|
connect(UIRefresh_Timer, &QTimer::timeout, this, &P902_RemotePage::UIRefreshTimeOut);
|
|
|
|
|
|
UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒(1 秒)
|
|
|
|
|
|
UIRefresh_Timer->start();
|
|
|
|
|
|
}
|
|
|
|
|
|
qreal P902_RemotePage::readCurrent(QString Dev){
|
2025-10-20 22:28:37 +08:00
|
|
|
|
qreal CurrU = getNodeValue("IN_Phase"+Dev+".Filtered30_U") .toReal();
|
|
|
|
|
|
qreal CurrV = getNodeValue("IN_Phase"+Dev+".Filtered30_V") .toReal();
|
|
|
|
|
|
qreal CurrW = getNodeValue("IN_Phase"+Dev+".Filtered30_W") .toReal();
|
2025-10-14 20:05:38 +08:00
|
|
|
|
return fmax(CurrU,fmax(CurrV,CurrW));
|
|
|
|
|
|
}
|
|
|
|
|
|
void P902_RemotePage::SetStyle2(QLabel *Label,QStringList List,bool b1,bool b2,bool isNull){
|
|
|
|
|
|
QString Style = "border-image: url(" + BitMaps().ListChoice_2Mode( List , b1 , b2,isNull ) + ");";
|
|
|
|
|
|
if(Label->styleSheet() != Style)
|
|
|
|
|
|
Label->setStyleSheet(Style);
|
|
|
|
|
|
}
|
|
|
|
|
|
void P902_RemotePage::SetStyle3(QLabel *Label,QStringList List,bool b1,bool b2,bool b3,bool isNull){
|
|
|
|
|
|
QString Style = "border-image: url(" + BitMaps().ListChoice_3Mode( List , b1 , b2, b3 ,isNull ) + ");";
|
|
|
|
|
|
if(Label->styleSheet() != Style)
|
|
|
|
|
|
Label->setStyleSheet(Style);
|
|
|
|
|
|
}
|
|
|
|
|
|
void P902_RemotePage::UIRefreshTimeOut()
|
|
|
|
|
|
{
|
|
|
|
|
|
if(gPageIndexStr != "P09")
|
|
|
|
|
|
return;
|
2025-10-20 22:28:37 +08:00
|
|
|
|
|
|
|
|
|
|
// 使用多核心管理器异步获取数据
|
|
|
|
|
|
//MultiCoreManager::instance()->submitTask([this]() {
|
|
|
|
|
|
// 准备数据容器
|
|
|
|
|
|
QMap<QString, uint32_t> keysData;
|
|
|
|
|
|
QMap<QString, float> currentsData;
|
|
|
|
|
|
|
|
|
|
|
|
// 异步读取各按键状态数据
|
|
|
|
|
|
keysData["DK1"] = getNodeValue("PageContol.RemoteDKey1").toUInt();
|
|
|
|
|
|
keysData["DK2"] = getNodeValue("PageContol.RemoteDKey2").toUInt();
|
|
|
|
|
|
keysData["AK1"] = getNodeValue("PageContol.RemoteAKey1").toUInt();
|
|
|
|
|
|
keysData["AK2"] = getNodeValue("PageContol.RemoteAKey2").toUInt();
|
|
|
|
|
|
|
|
|
|
|
|
// 异步读取各设备电流数据
|
|
|
|
|
|
currentsData["Pump"] = readCurrent("Pump");
|
|
|
|
|
|
currentsData["Cut"] = readCurrent("Cut");
|
|
|
|
|
|
currentsData["LoaderL"] = readCurrent("LoaderL");
|
|
|
|
|
|
currentsData["LoaderR"] = readCurrent("LoaderR");
|
|
|
|
|
|
currentsData["TransportL"] = readCurrent("TransportL");
|
|
|
|
|
|
currentsData["TransportR"] = readCurrent("TransportR");
|
|
|
|
|
|
|
|
|
|
|
|
// 在主线程中更新UI
|
|
|
|
|
|
QMetaObject::invokeMethod(this, [this, keysData, currentsData]() {
|
|
|
|
|
|
uint32_t DK1 = keysData["DK1"];
|
|
|
|
|
|
uint32_t DK2 = keysData["DK2"];
|
|
|
|
|
|
uint32_t AK1 = keysData["AK1"];
|
|
|
|
|
|
uint32_t AK2 = keysData["AK2"];
|
|
|
|
|
|
|
|
|
|
|
|
// 牵引速度
|
|
|
|
|
|
ui->Slider_Haul_L->setValue(extractUInt32_8BitPart(AK1,0));
|
|
|
|
|
|
ui->Slider_Haul_R->setValue(extractUInt32_8BitPart(AK1,1));
|
|
|
|
|
|
|
|
|
|
|
|
// 右侧摇杆
|
|
|
|
|
|
uint16_t dX = map(extractUInt32_8BitPart(AK1,2) + 256,0,512.,0,140)- ui->Label_TransportPos->width()/2;
|
|
|
|
|
|
uint16_t dY = map(extractUInt32_8BitPart(AK1,3) + 256,0,512.,0,140)- ui->Label_TransportPos->height()/2;
|
|
|
|
|
|
ui->Label_TransportPos->move(dX,dY);
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
2025-10-20 22:28:37 +08:00
|
|
|
|
// 通用模拟量
|
|
|
|
|
|
SetStyle2( ui->Switch_5 , BitMaps().RemUI_SwitchStyles , extractUInt32_8BitPart(AK2,0) < 127 , extractUInt32_8BitPart(AK2,0) > 127 );
|
|
|
|
|
|
SetStyle2( ui->DialBut_2 , BitMaps().RemUI_PutterStyles , extractUInt32_8BitPart(AK2,1) < 127 , extractUInt32_8BitPart(AK2,1) > 127 );
|
|
|
|
|
|
SetStyle2( ui->But_1 , BitMaps().RemUI_SwitchStyles , extractUInt32_8BitPart(AK2,2) > 127 , false );
|
|
|
|
|
|
SetStyle2( ui->But_3 , BitMaps().RemUI_SwitchStyles , extractUInt32_8BitPart(AK2,4) > 127 , false );
|
|
|
|
|
|
|
|
|
|
|
|
// 急停 复位 启动
|
|
|
|
|
|
SetStyle2( ui->But_5 , BitMaps().RemUI_SwitchStyles , !(getBitOf32Data(DK1,0) && getBitOf32Data(DK1,31)) , false );
|
|
|
|
|
|
SetStyle2( ui->But_2 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,1,0) , false );
|
|
|
|
|
|
SetStyle2( ui->But_4 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,30,0) , false );
|
|
|
|
|
|
|
|
|
|
|
|
// 设备启停
|
|
|
|
|
|
SetStyle2( ui->Switch_1 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,2) , getBitOf32Data(DK1,3) );
|
|
|
|
|
|
SetStyle2( ui->Switch_2 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,4) , getBitOf32Data(DK1,5) );
|
|
|
|
|
|
SetStyle2( ui->Switch_3 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,6) , getBitOf32Data(DK1,7) );
|
|
|
|
|
|
SetStyle2( ui->Switch_4 , BitMaps().RemUI_SwitchStyles , getBitOf32Data(DK1,8) , getBitOf32Data(DK1,9) );
|
|
|
|
|
|
|
|
|
|
|
|
// 高低速
|
|
|
|
|
|
SetStyle2( ui->Speed_1 , BitMaps().RemUI_SpeedStyles , !getBitOf32Data(DK1,10,0), getBitOf32Data(DK1,10,0) );
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
2025-10-20 22:28:37 +08:00
|
|
|
|
// 铲板液压
|
|
|
|
|
|
SetStyle2( ui->DialBut_3 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,11) , getBitOf32Data(DK1,12),0);
|
|
|
|
|
|
SetStyle2( ui->DialBut_4 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,13) , getBitOf32Data(DK1,14),0);
|
|
|
|
|
|
|
|
|
|
|
|
// 运输液压
|
|
|
|
|
|
SetStyle2( ui->DialBut_5 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,15) , getBitOf32Data(DK1,16),0);
|
|
|
|
|
|
SetStyle2( ui->DialBut_6 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,17) , getBitOf32Data(DK1,18),0);
|
|
|
|
|
|
|
|
|
|
|
|
// 临时支护液压
|
|
|
|
|
|
SetStyle2( ui->DialBut_7 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,19) , getBitOf32Data(DK1,20),0);
|
|
|
|
|
|
SetStyle2( ui->DialBut_8 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,21) , getBitOf32Data(DK1,22),0);
|
|
|
|
|
|
|
|
|
|
|
|
// 后支撑液压
|
|
|
|
|
|
SetStyle2( ui->DialBut_9 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,23) , getBitOf32Data(DK1,24),0);
|
|
|
|
|
|
SetStyle2( ui->DialBut_10 , BitMaps().RemUI_PutterStyles , getBitOf32Data(DK1,25) , getBitOf32Data(DK1,26),0);
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
2025-10-20 22:28:37 +08:00
|
|
|
|
// 工作模式
|
|
|
|
|
|
SetStyle3( ui->DialBut_1,
|
|
|
|
|
|
BitMaps().RemUI_ModeStyles,
|
|
|
|
|
|
getBitOf32Data(DK1,27),
|
|
|
|
|
|
getBitOf32Data(DK1,28),
|
|
|
|
|
|
getBitOf32Data(DK1,29)
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// 更新电流显示
|
|
|
|
|
|
ui->LCD_RemoteCur_1->display(currentsData["Pump"]);
|
|
|
|
|
|
ui->LCD_RemoteCur_2->display(currentsData["Cut"]);
|
|
|
|
|
|
ui->LCD_RemoteCur_3->display(currentsData["LoaderL"]);
|
|
|
|
|
|
ui->LCD_RemoteCur_4->display(currentsData["LoaderR"]);
|
|
|
|
|
|
ui->LCD_RemoteCur_5->display(currentsData["TransportL"]);
|
|
|
|
|
|
ui->LCD_RemoteCur_6->display(currentsData["TransportR"]);
|
|
|
|
|
|
}, Qt::QueuedConnection);
|
|
|
|
|
|
// }, "remote902_page_data_processing");
|
2025-10-14 20:05:38 +08:00
|
|
|
|
}
|
2025-10-20 22:28:37 +08:00
|
|
|
|
|