diff --git a/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h b/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h index 3a4477ff..76aea3f8 100644 --- a/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h +++ b/HanddleAI/HandleAiUi-new/algo/ALGO_Correction.h @@ -2,6 +2,7 @@ #include #include #include +#include struct CorrectionPoints { double OriginZ, OriginX, OriginY; @@ -339,21 +340,38 @@ void ALGO_Correction(std::shared_ptr data) data->writeBack("short", 274, "1"); return; CorrectionPoints resultPoints; - if (simpleCorrection(&data->laserData, resultPoints) == false) + bool correctionResult = simpleCorrection(&data->laserData, resultPoints); + std::cout << "correctionResult_X" << resultPoints.OriginX << std::endl; + std::cout << "correctionResult_Y" << resultPoints.OriginY << std::endl; + std::cout << "correctionResult_Z" << resultPoints.OriginZ << std::endl; + + if (correctionResult == false) { data->writeBack("short", 274, "1"); return; } Point3d point = getRPY(resultPoints); + auto currentProductConfig = _core._appConfig._switchProductWidgetDataPtr.getCurrentProductData(); + //json中记录的基础偏移 + double baseOffset_X = currentProductConfig._correctionConfigStruct.baseOffset_X; + double baseOffset_Y = currentProductConfig._correctionConfigStruct.baseOffset_Y; + double baseOffset_Z = currentProductConfig._correctionConfigStruct.baseOffset_Z; - //std::cout << "ox:" << resultPoints.Origin[0] << "oy:" << resultPoints.Origin[1] << "oz:" << resultPoints.Origin[2] << std::endl; - //std::cout << "Rx:" << point.x << "Ry:" << point.y << "Rz:" << point.z << std::endl; - //qDebug() << "productIndex:"<< data->productType <<"ox:" << resultPoints.Origin[0] << "oy : " << resultPoints.Origin[1] << "oz : " << resultPoints.Origin[2]; - //qDebug() << "Rx:" << point.x << "Ry:" << point.y << "Rz:" << point.z; + double correction_X = currentProductConfig._correctionConfigStruct.correction_X; + double correction_Y = currentProductConfig._correctionConfigStruct.correction_Y; + double correction_Z = currentProductConfig._correctionConfigStruct.correction_Z; - data->pointsOffsetStruct_.baseOffsetX = data->_productDataStruct.basePos[0] - resultPoints.OriginX; - data->pointsOffsetStruct_.baseOffsetY = data->_productDataStruct.basePos[1] - resultPoints.OriginY; - data->pointsOffsetStruct_.baseOffsetZ = data->_productDataStruct.basePos[2] - resultPoints.OriginZ; + double offsetLimit_X = currentProductConfig._correctionConfigStruct.offsetLimit_X; + double offsetLimit_Y = currentProductConfig._correctionConfigStruct.offsetLimit_Y; + double offsetLimit_Z = currentProductConfig._correctionConfigStruct.offsetLimit_Z; + + double correctionFinalResultX = correction_X - resultPoints.OriginX - baseOffset_X; + double correctionFinalResultY = correction_Y - resultPoints.OriginY - baseOffset_Y; + double correctionFinalResultZ = correction_Z - resultPoints.OriginZ - baseOffset_Z; + + std::cout << "correctionFinalResultX" << correctionFinalResultX << std::endl; + std::cout << "correctionFinalResultY" << correctionFinalResultY << std::endl; + std::cout << "correctionFinalResultZ" << correctionFinalResultZ << std::endl; //double offsetRx = data->_productDataStruct.baseRad[0] - point.x; //double offsetRy = data->_productDataStruct.baseRad[1] - point.y; diff --git a/HanddleAI/HandleAiUi-new/appConfig/appConfig.cpp b/HanddleAI/HandleAiUi-new/appConfig/appConfig.cpp index bf66f5e9..a32e1edc 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/appConfig.cpp +++ b/HanddleAI/HandleAiUi-new/appConfig/appConfig.cpp @@ -68,6 +68,25 @@ void appConfig::parsingProductData(std::string path) productData.connectorAmout = res["connectorAmout"]; productData.isBackExist = res["isBackExist"]; productData.backArmIndex = res["backArmIndex"]; + if (res["Correction"].empty() == false) + { + productData._correctionConfigStruct.correction_X = res["Correction"]["correction_X"]; + productData._correctionConfigStruct.correction_Y = res["Correction"]["correction_Y"]; + productData._correctionConfigStruct.correction_Z = res["Correction"]["correction_Z"]; + + productData._correctionConfigStruct.baseOffset_X = res["Correction"]["baseOffset_X"]; + productData._correctionConfigStruct.baseOffset_Y = res["Correction"]["baseOffset_Y"]; + productData._correctionConfigStruct.baseOffset_Z = res["Correction"]["baseOffset_Z"]; + + productData._correctionConfigStruct.offsetLimit_X = res["Correction"]["offsetLimit_X"]; + productData._correctionConfigStruct.offsetLimit_Y = res["Correction"]["offsetLimit_Y"]; + productData._correctionConfigStruct.offsetLimit_Z = res["Correction"]["offsetLimit_Z"]; + } + + for (auto it = res["partNumberList"].begin(); it != res["partNumberList"].end(); ++it) + { + productData.partNumberList.push_back(it.value()); + } for (auto it = res["cameraSetting"].begin(); it != res["cameraSetting"].end(); ++it) { std::vector result = split(it.value(), '/'); diff --git a/HanddleAI/HandleAiUi-new/appConfig/appConfig.h b/HanddleAI/HandleAiUi-new/appConfig/appConfig.h index 9446b83e..bfbb2a7c 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/appConfig.h +++ b/HanddleAI/HandleAiUi-new/appConfig/appConfig.h @@ -1,5 +1,6 @@ #include #include +#include class appConfig { public: @@ -7,11 +8,23 @@ public: sqlManager _sqlManager;//储存产品信息用 appConfig() { - parsingGlobalData(); - parsingProductData(productDataPath); + parsingGlobalData();//解析全局参数 + parsingProductData(productDataPath);//解析产品配置 + parsePartNumberWithIndex(); _sqlManager.initialization(this); } + void parsePartNumberWithIndex() + { + for (int index = 0 ;index < productDatas.size(); index++) + { + for (auto partNum : productDatas[index].partNumberList) + { + partNumberWithIndex.insert(std::make_pair(partNum, index)); + } + } + } + std::unordered_map partNumberWithIndex; switchProductWidgetDataPtr _switchProductWidgetDataPtr; std::string softwareTile;//软件标题 diff --git a/HanddleAI/HandleAiUi-new/appConfig/appconfigStruct.h b/HanddleAI/HandleAiUi-new/appConfig/appconfigStruct.h index cbb29484..b074b8c7 100644 --- a/HanddleAI/HandleAiUi-new/appConfig/appconfigStruct.h +++ b/HanddleAI/HandleAiUi-new/appConfig/appconfigStruct.h @@ -12,6 +12,18 @@ struct productSignStruct cv::Rect posRect; std::string sign; }; +struct correctionConfigStruct +{ + double correction_X = 0; + double correction_Y = 0; + double correction_Z = 0; + double baseOffset_X = 0; + double baseOffset_Y = 0; + double baseOffset_Z = 0; + double offsetLimit_X = 3; + double offsetLimit_Y = 3; + double offsetLimit_Z = 3; +}; struct productDataStruct { std::string name; @@ -37,6 +49,8 @@ struct productDataStruct int codedAlgoIndex = -1; std::unordered_map productSign; + std::vectorpartNumberList;//料号list + correctionConfigStruct _correctionConfigStruct; }; struct perConnector { diff --git a/HanddleAI/HandleAiUi-new/appConfig/productConfigManager.hpp b/HanddleAI/HandleAiUi-new/appConfig/productConfigManager.hpp new file mode 100644 index 00000000..b5481f3f --- /dev/null +++ b/HanddleAI/HandleAiUi-new/appConfig/productConfigManager.hpp @@ -0,0 +1,5 @@ + +class productConfigmanager +{ +public: +}; \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/appCore.hpp b/HanddleAI/HandleAiUi-new/appCore.hpp index 764eeafa..8edd822e 100644 --- a/HanddleAI/HandleAiUi-new/appCore.hpp +++ b/HanddleAI/HandleAiUi-new/appCore.hpp @@ -10,7 +10,7 @@ #include -#define disableBackEndCheck 0 +#define disableBackEndCheck 1 #define disableeAlgo 0 #define enableHideConsle 1 class detGlobalData diff --git a/HanddleAI/HandleAiUi-new/detProcess.hpp b/HanddleAI/HandleAiUi-new/detProcess.hpp index 2687a263..413a65ca 100644 --- a/HanddleAI/HandleAiUi-new/detProcess.hpp +++ b/HanddleAI/HandleAiUi-new/detProcess.hpp @@ -539,7 +539,9 @@ public slots: currentSn = SN.toStdString(); _triggerManager.sendFinsMsg("write_short_350_" + QString::number(_core._appConfig.productDatas[productTypeIn].indexOfArm)); _triggerManager.sendFinsMsg("write_short_351_1"); + qDebug() << "SN:" << SN << "开始运行,型号->" << QString::fromStdString(_core._detGlobalData.productTypeStr); + } //人工复判按下NG void uiModuleImageDoubleCheckQdialog_pressNG(int armPos,int type)//1 halcon 2ai diff --git a/HanddleAI/HandleAiUi-new/handleAi/handleAiModel.cpp b/HanddleAI/HandleAiUi-new/handleAi/handleAiModel.cpp index 72bc39e5..de9ef463 100644 --- a/HanddleAI/HandleAiUi-new/handleAi/handleAiModel.cpp +++ b/HanddleAI/HandleAiUi-new/handleAi/handleAiModel.cpp @@ -1,7 +1,7 @@ #include #include -#define enableHandleAiModel 1 +#define enableHandleAiModel 0 void handleAiModelManager::handleAiModelManager::run() { if (init == true) diff --git a/HanddleAI/HandleAiUi-new/uiModule/components/fancyProcessBar.h b/HanddleAI/HandleAiUi-new/uiModule/components/fancyProcessBar.h index 45398c9b..9041b1ee 100644 --- a/HanddleAI/HandleAiUi-new/uiModule/components/fancyProcessBar.h +++ b/HanddleAI/HandleAiUi-new/uiModule/components/fancyProcessBar.h @@ -52,13 +52,16 @@ public: maxValue = getMax(value, maxValue); minValue = getMin(value, minValue); currentValue = value; - if((maxValue - minValue) ==0) + if ((maxValue - minValue) == 0) setProgress(1); else if (value == 0) setProgress(0); - else - setProgress( value/(maxValue - minValue)); - + else + { + double v = (double)((double)(value - minValue) / (double)(maxValue - minValue)); + setProgress(v); + } + } void setProgress(double newProgress) { @@ -94,17 +97,17 @@ protected: painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignHCenter | Qt::AlignTop, QString::number(currentValue) + "ms"); if (maxValue == INT_MIN) painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignRight | Qt::AlignTop, "0ms"); - else + else painter.drawText(rect.adjusted(10, 10, -10, 10), Qt::AlignRight | Qt::AlignTop, QString::number(maxValue) + "ms"); - painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignLeft | Qt::AlignTop, "min"); + painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignLeft | Qt::AlignTop, "Min"); painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignHCenter | Qt::AlignTop, title); painter.drawText(rect.adjusted(10, 30, -10, -10), Qt::AlignRight | Qt::AlignTop, "Max"); int barWidth = rect.width() - 20; int barHeight = 5; - QRect barRect(10, rect.height() / 2 - barHeight / 2-5, barWidth, barHeight); + QRect barRect(10, rect.height() / 2 - barHeight / 2 - 5, barWidth, barHeight); // Draw progress in the bar int progressWidth = static_cast(barRect.width() * progress); @@ -130,7 +133,7 @@ private: bool init = false; QString title; int maxValue = INT_MIN, minValue = INT_MAX, currentValue = 0; - int frequency =50; + int frequency = 50; double progress; }; #pragma once diff --git a/HanddleAI/HandleAiUi-new/uiModule/uiModule_switchProduct.h b/HanddleAI/HandleAiUi-new/uiModule/uiModule_switchProduct.h index 0e2c92ac..5696656c 100644 --- a/HanddleAI/HandleAiUi-new/uiModule/uiModule_switchProduct.h +++ b/HanddleAI/HandleAiUi-new/uiModule/uiModule_switchProduct.h @@ -29,13 +29,23 @@ public: QVBoxLayout* layout = new QVBoxLayout(this); fancyButtonText* switchBtn = new fancyButtonText(100, 60, "修改", "修改当前机型"); QLabel* armHeartBeatSign = new QLabel(); + //料号条码输入 + QLineEdit* partNumberIntputLine = new QLineEdit(); + + //运行按钮 fancyButtonText* startBtn; + //SN条码输入 QLineEdit* snIntputLine = new QLineEdit(); //料号显示 - QComboBox* productSelect = new QComboBox(this); + QComboBox* productSelect = new QComboBox(this); QLabel* currentProduct = new QLabel(this); //料号类型 QComboBox* productNameTypeSwitch = new QComboBox(this); + void clear() + { + partNumberIntputLine->clear(); + snIntputLine->clear(); + } switchProductWidget() { currentProductIndexPtr = &_core._appConfig._switchProductWidgetDataPtr.currentProductIndex; @@ -68,19 +78,28 @@ public: layout->addLayout(switchLayout); } - snIntputLine->setFixedHeight(50); - snIntputLine->setFont(font); + + + QHBoxLayout* hBtnLayout2 = new QHBoxLayout(); + partNumberIntputLine->setFixedHeight(50); + partNumberIntputLine->setFont(font); + partNumberIntputLine->setPlaceholderText("料号条码输入"); + hBtnLayout2->addWidget(partNumberIntputLine); QHBoxLayout* hBtnLayout = new QHBoxLayout(); startBtn = new fancyButtonText(80, -1, "运行", "运行检测程序"); + snIntputLine->setFixedHeight(50); + snIntputLine->setFont(font); + snIntputLine->setPlaceholderText("SN条码输入"); hBtnLayout->addWidget(snIntputLine); hBtnLayout->addWidget(startBtn); + layout->addLayout(hBtnLayout2); layout->addLayout(hBtnLayout); productSelectFresh(0); connect(startBtn, &QPushButton::clicked, this, [=]() { - emit startArmProgramSignal(productSelect->currentIndex(), snIntputLine->text()); + emit startArmProgramSignal(indexFromPartNumber, snIntputLine->text()); std::cout << "按下按钮" << std::endl; }); connect(switchBtn, &QPushButton::clicked, this, &switchProductWidget::startSwitch); @@ -93,6 +112,14 @@ public: { productSelectFresh(productNameTypeSwitch->currentIndex()); }); + connect(partNumberIntputLine, &QLineEdit::textChanged, this, [=]() + { + partNumberIntputLineSlot(partNumberIntputLine->text().toStdString()); + }); + currentProduct->setText("请输入料号"); + productSelect->hide(); + switchBtn->hide(); + startBtn->setDisabled(true); } void productSelectFresh(int index) { @@ -138,7 +165,7 @@ public slots: if (status == true) { startBtn->toDefault(); - if(disableTextChange == false) + if (disableTextChange == false) startBtn->setText("运行"); snIntputLine->setDisabled(false); std::cout << "按下软件运行" << std::endl; @@ -156,8 +183,27 @@ signals: void startArmProgramSignal(int,QString); void switchProductSignal(int); private: + int indexFromPartNumber = -1; int siwtchBtnState = 0; private slots: + void partNumberIntputLineSlot(std::string partNumber) + { + auto it = _core._appConfig.partNumberWithIndex.find(partNumber); + if(it != _core._appConfig.partNumberWithIndex.end()) + { + int index = _core._appConfig.partNumberWithIndex.find(partNumber)->second; + currentProduct->setText(QString::fromStdString(_core._appConfig.productDatas[index].name)); + *currentProductIndexPtr = index; + startBtn->setEnabled(true); + indexFromPartNumber = index; + snIntputLine->setFocus(); + } + else + { + currentProduct->setText("未找到对应料号!"); + startBtn->setDisabled(true); + } + } void startSwitch() { if(siwtchBtnState == 0) diff --git a/lib/Hd_3DCameraLMI_module_PointLazer.exp b/lib/Hd_3DCameraLMI_module_PointLazer.exp index 97d8b87b..83d8b980 100644 Binary files a/lib/Hd_3DCameraLMI_module_PointLazer.exp and b/lib/Hd_3DCameraLMI_module_PointLazer.exp differ diff --git a/lib/Hd_3DCameraLMI_module_PointLazer.lib b/lib/Hd_3DCameraLMI_module_PointLazer.lib index 36c75b14..b04150d6 100644 Binary files a/lib/Hd_3DCameraLMI_module_PointLazer.lib and b/lib/Hd_3DCameraLMI_module_PointLazer.lib differ diff --git a/lib/Hd_DalsaCamera_module.exp b/lib/Hd_DalsaCamera_module.exp index ab118790..efae2b9e 100644 Binary files a/lib/Hd_DalsaCamera_module.exp and b/lib/Hd_DalsaCamera_module.exp differ diff --git a/lib/Hd_DalsaCamera_module.lib b/lib/Hd_DalsaCamera_module.lib index cc2d36e5..9c451b2e 100644 Binary files a/lib/Hd_DalsaCamera_module.lib and b/lib/Hd_DalsaCamera_module.lib differ diff --git a/lib/Hd_FinsTcp_module.exp b/lib/Hd_FinsTcp_module.exp index 05dc8bab..3de4f63b 100644 Binary files a/lib/Hd_FinsTcp_module.exp and b/lib/Hd_FinsTcp_module.exp differ diff --git a/lib/Hd_FinsTcp_module.lib b/lib/Hd_FinsTcp_module.lib index a50e177e..f679fdae 100644 Binary files a/lib/Hd_FinsTcp_module.lib and b/lib/Hd_FinsTcp_module.lib differ diff --git a/lib/Hd_MvCamera_module_GENTL.exp b/lib/Hd_MvCamera_module_GENTL.exp index cd7a0985..d4933722 100644 Binary files a/lib/Hd_MvCamera_module_GENTL.exp and b/lib/Hd_MvCamera_module_GENTL.exp differ diff --git a/lib/Hd_MvCamera_module_GENTL.lib b/lib/Hd_MvCamera_module_GENTL.lib index a65c613a..578b535e 100644 Binary files a/lib/Hd_MvCamera_module_GENTL.lib and b/lib/Hd_MvCamera_module_GENTL.lib differ diff --git a/lib/Hd_MvCamera_module_GIGE.exp b/lib/Hd_MvCamera_module_GIGE.exp index 564b8062..3dad3e86 100644 Binary files a/lib/Hd_MvCamera_module_GIGE.exp and b/lib/Hd_MvCamera_module_GIGE.exp differ diff --git a/lib/Hd_MvCamera_module_GIGE.lib b/lib/Hd_MvCamera_module_GIGE.lib index b1396b9b..f5ba12df 100644 Binary files a/lib/Hd_MvCamera_module_GIGE.lib and b/lib/Hd_MvCamera_module_GIGE.lib differ diff --git a/lib/Hd_ResultsSummary_module.exp b/lib/Hd_ResultsSummary_module.exp index 1880b09b..b54e9ed3 100644 Binary files a/lib/Hd_ResultsSummary_module.exp and b/lib/Hd_ResultsSummary_module.exp differ diff --git a/lib/Hd_ResultsSummary_module.lib b/lib/Hd_ResultsSummary_module.lib index a61fbd40..ff33633f 100644 Binary files a/lib/Hd_ResultsSummary_module.lib and b/lib/Hd_ResultsSummary_module.lib differ diff --git a/lib/Hd_SocketModule_ModbusTcp.exp b/lib/Hd_SocketModule_ModbusTcp.exp index f9780641..b95b63b1 100644 Binary files a/lib/Hd_SocketModule_ModbusTcp.exp and b/lib/Hd_SocketModule_ModbusTcp.exp differ diff --git a/lib/Hd_SocketModule_ModbusTcp.lib b/lib/Hd_SocketModule_ModbusTcp.lib index 5ec47732..7d987e79 100644 Binary files a/lib/Hd_SocketModule_ModbusTcp.lib and b/lib/Hd_SocketModule_ModbusTcp.lib differ