#include "P901_RemotePage.h" #include "ui_P901_RemotePage.h" #include #include #include #include #include P901_RemotePage::P901_RemotePage(QWidget *parent) : QWidget(parent), ui(new Ui::P901_RemotePage) { ui->setupUi(this); QTimer::singleShot(10, this, &P901_RemotePage::WinInit); } P901_RemotePage::~P901_RemotePage() { delete ui; } void P901_RemotePage::WinInit() { //所用定时器初始化 QTimer* UIRefresh_Timer = new QTimer(this); connect(UIRefresh_Timer, &QTimer::timeout, this, &P901_RemotePage::UIRefreshTimeOut); UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒(1 秒) UIRefresh_Timer->start(); } qreal P901_RemotePage::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)); } void P901_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 P901_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 P901_RemotePage::UIRefreshTimeOut() { if(gPageIndexStr != "P09") 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(); // 牵引速度 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); // 通用模拟量 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) ); // 铲板液压 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); // 工作模式 SetStyle3( ui->DialBut_1, BitMaps().RemUI_ModeStyles, getBitOf32Data(DK1,27), getBitOf32Data(DK1,28), getBitOf32Data(DK1,29) ); 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")); }