添加OpenCv

This commit is contained in:
2025-09-15 22:28:43 +08:00
parent c0593df9e1
commit 94282fb1d9
423 changed files with 622349 additions and 97439 deletions

View File

@@ -1,14 +1,135 @@
#include "P301_PumpPage.h"
#include "ui_P301_PumpPage.h"
#include <GlobalDefinitions/Variable.h>
#include <FileOperation/ConfigFiles.h>
P301_PumpPage::P301_PumpPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::P301_PumpPage)
{
ui->setupUi(this);
WinInit();
}
P301_PumpPage::~P301_PumpPage()
{
delete ui;
}
void P301_PumpPage::WinInit(){
// 现在 ui->CPW_1 已经是一个 CurvePlotWidget*
ui->CPW_1->addSeries("电机电流U", Qt::green);
ui->CPW_1->addSeries("电机电流V", Qt::blue);
ui->CPW_1->addSeries("电机电流W", Qt::darkCyan);
// 现在 ui->CPW_1 已经是一个 CurvePlotWidget*
ui->CPW_2->addSeries("电机温度", Qt::green);
//所用定时器初始化
QTimer* UIRefresh_Timer = new QTimer(this);
connect(UIRefresh_Timer, &QTimer::timeout, this, &P301_PumpPage::UIRefreshTimeOut);
UIRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒1 秒)
UIRefresh_Timer->start();
//所用定时器初始化
QTimer* TrailRefresh_Timer = new QTimer(this);
connect(TrailRefresh_Timer, &QTimer::timeout, this, &P301_PumpPage::TrailRefreshTimeOut);
TrailRefresh_Timer->setInterval(100); // 设置定时器间隔为 1000 毫秒1 秒)
TrailRefresh_Timer->start();
QList<QStringList> FileData = ConfigFiles().ReadFile_Csv("./ProgramConfig/UI_油泵界面启停条件_配置.csv");
for (int row = 1; row < FileData.size(); ++row)
{
QString TextObjName = QString("Text_SSConditions_%1").arg(row);
QLabel* Label = findChild<QLabel*>(TextObjName);
if (Label) {
QString Text = FileData.at(row)[1];
Text.replace("\\n","\n",Qt::CaseInsensitive);
Label->setText(Text);
}
TrueColor.append(FileData.at(row)[2]);
FalseColor.append(FileData.at(row)[3]);
}
}
void P301_PumpPage::SetProgressBar(QProgressBar *PB,uint16_t Value,uint8_t ColorIndex,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::UIRefreshTimeOut()
{
if(this->isHidden())
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_Curr_Pump.PageGroup2"] .toUInt();
uint32_t PB_GroupOilTemp = gOPC_NodeValue["ns=6;s=::AsGlobalPV:PB_Curr_Pump.PageGroup2"] .toUInt();
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();
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 位
uint8_t ColorU = (PercentageTmpColor / 10) % 10;
uint8_t ColorV = (PercentageTmpColor / 100) % 10;
uint8_t ColorW = PercentageTmpColor % 10;
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) {
QLabel* Label = findChild<QLabel*>(QString("Text_SSConditions_%1").arg(i));
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";
}
Label->setStyleSheet(StyleStr);
}
}
}
void P301_PumpPage::TrailRefreshTimeOut(){
if(this->isHidden())
return;
ui->CPW_1->appendPoint(0, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhaseCut.Filtered30_U"] .toReal());
ui->CPW_1->appendPoint(1, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhaseCut.Filtered30_V"] .toReal());
ui->CPW_1->appendPoint(2, gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhaseCut.Filtered30_W"] .toReal());
ui->CPW_2->appendPoint(0,gOPC_NodeValue["ns=6;s=::AsGlobalPV:IN_PhaseCut.Filtered_Temp"] .toDouble());
}