From 3f6c64d10c76673f4190f79c13b868cf56c6bf06 Mon Sep 17 00:00:00 2001 From: seiyu Date: Tue, 9 Jan 2024 16:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=80=E4=BA=9B=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=BB=A5=E5=8F=8A=E6=B7=BB=E5=8A=A0=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?win+tab=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cigarette/Cigarette.vcxproj | 4 +-- Cigarette/cigarette.cpp | 72 +++++++++++++++++++------------------ Cigarette/cigarette.h | 1 + Cigarette/cigarette.ui | 27 ++++++++++++-- Cigarette/common.h | 4 +-- 5 files changed, 68 insertions(+), 40 deletions(-) diff --git a/Cigarette/Cigarette.vcxproj b/Cigarette/Cigarette.vcxproj index 9a569e0..0a177e7 100644 --- a/Cigarette/Cigarette.vcxproj +++ b/Cigarette/Cigarette.vcxproj @@ -133,7 +133,7 @@ true true stdcpp14 - MaxSpeed + Disabled 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) - false + true qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Network.lib;%(AdditionalDependencies) diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index d6c4be8..a4a7a94 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -7,7 +7,7 @@ #include #include #include "exportData.h" -#include +#include int g_op_time; //操作员权限时长(默认300秒) int g_admin_time; //管理员操作权限时长(默认300秒) @@ -60,7 +60,6 @@ SyncQueue<_UDPSendInfo>* UDP_Info_queue; //SyncQueue<_ExportDataInfo> *export_Data_Info_queue; SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue; ExportDataThread exportDataThread; -FtpManager ftpManager; bool g_admin_mode; //是否管理员模式 @@ -872,7 +871,6 @@ void Cigarette::sendLatestData() { // 连接UDP发送最新的数据 int dataport = g_sys_conf.MonitorPort; _UDPSendInfo UDPSendInfo; - //UDP_Info_queue->take(UDPSendInfo); for (int i = 0; i < NumberOfSupportedCameras; i++) { @@ -880,19 +878,16 @@ void Cigarette::sendLatestData() { UDPSendInfo.FrameID = ok_frame; UDPSendInfo.ok[i] = ok[i]; #ifdef __UDPSend - //sThread.sendData(("4_" + to_string(ok[i])).c_str(), dataport + UDPSendInfo.index); UDP_Info_queue->put(UDPSendInfo); #endif UDPSendInfo.FrameID = ng_frame; UDPSendInfo.ng[i] = ng[i]; #ifdef __UDPSend - //sThread.sendData(("5_" + to_string(ng[i])).c_str(), dataport + UDPSendInfo.index); UDP_Info_queue->put(UDPSendInfo); #endif UDPSendInfo.FrameID = total_frame; UDPSendInfo.Total = production_number[i]; #ifdef __UDPSend - //sThread.sendData(("7_" + to_string(production_number[i])).c_str(), dataport + UDPSendInfo.index); UDP_Info_queue->put(UDPSendInfo); #endif } @@ -1251,14 +1246,15 @@ void Cigarette::OnNotifyHub(int Num, int Cnt,cv::Mat m) void Cigarette::OnDisplayTimeCostHub(int Num, int ms) { label_timecost_mat[Num]->setText(QString::number(ms) + "ms"); +#ifdef __ExportData exportData[Num].detectTime = QString::number(ms) + "ms"; +#endif } void Cigarette::OnDisplayCheckNumberHub(int Num, long no) { production_number[Num]++; lcdNumber_total_mat[Num]->display(production_number[Num]); - exportData[Num].checkNum = production_number[Num]; _UDPSendInfo UDPSendInfo; UDPSendInfo.FrameID = total_frame; UDPSendInfo.index = Num; @@ -1266,6 +1262,9 @@ void Cigarette::OnDisplayCheckNumberHub(int Num, long no) #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif +#ifdef __ExportData + exportData[Num].checkNum = production_number[Num]; +#endif } void Cigarette::OnDisplayJdNoHub(int Num, QString jd_no) @@ -1290,8 +1289,9 @@ 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);")); - +#ifdef __ExportData exportData[Num].okNum = ok[Num]; +#endif } void Cigarette::OnNGHub(int Num) @@ -1307,8 +1307,9 @@ void Cigarette::OnNGHub(int Num) lcdNumber_ng_mat[Num]->display(ng[Num]); label_reslut_mat[Num]->setText("NG"); label_reslut_mat[Num]->setStyleSheet(tr("background-color: rgb(255, 0, 0);")); - +#ifdef __ExportData exportData[Num].ngNum = ng[Num]; +#endif } void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num) { @@ -1320,7 +1321,9 @@ void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num) { #ifdef __UDPSend UDP_Info_queue->put(UDPSendInfo); #endif +#ifdef __ExportData exportData[Num].acquisitionTime = statisticalData + QStringLiteral("个/秒"); +#endif } //不剔除模式 @@ -1412,6 +1415,31 @@ void Cigarette::on_checkBox_debug_clicked(bool checked) } } +void Cigarette::on_pushButton_wintab_clicked(bool checked) { + INPUT inputs[4] = {}; + ZeroMemory(inputs, sizeof(inputs)); + + inputs[0].type = INPUT_KEYBOARD; + inputs[0].ki.wVk = VK_LWIN; + + inputs[1].type = INPUT_KEYBOARD; + inputs[1].ki.wVk = VK_TAB; + + inputs[2].type = INPUT_KEYBOARD; + inputs[2].ki.wVk = VK_TAB; + inputs[2].ki.dwFlags = KEYEVENTF_KEYUP; + + inputs[3].type = INPUT_KEYBOARD; + inputs[3].ki.wVk = VK_LWIN; + inputs[3].ki.dwFlags = KEYEVENTF_KEYUP; + + UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT)); + if (uSent != ARRAYSIZE(inputs)) + { + qDebug() << "SendInput failed" << HRESULT_FROM_WIN32(GetLastError()); + } +} + //打开PLC配置对话框 void Cigarette::on_toolButton_plc_released() { @@ -1773,30 +1801,7 @@ void Cigarette::handleTimeout() ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); ui.label_alarm->setText(QStringLiteral("无报警")); } - //if (alarm_info.alarm_code == 7) { - // ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); - // ui.label_alarm->setText(QStringLiteral("重连1#相机")); - // //重连1#相机 - // ReconnectCamHub(0); - // //清除报警标志 - // if (g_modbus_conf.alarm > 0) - // { - // uint16_t dest16[2] = {0,0}; - // int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); - // } - //} - //if (alarm_info.alarm_code == 8) { - // ui.label_alarm->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); - // ui.label_alarm->setText(QStringLiteral("重连2#相机")); - // //重连2#相机 - // ReconnectCamHub(1); - // //清除报警标志 - // if (g_modbus_conf.alarm > 0) - // { - // uint16_t dest16[2] = {0,0}; - // int ret = m_PLCDevice->write_short_2_plc(g_modbus_conf.alarm, 2, dest16); - // } - //} + #ifdef __UDPSend QString str; str = QString("alarm") + '_' + QString::number(alarm_info.alarm_code); @@ -2024,7 +2029,6 @@ void Cigarette::on_pushButton_clear_released()// #ifdef __UDPSend sThread.sendData("total_" + QString::number(0), g_sys_conf.FeedbackPort); #endif - } //读取系统管理员密码 diff --git a/Cigarette/cigarette.h b/Cigarette/cigarette.h index cb6eb8f..d0a8301 100644 --- a/Cigarette/cigarette.h +++ b/Cigarette/cigarette.h @@ -86,6 +86,7 @@ private slots : void on_btn_setup_released(); void on_checkBox_debug_clicked(bool checked); void on_checkBox_unkick_clicked(bool checked); + void on_pushButton_wintab_clicked(bool checked); void on_toolButton_plc_released(); void on_toolButton_alarm_released(); void on_pushButton_clear_released(); diff --git a/Cigarette/cigarette.ui b/Cigarette/cigarette.ui index 0682856..a495b8d 100644 --- a/Cigarette/cigarette.ui +++ b/Cigarette/cigarette.ui @@ -1576,7 +1576,7 @@ - 1090 + 1060 10 80 20 @@ -4394,7 +4394,7 @@ - 1090 + 1060 35 161 20 @@ -4415,6 +4415,28 @@ CDTH + + + + 1180 + 10 + 81 + 41 + + + + + 寰蒋闆呴粦 + 12 + + + + color:white + + + 鍒囨崲 + + rotate_1 groupBox_status label_title @@ -4522,6 +4544,7 @@ image_label_82 image_label_12 location + pushButton_wintab diff --git a/Cigarette/common.h b/Cigarette/common.h index f757298..b518a1f 100644 --- a/Cigarette/common.h +++ b/Cigarette/common.h @@ -7,7 +7,7 @@ #include "QtCore\qdatetime.h" //#define __DEBUG //debug信息输出功能 -#define __UDPSend //网络发送功能 +//#define __UDPSend //网络发送功能 #define USB_BASLER_NEW_FW //使用basler定制固件 //#define IMM_PROCESS //拍照后立马处理,不等校验信号 //#define IMM_FEED_BACK //处理完后立马反馈,不等校验信号 @@ -15,7 +15,7 @@ #define AI_WARM_UP //AI识别开始前的热身动作 #define LICENSE_VERIFY //开启license文件校验 //CAP_FEED_BACK和DOUBLE_FEED_BACK不要一起开 -#if defined (ONE_TIME_SHIFT) +#if defined (ONE_TIME_SHIFT) //#define CAP_FEED_BACK //拍照时也检测有没有测试结果,有的话就反馈 //#define DOUBLE_FEED_BACK //一次ng,两次反馈ng信号 #endif