Files
EJM_Display/Pages/P09_RemotePage.cpp

107 lines
5.5 KiB
C++
Raw Permalink Normal View History

2025-08-20 23:06:28 +08:00
#include "P09_RemotePage.h"
#include "ui_P09_RemotePage.h"
2025-09-15 22:28:43 +08:00
#include <QTimer>
#include <QDebug>
#include <GlobalDefinitions/Variable.h>
#include <PublicFunctions/BitMaps.h>
#include <PublicFunctions/Basic.h>
2025-08-20 23:06:28 +08:00
P09_RemotePage::P09_RemotePage(QWidget *parent) :
QWidget(parent),
ui(new Ui::P09_RemotePage)
{
ui->setupUi(this);
2025-10-10 17:44:10 +08:00
QTimer::singleShot(10, this, &P09_RemotePage::WinInit);
2025-08-20 23:06:28 +08:00
}
P09_RemotePage::~P09_RemotePage()
{
delete ui;
}
2025-09-15 22:28:43 +08:00
void P09_RemotePage::WinInit()
{
//所用定时器初始化
QTimer* UIRefresh_Timer = new QTimer(this);
connect(UIRefresh_Timer, &QTimer::timeout, this, &P09_RemotePage::UIRefreshTimeOut);
UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒1 秒)
UIRefresh_Timer->start();
}
qreal readCurrent(QString Dev){
qreal CurrU = gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Phase"+Dev+".Filtered30_U"] .toReal();
qreal CurrV = gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Phase"+Dev+".Filtered30_V"] .toReal();
qreal CurrW = gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Phase"+Dev+".Filtered30_W"] .toReal();
return fmax(CurrU,fmax(CurrV,CurrW));
}
2025-10-11 18:05:29 +08:00
void P09_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 P09_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);
}
2025-09-15 22:28:43 +08:00
void P09_RemotePage::UIRefreshTimeOut()
{
2025-10-10 17:44:10 +08:00
if(gPageIndexStr != "P09")
2025-09-15 22:28:43 +08:00
return;
QString StyleSheetSet;
uint32_t DK1 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageContol.RemoteDKey1"] .toUInt();
uint32_t DK2 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageContol.RemoteDKey2"] .toUInt();
uint32_t AK1 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageContol.RemoteAKey1"] .toUInt();
uint32_t AK2 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageContol.RemoteAKey2"] .toUInt();
2025-10-10 23:10:21 +08:00
// 牵引速度
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-09-15 22:28:43 +08:00
2025-10-10 23:10:21 +08:00
// 通用模拟量
2025-10-11 18:05:29 +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 );
2025-10-10 23:10:21 +08:00
// 急停 复位 启动
2025-10-11 18:05:29 +08:00
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 );
2025-10-10 23:10:21 +08:00
// 设备启停
2025-10-11 18:05:29 +08:00
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) );
2025-10-10 23:10:21 +08:00
// 高低速
2025-10-11 18:05:29 +08:00
SetStyle2( ui->Speed_1 , BitMaps().RemUI_SpeedStyles , !getBitOf32Data(DK1,10,0), getBitOf32Data(DK1,10,0) );
2025-09-15 22:28:43 +08:00
2025-10-10 23:10:21 +08:00
// 铲板液压
2025-10-11 18:05:29 +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);
2025-10-10 23:10:21 +08:00
// 运输液压
2025-10-11 18:05:29 +08:00
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);
2025-10-10 23:10:21 +08:00
// 临时支护液压
2025-10-11 18:05:29 +08:00
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);
2025-10-10 23:10:21 +08:00
// 后支撑液压
2025-10-11 18:05:29 +08:00
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-09-15 22:28:43 +08:00
2025-10-11 18:05:29 +08:00
// 工作模式
SetStyle3( ui->DialBut_1,
BitMaps().RemUI_ModeStyles,
getBitOf32Data(DK1,27),
getBitOf32Data(DK1,28),
getBitOf32Data(DK1,29)
);
2025-09-15 22:28:43 +08:00
ui->LCD_RemoteCur_1->display(readCurrent("Pump"));
ui->LCD_RemoteCur_2->display(readCurrent("Cut"));
ui->LCD_RemoteCur_3->display(readCurrent("LoaderL"));
ui->LCD_RemoteCur_4->display(readCurrent("LoaderR"));
ui->LCD_RemoteCur_5->display(readCurrent("TransportL"));
ui->LCD_RemoteCur_6->display(readCurrent("TransportR"));
}