|
|
|
@ -56,7 +56,8 @@ bool g_debug_mode; //
|
|
|
|
|
SyncQueue<cv::Mat> *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;i<NumberOfSupportedCameras;i++)
|
|
|
|
@ -221,30 +226,11 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
QString config_path = g_conf_path.config_path + "/conf.txt";
|
|
|
|
|
read_sys_config(g_sys_conf, config_path); //初始化系统配置
|
|
|
|
|
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
|
|
|
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>"<<buf<<std::endl;
|
|
|
|
|
|
|
|
|
|
cfg_file.open(buf, std::ios::app);
|
|
|
|
|
if (cfg_file.good())
|
|
|
|
@ -3836,7 +3543,6 @@ void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSuppor
|
|
|
|
|
sprintf(buf, "%c 总产量:%010I64d 剔除率:%02.5f%% 合格率:%02.5f%% NG率:%02.5f%%\n", (shift == 0) ? 'A' : ((shift == 1) ? 'B' : 'C'), quantity, ((double)Kick[i] / quantity) * 100, (1.0 - ng_rate) * 100, ng_rate * 100);
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
cfg_file.close();
|
|
|
|
|
}
|
|
|
|
|