解决客户端与远程端数据不统一的问题

main
seiyu 1 year ago
parent 1ba73b82f2
commit f5be5614bf

@ -231,7 +231,7 @@ void CaptureThreadHIK::process( void )
nRet = MV_CC_RegisterExceptionCallBack(CamHandle, LossCallBack[Local_Num], this);
if (nRet) { std::cout << "can not register loss callback" << std::endl; nnRet = nRet; }
#ifdef IMM_FEED_BACK ///不打开无反馈等( 延后一次两次用ifndef // 不延后用ifdef)
//#ifdef IMM_FEED_BACK ///不打开无反馈等( 延后一次两次用ifndef // 不延后用ifdef)
nRet = MV_CC_SetEnumValueByString(CamHandle, "EventSelector", "Line0FallingEdge");
if (nRet) { std::cout << "can not set EventSelector" << std::endl; nnRet = nRet; }
@ -249,7 +249,7 @@ void CaptureThreadHIK::process( void )
nRet = MV_CC_RegisterEventCallBackEx(CamHandle, "Line0RisingEdge", RisingGpioEvent[Local_Num], this);
if (nRet) { std::cout << "can not register GPIO callback" << std::endl; nnRet = nRet; }
#endif
//#endif
m_Timer = new QTimer();
connect(m_Timer, SIGNAL(timeout()), this, SLOT(fpsTimeout()));

@ -303,6 +303,7 @@ void AlgJd::post_process_batch(std::vector<cv::Mat>& vec_frame, std::vector<cv::
//std::cout << "outs.size()\t" << outs.size() << std::endl;
//std::cout << "Type\t" << outs[0].type() << std::endl;
for (size_t i = 0; i < outs.size(); ++i)
{
//std::cout << "outs.dims\t" << outs[i].dims << std::endl;

@ -395,6 +395,9 @@ Cigarette::Cigarette(QWidget *parent)
m_delay = new QTimer(this);//换班防连击
connect(m_delay, SIGNAL(timeout()), this, SLOT(enable_shift()));
m_sendMsg_delay = new QTimer(this);
connect(m_sendMsg_delay, SIGNAL(timeout()), this, SLOT(sendLatestData()));
m_op_delay = new QTimer(this);
connect(m_op_delay, SIGNAL(timeout()), this, SLOT(op_timeout()));
@ -499,6 +502,7 @@ Cigarette::Cigarette(QWidget *parent)
}
}
}
//connect(ui.btn_pause, SIGNAL(clicked()), this, SLOT(sendLatestData()));
}
Cigarette::~Cigarette()
@ -613,6 +617,9 @@ void Cigarette::pause_work()
//显示OK/NG按钮
label_reslut_mat[i]->setVisible(false);
}
m_sendMsg_delay->setSingleShot(true);
m_sendMsg_delay->start(1000);
}
void Cigarette::Exit()
@ -686,6 +693,7 @@ void Cigarette::on_btn_pause_released()
}
g_op_time = OP_TIME;
}
//锁定/解锁按钮
void Cigarette::on_btn_lock_released()
{
@ -770,7 +778,7 @@ void Cigarette::TestImgs()
std::cout << "srcDirPath=" << srcDirPath.toStdString() << std::endl;
srcDirPath += "/";
//获取该路径下的所有文件
getFiles(srcDirPath.toStdString() + "*.jpg", files);
getFiles(srcDirPath.toStdString() + "*.bmp", files);
if (files.size() == 0)
{
QMessageBox::StandardButton result = QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("没有找到图片"));
@ -847,6 +855,67 @@ void Cigarette::enable_shift()
ui.pushButton_clear->setEnabled(true);
}
void Cigarette::sendLatestData() {
// Á¬½ÓUDP·¢ËÍ×îеÄÊý¾Ý
int dataport = g_sys_conf.MonitorPort;
_UDPSendInfo UDPSendInfo;
//UDP_Info_queue->take(UDPSendInfo);
for (int i = 0; i < NumberOfSupportedCameras; i++)
{
UDPSendInfo.index = i;
UDPSendInfo.FrameID = ok_frame;
UDPSendInfo.ok[i] = ok[i];
//sThread.sendData("4_999", dataport + UDPSendInfo.index);
sThread.sendData(("4_" + to_string(ok[i])).c_str(), dataport + UDPSendInfo.index);
//std::cout << "ok[" << i << "] is " << to_string(ok[i]) << std::endl;
//std::cout << ("4_" + to_string(ok[i])).c_str() << std::endl;
//UDP_Info_queue->put(UDPSendInfo);
UDPSendInfo.FrameID = ng_frame;
UDPSendInfo.ng[i] = ng[i];
sThread.sendData(("5_" + to_string(ng[i])).c_str(), dataport + UDPSendInfo.index);
UDPSendInfo.FrameID = total_frame;
UDPSendInfo.Total = production_number[i];
sThread.sendData(("7_" + to_string(production_number[i])).c_str(), dataport + UDPSendInfo.index);
}
//while (isLoop) {
//switch (UDPSendInfo.FrameID) {
// case info_frame: {
// sThread.sendData(&UDPSendInfo, dataport);
// break;
// }
// case speed_frame: {
// sThread.sendSpeed(&UDPSendInfo, dataport);
// break;
// }
// case kick_frame: {
// sThread.sendKick(&UDPSendInfo, dataport);
// break;
// }
// case ok_frame: {
// sThread.sendOK(&UDPSendInfo, dataport);
// break;
// }
// case ng_frame: {
// sThread.sendNG(&UDPSendInfo, dataport);
// break;
// }
// case total_frame: {
// sThread.sendTotal(&UDPSendInfo, dataport);
// break;
// }
// case image_frame: {
// //sThread.sendImage(&UDPSendInfo, imageport);
// break;
// }
//}
//}
}
void Cigarette::OnRotateReleasedHub(int Num)//旋转按钮
{
QString str = "Start to rotate picture " + QString::number(90 * ((rotationAngle[Num] + 1) % 4)) + " degrees of camera " + QString::number(Num) + ".";
@ -856,7 +925,6 @@ void Cigarette::OnRotateReleasedHub(int Num)//
rotationAngle[Num] = (rotationAngle[Num] + 1) % 4;
save_rotate_message();
}
}
//打开/关闭相机
@ -1220,7 +1288,7 @@ void Cigarette::OnOKHub(int Num)
_UDPSendInfo UDPSendInfo;
UDPSendInfo.FrameID = ok_frame;
UDPSendInfo.index = Num;
UDPSendInfo.ok = ok[Num];
UDPSendInfo.ok[Num] = ok[Num];
#ifdef __UDPSend
UDP_Info_queue->put(UDPSendInfo);
#endif
@ -1235,7 +1303,7 @@ void Cigarette::OnNGHub(int Num)
_UDPSendInfo UDPSendInfo;
UDPSendInfo.FrameID = ng_frame;
UDPSendInfo.index = Num;
UDPSendInfo.ng = ng[Num];
UDPSendInfo.ng[Num] = ng[Num];
#ifdef __UDPSend
UDP_Info_queue->put(UDPSendInfo);
#endif
@ -1247,7 +1315,6 @@ void Cigarette::OnNGHub(int Num)
void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num)
{
label_cap_speed_mat[Num]->setText(statisticalData + QStringLiteral("个/秒"));
_UDPSendInfo UDPSendInfo;
UDPSendInfo.FrameID = speed_frame;
UDPSendInfo.index = Num;
@ -1972,12 +2039,12 @@ void Cigarette::on_pushButton_clear_released()//
UDPSendInfo.index = i;
UDPSendInfo.FrameID = ok_frame;
UDPSendInfo.ok = ok[i];
UDPSendInfo.ok[i] = ok[i];
#ifdef __UDPSend
UDP_Info_queue->put(UDPSendInfo);
#endif
UDPSendInfo.FrameID = ng_frame;
UDPSendInfo.ok = ng[i];
UDPSendInfo.ng[i] = ng[i];
#ifdef __UDPSend
UDP_Info_queue->put(UDPSendInfo);
#endif
@ -3443,7 +3510,6 @@ void Cigarette::EnableDebugMode()
else if(SingleCamInfo[i].CamClass == BaslerClassID)
{
bool nRet = false;
nRet = BaslerCamHandle[i]->AcquisitionFrameRate.TrySetValue(10);
if (!nRet) { std::cout << "can not set Basler's AcquisitionFrameRate" << std::endl; }
nRet = BaslerCamHandle[i]->AcquisitionFrameRateEnable.TrySetValue(true);
@ -3676,6 +3742,7 @@ void Cigarette::record_output_statistic(qint64 quantity, int shift)
void Cigarette::recMsgFromUdp(QString data)
{
//std::cout << data.toStdString() << std::endl;
#ifdef __UDPSend
if (data == "START")
{
@ -3743,8 +3810,6 @@ void Cigarette::recMsgFromUdp(QString data)
{
OnRotateReleasedHub(7);
}
else if (data == "LOCK")
{
if (!g_admin_mode)
@ -4012,6 +4077,7 @@ void Cigarette::recMsgFromUdp(QString data)
str += QString::number(g_sys_conf.no[i][0]) + '_' + QString::number(g_sys_conf.no[i][1]) + '_' + QString::number(g_sys_conf.no[i][2]) + '_';
}
sThread.sendData(str, g_sys_conf.FeedbackPort);
//std::cout << "=> to UDP: " << str.toStdString() << std::endl;
}
else if (dataList[0] == "UPDSETTING")
{

@ -80,6 +80,7 @@ public:
private slots :
void on_btn_start_released();
void on_btn_pause_released();
//void on_btn_pause_clicked(bool checked);
void on_btn_lock_released();
void on_btn_setup_released();
void on_checkBox_debug_clicked(bool checked);
@ -88,6 +89,7 @@ private slots :
void on_toolButton_alarm_released();
void on_pushButton_clear_released();
void enable_shift();
void sendLatestData();
void OnNotifyHub(int Num, int Cnt, cv::Mat m);
void OnDisplayTimeCostHub(int Num, int ms);
void OnDisplayCheckNumberHub(int Num, long no);
@ -163,6 +165,7 @@ public:
QTimer *m_pTimer;
QTimer *m_delay; //换班防止连击
QTimer* m_sendMsg_delay; // 停止工作后发送最新数据给远程端
QTimer *m_op_delay; //操作员权限剩余时间
QTimer *m_admin_delay; //操作员权限剩余时间
QTimer *clean_pTimer; //定时清理任务

@ -1188,7 +1188,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -1248,7 +1248,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -1552,10 +1552,10 @@
<widget class="QLabel" name="label_17">
<property name="geometry">
<rect>
<x>880</x>
<x>830</x>
<y>10</y>
<width>191</width>
<height>21</height>
<width>210</width>
<height>20</height>
</rect>
</property>
<property name="font">
@ -1570,16 +1570,16 @@
<string notr="true">color:white</string>
</property>
<property name="text">
<string>Tel:87907256(0532)</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt; Tel:87907256(0532)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="label_18">
<property name="geometry">
<rect>
<x>1080</x>
<x>1090</x>
<y>10</y>
<width>81</width>
<height>21</height>
<width>80</width>
<height>20</height>
</rect>
</property>
<property name="font">
@ -1600,10 +1600,10 @@
<widget class="QLabel" name="label_cur_time">
<property name="geometry">
<rect>
<x>920</x>
<y>30</y>
<width>211</width>
<height>31</height>
<x>830</x>
<y>35</y>
<width>210</width>
<height>20</height>
</rect>
</property>
<property name="font">
@ -1618,7 +1618,7 @@
<string notr="true">color:white</string>
</property>
<property name="text">
<string>2020-10-10 13:15:39</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;2020-10-10 13:15:39&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@ -1933,7 +1933,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -1993,7 +1993,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -2321,7 +2321,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -2381,7 +2381,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -2602,7 +2602,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -2662,7 +2662,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3216,7 +3216,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3276,7 +3276,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3436,7 +3436,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3496,7 +3496,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3608,7 +3608,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3668,7 +3668,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3876,7 +3876,7 @@
<rect>
<x>220</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -3936,7 +3936,7 @@
<rect>
<x>360</x>
<y>20</y>
<width>50</width>
<width>61</width>
<height>20</height>
</rect>
</property>
@ -4394,10 +4394,10 @@
<widget class="QLabel" name="location">
<property name="geometry">
<rect>
<x>1180</x>
<y>10</y>
<width>81</width>
<height>21</height>
<x>1090</x>
<y>35</y>
<width>161</width>
<height>20</height>
</rect>
</property>
<property name="font">

@ -9,7 +9,7 @@
//#define __DEBUG //debug信息输出功能
#define __UDPSend //网络发送功能
#define USB_BASLER_NEW_FW //使用basler定制固件
#define IMM_PROCESS //拍照后立马处理,不等校验信号
//#define IMM_PROCESS //拍照后立马处理,不等校验信号
#define IMM_FEED_BACK //处理完后立马反馈,不等校验信号
//#define ONE_TIME_SHIFT //错开一拍发送反馈(默认错开两次)
#define AI_WARM_UP //AI识别开始前的热身动作

@ -52,7 +52,7 @@ protected:
p_debug_queue->take(image);
if (image.data)
{
cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像
//cv::cvtColor(image, image, CV_BGR2RGB); //灰度图像转为彩色图像
if (isNeedRotate[local_camera_number]) {
if(rotationAngle[local_camera_number] != (cv::ROTATE_90_COUNTERCLOCKWISE + 1))
{

@ -668,7 +668,7 @@ void DialogSetup::on_pushButton_change_released()
connect(this, &DialogSetup::sendMsgToShift, m_change_shift, &change_shift::recMsgFromDialogSetup);
m_change_shift->show();
m_change_shift->move(this->geometry().center() - m_change_shift->rect().center());
emit sendMsgToShift(g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC);
emit sendMsgToShift (g_sys_conf.shiftA, g_sys_conf.shiftB, g_sys_conf.shiftC);
}
void DialogSetup::on_pushButton_statistic_released()
{

@ -115,7 +115,7 @@ void threadSend::sendOK(_UDPSendInfo *UDPSendInfo,int port)
{
QString res = QString("%1_%2")
.arg(QString::number(UDPSendInfo->FrameID))
.arg(QString::number(UDPSendInfo->ok));
.arg(QString::number(UDPSendInfo->ok[UDPSendInfo->index]));
mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index);
}
@ -123,7 +123,7 @@ void threadSend::sendNG(_UDPSendInfo *UDPSendInfo,int port)
{
QString res = QString("%1_%2")
.arg(QString::number(UDPSendInfo->FrameID))
.arg(QString::number(UDPSendInfo->ng));
.arg(QString::number(UDPSendInfo->ng[UDPSendInfo->index]));
mSocket.writeDatagram(res.toUtf8(), QHostAddress(ip), port + UDPSendInfo->index);
}

@ -32,8 +32,8 @@ public:
long Total;
QString JD;
QString timecost;
int ok;
int ng;
int ok[NumberOfSupportedCameras];
int ng[NumberOfSupportedCameras];
QString speed;
int Kick[NumberOfSupportedCameras];
@ -45,8 +45,8 @@ public:
Total = 0;
JD = QString("0,0,0");
timecost = QString("0ms");;
ok = false;
ng = false;
for (int i = 0; i < NumberOfSupportedCameras; i++)ok[i] = 0;
for (int i = 0; i < NumberOfSupportedCameras; i++)ng[i] = 0;
speed = QString(" ");
for(int i=0;i<NumberOfSupportedCameras;i++)Kick[i]=0;
}

Loading…
Cancel
Save