This commit is contained in:
2025-10-20 22:28:37 +08:00
parent eeb5af98eb
commit 7d148d79c9
429 changed files with 13624 additions and 586480 deletions

View File

@@ -18,18 +18,26 @@ int TransportPosMaxY = 0;
int OldRollerPos[2][2]={{0,0},{0,0}};
QImage Brush[2];
QElapsedTimer TmpTime;
P01_MianPage::P01_MianPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::P01_MianPage)
ui(new Ui::P01_MianPage),
mObjLoader(nullptr),
m_workerThread(nullptr),
m_workerLoader(nullptr),
m_loadingStep(0),
UIRefresh_Timer(nullptr),
TrailRefresh_Timer(nullptr)
{
ui->setupUi(this);
QTimer::singleShot(10, this, &P01_MianPage::PageInit);
// QTimer::singleShot(1000, this, &P01_MianPage::Show3D);
}
qint64 JgTime;
void P01_MianPage::PageInit()
{
TmpTime.start();
QPixmap pix(":/Icos/Icos/Sursor.png");
QCursor custom(pix, pix.width()/2, pix.height()/2);
setCursor(custom);
@@ -45,19 +53,63 @@ void P01_MianPage::PageInit()
ui->Gif_Radar->show();
//所用定时器初始化
QTimer* UIRefresh_Timer = new QTimer(this);
UIRefresh_Timer = new QTimer(this);
connect(UIRefresh_Timer, &QTimer::timeout, this, &P01_MianPage::UIRefreshTimeOut);
UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒1 秒)
UIRefresh_Timer->start();
//所用定时器初始化
QTimer* TrailRefresh_Timer = new QTimer(this);
TrailRefresh_Timer = new QTimer(this);
connect(TrailRefresh_Timer, &QTimer::timeout, this, &P01_MianPage::TrailRefreshTimeOut);
TrailRefresh_Timer->setInterval(1000); // 设置定时器间隔为 1000 毫秒1 秒)
TrailRefresh_Timer->start();
qDebug()<<"初始化执行完成后,消耗时间"<<TmpTime.elapsed();
JgTime = TmpTime.elapsed();
}
P01_MianPage::~P01_MianPage()
{
// 安全清理线程和资源
if (m_workerThread && m_workerThread->isRunning()) {
m_workerThread->quit();
m_workerThread->wait(1000); // 等待1秒
if (m_workerThread->isRunning()) {
m_workerThread->terminate(); // 强制终止
}
m_workerThread->deleteLater();
m_workerThread = nullptr;
}
// 清理ObjLoader对象
if (mObjLoader) {
mObjLoader->deleteLater();
mObjLoader = nullptr;
}
if (m_workerLoader) {
m_workerLoader->deleteLater();
m_workerLoader = nullptr;
}
// 清理PageInit中创建的定时器
if (UIRefresh_Timer) {
UIRefresh_Timer->stop();
UIRefresh_Timer->deleteLater();
UIRefresh_Timer = nullptr;
}
if (TrailRefresh_Timer) {
TrailRefresh_Timer->stop();
TrailRefresh_Timer->deleteLater();
TrailRefresh_Timer = nullptr;
}
// 清理QMovie对象
if (ui->Gif_Radar->movie()) {
ui->Gif_Radar->movie()->stop();
delete ui->Gif_Radar->movie();
ui->Gif_Radar->setMovie(nullptr);
}
delete ui;
}
void P01_MianPage::Show3D()
@@ -86,9 +138,9 @@ void P01_MianPage::Show3D()
m_workerLoader = new ObjLoader();
m_workerLoader->moveToThread(m_workerThread);
// 连接预处理完成信号(确保ObjLoader类中已声明preprocessDone信号
connect(m_workerLoader, SIGNAL(preprocessDone(QString, QVector3D, float)),
this, SLOT(onPreprocessResult(QString, QVector3D, float)));
// 连接预处理完成信号(使用现代信号槽语法
connect(m_workerLoader, &ObjLoader::preprocessDone,
this, &P01_MianPage::onPreprocessResult);
// 处理单个设备预处理完成
connect(this, &P01_MianPage::preprocessFinished, this, &P01_MianPage::onPreprocessFinished);
@@ -104,11 +156,21 @@ void P01_MianPage::Show3D()
// 所有设备加载完成
connect(this, &P01_MianPage::allDevicesLoaded, this, [=]() {
// 清理工作线程
m_workerThread->quit();
m_workerThread->wait();
m_workerLoader->deleteLater();
if (m_workerThread && m_workerThread->isRunning()) {
m_workerThread->quit();
m_workerThread->wait(1000); // 等待1秒
if (m_workerThread->isRunning()) {
m_workerThread->terminate(); // 强制终止
}
m_workerThread->deleteLater();
m_workerThread = nullptr;
}
// 清理工作加载器
if (m_workerLoader) {
m_workerLoader->deleteLater();
m_workerLoader = nullptr;
}
// 启动旋转定时器
QTimer *RotateDev_Timer = new QTimer(this);
@@ -283,37 +345,37 @@ void P01_MianPage::UIRefreshTimeOut()
return;
uint32_t TmpBools[10];
TmpBools[0] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B0"] .toUInt();
TmpBools[1] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B1"] .toUInt();
TmpBools[2] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B2"] .toUInt();
TmpBools[3] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B3"] .toUInt();
TmpBools[4] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B4"] .toUInt();
TmpBools[5] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B5"] .toUInt();
TmpBools[6] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B6"] .toUInt();
TmpBools[7] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B7"] .toUInt();
TmpBools[8] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B8"] .toUInt();
TmpBools[9] = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PageBOOLS.B9"] .toUInt();
TmpBools[0] = getNodeValue("PageBOOLS.B0") .toUInt();
TmpBools[1] = getNodeValue("PageBOOLS.B1") .toUInt();
TmpBools[2] = getNodeValue("PageBOOLS.B2") .toUInt();
TmpBools[3] = getNodeValue("PageBOOLS.B3") .toUInt();
TmpBools[4] = getNodeValue("PageBOOLS.B4") .toUInt();
TmpBools[5] = getNodeValue("PageBOOLS.B5") .toUInt();
TmpBools[6] = getNodeValue("PageBOOLS.B6") .toUInt();
TmpBools[7] = getNodeValue("PageBOOLS.B7") .toUInt();
TmpBools[8] = getNodeValue("PageBOOLS.B8") .toUInt();
TmpBools[9] = getNodeValue("PageBOOLS.B9") .toUInt();
//杂进度条显示
QStringList LevelCor = {"rgb(255, 0, 0)","rgb(255, 0, 0)","rgb(0, 255, 0)","rgb(0, 255, 255)"};
ProgressBar_LCD(ui->PB_SpareTemp,ui->LCD_SpareTemp,"ns=6;s=::AsGlobalPV:PB_SpareTemp.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.SpareTemp",glMotorTempColor);
ProgressBar_LCD(ui->PB_OilLevel,ui->LCD_OilLevel,"ns=6;s=::AsGlobalPV:PB_OilLevel.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.OilLevel",LevelCor);
ProgressBar_LCD(ui->PB_OilTemp,ui->LCD_OilTemp,"ns=6;s=::AsGlobalPV:PB_OilTemp.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.OilTemp",glMotorTempColor);
QStringList LevelCor = {"color: #ef4444","color: #f59e0b","#22c55e","color: rgb(0, 233, 253)"};
ProgressBar_LCD(ui->PB_SpareTemp,ui->LCD_SpareTemp,"PB_SpareTemp.PageGroup","IN_Sersor.SpareTemp",glMotorTempColor);
ProgressBar_LCD(ui->PB_OilLevel,ui->LCD_OilLevel,"PB_OilLevel.PageGroup","IN_Sersor.OilLevel",LevelCor);
ProgressBar_LCD(ui->PB_OilTemp,ui->LCD_OilTemp,"PB_OilTemp.PageGroup","IN_Sersor.OilTemp",glMotorTempColor);
QStringList NullColor = {"rgb(0, 255, 255)","rgb(0, 255, 255)","rgb(0, 255, 255)","rgb(0, 255, 255)"};
ProgressBar_LCD(ui->PB_PressurePump_1,ui->LCD_PressurePump_1,"ns=6;s=::AsGlobalPV:PB_PressurePump1.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.Pressure_Pump1",NullColor);
ProgressBar_LCD(ui->PB_PressurePump_2,ui->LCD_PressurePump_2,"ns=6;s=::AsGlobalPV:PB_PressurePump2.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.Pressure_Pump2",NullColor);
ProgressBar_LCD(ui->PB_PressurePump_3,ui->LCD_PressurePump_3,"ns=6;s=::AsGlobalPV:PB_PressurePump3.PageGroup","ns=6;s=::AsGlobalPV:IN_Sersor.Pressure_Pump3",NullColor);
QStringList NullColor = {"color: rgb(0, 233, 253)","color: rgb(0, 233, 253)","color: rgb(0, 233, 253)","color: rgb(0, 233, 253)"};
ProgressBar_LCD(ui->PB_PressurePump_1,ui->LCD_PressurePump_1,"PB_PressurePump1.PageGroup","IN_Sersor.Pressure_Pump1",NullColor);
ProgressBar_LCD(ui->PB_PressurePump_2,ui->LCD_PressurePump_2,"PB_PressurePump2.PageGroup","IN_Sersor.Pressure_Pump2",NullColor);
ProgressBar_LCD(ui->PB_PressurePump_3,ui->LCD_PressurePump_3,"PB_PressurePump3.PageGroup","IN_Sersor.Pressure_Pump3",NullColor);
// 编码器数值显示
ui->LCD_EncoderL->display(QString::number(gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Encoder.EncoderL"] .toUInt()));
ui->LCD_EncoderR->display(QString::number(gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Encoder.EncoderR"] .toUInt()));
ui->LCD_EncoderL->display(QString::number(getNodeValue("IN_Encoder.EncoderL") .toUInt()));
ui->LCD_EncoderR->display(QString::number(getNodeValue("IN_Encoder.EncoderR") .toUInt()));
// 急停的显示
for (uint8_t i=0;i<12;i++) {
QString TextObjName = QString("Led_EStop_%1").arg(i);
QLabel* Label = findChild<QLabel*>(TextObjName);
if (Label) {
SetStyleStr(Label,getBitOf32Data(TmpBools[0], i,false),"color: rgb(255, 0, 0);","color: rgb(0, 255, 0);");
SetStyleStr(Label,getBitOf32Data(TmpBools[0], i,false),"color: #ef4444","color: #22c55e");
}
}
@@ -325,24 +387,24 @@ void P01_MianPage::UIRefreshTimeOut()
//传感器及阀控模块输出的显示
SetStyleStr(ui->Status_P1_1,getBitOf32Data(TmpBools[2], 1,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_2,getBitOf32Data(TmpBools[2], 3,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_3,getBitOf32Data(TmpBools[2], 5,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_4,getBitOf32Data(TmpBools[2], 4,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_5,getBitOf32Data(TmpBools[1], 23,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_6,getBitOf32Data(TmpBools[2], 0,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P1_1,getBitOf32Data(TmpBools[2], 1,false),"color: #22c55e","");
SetStyleStr(ui->Status_P1_2,getBitOf32Data(TmpBools[2], 3,false),"color: #22c55e","");
SetStyleStr(ui->Status_P1_3,getBitOf32Data(TmpBools[2], 5,false),"color: #22c55e","");
SetStyleStr(ui->Status_P1_4,getBitOf32Data(TmpBools[2], 4,false),"color: #22c55e","");
SetStyleStr(ui->Status_P1_5,getBitOf32Data(TmpBools[1], 23,false),"color: #22c55e","");
SetStyleStr(ui->Status_P1_6,getBitOf32Data(TmpBools[2], 0,false),"color: #22c55e","");
SetStyleStr(ui->Status_P2_1,getBitOf32Data(TmpBools[1], 22,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P2_2,getBitOf32Data(TmpBools[1], 30,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P2_3,getBitOf32Data(TmpBools[1], 21,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P2_4,getBitOf32Data(TmpBools[1], 20,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P2_5,getBitOf32Data(TmpBools[1], 29,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P2_1,getBitOf32Data(TmpBools[1], 22,false),"color: #22c55e","");
SetStyleStr(ui->Status_P2_2,getBitOf32Data(TmpBools[1], 30,false),"color: #22c55e","");
SetStyleStr(ui->Status_P2_3,getBitOf32Data(TmpBools[1], 21,false),"color: #22c55e","");
SetStyleStr(ui->Status_P2_4,getBitOf32Data(TmpBools[1], 20,false),"color: #22c55e","");
SetStyleStr(ui->Status_P2_5,getBitOf32Data(TmpBools[1], 29,false),"color: #22c55e","");
SetStyleStr(ui->Status_P3_1,getBitOf32Data(TmpBools[1], 24,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P3_2,getBitOf32Data(TmpBools[1], 25,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P3_3,getBitOf32Data(TmpBools[1], 26,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P3_4,getBitOf32Data(TmpBools[1], 27,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P3_5,getBitOf32Data(TmpBools[1], 28,false),"color: rgb(0, 255, 0);","");
SetStyleStr(ui->Status_P3_1,getBitOf32Data(TmpBools[1], 24,false),"color: #22c55e","");
SetStyleStr(ui->Status_P3_2,getBitOf32Data(TmpBools[1], 25,false),"color: #22c55e","");
SetStyleStr(ui->Status_P3_3,getBitOf32Data(TmpBools[1], 26,false),"color: #22c55e","");
SetStyleStr(ui->Status_P3_4,getBitOf32Data(TmpBools[1], 27,false),"color: #22c55e","");
SetStyleStr(ui->Status_P3_5,getBitOf32Data(TmpBools[1], 28,false),"color: #22c55e","");
//油缸伸缩状态显示
QStringList OilCylindStyle = {"","border-image: url(:/Icos/Icos/icon_stretch.png);","border-image: url(:/Icos/Icos/icon_shorten.png);"};
@@ -377,18 +439,18 @@ void P01_MianPage::UIRefreshTimeOut()
}
void P01_MianPage::ProgressBar_LCD(QProgressBar *QPB,QLCDNumber *QLCD,QString NodeID_Bar,QString NodeID_Value,QStringList Colors){
uint32_t PB_Group1 = gOPC_NodeValue[NodeID_Bar] .toUInt();
float Value = gOPC_NodeValue[NodeID_Value] .toFloat();
uint32_t PB_Group1 = getNodeValue(NodeID_Bar) .toUInt();
float Value = getNodeValue(NodeID_Value) .toFloat();
uint16_t PValue= static_cast<uint16_t>(PB_Group1 >> 16); // 高 16 位
uint16_t PColor = static_cast<uint16_t>(PB_Group1 & 0xFFFF);// 低 16 位
SetProgressBar(QPB,PValue,PColor,Colors);
QLCD->display(QString::number(Value,'f',2));
}
void P01_MianPage::PB_Refresh(QString Dev){
uint32_t PB_Group1 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_"+Dev+".PageGroup1"] .toUInt();
uint32_t PB_Group2 = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_"+Dev+".PageGroup2"] .toUInt();
uint32_t PB_MotorTemp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Temp_"+Dev+".PageGroup"] .toUInt();
uint32_t PB_Group1 = getNodeValue("PB_Curr_"+Dev+".PageGroup1") .toUInt();
uint32_t PB_Group2 = getNodeValue("PB_Curr_"+Dev+".PageGroup2") .toUInt();
uint32_t PB_MotorTemp = getNodeValue("PB_Temp_"+Dev+".PageGroup") .toUInt();
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 位
@@ -401,19 +463,19 @@ void P01_MianPage::PB_Refresh(QString Dev){
uint16_t PercentageMotorTemp = static_cast<uint16_t>(PB_MotorTemp >> 16); // 高 16 位
uint16_t ColorTemp = static_cast<uint16_t>(PB_MotorTemp & 0xFFFF);// 低 16 位
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();
qreal Temp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_Phase"+Dev+".Filtered_Temp"] .toReal();
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();
qreal Temp = getNodeValue("IN_Phase"+Dev+".Filtered_Temp") .toReal();
qreal Curr = fmax(CurrU,fmax(CurrV,CurrW));
qreal Rated;
if (Dev == "LoaderL" || Dev == "LoaderR" )
Rated = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PS.gRatedCur_Loader"] .toReal();
Rated = getNodeValue("PS.gRatedCur_Loader") .toReal();
else if(Dev == "TransportL" || Dev == "TransportR" )
Rated = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PS.gRatedCur_Transport"] .toReal();
Rated = getNodeValue("PS.gRatedCur_Transport") .toReal();
else{
Rated = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PS.gRatedCur_"+Dev] .toReal();
Rated = getNodeValue("PS.gRatedCur_"+Dev) .toReal();
}
@@ -457,14 +519,14 @@ void P01_MianPage::TrailRefreshTimeOut(){
if(gPageIndexStr != "P01")
return;
// 画板的显示
uint32_t Diameter = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.Diameter"] .toUInt();
uint32_t LengthHeight = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.LengthHeight"] .toUInt();
uint32_t SideView = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.SideView"] .toUInt();
uint32_t FaceView = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.FaceView"] .toUInt();
uint32_t Diameter = getNodeValue("RollerPosition.Diameter") .toUInt();
uint32_t LengthHeight = getNodeValue("RollerPosition.LengthHeight") .toUInt();
uint32_t SideView = getNodeValue("RollerPosition.SideView") .toUInt();
uint32_t FaceView = getNodeValue("RollerPosition.FaceView") .toUInt();
uint32_t TransPos = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.TransportPos"] .toUInt();
uint32_t TmpHaul = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.ShowHaulSpeed"] .toUInt();
float CenterHeight = gOPC_NodeValue["ns=6;s=::AsGlobalPV:RollerPosition.CenterHeight"] .toFloat();
uint32_t TransPos = getNodeValue("RollerPosition.TransportPos") .toUInt();
uint32_t TmpHaul = getNodeValue("RollerPosition.ShowHaulSpeed") .toUInt();
float CenterHeight = getNodeValue("RollerPosition.CenterHeight") .toFloat();
int16_t Roller_SideX = static_cast<int16_t>(SideView >> 16); // 高 16 位
int16_t Roller_SideY = static_cast<int16_t>(SideView & 0xFFFF);// 低 16 位
@@ -574,6 +636,7 @@ void P01_MianPage::SetStyleStr(QLabel *L,bool B1,bool B2,QStringList StyStr){
}else{
Style = "";
}
if(L->styleSheet() != Style)
L->setStyleSheet(Style);
}