|
|
@ -1454,116 +1454,16 @@ 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)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint16_t dest16[2];
|
|
|
|
// 读取剔除值
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16);
|
|
|
|
|
|
|
|
if (ret == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int cur_quantity = dest16[0] + (dest16[1] << 16);
|
|
|
|
|
|
|
|
ui.lcdNumber_total_no->display(cur_quantity);
|
|
|
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
|
|
|
sThread.sendData("total_" + QString::number(cur_quantity), g_sys_conf.FeedbackPort);
|
|
|
|
|
|
|
|
sThread.sendData("totallast_" + QString::number(ui.lcdNumber_total_no_last->intValue()), g_sys_conf.FeedbackPort);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ui.label_plc->setText(QStringLiteral("PLC在线"));
|
|
|
|
|
|
|
|
ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
|
|
|
|
|
|
|
|
if(!(m_PLCDevice->g_plc_status&0x01))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
init_plc_value();
|
|
|
|
|
|
|
|
if(g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_debug_mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("操作顺序检查"), QStringLiteral("请先点击“调试模式”复选框,取消调试模式,才可以开始工作"), QMessageBox::Ok);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
start_work();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pause_work();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_PLCDevice->g_plc_status|=(0x01);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//自动换班
|
|
|
|
|
|
|
|
if (g_sys_conf.auto_shift&&g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_seconds++;
|
|
|
|
|
|
|
|
if (g_seconds % 10 == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cur_quantity == g_lst_quantiy)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
quantity_stop_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
quantity_stop_count = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quantity_stop_count == STOP_SECONDS) //触发一次换班
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_lst_quantiy = cur_quantity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (g_sys_conf.timing_shift && g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qint64 secA = time.secsTo(g_sys_conf.shiftA);
|
|
|
|
|
|
|
|
qint64 secB = time.secsTo(g_sys_conf.shiftB);
|
|
|
|
|
|
|
|
qint64 secC = time.secsTo(g_sys_conf.shiftC);
|
|
|
|
|
|
|
|
if (secA == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, 0);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (secB == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, 1);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (secC == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, 2);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui.label_plc->setText(QStringLiteral("PLC断开"));
|
|
|
|
|
|
|
|
ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);"));
|
|
|
|
|
|
|
|
m_PLCDevice->g_plc_status&=~(0x01);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//剔除次数
|
|
|
|
|
|
|
|
if (m_PLCDevice->g_plc_ok)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!g_plc_dialog_open) //PLC配置对话框没有打开
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
|
|
if (g_modbus_conf.kick1 > 0)
|
|
|
|
if (g_modbus_conf.kick1 > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1571,6 +1471,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick1, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick1, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[0] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_1->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1589,6 +1490,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick2, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick2, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[1] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_2->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1607,6 +1509,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick3, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[2] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_3->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1625,6 +1528,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick4, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[3] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_4->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1643,6 +1547,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick5, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[4] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_5->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1661,6 +1566,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick6, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[5] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_6->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1679,6 +1585,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick7, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[6] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_7->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1697,6 +1604,7 @@ void Cigarette::handleTimeout()
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16);
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.kick8, 2, dest16);
|
|
|
|
if (ret == 2)
|
|
|
|
if (ret == 2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
Kick[7] = dest16[0] + (dest16[1] << 16);
|
|
|
|
ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
ui.lcdNumber_kick_8->display(dest16[0] + (dest16[1] << 16));
|
|
|
|
#ifdef __UDPSend
|
|
|
|
#ifdef __UDPSend
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
|
_UDPSendInfo UDPSendInfo;
|
|
|
@ -1708,6 +1616,246 @@ void Cigarette::handleTimeout()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 读取产量值
|
|
|
|
|
|
|
|
uint16_t dest16[2];
|
|
|
|
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc(g_modbus_conf.quantity, 2, dest16);
|
|
|
|
|
|
|
|
if (ret == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int cur_quantity = dest16[0] + (dest16[1] << 16);
|
|
|
|
|
|
|
|
ui.lcdNumber_total_no->display(cur_quantity);
|
|
|
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
|
|
|
sThread.sendData("total_" + QString::number(cur_quantity), g_sys_conf.FeedbackPort);
|
|
|
|
|
|
|
|
sThread.sendData("totallast_" + QString::number(ui.lcdNumber_total_no_last->intValue()), g_sys_conf.FeedbackPort);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ui.label_plc->setText(QStringLiteral("PLC在线"));
|
|
|
|
|
|
|
|
ui.label_plc->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
|
|
|
|
|
|
|
|
if (!(m_PLCDevice->g_plc_status & 0x01))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
init_plc_value();
|
|
|
|
|
|
|
|
if (g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (g_debug_mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("操作顺序检查"), QStringLiteral("请先点击“调试模式”复选框,取消调试模式,才可以开始工作"), QMessageBox::Ok);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
start_work();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pause_work();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_PLCDevice->g_plc_status |= (0x01);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//自动换班
|
|
|
|
|
|
|
|
if (g_sys_conf.auto_shift && g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_seconds++;
|
|
|
|
|
|
|
|
if (g_seconds % 10 == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cur_quantity == g_lst_quantiy)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
quantity_stop_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
quantity_stop_count = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quantity_stop_count == STOP_SECONDS) //触发一次换班
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_lst_quantiy = cur_quantity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (g_sys_conf.timing_shift && g_working)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qint64 secA = time.secsTo(g_sys_conf.shiftA);
|
|
|
|
|
|
|
|
qint64 secB = time.secsTo(g_sys_conf.shiftB);
|
|
|
|
|
|
|
|
qint64 secC = time.secsTo(g_sys_conf.shiftC);
|
|
|
|
|
|
|
|
if (secA == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, Kick, 0);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (secB == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, Kick, 1);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (secC == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
|
|
|
record_output_statistic(cur_quantity, Kick, 2);
|
|
|
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui.label_plc->setText(QStringLiteral("PLC断开"));
|
|
|
|
|
|
|
|
ui.label_plc->setStyleSheet(tr("background-color: rgb(255, 255, 0);"));
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//相机掉线检测
|
|
|
|
//相机掉线检测
|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|
|
|