|
|
|
@ -55,7 +55,7 @@ ASyncQueue<bool> *g_result_queue[NumberOfSupportedCameras]; //
|
|
|
|
|
bool g_debug_mode; //相机调试模式,工作模式必须暂停状态才能打开
|
|
|
|
|
SyncQueue<cv::Mat> *g_debug_queue[NumberOfSupportedCameras]; //相机调试模式图像队列
|
|
|
|
|
|
|
|
|
|
SyncQueue<_UDPSendInfo> *UDP_Info_queue;
|
|
|
|
|
SyncQueue<_UDPSendInfo>* UDP_Info_queue;
|
|
|
|
|
//SyncQueue<_ExportDataInfo> *export_Data_Info_queue;
|
|
|
|
|
SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
|
|
|
|
|
ExportDataThread exportDataThread;
|
|
|
|
@ -81,6 +81,7 @@ int quantity_stop_count; //
|
|
|
|
|
int g_seconds;
|
|
|
|
|
int CurOpLabel;
|
|
|
|
|
bool onrestart = false;
|
|
|
|
|
bool flag = false;
|
|
|
|
|
|
|
|
|
|
VOID BeforeWork(int shoot[])
|
|
|
|
|
{
|
|
|
|
@ -244,11 +245,11 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
saveThread.init();
|
|
|
|
|
saveThread.start_work();
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
sThread.init(UDP_Info_queue,g_sys_conf.MonitorIP ,g_sys_conf.MonitorPort);
|
|
|
|
|
sThread.init(UDP_Info_queue, g_sys_conf.MonitorIP, g_sys_conf.MonitorPort);
|
|
|
|
|
sThread.start_work();
|
|
|
|
|
|
|
|
|
|
rThread = new threadReceive();
|
|
|
|
|
rThread->init(g_sys_conf.MonitorIP ,g_sys_conf.MonitorPort);
|
|
|
|
|
rThread->init(g_sys_conf.MonitorIP, g_sys_conf.MonitorPort);
|
|
|
|
|
connect(rThread, &threadReceive::sendMsgToCigratte, this, &Cigarette::recMsgFromUdp);
|
|
|
|
|
rThread->start_work();
|
|
|
|
|
#endif
|
|
|
|
@ -256,6 +257,7 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
exportDataThread.init();
|
|
|
|
|
exportDataThread.start_work();
|
|
|
|
|
connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
m_PLCDevice = new PLCDevice;
|
|
|
|
@ -1244,6 +1246,7 @@ 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");
|
|
|
|
|
exportData[Num].detectTime = QString::number(ms) + "ms";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::OnDisplayCheckNumberHub(int Num, long no)
|
|
|
|
@ -1262,6 +1265,10 @@ void Cigarette::OnDisplayCheckNumberHub(int Num, long no)
|
|
|
|
|
void Cigarette::OnDisplayJdNoHub(int Num, QString jd_no)
|
|
|
|
|
{
|
|
|
|
|
label_jd_no_mat[Num]->setText(jd_no);
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
exportData[Num].cameraId = Num;
|
|
|
|
|
exportData[Num].jdNum = jd_no;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::OnOKHub(int Num)
|
|
|
|
@ -1278,7 +1285,7 @@ void Cigarette::OnOKHub(int Num)
|
|
|
|
|
label_reslut_mat[Num]->setText("OK");
|
|
|
|
|
label_reslut_mat[Num]->setStyleSheet(tr("background-color: rgb(0, 255, 0);"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exportData[Num].okNum = ok[Num];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::OnNGHub(int Num)
|
|
|
|
@ -1294,10 +1301,11 @@ 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);"));
|
|
|
|
|
|
|
|
|
|
exportData[Num].ngNum = ng[Num];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num)
|
|
|
|
|
{
|
|
|
|
|
void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num) {
|
|
|
|
|
label_cap_speed_mat[Num]->setText(statisticalData + QStringLiteral("个/秒"));
|
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
|
UDPSendInfo.FrameID = speed_frame;
|
|
|
|
@ -1306,6 +1314,7 @@ void Cigarette::updateStatisticsHub(const QString& statisticalData, int Num)
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
UDP_Info_queue->put(UDPSendInfo);
|
|
|
|
|
#endif
|
|
|
|
|
exportData[Num].acquisitionTime = statisticalData + QStringLiteral("¸ö/Ãë");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//不剔除模式
|
|
|
|
@ -1479,13 +1488,16 @@ void Cigarette::handleTimeout()
|
|
|
|
|
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]);
|
|
|
|
|
lcdNumber_kick_mat[i]->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
|
UDPSendInfo.FrameID = kick_frame;
|
|
|
|
|
UDPSendInfo.index = 0;
|
|
|
|
|
UDPSendInfo.index = i;
|
|
|
|
|
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
|
|
|
|
|
UDP_Info_queue->put(UDPSendInfo);
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
exportData[i].kick = dest16[0] + (dest16[1] << 16);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1860,10 +1872,9 @@ void Cigarette::on_toolButton_alarm_released()
|
|
|
|
|
}
|
|
|
|
|
void Cigarette::on_pushButton_clear_released()//换班
|
|
|
|
|
{
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
_XMLExportDataInfo exportXMLDataInfo;
|
|
|
|
|
#endif
|
|
|
|
|
emit sengMsgToClog("Change shift.");
|
|
|
|
|
emit sendMsgToExportData();
|
|
|
|
|
|
|
|
|
|
if (!g_admin_mode)
|
|
|
|
|
{
|
|
|
|
|
if (!g_op_mode)
|
|
|
|
@ -1889,10 +1900,6 @@ 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;
|
|
|
|
@ -1943,48 +1950,13 @@ 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 __ExportData
|
|
|
|
|
exportData->totalCheckNum = cur_quantity;
|
|
|
|
|
#endif
|
|
|
|
|
#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)
|
|
|
|
@ -1999,6 +1971,45 @@ void Cigarette::on_pushButton_clear_released()//
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_op_time = OP_TIME;
|
|
|
|
|
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++) {
|
|
|
|
|
_XMLExportDataInfo exportXMLDataInfo;
|
|
|
|
|
exportXMLDataInfo.cameraTotal = NumberOfSupportedCameras;
|
|
|
|
|
exportXMLDataInfo.cameraId = exportData[i].cameraId;
|
|
|
|
|
exportXMLDataInfo.TotalCheckNum = exportData[i].totalCheckNum;
|
|
|
|
|
exportXMLDataInfo.shotCounts = g_sys_conf.shoot[i];
|
|
|
|
|
exportXMLDataInfo.DetectSpeed = exportData[i].detectTime;
|
|
|
|
|
exportXMLDataInfo.AcquisitionSpeed = exportData[i].acquisitionTime;
|
|
|
|
|
exportXMLDataInfo.jdNum = exportData[i].jdNum;
|
|
|
|
|
exportXMLDataInfo.okNum = exportData[i].okNum;
|
|
|
|
|
exportXMLDataInfo.ngNum = exportData[i].ngNum;
|
|
|
|
|
exportXMLDataInfo.kickNum= exportData[i].kick;
|
|
|
|
|
int flag = 0;
|
|
|
|
|
for (int i = 1; i < NumberOfSupportedCameras; i++) {
|
|
|
|
|
if (exportData[i].kick != exportData[0].kick) {
|
|
|
|
|
flag = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag == 1) {
|
|
|
|
|
// KickÖµ²»Ò»ÖÂ
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++) {
|
|
|
|
|
exportXMLDataInfo.TotalKickNum += exportData[i].kick;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
exportXMLDataInfo.TotalKickNum = exportData[0].kick;
|
|
|
|
|
if (exportXMLDataInfo.TotalKickNum == 0)
|
|
|
|
|
exportXMLDataInfo.KickRate = 0;
|
|
|
|
|
else
|
|
|
|
|
exportXMLDataInfo.KickRate = (double)exportXMLDataInfo.TotalKickNum / exportXMLDataInfo.TotalCheckNum;
|
|
|
|
|
exportXMLDataInfo.PassRate = 1.0 - exportXMLDataInfo.KickRate;
|
|
|
|
|
|
|
|
|
|
export_XMLData_Info_queue->put(exportXMLDataInfo);
|
|
|
|
|
}
|
|
|
|
|
flag = false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//读取系统管理员密码
|
|
|
|
@ -2505,7 +2516,7 @@ bool Cigarette::read_modbus_config(ModbusConf &conf)
|
|
|
|
|
size_t pos = line.find('=');
|
|
|
|
|
std::string tmp_key = line.substr(0, pos);
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++) {
|
|
|
|
|
str_kick = QString("KICK%1").arg(i + 1);
|
|
|
|
|
str_kick = QString("KICK%1").arg(i+1);
|
|
|
|
|
if (tmp_key == str_kick.toStdString())
|
|
|
|
|
conf.kick[i] = atoi(line.substr(pos + 1).c_str());
|
|
|
|
|
}
|
|
|
|
|