更新遥控器画面

This commit is contained in:
2025-10-10 17:44:10 +08:00
parent faf921afc7
commit 945dadc8e8
86 changed files with 14150 additions and 2607 deletions

View File

@@ -132,8 +132,7 @@ void P301_PumpPage::Show3D()
// 启动工作线程
m_workerThread->start();
}
void P301_PumpPage::SetPos(float Zoom,QVector3D Move,QVector3D Pos){
void P301_PumpPage::SetPos(const float Zoom,QVector3D Move,const QVector3D Pos){
mObjLoader->scaleDevice(DevName3D,Zoom);
mObjLoader->moveArmLocalOriginTo(DevName3D, Move);//14.1, -1.4, 3.4
@@ -146,84 +145,107 @@ void P301_PumpPage::SetPos(float Zoom,QVector3D Move,QVector3D Pos){
cam->setViewCenter(QVector3D(0, 0, 0)); // 看向电控箱体的世界位置
}
}
void P301_PumpPage::SetProgressBar(QProgressBar *PB,uint16_t Value,uint8_t ColorIndex,QStringList Color){
void P301_PumpPage::SetProgressBar(QProgressBar *PB,const uint16_t Value,const uint8_t ColorIndex,const QStringList Color){
PB->setValue(Value);
if(ColorIndex < Color.length()){
PB->setStyleSheet("QProgressBar {\n background-color: transparent;\n border: 2px solid #888888;\n border-radius: 3px;\n}\nQProgressBar::chunk {\n background-color:"+Color[ColorIndex]+";\n}");
}
}
void P301_PumpPage::SetProgressBar(QProgressBar *PB,QLCDNumber *LCD,const QString NodeGroup,const QString NodeLCD,const QStringList Color){
// 从OPC节点获取油位显示组数据32位无符号整数
uint32_t PB_Group = gOPC_NodeValue["ns=6;s=::AsGlobalPV:" + NodeGroup].toUInt();
// 从32位数据中拆分出16位油位百分比值和颜色值
uint16_t Percentage = static_cast<uint16_t>(PB_Group >> 16); // 高16位百分比
uint16_t ColorIndex = static_cast<uint16_t>(PB_Group & 0xFFFF); // 低16位颜色值索引
// 设置油位进度条显示(百分比、颜色和样式)
SetProgressBar(PB, Percentage, ColorIndex, Color);
// 在LCD上显示实际油位测量值
LCD->display(gOPC_NodeValue["ns=6;s=::AsGlobalPV:" +NodeLCD].toReal());
}
void P301_PumpPage::UIRefreshTimeOut()
{
if(this->isHidden())
if(!gPageIndexStr.contains("P301"))
return;
uint32_t PB_Group1 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_Pump.PageGroup1"] .toUInt();
uint32_t PB_Group2 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_Pump.PageGroup2"] .toUInt();
uint32_t PB_GroupOilLevel = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_OilLevel.PageGroup"] .toUInt();
uint32_t PB_GroupOilTemp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_OilTemp.PageGroup"] .toUInt();
uint32_t PB_MotorTemp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Temp_Pump.PageGroup"] .toUInt();
/************************************* 电机基本信息 *************************************/
// 从OPC节点获取电机相关的状态数据32位无符号整数
uint32_t PB_Group1 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_Pump.PageGroup1"] .toUInt(); // 电流显示组1数据
uint32_t PB_Group2 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_Pump.PageGroup2"] .toUInt(); // 电流显示组2数据
uint32_t PB_MotorTemp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Temp_Pump.PageGroup"] .toUInt(); // 电机温度显示数据
uint32_t SSConditions = gOPC_NodeValue["ns=6;s=::AsGlobalPV:StartStopConditions.Pump"] .toUInt(); // 启停条件状态数据
uint32_t SSConditions = gOPC_NodeValue["ns=6;s=::AsGlobalPV:StartStopConditions.Pump"] .toUInt();
// 从32位数据中提取16位百分比值高16位和低16位拆分
uint16_t PercentageCurU = static_cast<uint16_t>(PB_Group1 >> 16); // U相电流百分比高16位
uint16_t PercentageCurV = static_cast<uint16_t>(PB_Group1 & 0xFFFF);// V相电流百分比低16位
uint16_t PercentageCurW = static_cast<uint16_t>(PB_Group2 >> 16); // W相电流百分比高16位
uint16_t PercentageTmpColor = static_cast<uint16_t>(PB_Group2 & 0xFFFF);// 温度颜色百分比低16位
uint16_t PercentageMotorTemp= static_cast<uint16_t>(PB_MotorTemp >> 16); // 电机温度百分比高16位
uint16_t ColorTemp = static_cast<uint16_t>(PB_MotorTemp & 0xFFFF);// 温度颜色值低16位
// 解析颜色值(从百分比中提取个位、十位、百位)
uint8_t ColorU = (PercentageTmpColor / 10) % 10; // U相颜色值十位
uint8_t ColorV = (PercentageTmpColor / 100) % 10; // V相颜色值百位
uint8_t ColorW = PercentageTmpColor % 10; // W相颜色值个位
uint16_t PercentageCurU = static_cast<uint16_t>(PB_Group1 >> 16); // 高 16 位
uint16_t PercentageCurV = static_cast<uint16_t>(PB_Group1 & 0xFFFF);// 低 16 位
uint16_t PercentageCurW = static_cast<uint16_t>(PB_Group2 >> 16); // 高 16 位
uint16_t PercentageTmpColor = static_cast<uint16_t>(PB_Group2 & 0xFFFF);// 低 16 位
// 设置进度条显示(电流和温度)
SetProgressBar(ui->PB_Cur_1, PercentageCurU, ColorU, glMotorCurColor); // U相电流进度条
SetProgressBar(ui->PB_Cur_2, PercentageCurV, ColorV, glMotorCurColor); // V相电流进度条
SetProgressBar(ui->PB_Cur_3, PercentageCurW, ColorW, glMotorCurColor); // W相电流进度条
SetProgressBar(ui->PB_Temp, PercentageMotorTemp, ColorTemp, glMotorTempColor); // 电机温度进度条
uint8_t ColorU = (PercentageTmpColor / 10) % 10;
uint8_t ColorV = (PercentageTmpColor / 100) % 10;
uint8_t ColorW = PercentageTmpColor % 10;
// 在LCD上显示实际测量值电流和温度
ui->LCD_Cur_1->display(gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_U"] .toReal()); // U相电流实际值
ui->LCD_Cur_2->display(gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_V"] .toReal()); // V相电流实际值
ui->LCD_Cur_3->display(gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_W"] .toReal()); // W相电流实际值
ui->LCD_Temp->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered_Temp"] .toReal()); // 电机温度实际值
uint16_t PercentageOilLevel = static_cast<uint16_t>(PB_GroupOilLevel >> 16); // 高 16 位
uint16_t ColorOilLevel = static_cast<uint16_t>(PB_GroupOilLevel & 0xFFFF);// 低 16 位
uint16_t PercentageOilTemp = static_cast<uint16_t>(PB_GroupOilTemp >> 16); // 高 16 位
uint16_t ColorOilTemp = static_cast<uint16_t>(PB_GroupOilTemp & 0xFFFF);// 低 16 位
uint16_t PercentageMotorTemp = static_cast<uint16_t>(PB_MotorTemp >> 16); // 高 16 位
uint16_t ColorTemp = static_cast<uint16_t>(PB_MotorTemp & 0xFFFF);// 低 16 位
SetProgressBar(ui->PB_Cur_1,PercentageCurU,ColorU,glMotorCurColor);
SetProgressBar(ui->PB_Cur_2,PercentageCurV,ColorV,glMotorCurColor);
SetProgressBar(ui->PB_Cur_3,PercentageCurW,ColorW,glMotorCurColor);
SetProgressBar(ui->PB_Temp,PercentageMotorTemp,ColorTemp,glMotorTempColor);
SetProgressBar(ui->PB_OilLevel,PercentageOilLevel,ColorOilLevel,slOilLevel);
SetProgressBar(ui->PB_OilTemp,PercentageOilTemp,ColorOilTemp,slOilTemp);
ui->LCD_Cur_1->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_U"] .toReal());
ui->LCD_Cur_2->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_V"] .toReal());
ui->LCD_Cur_3->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_W"] .toReal());
ui->LCD_Temp->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered_Temp"] .toReal());
ui->LCD_OilLevel->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Sersor.OilLevel"] .toReal());
ui->LCD_OilTemp->display( gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Sersor.OilTemp"] .toReal());
for (int i = 0; i < 32; ++i) {
// 更新32个启停条件状态标签的显示样式
for (int i = 0; i < 32; ++i)
{
// 根据索引查找对应的标签控件
QLabel* Label = findChild<QLabel*>(QString("Text_SSConditions_%1").arg(i));
if (Label) {
// 如果找到标签
if (Label){
// 基础样式:默认背景图
QString StyleStr = "border-image: url(:/Frames/null.png);\n";
if(getBitOf32Data(SSConditions, i,false)){
StyleStr = StyleStr + TrueColor[i]+"\n";
}else{
StyleStr = StyleStr + FalseColor[i]+"\n";
}
// 根据状态位设置不同颜色True/False对应不同样式
StyleStr += getBitOf32Data(SSConditions, i, false) ? TrueColor[i] + "\n" : FalseColor[i] + "\n";
// 应用样式到标签
Label->setStyleSheet(StyleStr);
}
}
/**************************************************************************************/
/************************************* 油箱液位信息 *************************************/
SetProgressBar(ui->PB_1,ui->LCD_1,"PB_OilLevel.PageGroup","IN_Sersor.OilLevel",slOilLevel);
/**************************************************************************************/
/************************************* 油箱温度信息 *************************************/
SetProgressBar(ui->PB_2,ui->LCD_2,"PB_OilTemp.PageGroup","IN_Sersor.OilTemp",slOilTemp);
/**************************************************************************************/
}
void P301_PumpPage::TrailRefreshTimeOut(){
ui->CPW_1->appendPoint(0, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_U"] .toReal());
ui->CPW_1->appendPoint(1, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_V"] .toReal());
ui->CPW_1->appendPoint(2, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_W"] .toReal());
ui->CPW_2->appendPoint(0,gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered_Temp"] .toDouble());
ui->CPW_1->appendPoint(0, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_U"] .toReal());
ui->CPW_1->appendPoint(1, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_V"] .toReal());
ui->CPW_1->appendPoint(2, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered30_W"] .toReal());
ui->CPW_2->appendPoint(0, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhasePump.Filtered_Temp"] .toDouble());
}
void P301_PumpPage::RotateDev(){
if(!gPageIndexStr.contains("P301"))
return;
mAngle = mAngle + 1;
if(mAngle > 360) mAngle =0;
mObjLoader->rotateArmToAbsoluteYAngle(DevName3D, mAngle);