修改产量统计功能的剔除率异常并增加ng率

main
seiyu 1 year ago
parent 41fe0fff27
commit 85d59b3ee9

@ -1454,16 +1454,171 @@ void Cigarette::handleTimeout()
QString run_stat = QString(QStringLiteral("运行%1天%2时%3分%4秒")) QString run_stat = QString(QStringLiteral("运行%1天%2时%3分%4秒"))
.arg(days).arg(hours).arg(minutes).arg(second); .arg(days).arg(hours).arg(minutes).arg(second);
ui.label_run_stat->setText(run_stat); ui.label_run_stat->setText(run_stat);
int Kick[NumberOfSupportedCameras] = { 0 };
//当班产量从配置的PLC地址中读取
if (m_PLCDevice->g_plc_ok) if (m_PLCDevice->g_plc_ok)
{ {
if (!g_plc_dialog_open) //PLC配置对话框没有打开 if (!g_plc_dialog_open) //PLC配置对话框没有打开
{ {
//当班产量从配置的PLC地址中读取
if (g_modbus_conf.quantity > 0) 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));
#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);
#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]; uint16_t dest16[2];
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16); int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.quantity, 2, dest16);
if (ret == 2) if (ret == 2)
{ {
int cur_quantity = dest16[0] + (dest16[1] << 16); int cur_quantity = dest16[0] + (dest16[1] << 16);
@ -1474,10 +1629,10 @@ void Cigarette::handleTimeout()
#endif #endif
ui.label_plc->setText(QStringLiteral("PLC在线")); ui.label_plc->setText(QStringLiteral("PLC在线"));
ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);")); ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
if(!(m_PLCDevice->g_plc_status&0x01)) if (!(m_PLCDevice->g_plc_status & 0x01))
{ {
init_plc_value(); init_plc_value();
if(g_working) if (g_working)
{ {
if (g_debug_mode) if (g_debug_mode)
{ {
@ -1490,10 +1645,10 @@ void Cigarette::handleTimeout()
{ {
pause_work(); pause_work();
} }
m_PLCDevice->g_plc_status|=(0x01); m_PLCDevice->g_plc_status |= (0x01);
} }
//自动换班 //自动换班
if (g_sys_conf.auto_shift&&g_working) if (g_sys_conf.auto_shift && g_working)
{ {
g_seconds++; g_seconds++;
if (g_seconds % 10 == 0) if (g_seconds % 10 == 0)
@ -1525,7 +1680,7 @@ void Cigarette::handleTimeout()
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); //停止工作 on_btn_pause_released(); //停止工作
record_output_statistic(cur_quantity, 0); record_output_statistic(cur_quantity, Kick, 0);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
g_op_mode = false; //退出操作员模式 g_op_mode = false; //退出操作员模式
@ -1534,7 +1689,7 @@ void Cigarette::handleTimeout()
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); //停止工作 on_btn_pause_released(); //停止工作
record_output_statistic(cur_quantity, 1); record_output_statistic(cur_quantity, Kick, 1);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
g_op_mode = false; //退出操作员模式 g_op_mode = false; //退出操作员模式
@ -1543,7 +1698,7 @@ void Cigarette::handleTimeout()
{ {
g_op_mode = true; //激活操作员模式 g_op_mode = true; //激活操作员模式
on_btn_pause_released(); //停止工作 on_btn_pause_released(); //停止工作
record_output_statistic(cur_quantity, 2); record_output_statistic(cur_quantity, Kick, 2);
on_pushButton_clear_released(); //换班 on_pushButton_clear_released(); //换班
on_btn_start_released(); //开始 on_btn_start_released(); //开始
g_op_mode = false; //退出操作员模式 g_op_mode = false; //退出操作员模式
@ -1554,160 +1709,153 @@ void Cigarette::handleTimeout()
{ {
ui.label_plc->setText(QStringLiteral("PLC断开")); ui.label_plc->setText(QStringLiteral("PLC断开"));
ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);")); ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);"));
m_PLCDevice->g_plc_status&=~(0x01); m_PLCDevice->g_plc_status &= ~(0x01);
} }
} }
} //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
} // if (g_modbus_conf.kick1 > 0)
//剔除次数 // {
if (m_PLCDevice->g_plc_ok) // uint16_t dest16[2];
{ // int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick1, 2, dest16);
if (!g_plc_dialog_open) //PLC配置对话框没有打开 // if (ret == 2)
{ // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0) // ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick1 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick1, 2, dest16); // UDPSendInfo.index = 0;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 0; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick2 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick2, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1) // ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick2 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.kick2, 2, dest16); // UDPSendInfo.index = 1;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 1; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick3 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2) // ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick3 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16); // UDPSendInfo.index = 2;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 2; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick4 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3) // ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick4 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16); // UDPSendInfo.index = 3;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 3; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick5 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4) // ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick5 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16); // UDPSendInfo.index = 4;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 4; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick6 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5) // ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick6 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16); // UDPSendInfo.index = 5;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 5; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick7 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6) // ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick7 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16); // UDPSendInfo.index = 6;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 6; //#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16); // if (g_modbus_conf.kick8 > 0)
UDP_Info_queue->put(UDPSendInfo); // {
#endif // uint16_t dest16[2];
} // int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16);
} // if (ret == 2)
#endif // {
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7) // ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16));
if (g_modbus_conf.kick8 > 0) //#ifdef __UDPSend
{ // _UDPSendInfo UDPSendInfo;
uint16_t dest16[2]; // UDPSendInfo.FrameID = kick_frame;
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16); // UDPSendInfo.index = 7;
if (ret == 2) // UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
{ // UDP_Info_queue->put(UDPSendInfo);
ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16)); //#endif
#ifdef __UDPSend // }
_UDPSendInfo UDPSendInfo; // }
UDPSendInfo.FrameID = kick_frame; //#endif
UDPSendInfo.index = 7;
UDPSendInfo.Kick[UDPSendInfo.index] = dest16[0] + (dest16[1] << 16);
UDP_Info_queue->put(UDPSendInfo);
#endif
}
}
#endif
} }
} }
//相机掉线检测 //相机掉线检测
@ -3587,104 +3735,8 @@ void Cigarette::CleanThreadStartAuto()
handleThread->start(); handleThread->start();
} }
void Cigarette::record_output_statistic(qint64 quantity, int shift) void Cigarette::record_output_statistic(qint64 quantity, int Kick[NumberOfSupportedCameras], int shift)
{ {
float Kick[NumberOfSupportedCameras] = {0};
if (m_PLCDevice->g_plc_ok)
{
if (!g_plc_dialog_open) //PLC配置对话框没有打开
{
#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);
}
}
#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);
}
}
#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);
}
}
#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);
}
}
#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);
}
}
#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);
}
}
#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);
}
}
#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);
}
}
#endif
}
}
for (int i = 0; i < NumberOfSupportedCameras; i++) for (int i = 0; i < NumberOfSupportedCameras; i++)
{ {
if (SingleCamInfo[i].IsOpen && quantity > 0) { if (SingleCamInfo[i].IsOpen && quantity > 0) {
@ -3705,7 +3757,12 @@ void Cigarette::record_output_statistic(qint64 quantity, int shift)
cfg_file.write(buf, strlen(buf)); cfg_file.write(buf, strlen(buf));
} }
memset(buf, 0, 256); memset(buf, 0, 256);
sprintf(buf, "%c 总产量:%010I64d 剔除率:%02.5f%% 合格率:%02.5f%% \n", (shift == 0) ? 'A' : ((shift == 1) ? 'B' : 'C'), quantity, (Kick[i] / quantity) * 100, (1.0 - (Kick[i] / quantity)) * 100); double ng_rate;
if (ng[i] > 0)
ng_rate = double(ng[i]) / production_number[i];
else
ng_rate = 0;
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)); cfg_file.write(buf, strlen(buf));
memset(buf, 0, 256); memset(buf, 0, 256);

@ -161,7 +161,7 @@ public:
DebugThread debug_thread[NumberOfSupportedCameras]; DebugThread debug_thread[NumberOfSupportedCameras];
SaveThread saveThread; SaveThread saveThread;
void record_output_statistic(qint64 cur_quantity, int shift); void record_output_statistic(qint64 cur_quantity, int Kick[NumberOfSupportedCameras], int shift);
QTimer *m_pTimer; QTimer *m_pTimer;
QTimer *m_delay; //换班防止连击 QTimer *m_delay; //换班防止连击

Loading…
Cancel
Save