|
|
|
@ -192,6 +192,7 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
ng[i] = 0;
|
|
|
|
|
g_display_label_conf[i].g_last_mat[0] = cv::Mat::zeros(20, 20, CV_8UC3);
|
|
|
|
|
g_display_label_conf[i].g_last_mat[1] = cv::Mat::zeros(20, 20, CV_8UC3);
|
|
|
|
|
DrawRect_init(i);
|
|
|
|
|
}
|
|
|
|
|
ui.lcdNumber_total_no->display(0);
|
|
|
|
|
ui.lcdNumber_total_no_last->display(0);
|
|
|
|
@ -204,14 +205,38 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
read_sys_config(g_sys_conf); //初始化系统配置
|
|
|
|
|
|
|
|
|
|
g_modbus_conf.kick1 = 0;
|
|
|
|
|
g_modbus_conf.kick2 = 0;
|
|
|
|
|
g_modbus_conf.kick3 = 0;
|
|
|
|
|
g_modbus_conf.kick4 = 0;
|
|
|
|
|
g_modbus_conf.kick5 = 0;
|
|
|
|
|
g_modbus_conf.kick6 = 0;
|
|
|
|
|
g_modbus_conf.kick7 = 0;
|
|
|
|
|
g_modbus_conf.kick8 = 0;
|
|
|
|
|
//g_modbus_conf.kick1 = 0;
|
|
|
|
|
//g_modbus_conf.kick2 = 0;
|
|
|
|
|
//g_modbus_conf.kick3 = 0;
|
|
|
|
|
//g_modbus_conf.kick4 = 0;
|
|
|
|
|
//g_modbus_conf.kick5 = 0;
|
|
|
|
|
//g_modbus_conf.kick6 = 0;
|
|
|
|
|
//g_modbus_conf.kick7 = 0;
|
|
|
|
|
//g_modbus_conf.kick8 = 0;
|
|
|
|
|
#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; //1#通道剔除个数地址
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
|
|
|
|
g_modbus_conf.kick6 = 0; //2#通道剔除个数地址
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
|
|
|
|
g_modbus_conf.kick7 = 0; //3#通道剔除个数地址
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
|
|
|
|
g_modbus_conf.kick8 = 0; //4#通道剔除个数地址
|
|
|
|
|
#endif
|
|
|
|
|
g_modbus_conf.quantity = 0;
|
|
|
|
|
g_modbus_conf.shift = 0;
|
|
|
|
|
g_modbus_conf.work = 0;
|
|
|
|
@ -289,7 +314,7 @@ Cigarette::Cigarette(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
if(SingleCamInfo[i].Detect){
|
|
|
|
|
cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
|
|
|
|
|
if (!alg_jd[i].init(g_sys_conf.path_model,g_sys_conf.path_jpg))
|
|
|
|
|
if (!alg_jd[i].init(g_sys_conf.path_model,g_sys_conf.model_name))
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("系统自检失败"), QStringLiteral("AI模型1初始化失败,请检查程序完整性"), QMessageBox::Ok);
|
|
|
|
|
exit(-1);
|
|
|
|
@ -523,6 +548,7 @@ void Cigarette::on_btn_start_released()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_op_time = OP_TIME;
|
|
|
|
|
ui.checkBox_debug->setEnabled(true); //使能相机调试checkBox
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::pause_work()
|
|
|
|
@ -590,7 +616,7 @@ void Cigarette::Exit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//暂停按钮
|
|
|
|
|
//停止工作按钮
|
|
|
|
|
void Cigarette::on_btn_pause_released()
|
|
|
|
|
{
|
|
|
|
|
emit sengMsgToClog("Pause the application.");
|
|
|
|
@ -1001,6 +1027,48 @@ void Cigarette::OnDBClickHub(int Num_Cnt)
|
|
|
|
|
}
|
|
|
|
|
OnNotifyHub(Num,Cnt,g_display_label_conf[Num].g_last_mat[Cnt]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::DrawRect_init(int Num_Cnt) {
|
|
|
|
|
//int Num = Num_Cnt >> 4;
|
|
|
|
|
//int Cnt = Num_Cnt & 0x0f;
|
|
|
|
|
|
|
|
|
|
int Num = Num_Cnt & 0x0f;
|
|
|
|
|
int Cnt = Num_Cnt >> 4;
|
|
|
|
|
if (g_display_label_conf[Num].Flag[Cnt] & DisplayLabel_Type_Bit)
|
|
|
|
|
{
|
|
|
|
|
g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Type_Bit;
|
|
|
|
|
g_display_label_conf[Num].Flag[Cnt] &= ~DisplayLabel_Conf_Bit;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
g_display_label_conf[Num].Flag[Cnt] |= DisplayLabel_Type_Bit;
|
|
|
|
|
std::fstream cfg_file;
|
|
|
|
|
char buf[256];
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, SELECT_RECTS_FILE, Num, Cnt);
|
|
|
|
|
cfg_file.open(buf);
|
|
|
|
|
if (!cfg_file.is_open())
|
|
|
|
|
{
|
|
|
|
|
std::cout << "Error: Open config file SelectRects.txt" << std::endl;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
while (!cfg_file.eof())
|
|
|
|
|
{
|
|
|
|
|
char tmp[256] = "";
|
|
|
|
|
cfg_file.getline(tmp, 256);
|
|
|
|
|
QString line = QString::fromStdString(std::string(tmp));
|
|
|
|
|
QStringList dataList = line.split(',');
|
|
|
|
|
if (dataList.length() == 4)
|
|
|
|
|
{
|
|
|
|
|
RectRatio m_RectRatio = RectRatio(
|
|
|
|
|
cv::Point2f(dataList[0].toFloat(), dataList[1].toFloat()),
|
|
|
|
|
cv::Point2f(dataList[2].toFloat(), dataList[3].toFloat())
|
|
|
|
|
);
|
|
|
|
|
g_display_label_conf[Num].RectVet[Cnt].push_back(m_RectRatio);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::OnTPClickHub(int Num_Cnt)
|
|
|
|
|
{
|
|
|
|
|
int Num = Num_Cnt >> 4;
|
|
|
|
@ -1205,8 +1273,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (g_working)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘暂停工作’按钮,才能进入调试模式"), QMessageBox::Ok);
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("操作顺序检查 "), QStringLiteral("请先点击‘停止工作’按钮,才能进入调试模式"), QMessageBox::Ok);
|
|
|
|
|
ui.checkBox_debug->setChecked(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1222,8 +1291,9 @@ void Cigarette::on_checkBox_debug_clicked(bool checked)
|
|
|
|
|
{
|
|
|
|
|
emit sengMsgToClog("Exit debug mode.");
|
|
|
|
|
DisableDebugMode();
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
//on_pushButton_clear_released(); //换班
|
|
|
|
|
ui.checkBox_debug->setChecked(false);
|
|
|
|
|
ui.checkBox_debug->setEnabled(true);
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
sThread.sendData("DebugDis", g_sys_conf.FeedbackPort);
|
|
|
|
|
#endif
|
|
|
|
@ -1351,7 +1421,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (quantity_stop_count == STOP_SECONDS) //触发一次换班
|
|
|
|
|
{
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
on_btn_pause_released(); //暂停
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
|
g_op_mode = false; //退出操作员模式
|
|
|
|
@ -1367,7 +1437,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (secA == 0)
|
|
|
|
|
{
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
on_btn_pause_released(); //暂停
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
record_output_statistic(cur_quantity, 0);
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
@ -1376,7 +1446,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
else if (secB == 0)
|
|
|
|
|
{
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
on_btn_pause_released(); //暂停
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
record_output_statistic(cur_quantity, 1);
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
@ -1385,7 +1455,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
else if (secC == 0)
|
|
|
|
|
{
|
|
|
|
|
g_op_mode = true; //激活操作员模式
|
|
|
|
|
on_btn_pause_released(); //暂停
|
|
|
|
|
on_btn_pause_released(); //停止工作
|
|
|
|
|
record_output_statistic(cur_quantity, 2);
|
|
|
|
|
on_pushButton_clear_released(); //换班
|
|
|
|
|
on_btn_start_released(); //开始
|
|
|
|
@ -1554,6 +1624,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//相机掉线检测
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>0)
|
|
|
|
|
if (SingleCamInfo[0].OffLine) //1#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[0] = false;
|
|
|
|
@ -1568,6 +1639,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[0].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>1)
|
|
|
|
|
if (SingleCamInfo[1].OffLine) //2#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[1] = false;
|
|
|
|
@ -1582,6 +1655,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if(ret > 0) SingleCamInfo[1].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>2)
|
|
|
|
|
if (SingleCamInfo[2].OffLine) //3#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[2] = false;
|
|
|
|
@ -1596,7 +1671,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[2].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>3)
|
|
|
|
|
if (SingleCamInfo[3].OffLine) //4#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[3] = false;
|
|
|
|
@ -1611,6 +1687,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[3].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>4)
|
|
|
|
|
if (SingleCamInfo[4].OffLine) //5#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[4] = false;
|
|
|
|
@ -1625,6 +1703,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[4].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>5)
|
|
|
|
|
if (SingleCamInfo[5].OffLine) //6#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[5] = false;
|
|
|
|
@ -1639,6 +1719,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[5].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>6)
|
|
|
|
|
if (SingleCamInfo[6].OffLine) //7#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[6] = false;
|
|
|
|
@ -1653,6 +1735,8 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[6].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(NumberOfSupportedCameras) && (NumberOfSupportedCameras>7)
|
|
|
|
|
if (SingleCamInfo[7].OffLine) //8#相机掉线
|
|
|
|
|
{
|
|
|
|
|
//SingleCamInfo[7] = false;
|
|
|
|
@ -1667,6 +1751,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
if (ret > 0) SingleCamInfo[7].OffLine = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//读取报警信息
|
|
|
|
|
if (m_PLCDevice->g_plc_ok)
|
|
|
|
@ -1691,7 +1776,12 @@ void Cigarette::handleTimeout()
|
|
|
|
|
{
|
|
|
|
|
g_vec_alarm.push_back(alarm_info);
|
|
|
|
|
g_last_alarm_code = alarm_info.alarm_code;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (g_vec_alarm.empty()) {
|
|
|
|
|
g_vec_alarm.push_back(alarm_info);
|
|
|
|
|
g_last_alarm_code = alarm_info.alarm_code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (alarm_info.alarm_code == 0) {
|
|
|
|
@ -1735,7 +1825,7 @@ void Cigarette::handleTimeout()
|
|
|
|
|
void Cigarette::on_pushButton_reset_released()///复位按钮
|
|
|
|
|
{
|
|
|
|
|
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 1);
|
|
|
|
|
Sleep(1000);
|
|
|
|
|
//Sleep(1000);
|
|
|
|
|
if (g_modbus_conf.reset > 0)
|
|
|
|
|
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.reset, 0);
|
|
|
|
|
}
|
|
|
|
@ -1818,7 +1908,7 @@ void Cigarette::on_pushButton_clear_released()//
|
|
|
|
|
}
|
|
|
|
|
if(g_working)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“暂停工作”按钮,进入暂停模式,才可以进行换班操作 "), QMessageBox::Ok);
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("状态检查"), QStringLiteral("请先点击“停止工作”按钮,才可以进行换班操作 "), QMessageBox::Ok);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ui.pushButton_clear->setEnabled(false);
|
|
|
|
@ -1872,7 +1962,7 @@ void Cigarette::on_pushButton_clear_released()//
|
|
|
|
|
{
|
|
|
|
|
uint16_t dest16[2];
|
|
|
|
|
int ret = m_PLCDevice->read_short_from_plc( g_modbus_conf.quantity, 2, dest16);
|
|
|
|
|
std::cout << ret << std::endl;
|
|
|
|
|
//std::cout << ret << std::endl;
|
|
|
|
|
if (ret > 0)
|
|
|
|
|
{
|
|
|
|
|
int cur_quantity = dest16[0] + (dest16[1] << 16);
|
|
|
|
@ -1901,7 +1991,7 @@ void Cigarette::on_pushButton_clear_released()//
|
|
|
|
|
QString Cigarette::read_pswd()
|
|
|
|
|
{
|
|
|
|
|
std::fstream cfg_file;
|
|
|
|
|
cfg_file.open("pswd.txt");
|
|
|
|
|
cfg_file.open("D:/Release/pswd.txt");
|
|
|
|
|
if (!cfg_file.is_open())
|
|
|
|
|
{
|
|
|
|
|
std::cout << "Error: Open config file pswd.txt"<< std::endl;
|
|
|
|
@ -1933,7 +2023,7 @@ QString Cigarette::read_pswd()
|
|
|
|
|
QString Cigarette::read_op_pswd()
|
|
|
|
|
{
|
|
|
|
|
std::fstream cfg_file;
|
|
|
|
|
cfg_file.open("pswd_op.txt");
|
|
|
|
|
cfg_file.open("D:/Release/pswd_op.txt");
|
|
|
|
|
if (!cfg_file.is_open())
|
|
|
|
|
{
|
|
|
|
|
std::cout << "Error: Open config file pswd_op.txt" << std::endl;
|
|
|
|
@ -2057,6 +2147,10 @@ bool Cigarette::read_sys_config(SysConf &conf)
|
|
|
|
|
{
|
|
|
|
|
conf.path_model = line.substr(pos + 1).c_str();
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "MODELNAME")
|
|
|
|
|
{
|
|
|
|
|
conf.model_name = line.substr(pos + 1).c_str();
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "JPGPATH")
|
|
|
|
|
{
|
|
|
|
|
conf.path_jpg = line.substr(pos + 1).c_str();
|
|
|
|
|