|
|
|
@ -67,6 +67,7 @@ SyncQueue<_UDPSendInfo>* UDP_Info_queue;
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef __TCPSend
|
|
|
|
|
SyncQueue<_TCPSendInfo>* TCP_Info_queue;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
bool flag = false;
|
|
|
|
|
SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
|
|
|
|
@ -113,7 +114,7 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
InitPtrMat();
|
|
|
|
|
read_conf(g_conf_path);
|
|
|
|
|
|
|
|
|
|
if (!g_conf_path.config_path.isEmpty()) {
|
|
|
|
|
if (!g_conf_path.config_path.isEmpty()) {//判断conf路径是否存在, 空 isEmpty=1,不空 isEmpty=0
|
|
|
|
|
// 如果非空
|
|
|
|
|
QDir* dirinfo = new QDir(g_conf_path.config_path);
|
|
|
|
|
if (!dirinfo->exists()) {
|
|
|
|
@ -127,30 +128,33 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
g_conf_path.config_path = "D:/conf";
|
|
|
|
|
|
|
|
|
|
bool update_rotate = false;
|
|
|
|
|
if (!read_rotate_message()) {
|
|
|
|
|
if (!read_rotate_message()) {//读取旋转参数
|
|
|
|
|
update_rotate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QThread* hThread = new QThread();
|
|
|
|
|
CLog* clogWorkThread = new CLog();
|
|
|
|
|
clogWorkThread->moveToThread(hThread);
|
|
|
|
|
connect(this, &Cigarette::destroyed, hThread, &QThread::quit);
|
|
|
|
|
connect(hThread, &QThread::finished, clogWorkThread, &CLog::deleteLater);
|
|
|
|
|
connect(this, &Cigarette::sengMsgToClog, clogWorkThread, &CLog::recMegFromCigarette);
|
|
|
|
|
QThread* hThread = new QThread();//主线程
|
|
|
|
|
CLog* clogWorkThread = new CLog();//日志线程
|
|
|
|
|
clogWorkThread->moveToThread(hThread);//将日志线程依附到主线程(相当于父类)
|
|
|
|
|
connect(this, &Cigarette::destroyed, hThread, &QThread::quit);//Cigarette退出系统了,或这个类崩溃了;清除Qt所有线程
|
|
|
|
|
connect(hThread, &QThread::finished, clogWorkThread, &CLog::deleteLater);//Qt类结束,清除日志类
|
|
|
|
|
connect(this, &Cigarette::sengMsgToClog, clogWorkThread, &CLog::recMegFromCigarette);// sengMsgToClog 写日志的信号,recMegFromCigarette 写日志操作
|
|
|
|
|
hThread->start();
|
|
|
|
|
|
|
|
|
|
emit sengMsgToClog("Application Start.");
|
|
|
|
|
|
|
|
|
|
//初始化队列
|
|
|
|
|
//保存队列
|
|
|
|
|
g_save_queue = new SyncQueue<std::pair<std::string, cv::Mat>>(Queue_Size);
|
|
|
|
|
g_save_queue->name = "save queue";
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
|
UDP_Info_queue = new SyncQueue<_UDPSendInfo>(Queue_Size);
|
|
|
|
|
UDP_Info_queue->name = "UDP Info queue";
|
|
|
|
|
#endif
|
|
|
|
|
//TCP队列
|
|
|
|
|
#ifdef __TCPSend
|
|
|
|
|
TCP_Info_queue = new SyncQueue<_TCPSendInfo>(Queue_Size);
|
|
|
|
|
TCP_Info_queue->name = "TCP Info queue";
|
|
|
|
|
#endif
|
|
|
|
|
//FTP数据队列
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
export_XMLData_Info_queue = new SyncQueue<_XMLExportDataInfo>(Queue_Size);
|
|
|
|
|
export_XMLData_Info_queue->name = "Export Data Info queue";
|
|
|
|
@ -158,6 +162,7 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
last_shift = 256;
|
|
|
|
|
work_camera_nums = 0;
|
|
|
|
|
|
|
|
|
|
//相机公共队列(合成图片)
|
|
|
|
|
#ifdef SYNC_CAMERA
|
|
|
|
|
g_image_sync_queue = new SyncQueue<std::vector<std::pair<int, cv::Mat>>>(Queue_Size);
|
|
|
|
|
g_image_sync_queue->name = format("sync_image");
|
|
|
|
@ -165,20 +170,26 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
#ifndef SYNC_CAMERA
|
|
|
|
|
//相机单独队列
|
|
|
|
|
g_image_queue[i] = new SyncQueue<std::pair<int, cv::Mat> >(Queue_Size);
|
|
|
|
|
g_image_queue[i]->name = format("image_%d", i);
|
|
|
|
|
#endif
|
|
|
|
|
//结果队列
|
|
|
|
|
g_result_queue[i] = new ASyncQueue<bool>(Queue_Size);
|
|
|
|
|
g_result_queue[i]->name = format("result_%d", i);
|
|
|
|
|
//结果延后队列
|
|
|
|
|
g_result_wait_queue[i] = new ASyncQueue<bool>(Queue_Size);
|
|
|
|
|
g_result_wait_queue[i]->name = format("result_wait%d", i);
|
|
|
|
|
//两个结果队列
|
|
|
|
|
g_double_queue[i] = new ASyncQueue<bool>(Queue_Size);
|
|
|
|
|
g_double_queue[i]->name = format("double_wait%d", i);
|
|
|
|
|
//拍照队列
|
|
|
|
|
g_shooted_queue[i] = new ASyncQueue<bool>(Queue_Size);
|
|
|
|
|
g_shooted_queue[i]->name = format("shooted_%d", i);
|
|
|
|
|
//调试队列
|
|
|
|
|
g_debug_queue[i] = new SyncQueue<cv::Mat>(Queue_Size);
|
|
|
|
|
g_debug_queue[i]->name = format("debug_%d", i);
|
|
|
|
|
if (update_rotate) {
|
|
|
|
|
if (update_rotate) {//未读到旋转参数,进行初始化
|
|
|
|
|
rotationAngle[i] = cv::ROTATE_90_COUNTERCLOCKWISE + 1;
|
|
|
|
|
isNeedRotate[i] = false;
|
|
|
|
|
}
|
|
|
|
@ -196,7 +207,7 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
g_op_time = OP_TIME;
|
|
|
|
|
g_op_pswd = read_op_pswd();
|
|
|
|
|
|
|
|
|
|
g_working = false;
|
|
|
|
|
g_working = false;//调试标志
|
|
|
|
|
g_debug_mode = false;
|
|
|
|
|
|
|
|
|
|
g_alarm_msg << QStringLiteral("无报警") /// 0
|
|
|
|
@ -219,14 +230,14 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
g_display_label_conf[i].g_max[0] = false;
|
|
|
|
|
g_display_label_conf[i].g_max[0] = false;//视图最大化
|
|
|
|
|
g_display_label_conf[i].g_max[1] = false;
|
|
|
|
|
OpenWithUserID[i] = 0xff;
|
|
|
|
|
production_number[i] = 0;
|
|
|
|
|
lcdNumber_total_mat[i]->display(production_number[i]);
|
|
|
|
|
OpenWithUserID[i] = 0xff;//没用
|
|
|
|
|
production_number[i] = 0;//检测个数
|
|
|
|
|
lcdNumber_total_mat[i]->display(production_number[i]);//display 显示到界面
|
|
|
|
|
ok[i] = 0;
|
|
|
|
|
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[0] = cv::Mat::zeros(20, 20, CV_8UC3);//放大后的图片
|
|
|
|
|
g_display_label_conf[i].g_last_mat[1] = cv::Mat::zeros(20, 20, CV_8UC3);
|
|
|
|
|
#ifdef DRAW_RECT
|
|
|
|
|
DrawRect_init(i);
|
|
|
|
@ -259,7 +270,7 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
read_modbus_config(g_modbus_conf); //初始化modbus地址
|
|
|
|
|
|
|
|
|
|
//保存图片线程
|
|
|
|
|
saveThread.init();
|
|
|
|
|
saveThread.init();//初始化
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
connect(&saveThread, &SaveThread::sendDataToExport, &exportDataThread, &ExportDataThread::GetDataFromSaveThread);
|
|
|
|
|
#endif
|
|
|
|
@ -273,20 +284,26 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
connect(rThread, &threadReceive::sendMsgToCigratte, this, &Cigarette::recMsgFromUdp);
|
|
|
|
|
rThread->start_work();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//初始化TCP数据传输线程
|
|
|
|
|
#ifdef __TCPSend
|
|
|
|
|
std::string serverIp = g_sys_conf.TcpIP;
|
|
|
|
|
int serverPort = g_sys_conf.TcpPort;
|
|
|
|
|
tcpSendThread.init(TCP_Info_queue, serverIp, serverPort);
|
|
|
|
|
tcpSendThread.start_work();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
exportDataThread.init();
|
|
|
|
|
#endif
|
|
|
|
|
//初始化FTP数据传输线程
|
|
|
|
|
#ifdef __ExportData
|
|
|
|
|
string ftpip = g_sys_conf.FtpIP;
|
|
|
|
|
int ftpport = g_sys_conf.FtpPort;
|
|
|
|
|
string ftpusername = g_sys_conf.FtpUserName;
|
|
|
|
|
string ftpuserpwd = g_sys_conf.FtpUserPwd;
|
|
|
|
|
exportDataThread.init(ftpip,ftpport,ftpusername,ftpuserpwd);
|
|
|
|
|
connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette);
|
|
|
|
|
exportDataThread.start_work();
|
|
|
|
|
//connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//初始化通讯PLC
|
|
|
|
|
m_PLCDevice = new PLCDevice;
|
|
|
|
|
PLCDevice::init_plc(m_PLCDevice);
|
|
|
|
|
if (m_PLCDevice->g_plc_ok)
|
|
|
|
@ -315,21 +332,22 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
}
|
|
|
|
|
std::cout << " Enumerate Cameras..." << std::endl;
|
|
|
|
|
|
|
|
|
|
EnumerateCameras((SingleCamInfoStruct*)&SingleCamInfo, true, g_sys_conf);
|
|
|
|
|
EnumerateCameras((SingleCamInfoStruct*)&SingleCamInfo, true, g_sys_conf);//枚举相机
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 剔除值清0
|
|
|
|
|
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.shift, 1);//给PLC发送换班消息
|
|
|
|
|
|
|
|
|
|
#ifdef SYNC_CAMERA
|
|
|
|
|
CreatWorkThread(0, 0, this);
|
|
|
|
|
CreatWorkThread(0, 0, this);//创建相机公共工作线程
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//创建相机工作线程
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
if (SingleCamInfo[i].Detect) {
|
|
|
|
|
work_camera_nums++;
|
|
|
|
|
//读取模型文件
|
|
|
|
|
if (SingleCamInfo[i].Detect) {//检测相机是否存在
|
|
|
|
|
work_camera_nums++;//相机数量
|
|
|
|
|
cam_status_mat[i]->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
|
|
|
|
|
QString model_path, model_name;
|
|
|
|
|
if (g_sys_conf.model_path.isEmpty()) {
|
|
|
|
@ -352,14 +370,15 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
exit(-1);
|
|
|
|
|
}
|
|
|
|
|
#ifdef SYNC_CAMERA
|
|
|
|
|
//调试模式线程
|
|
|
|
|
debug_thread[i].init(g_debug_queue[i], i);
|
|
|
|
|
connect(&debug_thread[i], SIGNAL(notify(int, int, cv::Mat)), this, SLOT(OnNotifyHub(int, int, cv::Mat)));
|
|
|
|
|
debug_thread[i].start_work();
|
|
|
|
|
#else
|
|
|
|
|
CreatWorkThread(SingleCamInfo[i].CamClass, i, this);
|
|
|
|
|
CreatWorkThread(SingleCamInfo[i].CamClass, i, this);//创建相机单独工作线程
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
else {//报警信息
|
|
|
|
|
QDateTime ts_start = QDateTime::currentDateTime();
|
|
|
|
|
QTime time = QTime::currentTime();
|
|
|
|
|
QDateTime local(ts_start);
|
|
|
|
@ -428,9 +447,9 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
sThread.sendData("LockOk", g_sys_conf.FeedbackPort);
|
|
|
|
|
#endif
|
|
|
|
|
DisableDebugMode();
|
|
|
|
|
|
|
|
|
|
//读取PLC信息等
|
|
|
|
|
m_pTimer = new QTimer(this);
|
|
|
|
|
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
|
|
|
|
|
connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));//SIGNAL(timeout())周期性,触发SLOT(handleTimeout());周期为start(1000);
|
|
|
|
|
m_pTimer->start(1000);
|
|
|
|
|
|
|
|
|
|
m_delay = new QTimer(this);//换班防连击
|
|
|
|
@ -440,19 +459,23 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
m_sendMsg_delay = new QTimer(this);
|
|
|
|
|
connect(m_sendMsg_delay, SIGNAL(timeout()), this, SLOT(sendLatestData()));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//SIGNAL信号函数与SLOT槽函数,参数必须对应
|
|
|
|
|
//无参信号对应无参槽函数
|
|
|
|
|
//检查操作员时间
|
|
|
|
|
m_op_delay = new QTimer(this);
|
|
|
|
|
connect(m_op_delay, SIGNAL(timeout()), this, SLOT(op_timeout()));
|
|
|
|
|
|
|
|
|
|
//检查管理员时间
|
|
|
|
|
m_admin_delay = new QTimer(this);
|
|
|
|
|
connect(m_admin_delay, SIGNAL(timeout()), this, SLOT(admin_timeout()));
|
|
|
|
|
|
|
|
|
|
//定时自动清理照片
|
|
|
|
|
clean_pTimer = new QTimer(this);
|
|
|
|
|
connect(clean_pTimer, SIGNAL(timeout()), this, SLOT(CleanThreadStartAuto()));
|
|
|
|
|
clean_pTimer->start(3600000);
|
|
|
|
|
//报警标签双击消警
|
|
|
|
|
connect(ui.label_alarm, SIGNAL(QlabelDoubleClick()), this, SLOT(OnCancelAlarm()));//
|
|
|
|
|
|
|
|
|
|
connect(ui.label_alarm, SIGNAL(QlabelDoubleClick()), this, SLOT(OnCancelAlarm()));//报警标签双击消警
|
|
|
|
|
|
|
|
|
|
//无参对有参需要利用信号转发器QSignalMapper(this)
|
|
|
|
|
//信号转发器
|
|
|
|
|
image_lable_DBsignalMapper0 = new QSignalMapper(this);
|
|
|
|
|
image_lable_DBsignalMapper1 = new QSignalMapper(this);
|
|
|
|
|
image_lable_TPsignalMapper0 = new QSignalMapper(this);
|
|
|
|
@ -461,11 +484,14 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
pTimer_Cam_signalMapper = new QSignalMapper(this);
|
|
|
|
|
toolButton_cam_signalMapper = new QSignalMapper(this);
|
|
|
|
|
RotateReleased_signalMapper = new QSignalMapper(this);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
//SIGNAL信号函数与SLOT槽函数,参数必须对应
|
|
|
|
|
|
|
|
|
|
m_pTimer_Cam_mat[i] = new QTimer(this);
|
|
|
|
|
connect(m_pTimer_Cam_mat[i], SIGNAL(timeout()), pTimer_Cam_signalMapper, SLOT(map()));
|
|
|
|
|
pTimer_Cam_signalMapper->setMapping(m_pTimer_Cam_mat[i], i);
|
|
|
|
|
pTimer_Cam_signalMapper->setMapping(m_pTimer_Cam_mat[i], i);//此句执行后map()=>mapped(int);相当于无参变有参
|
|
|
|
|
|
|
|
|
|
connect(display_lable_mat[i][0], SIGNAL(QlabelDoubleClick()), image_lable_DBsignalMapper0, SLOT(map()));
|
|
|
|
|
image_lable_DBsignalMapper0->setMapping(display_lable_mat[i][0], i << 4 | 0);
|
|
|
|
@ -489,6 +515,8 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
RotateReleased_signalMapper->setMapping(rotate_mat[i], i);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//SIGNAL信号函数与SLOT槽函数,参数必须对应
|
|
|
|
|
//有参对有参
|
|
|
|
|
connect(toolButton_cam_signalMapper, SIGNAL(mapped(int)), this, SLOT(OnToolButtonCamReleasedHub(int)));
|
|
|
|
|
//connect(pTimer_Cam_signalMapper, SIGNAL(mapped(int)), this, SLOT(OpenCamTimeoutHub(int)));
|
|
|
|
|
connect(image_lable_DBsignalMapper0, SIGNAL(mapped(int)), this, SLOT(OnDBClickHub(int)));
|
|
|
|
@ -531,7 +559,7 @@ Cigarette::Cigarette(QWidget* parent)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_PLCDevice->g_plc_ok) {
|
|
|
|
|
BeforeWork(g_sys_conf.shoot);
|
|
|
|
|
BeforeWork(g_sys_conf.shoot);//预热
|
|
|
|
|
int ret = m_PLCDevice->write_bit_2_plc(g_modbus_conf.work, 1);
|
|
|
|
|
ui.label_title->setStyleSheet(tr("background-color: rgb(0, 170, 0);"));
|
|
|
|
|
#ifdef __UDPSend
|
|
|
|
@ -994,7 +1022,7 @@ void Cigarette::OnToolButtonCamReleasedHub(int Num)
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("权限检查"), QStringLiteral("请先点击解锁按钮,进入管理员模式"), QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//重连相机
|
|
|
|
|
void Cigarette::ReconnectCamHub(int Num)
|
|
|
|
|
{
|
|
|
|
|
//close
|
|
|
|
@ -1007,7 +1035,6 @@ void Cigarette::ReconnectCamHub(int Num)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::OpenCamTimeoutHub(int Num) //重新打开相机
|
|
|
|
|
{
|
|
|
|
|
//open
|
|
|
|
@ -1024,14 +1051,14 @@ void Cigarette::OnKey(QKeyEvent* event)
|
|
|
|
|
int Cnt = CurOpLabel & 0x0f;
|
|
|
|
|
|
|
|
|
|
std::lock_guard<std::mutex> locker(g_display_label_conf[Num].lock);
|
|
|
|
|
if (event->key() == Qt::Key_Escape && event->isAutoRepeat() == false)
|
|
|
|
|
if (event->key() == Qt::Key_Escape && event->isAutoRepeat() == false)//画框Esc清除参数
|
|
|
|
|
{
|
|
|
|
|
if (g_display_label_conf[Num].RectVet[Cnt].size())
|
|
|
|
|
{
|
|
|
|
|
g_display_label_conf[Num].RectVet[Cnt].pop_back();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (event->key() == Qt::Key_Return && event->isAutoRepeat() == false)
|
|
|
|
|
else if (event->key() == Qt::Key_Return && event->isAutoRepeat() == false)//画框回车保存参数
|
|
|
|
|
{
|
|
|
|
|
std::fstream cfg_file;
|
|
|
|
|
char buf[256];
|
|
|
|
@ -1537,7 +1564,7 @@ void Cigarette::admin_timeout()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Cigarette::handleTimeout()
|
|
|
|
|
void Cigarette::handleTimeout()//获取时间,读取PLC产量、剔除数;检测相机状态;读取PLC报警信息
|
|
|
|
|
{
|
|
|
|
|
QDateTime ts_start = QDateTime::currentDateTime();
|
|
|
|
|
QTime time = QTime::currentTime();
|
|
|
|
@ -2044,8 +2071,8 @@ void Cigarette::on_pushButton_clear_released()//换班
|
|
|
|
|
g_op_time = OP_TIME;
|
|
|
|
|
|
|
|
|
|
ui.pushButton_clear->setEnabled(false);
|
|
|
|
|
m_delay->setSingleShot(true);
|
|
|
|
|
m_delay->start(5000);
|
|
|
|
|
m_delay->setSingleShot(true);//执行一次
|
|
|
|
|
m_delay->start(5000);//5秒
|
|
|
|
|
Sleep(500);
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
|
{
|
|
|
|
@ -2150,15 +2177,15 @@ QString Cigarette::read_op_pswd()
|
|
|
|
|
bool Cigarette::read_conf(ConfPath& conf_path) {
|
|
|
|
|
std::fstream conf_file;
|
|
|
|
|
conf_file.open(CONFPATH);
|
|
|
|
|
if (!conf_file.is_open()) {
|
|
|
|
|
if (!conf_file.is_open()) {//判断能否打开文件
|
|
|
|
|
std::cout << "Error: Open conf path file " << CONFPATH << std::endl;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
while (!conf_file.eof()) {
|
|
|
|
|
while (!conf_file.eof()) {//从头读到尾,完成后conf_file.eof()==TRUE
|
|
|
|
|
char tmp[256] = "";
|
|
|
|
|
conf_file.getline(tmp, 256);
|
|
|
|
|
std::string line(tmp);
|
|
|
|
|
if (line.length() > 0) {
|
|
|
|
|
if (line.length() > 0) {//按行读取
|
|
|
|
|
size_t pos = line.find('=');
|
|
|
|
|
std::string tmp_key = line.substr(0, pos);
|
|
|
|
|
if (tmp_key == "CONF_PATH") {
|
|
|
|
@ -2566,6 +2593,22 @@ bool Cigarette::read_sys_config(SysConf& conf, QString conf_path)
|
|
|
|
|
{
|
|
|
|
|
conf.TcpPort = atoi(line.substr(pos + 1).c_str());
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "FtpIP")
|
|
|
|
|
{
|
|
|
|
|
conf.FtpIP = line.substr(pos + 1);
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "FtpPort")
|
|
|
|
|
{
|
|
|
|
|
conf.FtpPort = atoi(line.substr(pos + 1).c_str());
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "FtpUserName")
|
|
|
|
|
{
|
|
|
|
|
conf.FtpUserName= line.substr(pos + 1);
|
|
|
|
|
}
|
|
|
|
|
else if (tmp_key == "FtpUserPwd")
|
|
|
|
|
{
|
|
|
|
|
conf.FtpUserPwd = line.substr(pos + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3127,11 +3170,11 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
else if (SingleCamInfo[Num].CamClass == HIKClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "open for hik";
|
|
|
|
|
int nRet = MV_OK;
|
|
|
|
|
int nRet = MV_OK;//海康内部定义MV_OK = 0x0000000;
|
|
|
|
|
void* camhandle;
|
|
|
|
|
nRet = MV_CC_CreateHandle(&camhandle, HIKCamera::stDeviceList.pDeviceInfo[SingleCamInfo[Num].unfiltered_num]);
|
|
|
|
|
HIKCamHandle[Num] = camhandle;
|
|
|
|
|
nRet = MV_CC_OpenDevice(camhandle);
|
|
|
|
|
nRet = MV_CC_OpenDevice(camhandle);//打开相机成功返回MV_OK
|
|
|
|
|
if (nRet)
|
|
|
|
|
{
|
|
|
|
|
MV_CC_CloseDevice(camhandle);
|
|
|
|
@ -3143,6 +3186,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
}
|
|
|
|
|
if (HIKCamera::stDeviceList.pDeviceInfo[SingleCamInfo[Num].unfiltered_num]->nTLayerType == MV_GIGE_DEVICE)
|
|
|
|
|
{
|
|
|
|
|
//配置网口相机
|
|
|
|
|
int nPacketSize = MV_CC_GetOptimalPacketSize(camhandle);
|
|
|
|
|
if (nPacketSize > 0)
|
|
|
|
|
{
|
|
|
|
@ -3236,7 +3280,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
if (!g_debug_mode)
|
|
|
|
|
connect(pHIKCaptureThread[Num], SIGNAL(updateStatistics(const QString&, int)), this, SLOT(updateStatisticsHub(const QString&, int)));
|
|
|
|
|
pThread[Num]->start();
|
|
|
|
|
if (pThread[Num]->isRunning())
|
|
|
|
|
if (pThread[Num]->isRunning())//线程开始工作后打印消息
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "hik pThread OK";
|
|
|
|
|
SingleCamInfo[Num].IsOpen = true;
|
|
|
|
@ -3250,6 +3294,7 @@ bool Cigarette::ControlCamOpenOrClose(int Num, bool OpenOrClose)
|
|
|
|
|
if (SingleCamInfo[Num].CamClass == BalluffClassID)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "close for balluff";
|
|
|
|
|
//取消函数连接
|
|
|
|
|
disconnect(pThread[Num], SIGNAL(started()), pCaptureThread[Num], SLOT(process()));
|
|
|
|
|
//disconnect(pCaptureThread[Num], SIGNAL(error(QString)), this, SLOT(errorString(QString)));
|
|
|
|
|
disconnect(pCaptureThread[Num], SIGNAL(finished()), pThread[Num], SLOT(quit()));
|
|
|
|
@ -3542,7 +3587,7 @@ void Cigarette::EnableDebugMode()
|
|
|
|
|
}
|
|
|
|
|
g_debug_mode = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//非调试模式
|
|
|
|
|
void Cigarette::DisableDebugMode()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < NumberOfSupportedCameras; i++)
|
|
|
|
@ -3600,7 +3645,7 @@ void Cigarette::CleanThreadStart()
|
|
|
|
|
QThread* handleThread = new QThread();
|
|
|
|
|
CleanWorkThread* cleanWorkThread = new CleanWorkThread();
|
|
|
|
|
|
|
|
|
|
cleanWorkThread->moveToThread(handleThread);
|
|
|
|
|
cleanWorkThread->moveToThread(handleThread);//依附到handleThread线程
|
|
|
|
|
|
|
|
|
|
connect(handleThread, &QThread::started, cleanWorkThread, &CleanWorkThread::startWork);
|
|
|
|
|
connect(cleanWorkThread, &CleanWorkThread::workStart, cleanWorkThread, &CleanWorkThread::setSel);
|
|
|
|
|