From 215acc558b75b5038a96f5c37e1d9a8c9a25d22c Mon Sep 17 00:00:00 2001 From: seiyu Date: Mon, 15 Jan 2024 16:43:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B4=E9=B2=81=E5=A4=AB?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81=E3=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BA=A7=E9=87=8F=E7=BB=9F=E8=AE=A1=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/cigarette.cpp | 48 ++++++++++++++++++---------------- Cigarette/exportData.cpp | 4 +-- Cigarette/output_statistic.cpp | 31 ---------------------- 3 files changed, 27 insertions(+), 56 deletions(-) diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index e914cb4..9a5a484 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -1597,7 +1597,7 @@ void Cigarette::handleTimeout() { qint64 secA = time.secsTo(g_sys_conf.shiftA); qint64 secB = time.secsTo(g_sys_conf.shiftB); - qint64 secC = time.secsTo(g_sys_conf.shiftC); + qint64 secC = time.secsTo(g_sys_conf.shiftC); if (secA == 0) { g_op_mode = true; //激活操作员模式 @@ -1912,7 +1912,7 @@ void Cigarette::on_pushButton_clear_released()// if (g_modbus_conf.quantity > 0) { uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.quantity, 2, dest16); //std::cout << ret << std::endl; if (ret > 0) { @@ -1972,7 +1972,6 @@ void Cigarette::on_pushButton_clear_released()// } //flag = false; #endif - //发送换班消息给PLC if (g_modbus_conf.shift > 0) { @@ -3356,24 +3355,26 @@ void Cigarette::EnumerateCameras(SingleCamInfoStruct *TempSingleCamInfoStruct,bo for (int i = 0; i < min(unfiltered, NumberOfSupportedCameras); i++) { Device* pDev = BalluffCamera::devMgr[i]; - std::string manufacture = pDev->manufacturer.read(); - if(showinfo)std::cout << "Camera:" << i << ",vendor = " << manufacture << std::endl; - transform(manufacture.begin(), manufacture.end(), manufacture.begin(), ::toupper); - SingleCamInfoStruct CamInfo; - if ((!manufacture.compare(0, 7, "BALLUFF"))||(!manufacture.compare(0, 13, "MATRIX VISION"))) - { - mvIMPACT::acquire::GenICam::DeviceControl dc(pDev); - std::string UserID = dc.deviceUserID.read(); - pDev->close(); - if(showinfo)std::cout << "Balluff user ID = " << UserID << std::endl; - CamInfo.UserID = atoi(UserID.c_str()); - CamInfo.CamClass = BalluffClassID; - CamInfo.unfiltered_num = i; - CamInfo.Detect = false; - CamInfo.IsOpen = false; - CamInfo.OffLine = false; - TempSingleCamInfo.push_back(CamInfo); - balluff_cnt++; + if (!pDev->isInUse()) { + std::string manufacture = pDev->manufacturer.read(); + if (showinfo)std::cout << "Camera:" << i << ",vendor = " << manufacture << std::endl; + transform(manufacture.begin(), manufacture.end(), manufacture.begin(), ::toupper); + SingleCamInfoStruct CamInfo; + if ((!manufacture.compare(0, 7, "BALLUFF")) || (!manufacture.compare(0, 13, "MATRIX VISION"))) + { + mvIMPACT::acquire::GenICam::DeviceControl dc(pDev); + std::string UserID = dc.deviceUserID.read(); + pDev->close(); + if (showinfo)std::cout << "Balluff user ID = " << UserID << std::endl; + CamInfo.UserID = atoi(UserID.c_str()); + CamInfo.CamClass = BalluffClassID; + CamInfo.unfiltered_num = i; + CamInfo.Detect = false; + CamInfo.IsOpen = false; + CamInfo.OffLine = false; + TempSingleCamInfo.push_back(CamInfo); + balluff_cnt++; + } } } @@ -3555,9 +3556,10 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor memset(buf, 0, 256); sprintf(buf, "\n\n**************************************************************************************\n"); cfg_file.write(buf, strlen(buf)); - QDate date = QDate::currentDate(); + //QDate date = QDate::currentDate(); + QDateTime date = QDateTime::currentDateTime(); memset(buf, 0, 256); - sprintf(buf, "%s:\n", date.toString("yyyy-MM-dd ").toStdString().c_str()); + sprintf(buf, "%s:\n", date.toString("yyyy-MM-dd_HH-mm-ss").toStdString().c_str()); cfg_file.write(buf, strlen(buf)); } memset(buf, 0, 256); diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp index bb4cca3..a83fba5 100644 --- a/Cigarette/exportData.cpp +++ b/Cigarette/exportData.cpp @@ -190,14 +190,14 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& dat // 合格率 XMLElement* PassRate = pDocument[data.cameraId]->NewElement("PassRate"); - std::string temp_str = std::to_string(data.PassRate * 100); + std::string temp_str = std::to_string(data.PassRate * 100 ) + "%"; const char* temp_char = temp_str.c_str(); PassRate->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); JudgeNum->InsertEndChild(PassRate); // 剔除率 XMLElement* KickRate = pDocument[data.cameraId]->NewElement("KickRate"); - temp_str = std::to_string(data.KickRate * 100); + temp_str = std::to_string(data.KickRate * 100) + "%"; temp_char = temp_str.c_str(); KickRate->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); JudgeNum->InsertEndChild(KickRate); diff --git a/Cigarette/output_statistic.cpp b/Cigarette/output_statistic.cpp index b247149..c0981d9 100644 --- a/Cigarette/output_statistic.cpp +++ b/Cigarette/output_statistic.cpp @@ -47,36 +47,6 @@ output_statistic::~output_statistic() void output_statistic::recMsgFromDialogSetup() { -#ifdef __ExportData - _ExportDataInfo data; - map averageData[NumberOfSupportedCameras]; - - ui.tabWidget->setTabVisible(1, false); - ui.tabWidget->setTabVisible(2, false); - ui.tabWidget->setTabVisible(3, false); - ui.tabWidget->setTabVisible(4, false); - ui.tabWidget->setTabVisible(5, false); - ui.tabWidget->setTabVisible(6, false); - ui.tabWidget->setTabVisible(7, false); - ui.tabWidget->setTabText(0, "Statistical data"); - - - for (int index = 0; index < NumberOfSupportedCameras; index++) { - data.getAverageData(averageData[index], index); - QString text; - text.append(" CameraId: "); - text.append(std::to_string((int)averageData[index]["CameraId"]).c_str()); - text.append("\n IsNG: "); - text.append(std::to_string((int)averageData[index]["IsNG"]).c_str()); - text.append("\n IsJdExist: "); - text.append(std::to_string((int)averageData[index]["IsJdExist"]).c_str()); - text.append("\n TimeCost: "); - text.append(std::to_string(averageData[index]["TimeCost"]).c_str()); - text.append("\n*************************************************\n"); - ui.textBrowser_1->insertPlainText(text); - } - -#else QString file_path, file_name; QFile file; for (int i = 0; i < NumberOfSupportedCameras; i++) { @@ -95,6 +65,5 @@ void output_statistic::recMsgFromDialogSetup() file.close(); this->show(); } -#endif //this->show(); } \ No newline at end of file