diff --git a/Cigarette/CaptureThread.cpp b/Cigarette/CaptureThread.cpp index f22d5c3..de2faa5 100644 --- a/Cigarette/CaptureThread.cpp +++ b/Cigarette/CaptureThread.cpp @@ -1,7 +1,9 @@ #include "CaptureThread.h" #include "common.h" +#include "exportData.h" extern bool g_debug_mode; //相机调试模式,工作模式必须停止状态才能打开 +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; //----------------------------------------------------------------------------- CaptureThread::CaptureThread( Device* pCurrDev, bool boTerminated, FunctionInterface* pFI_ ,int Num) : @@ -17,6 +19,11 @@ void CaptureThread::fpsTimeout(void) m_cntLastGrabbedImages = m_cntGrabbedImages; QString data = QString("%1").arg(delta); emit updateStatistics(data.left(4), Local_Num); +#ifdef __ExportData + _XMLExportDataInfo exportXMLDataInfo; + exportXMLDataInfo.AcquisitionSpeed = data.left(4).toStdString(); + export_XMLData_Info_queue->put(exportXMLDataInfo); +#endif } CaptureThread::~CaptureThread() @@ -112,7 +119,12 @@ void CaptureThread::process( void ) if (cnt % 10 == 0) { QString data = QString::fromStdString(statistics.framesPerSecond.readS()); - emit updateStatistics(data.left(3),Local_Num); + emit updateStatistics(data.left(4),Local_Num); +#ifdef __ExportData + _XMLExportDataInfo exportXMLDataInfo; + exportXMLDataInfo.AcquisitionSpeed = data.left(3).toStdString(); + export_XMLData_Info_queue->put(exportXMLDataInfo); +#endif } } else diff --git a/Cigarette/CaptureThreadBasler.cpp b/Cigarette/CaptureThreadBasler.cpp index b5c032d..1594aa1 100644 --- a/Cigarette/CaptureThreadBasler.cpp +++ b/Cigarette/CaptureThreadBasler.cpp @@ -3,6 +3,8 @@ #include "PLCDevice.h" #include "common.h" #include +#include +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; extern PLCDevice * m_PLCDevice; //----------------------------------------------------------------------------- CaptureThreadBasler::CaptureThreadBasler(Pylon::CBaslerUniversalInstantCamera* pCurrDev, bool boTerminated,int Num,int shoot) : @@ -163,6 +165,11 @@ void CaptureThreadBasler::fpsTimeout() m_cntLastGrabbedImages = m_cntGrabbedImages; QString data = QString("%1").arg(delta); emit updateStatistics(data.left(4), Local_Num); +#ifdef __ExportData + _XMLExportDataInfo exportXMLDataInfo; + exportXMLDataInfo.AcquisitionSpeed = data.left(3).toStdString(); + export_XMLData_Info_queue->put(exportXMLDataInfo); +#endif } void CaptureThreadBasler::ioTimeout() diff --git a/Cigarette/CaptureThreadHIK.cpp b/Cigarette/CaptureThreadHIK.cpp index 07e5fd3..aa4d05f 100644 --- a/Cigarette/CaptureThreadHIK.cpp +++ b/Cigarette/CaptureThreadHIK.cpp @@ -3,8 +3,10 @@ #include "PLCDevice.h" #include "common.h" #include +#include "exportData.h" extern bool g_debug_mode; //相机调试模式,工作模式必须停止状态才能打开 extern SingleCamInfoStruct SingleCamInfo[NumberOfSupportedCameras]; +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; extern PLCDevice * m_PLCDevice; inline void LossCallBackfunction(unsigned int pData, void* pUser){ @@ -202,6 +204,11 @@ void CaptureThreadHIK::fpsTimeout(void) m_cntLastGrabbedImages = m_cntGrabbedImages; QString data = QString("%1").arg(delta); emit updateStatistics(data.left(4), Local_Num); +#ifdef __ExportData + _XMLExportDataInfo exportXMLDataInfo; + exportXMLDataInfo.AcquisitionSpeed = data.left(3).toStdString(); + export_XMLData_Info_queue->put(exportXMLDataInfo); +#endif } //----------------------------------------------------------------------------- diff --git a/Cigarette/Cigarette.vcxproj b/Cigarette/Cigarette.vcxproj index 2953400..5d0c458 100644 --- a/Cigarette/Cigarette.vcxproj +++ b/Cigarette/Cigarette.vcxproj @@ -133,7 +133,7 @@ true true stdcpp14 - Disabled + MaxSpeed false 4819;%(DisableSpecificWarnings) @@ -141,7 +141,7 @@ Console $(OutDir)\$(ProjectName).exe $(QTDIR)\lib;$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;%(AdditionalLibraryDirectories) - true + false qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Network.lib;%(AdditionalDependencies) diff --git a/Cigarette/basecamera.h b/Cigarette/basecamera.h index df90994..ec35673 100644 --- a/Cigarette/basecamera.h +++ b/Cigarette/basecamera.h @@ -2,7 +2,7 @@ #include -#define NumberOfSupportedCameras 8 +#define NumberOfSupportedCameras 2 #define EdgeEvent 1 #define ImageCap 2 diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index 0d40355..a964323 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -56,7 +56,8 @@ bool g_debug_mode; // SyncQueue *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列 SyncQueue<_UDPSendInfo> *UDP_Info_queue; -SyncQueue<_ExportDataInfo> *export_Data_Info_queue; +//SyncQueue<_ExportDataInfo> *export_Data_Info_queue; +SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; ExportDataThread exportDataThread; bool g_admin_mode; //是否管理员模式 @@ -135,8 +136,12 @@ Cigarette::Cigarette(QWidget *parent) g_save_queue->name = "save queue"; UDP_Info_queue = new SyncQueue<_UDPSendInfo>(Queue_Size); UDP_Info_queue->name = "UDP Info queue"; - export_Data_Info_queue = new SyncQueue<_ExportDataInfo>(Queue_Size); - export_Data_Info_queue->name = "Export Data Info queue"; + + //export_Data_Info_queue = new SyncQueue<_ExportDataInfo>(Queue_Size); + //export_Data_Info_queue->name = "Export Data Info queue"; + export_XMLData_Info_queue = new SyncQueue<_XMLExportDataInfo>(Queue_Size); + export_XMLData_Info_queue->name = "Export Data Info queue"; + last_shift = 256; for(int i=0;i0) - g_modbus_conf.kick1 = 0; //1#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) - g_modbus_conf.kick2 = 0; //2#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) - g_modbus_conf.kick3 = 0; //3#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) - g_modbus_conf.kick4 = 0; //4#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) - g_modbus_conf.kick5 = 0; //5#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) - g_modbus_conf.kick6 = 0; //6#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) - g_modbus_conf.kick7 = 0; //7#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) - g_modbus_conf.kick8 = 0; //8#通道剔除个数地址 + for (int i = 0; i < NumberOfSupportedCameras; i++) { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > i) + g_modbus_conf.kick[i] = 0; #endif + } g_modbus_conf.quantity = 0; g_modbus_conf.shift = 0; g_modbus_conf.work = 0; @@ -1291,6 +1277,8 @@ void Cigarette::OnOKHub(int Num) lcdNumber_ok_mat[Num]->display(ok[Num]); label_reslut_mat[Num]->setText("OK"); label_reslut_mat[Num]->setStyleSheet(tr("background-color: rgb(0, 255, 0);")); + + } void Cigarette::OnNGHub(int Num) @@ -1484,158 +1472,26 @@ void Cigarette::handleTimeout() if (g_modbus_conf.quantity > 0) { // 读取剔除值 -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) - if (g_modbus_conf.kick1 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick1, 2, dest16); - if (ret == 2) - { - Kick[0] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 0; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) - if (g_modbus_conf.kick2 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick2, 2, dest16); - if (ret == 2) - { - Kick[1] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16)); + for (int i = 0; i < NumberOfSupportedCameras; i++) { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > i) + if (g_modbus_conf.kick[i] > 0) { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick[i], 2, dest16); + if (ret == 2) { + Kick[i] = dest16[0] + (dest16[1] << 16); + lcdNumber_kick_mat[i]->display(Kick[i]); #ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 1; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) - if (g_modbus_conf.kick3 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16); - if (ret == 2) - { - Kick[2] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 2; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) - if (g_modbus_conf.kick4 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16); - if (ret == 2) - { - Kick[3] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 3; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) - if (g_modbus_conf.kick5 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16); - if (ret == 2) - { - Kick[4] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 4; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) - if (g_modbus_conf.kick6 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16); - if (ret == 2) - { - Kick[5] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 5; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); + _UDPSendInfo UDPSendInfo; + UDPSendInfo.FrameID = kick_frame; + UDPSendInfo.index = 0; + UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); + UDP_Info_queue->put(UDPSendInfo); #endif + } } - } #endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) - if (g_modbus_conf.kick7 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16); - if (ret == 2) - { - Kick[6] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 6; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) - if (g_modbus_conf.kick8 > 0) - { - uint16_t dest16[2]; - int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16); - if (ret == 2) - { - Kick[7] = dest16[0] + (dest16[1] << 16); - ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16)); -#ifdef __UDPSend - _UDPSendInfo UDPSendInfo; - UDPSendInfo.FrameID = kick_frame; - UDPSendInfo.index = 7; - UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); - UDP_Info_queue->put(UDPSendInfo); -#endif - } - } -#endif + // 读取产量值 uint16_t dest16[2]; int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.quantity, 2, dest16); @@ -1732,150 +1588,6 @@ void Cigarette::handleTimeout() m_PLCDevice->g_plc_status &= ~(0x01); } } -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) -// if (g_modbus_conf.kick1 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick1, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 0; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) -// if (g_modbus_conf.kick2 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick2, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 1; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) -// if (g_modbus_conf.kick3 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 2; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) -// if (g_modbus_conf.kick4 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 3; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) -// if (g_modbus_conf.kick5 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 4; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) -// if (g_modbus_conf.kick6 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 5; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) -// if (g_modbus_conf.kick7 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 6; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif -//#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) -// if (g_modbus_conf.kick8 > 0) -// { -// uint16_t dest16[2]; -// int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16); -// if (ret == 2) -// { -// ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16)); -//#ifdef __UDPSend -// _UDPSendInfo UDPSendInfo; -// UDPSendInfo.FrameID = kick_frame; -// UDPSendInfo.index = 7; -// UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); -// UDP_Info_queue->put(UDPSendInfo); -//#endif -// } -// } -//#endif } } //相机掉线检测 @@ -2148,6 +1860,9 @@ void Cigarette::on_toolButton_alarm_released() } void Cigarette::on_pushButton_clear_released()//换班 { +#ifdef __ExportData + _XMLExportDataInfo exportXMLDataInfo; +#endif emit sengMsgToClog("Change shift."); if (!g_admin_mode) { @@ -2174,6 +1889,10 @@ void Cigarette::on_pushButton_clear_released()// { production_number[i]=0; lcdNumber_total_mat[i]->display(production_number[i]); +#ifdef __ExportData + exportXMLDataInfo.okNum[i] = ok[i]; + exportXMLDataInfo.ngNum[i] = ng[i]; +#endif ok[i] = 0; lcdNumber_ok_mat[i]->display(ok[i]); ng[i] = 0; @@ -2208,6 +1927,8 @@ void Cigarette::on_pushButton_clear_released()// #ifdef __UDPSend sThread.sendData("total_" + QString::number(0), g_sys_conf.FeedbackPort); #endif + + //通过PLC读取当班产量,显示在上班产量中 if (m_PLCDevice->g_plc_ok) { @@ -2222,10 +1943,48 @@ void Cigarette::on_pushButton_clear_released()// { int cur_quantity = dest16[0] + (dest16[1] << 16); ui.lcdNumber_total_no_last->display(cur_quantity); + exportXMLDataInfo.TotalCheckNum = cur_quantity; #ifdef __UDPSend sThread.sendData("totallast_" + QString::number(cur_quantity), g_sys_conf.FeedbackPort); #endif } + +#ifdef __ExportData + // 读取剔除值 + for (int i = 0; i < NumberOfSupportedCameras; i++) { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > i) + if (g_modbus_conf.kick[i] > 0) { + uint16_t dest16[2]; + int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick[i], 2, dest16); + if (ret == 2) { + exportXMLDataInfo.kickNum[i] = dest16[0] + (dest16[1] << 16); + } + } +#endif + + } + int flag = 0; + for (int i = 1; i < NumberOfSupportedCameras; i++) { + if (exportXMLDataInfo.kickNum[i] != exportXMLDataInfo.kickNum[0]) { + flag = 1; + break; + } + } + if (flag == 1) { + // Kick值不一致 + for (int i = 0; i < NumberOfSupportedCameras; i++) { + exportXMLDataInfo.TotalKickNum += exportXMLDataInfo.kickNum[i]; + } + } + else + exportXMLDataInfo.TotalKickNum = exportXMLDataInfo.kickNum[0]; + + exportXMLDataInfo.KickRate = ((double)exportXMLDataInfo.TotalKickNum / (double)exportXMLDataInfo.TotalCheckNum) * 100; + exportXMLDataInfo.PassRate = (1.0 - exportXMLDataInfo.KickRate) * 100; + + export_XMLData_Info_queue->put(exportXMLDataInfo); +#endif + } //发送换班消息给PLC if (g_modbus_conf.shift > 0) @@ -2727,6 +2486,7 @@ bool Cigarette::read_sys_config(SysConf &conf, QString conf_path) bool Cigarette::read_modbus_config(ModbusConf &conf) { + QString str_kick; std::fstream cfg_file; QString modbus_file = g_conf_path.config_path + "/" + MODBUS_CONFIGURE_FILE; cfg_file.open(modbus_file.toLocal8Bit().constData()); @@ -2744,59 +2504,12 @@ bool Cigarette::read_modbus_config(ModbusConf &conf) { size_t pos = line.find('='); std::string tmp_key = line.substr(0, pos); - if (tmp_key == "QUANTITY") - { - conf.quantity = atoi(line.substr(pos + 1).c_str()); - } -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) - else if (tmp_key == "KICK1") - { - conf.kick1 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) - else if (tmp_key == "KICK2") - { - conf.kick2 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) - else if (tmp_key == "KICK3") - { - conf.kick3 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) - else if (tmp_key == "KICK4") - { - conf.kick4 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) - else if (tmp_key == "KICK5") - { - conf.kick5 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) - else if (tmp_key == "KICK6") - { - conf.kick6 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) - else if (tmp_key == "KICK7") - { - conf.kick7 = atoi(line.substr(pos + 1).c_str()); - } -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) - else if (tmp_key == "KICK8") - { - conf.kick8 = atoi(line.substr(pos + 1).c_str()); + for (int i = 0; i < NumberOfSupportedCameras; i++) { + str_kick = QString("KICK%1").arg(i + 1); + if (tmp_key == str_kick.toStdString()) + conf.kick[i] = atoi(line.substr(pos + 1).c_str()); } -#endif - else if (tmp_key == "QUANTITY") + if (tmp_key == "QUANTITY") { conf.quantity = atoi(line.substr(pos + 1).c_str()); } @@ -3042,6 +2755,7 @@ lcdNumber_total_mat[a]=ui.lcdNumber_total_##b;\ label_jd_no_mat[a]=ui.label_jd_no_##b;\ lcdNumber_ok_mat[a]=ui.lcdNumber_ok_##b;\ lcdNumber_ng_mat[a]=ui.lcdNumber_ng_##b;\ +lcdNumber_kick_mat[a]=ui.lcdNumber_kick_##b;\ label_reslut_mat[a]=ui.label_reslut_##b;\ rotate_mat[a]=ui.rotate_##b;\ label_ng_mat[a]=ui.label_ng_##b; @@ -3801,19 +3515,12 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor { if (SingleCamInfo[i].IsOpen && quantity > 0) { std::fstream cfg_file; - //char str[256]; - //memset(str, 0, 256); - //sprintf(str, STATISTIC_FILE, i); - //char buf[256]; - //memset(buf, 0, 256); - //sprintf(buf, "%s/%s", g_conf_path.config_path.toLocal8Bit().constData(), str); file_name = QString(STATISTIC_FILE).arg(i); file_path = g_conf_path.config_path + "/" + file_name; char buf[256]; memset(buf, 0, 256); sprintf(buf, "%s", file_path.toLocal8Bit().constData()); - //std::cout<<"===buf>"<0) - int kick1; //1#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) - int kick2; //2#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) - int kick3; //3#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) - int kick4; //4#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) - int kick5; //5#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) - int kick6; //6#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) - int kick7; //7#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) - int kick8; //8#通道剔除个数地址 -#endif + int kick[NumberOfSupportedCameras]; + int quantity; //当班产量地址 int shift; //换班地址 int work; //开始/停止 @@ -188,30 +166,11 @@ public: ModbusConf() { -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) - kick1=0; //1#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) - kick2=0; //2#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) - kick3=0; //3#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) - kick4=0; //4#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) - kick5=0; //5#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) - kick6=0; //6#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) - kick7=0; //7#通道剔除个数地址 -#endif -#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) - kick8=0; //8#通道剔除个数地址 + for (int i = 0; i < NumberOfSupportedCameras; i++) { +#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras > i) + kick[i] = 0; #endif + } quantity=0; //当班产量地址 shift=0; //换班地址 work=0; //开始/停止 diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp index 0caa9e5..f4cffe1 100644 --- a/Cigarette/exportData.cpp +++ b/Cigarette/exportData.cpp @@ -9,21 +9,18 @@ #include Cigarette* cg; -extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +//extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; extern ConfPath g_conf_path; ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent) { - //char xmlPath[256]; cg->read_conf(g_conf_path); - for (int index = 0; index < NumberOfSupportedCameras; index++) { XMLError error; pDocument[index] = new tinyxml2::XMLDocument(); - //memset(xmlPath, 0, 256); QString xmlPath = QString(EXPORTDATA_FILE).arg(index); - //sprintf(xmlPath, EXPORTDATA_FILE, index); QString filePath = g_conf_path.config_path + "/" + xmlPath; error = pDocument[index]->LoadFile(filePath.toLocal8Bit().constData()); @@ -43,14 +40,24 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent) insertXMLNode(xmlPath, data); */ - _XMLExportDataInfo data; - data.cameraId = index; - data.cameraTotal = 3; - data.TotalCheckNum = 1000; - data.TotalKickNum = 900; - data.AcquisitionSpeed = "3ms"; - insertXMLNode(filePath.toLocal8Bit().constData(), data); - } + //_XMLExportDataInfo data; + //// 总的统计数据 + //data.TotalCheckNum = 1000; + //data.TotalKickNum = 900; + //data.PassRate = 99.8; + //data.KickRate = 0.2; + //// 各相机数据 + //data.cameraTotal = NumberOfSupportedCameras; + //data.cameraId = index; + //data.shotCounts = 3; + //data.okNum = 560; + //data.ngNum = 440; + //data.kickNum = 440; + //data.AcquisitionSpeed = "3ms"; + //for (int i = 0; i < data.shotCounts; i++) data.jdNum[i] = 4; + //data.DetectSpeed = "5ms"; + //insertXMLNode(filePath.toLocal8Bit().constData(), data); + } } void ExportDataThread::init() @@ -66,8 +73,10 @@ void ExportDataThread::start_work() void ExportDataThread::stop() { b_quit = true; - _ExportDataInfo data; - export_Data_Info_queue->put(data); + //_ExportDataInfo data; + //export_Data_Info_queue->put(data); + _XMLExportDataInfo data; + export_XMLData_Info_queue->put(data); } bool _ExportDataInfo::getAverageData(map &averageData, int index) @@ -118,7 +127,46 @@ bool _ExportDataInfo::getAverageData(map &averageData, int index) return true; } -int ExportDataThread::insertXMLNode(const char* xmlPath, _ExportDataInfo& data) +//int ExportDataThread::insertXMLNode(const char* xmlPath, _ExportDataInfo& data) +//{ +// XMLElement* root = pDocument[data.cameraId]->RootElement(); +// +// if (root == NULL) { +// root = pDocument[data.cameraId]->NewElement("Root"); +// pDocument[data.cameraId]->InsertEndChild(root); +// pDocument[data.cameraId]->SaveFile(xmlPath); +// } +// +// XMLElement* CameraNode = pDocument[data.cameraId]->NewElement("Camera"); +// CameraNode->SetAttribute("Id", data.cameraId); +// CameraNode->SetAttribute("Count ", data.cameraTotal); +// root->InsertEndChild(CameraNode); +// +// XMLElement* IsNG = pDocument[data.cameraId]->NewElement("IsNG"); +// XMLText* IsNGText = pDocument[data.cameraId]->NewText(data.isNg ? "TRUE" : "FALSE"); +// IsNG->InsertEndChild(IsNGText); +// CameraNode->InsertEndChild(IsNG); +// +// XMLElement* timeCost = pDocument[data.cameraId]->NewElement("TimeCost"); +// timeCost->InsertEndChild(pDocument[data.cameraId]->NewText(data.timeCost.c_str())); +// CameraNode->InsertEndChild(timeCost); +// +// XMLElement* isJdExist = pDocument[data.cameraId]->NewElement("IsJdExist"); +// isJdExist->InsertEndChild(pDocument[data.cameraId]->NewText(data.isJdExist[0] ? "TRUE" : "FALSE")); +// CameraNode->InsertEndChild(isJdExist); +// +// // XMLElement* jdInterval = pDocument[data.cameraId]->NewElement("JdInterval"); +// // jdInterval->InsertEndChild(pDocument[data.cameraId]->NewText((const char*)&data.jdInterval)); +// // CameraNode->InsertEndChild(jdInterval); +// +// // XMLElement* jdInterval = pDocument[data.cameraId]->NewElement("jdPointsLocation"); +// // jdInterval->InsertEndChild(pDocument[data.cameraId]->NewText(data.getPoint(0).c_str())); +// // CameraNode->InsertEndChild(jdInterval); +// +// return pDocument[data.cameraId]->SaveFile(xmlPath); +//} + +int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& data) { XMLElement* root = pDocument[data.cameraId]->RootElement(); @@ -128,74 +176,78 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _ExportDataInfo& data) pDocument[data.cameraId]->SaveFile(xmlPath); } - XMLElement* CameraNode = pDocument[data.cameraId]->NewElement("Camera"); - CameraNode->SetAttribute("Id", data.cameraId); - CameraNode->SetAttribute("Count ", data.cameraTotal); - root->InsertEndChild(CameraNode); - - XMLElement* IsNG = pDocument[data.cameraId]->NewElement("IsNG"); - XMLText* IsNGText = pDocument[data.cameraId]->NewText(data.isNg ? "TRUE" : "FALSE"); - IsNG->InsertEndChild(IsNGText); - CameraNode->InsertEndChild(IsNG); - - XMLElement* timeCost = pDocument[data.cameraId]->NewElement("TimeCost"); - timeCost->InsertEndChild(pDocument[data.cameraId]->NewText(data.timeCost.c_str())); - CameraNode->InsertEndChild(timeCost); - - XMLElement* isJdExist = pDocument[data.cameraId]->NewElement("IsJdExist"); - isJdExist->InsertEndChild(pDocument[data.cameraId]->NewText(data.isJdExist[0] ? "TRUE" : "FALSE")); - CameraNode->InsertEndChild(isJdExist); + /// 总统计数据 + // 总检测数量 + XMLElement* Total= pDocument[data.cameraId]->NewElement("Total Datas"); - // XMLElement* jdInterval = pDocument[data.cameraId]->NewElement("JdInterval"); - // jdInterval->InsertEndChild(pDocument[data.cameraId]->NewText((const char*)&data.jdInterval)); - // CameraNode->InsertEndChild(jdInterval); - - // XMLElement* jdInterval = pDocument[data.cameraId]->NewElement("jdPointsLocation"); - // jdInterval->InsertEndChild(pDocument[data.cameraId]->NewText(data.getPoint(0).c_str())); - // CameraNode->InsertEndChild(jdInterval); + XMLElement* TotalCheckNum = pDocument[data.cameraId]->NewElement("TotalCheckNum"); + char s[20]; + TotalCheckNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.TotalCheckNum, s, 10))); + Total->InsertEndChild(TotalCheckNum); - return pDocument[data.cameraId]->SaveFile(xmlPath); -} + // 总剔除数量 + XMLElement* TotalKickNum = pDocument[data.cameraId]->NewElement("TotalKickNum"); + TotalKickNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.TotalKickNum, s, 10))); + Total->InsertEndChild(TotalKickNum); -int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& data) -{ - XMLElement* root = pDocument[data.cameraId]->RootElement(); + // 合格率 + XMLElement* PassRate = pDocument[data.cameraId]->NewElement("PassRate"); + std::string temp_str = std::to_string(data.PassRate); + const char* temp_char = temp_str.c_str(); + PassRate->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); + Total->InsertEndChild(PassRate); + + // 剔除率 + XMLElement* KickRate = pDocument[data.cameraId]->NewElement("KickRate"); + temp_str = std::to_string(data.KickRate); + temp_char = temp_str.c_str(); + KickRate->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); + Total->InsertEndChild(KickRate); - if (root == NULL) { - root = pDocument[data.cameraId]->NewElement("Root"); - pDocument[data.cameraId]->InsertEndChild(root); - pDocument[data.cameraId]->SaveFile(xmlPath); - } + root->InsertEndChild(Total); + /// 各相机数据 + // 相机id & 总数 XMLElement* CameraNode = pDocument[data.cameraId]->NewElement("Camera"); - CameraNode->SetAttribute("Id", data.cameraId); CameraNode->SetAttribute("Count ", data.cameraTotal); - root->InsertEndChild(CameraNode); - - //XMLElement* IsNG = pDocument[data.cameraId]->NewElement("IsNG"); - //XMLText* IsNGText = pDocument[data.cameraId]->NewText(data.isNg ? "TRUE" : "FALSE"); - //IsNG->InsertEndChild(IsNGText); - //CameraNode->InsertEndChild(IsNG); - - //XMLElement* timeCost = pDocument[data.cameraId]->NewElement("TimeCost"); - //timeCost->InsertEndChild(pDocument[data.cameraId]->NewText(data.timeCost.c_str())); - //CameraNode->InsertEndChild(timeCost); - - XMLElement* TotalCheckNum = pDocument[data.cameraId]->NewElement("TotalCheckNum"); - std::string temp_str = std::to_string(data.TotalCheckNum); - const char* temp_char = temp_str.c_str(); - TotalCheckNum->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); - CameraNode->InsertEndChild(TotalCheckNum); + CameraNode->SetAttribute("Id", data.cameraId); - XMLElement* TotalKickNum = pDocument[data.cameraId]->NewElement("TotalKickNum"); - temp_str = std::to_string(data.TotalKickNum); - temp_char = temp_str.c_str(); - TotalKickNum->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char)); - CameraNode->InsertEndChild(TotalKickNum); + XMLElement* JudgeNum = pDocument[data.cameraId]->NewElement("JudgeNum"); + // 各相机ok数量 + XMLElement* okNum = pDocument[data.cameraId]->NewElement("OkNum"); + okNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.okNum[data.cameraId], s, 10))); + JudgeNum->InsertEndChild(okNum); + // 各相机ng数量 + XMLElement* ngNum = pDocument[data.cameraId]->NewElement("NgNum"); + ngNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.ngNum[data.cameraId], s, 10))); + JudgeNum->InsertEndChild(ngNum); + // 各相机实际剔除数量(单通道剔除时为总剔除数量) + XMLElement* kickNum = pDocument[data.cameraId]->NewElement("KickNum"); + kickNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.kickNum[data.cameraId], s, 10))); + JudgeNum->InsertEndChild(kickNum); + + // 各相机胶点识别个数 + XMLElement* JdNum = pDocument[data.cameraId]->NewElement("JdNum"); + JdNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.shotCounts, s, 10))); + for (int j = 0; j < data.shotCounts; j++) + JdNum->InsertEndChild(pDocument[data.cameraId]->NewText(itoa(data.jdNum[j], s, 10))); + JudgeNum->InsertEndChild(JdNum); + + CameraNode->InsertEndChild(JudgeNum); + + // 各相机采集速度 + XMLElement* speed = pDocument[data.cameraId]->NewElement("Speed"); XMLElement* AcquisitionSpeed = pDocument[data.cameraId]->NewElement("AcquisitionSpeed"); AcquisitionSpeed->InsertEndChild(pDocument[data.cameraId]->NewText(data.AcquisitionSpeed.c_str())); - CameraNode->InsertEndChild(AcquisitionSpeed); + speed->InsertEndChild(AcquisitionSpeed); + // 各相机检测速度 + XMLElement* DetectSpeed = pDocument[data.cameraId]->NewElement("DetectSpeed"); + DetectSpeed->InsertEndChild(pDocument[data.cameraId]->NewText(data.DetectSpeed.c_str())); + speed->InsertEndChild(DetectSpeed); + CameraNode->InsertEndChild(speed); + + root->InsertEndChild(CameraNode); return pDocument[data.cameraId]->SaveFile(xmlPath); } @@ -203,8 +255,10 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& dat void ExportDataThread::run() { while (!b_quit) { - _ExportDataInfo element; - export_Data_Info_queue->take(element); + //_ExportDataInfo element; + //export_Data_Info_queue->take(element); + _XMLExportDataInfo element; + export_XMLData_Info_queue->take(element); if (element.cameraId != -1) { char buf[256]; memset(buf, 0, 256); @@ -212,6 +266,7 @@ void ExportDataThread::run() QString filePath = g_conf_path.config_path + "/" + xmlPath; sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId); insertXMLNode(buf, element); + // // Ftp transfer demo // diff --git a/Cigarette/exportData.h b/Cigarette/exportData.h index 3af5ae1..9dee399 100644 --- a/Cigarette/exportData.h +++ b/Cigarette/exportData.h @@ -25,12 +25,13 @@ public: // 各相机数据 long long cameraTotal; int cameraId; - int okNum; // 各相机ok数量 - int ngNum; // 各相机ng数量 - int kickNum; // 各相机实际剔除数量(单通道剔除时为总剔除数量) + int shotCounts; // 拍摄张数 + int okNum[NumberOfSupportedCameras]; // 各相机ok数量 + int ngNum[NumberOfSupportedCameras]; // 各相机ng数量 + int kickNum[NumberOfSupportedCameras]; // 各相机实际剔除数量(单通道剔除时为总剔除数量) string AcquisitionSpeed; // 各相机采集速度 int jdNum[20]; // 各相机胶点识别个数 - string DetectSpeed; // 各相机检测速度 + string DetectSpeed; // 各相机检测速度(识别时间) _XMLExportDataInfo() { // 总的统计数据 @@ -38,11 +39,15 @@ public: TotalKickNum = 0; // 总剔除数量 PassRate = 0.0; // 合格率 KickRate = 0.0; // 剔除率 + cameraId = -1; + shotCounts = 0; // 各相机数据 - cameraId = -1; - okNum = 0; // 各相机ok数量 - ngNum = 0; // 各相机ng数量 - kickNum = 0; // 各相机实际剔除数量(单通道剔除时为总剔除数量) + for (int i = 0; i < NumberOfSupportedCameras; i++) { + okNum[i] = 0; + ngNum[i] = 0; + kickNum[i] = 0; // 各相机实际剔除数量(单通道剔除时为总剔除数量) + } + AcquisitionSpeed = "0ms"; // 各相机采集速度 for (int i = 0; i < 20; i++) jdNum[i] = 0; // 各相机胶点识别个数 DetectSpeed = "0ms"; // 各相机检测速度 @@ -90,7 +95,8 @@ public: } }; -extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +//extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; class ExportDataThread : public QThread { diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp index 1f6066b..62fa631 100644 --- a/Cigarette/workthread.cpp +++ b/Cigarette/workthread.cpp @@ -19,7 +19,8 @@ extern bool isNeedRotate[NumberOfSupportedCameras]; extern SyncQueue >* g_save_queue; //图片保存队列 extern SyncQueue >* g_image_queue[NumberOfSupportedCameras]; //int表示一个目标拍了几张 extern SyncQueue<_UDPSendInfo> *UDP_Info_queue; -extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +//extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; +extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; extern PLCDevice* m_PLCDevice; extern bool g_debug_mode; @@ -85,9 +86,12 @@ void WorkThread::run() UDPSendInfo.FrameID = info_frame; UDPSendInfo.index = local_camera_number; - _ExportDataInfo exportDataInfo; - - exportDataInfo.cameraId = local_camera_number; + //_ExportDataInfo exportDataInfo; + //exportDataInfo.cameraId = local_camera_number; + _XMLExportDataInfo exportXMLDataInfo; + exportXMLDataInfo.cameraTotal = NumberOfSupportedCameras; + exportXMLDataInfo.cameraId = local_camera_number; + exportXMLDataInfo.shotCounts = unit_count; if (!image.data) { @@ -99,7 +103,7 @@ void WorkThread::run() } if (local_SysConf.shoot[local_camera_number] == unit_count) { - exportDataInfo.shotCounts = unit_count; + //exportDataInfo.shotCounts = unit_count; std::vector vec_in; int w = image.cols; int h = image.rows / unit_count; @@ -133,7 +137,8 @@ void WorkThread::run() int time_process = ts_start.msecsTo(ts_jd); emit display_timecost(local_camera_number, time_process); UDPSendInfo.timecost = QString::number(time_process); - exportDataInfo.timeCost = QString::number(time_process).toStdString(); + //exportDataInfo.timeCost = QString::number(time_process).toStdString(); + exportXMLDataInfo.DetectSpeed = QString::number(time_process).toStdString(); cv::Mat image1; cv::Mat image2; @@ -142,8 +147,9 @@ void WorkThread::run() for(int index=0;index 0; + //exportDataInfo.jd[index] = vec_results[index].size(); + //exportDataInfo.isJdExist[index] = vec_results[index].size() > 0; + exportXMLDataInfo.jdNum[index] = vec_results[index].size(); } jd_no.chop(1); emit display_jd_no(local_camera_number, jd_no); @@ -214,7 +220,7 @@ void WorkThread::run() #endif } result_index++; - exportDataInfo.isNg = IsNG; + //exportDataInfo.isNg = IsNG; if (!IsNG) { @@ -260,7 +266,7 @@ void WorkThread::run() if (!g_debug_mode) { emit display_check_total(local_camera_number, ++frame_total); - exportDataInfo.cameraTotal = frame_total; + //exportDataInfo.cameraTotal = frame_total; emit notify(local_camera_number, 0, image1); if (unit_count >= 3) @@ -285,7 +291,8 @@ void WorkThread::run() UDP_Info_queue->put(UDPSendInfo); #endif #ifdef __ExportData - export_Data_Info_queue->put(exportDataInfo); + //export_Data_Info_queue->put(exportDataInfo); + export_XMLData_Info_queue->put(exportXMLDataInfo); #endif } } diff --git a/Cigarette/workthread.h b/Cigarette/workthread.h index 2ad278b..ec8ad57 100644 --- a/Cigarette/workthread.h +++ b/Cigarette/workthread.h @@ -35,8 +35,8 @@ protected: public: int local_camera_number; int local_classid; - SyncQueue > *local_g_image_queue; - ASyncQueue *local_g_result_queue; + SyncQueue>* local_g_image_queue; + ASyncQueue* local_g_result_queue; bool b_quit; long frame_total; SysConf local_SysConf;