diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp index 32b99e5..d6c4be8 100644 --- a/Cigarette/cigarette.cpp +++ b/Cigarette/cigarette.cpp @@ -245,6 +245,9 @@ Cigarette::Cigarette(QWidget *parent) //保存图片线程 saveThread.init(); +#ifdef __ExportData + connect(&saveThread, &SaveThread::sendDataToExport, &exportDataThread, &ExportDataThread::GetDataFromSaveThread); +#endif saveThread.start_work(); #ifdef __UDPSend sThread.init(UDP_Info_queue, g_sys_conf.MonitorIP, g_sys_conf.MonitorPort); @@ -258,8 +261,8 @@ Cigarette::Cigarette(QWidget *parent) #ifdef __ExportData exportDataThread.init(); - exportDataThread.start_work(); connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette); + exportDataThread.start_work(); #endif m_PLCDevice = new PLCDevice; diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp index 8944068..390805c 100644 --- a/Cigarette/exportData.cpp +++ b/Cigarette/exportData.cpp @@ -258,7 +258,7 @@ void ExportDataThread::check_save_dir(std::string dir_path) string tempPath = dir_path.substr(0, pos + 1); FtpCreateDirectoryA(hftp, tempPath.c_str()); } - FtpSetCurrentDirectoryA(hftp, dir_path.c_str()); + //FtpSetCurrentDirectoryA(hftp, dir_path.c_str()); } } @@ -290,7 +290,7 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) { string destFileName = remotePath.substr(pos + 1); string tempPath = remotePath.substr(0, pos + 1); check_save_dir(tempPath); - if (!FtpPutFileA(hftp, filePath.c_str(), destFileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0)) + if (!FtpPutFileA(hftp, filePath.c_str(), remotePath.c_str(), FTP_TRANSFER_TYPE_BINARY, 0)) qDebug() << "ftp put file failed because" << dw; } // 上传源为一个文件夹 @@ -306,6 +306,13 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) { } } } + +void ExportDataThread::GetDataFromSaveThread(QString filePath) { + QString remotePath; + remotePath = filePath.mid(filePath.indexOf("image") - 1); + ConnectServer(filePath, remotePath); +} + //*****************************************已经调试好,没有理清逻辑前不要动********************** void ExportDataThread::GetFiles(string path, std::vector& files) { //文件句柄 @@ -334,6 +341,7 @@ void ExportDataThread::GetFiles(string path, std::vector& files) { } } +/* BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) { DWORD dwBytesReturn = 0; DWORD UploadDataSize = 0; @@ -370,4 +378,5 @@ BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) { delete[] buffer; CloseHandle(hFile); return TRUE; -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/Cigarette/exportData.h b/Cigarette/exportData.h index 4d28ad0..d9b4e7d 100644 --- a/Cigarette/exportData.h +++ b/Cigarette/exportData.h @@ -135,4 +135,5 @@ public: public slots: void EDrecMsgFromCigarette(); + void GetDataFromSaveThread(QString filePath); }; diff --git a/Cigarette/savethread.h b/Cigarette/savethread.h index 8c6f708..4a30729 100644 --- a/Cigarette/savethread.h +++ b/Cigarette/savethread.h @@ -20,7 +20,7 @@ class SaveThread : public QThread { Q_OBJECT signals: - + void sendDataToExport(QString filePath); public: SaveThread(QObject *parent = 0): QThread(parent) @@ -47,6 +47,7 @@ public: { b_quit = true; } + protected: void run() { @@ -62,6 +63,11 @@ protected: std::string dir_path = file_name.substr(0, found); check_save_dir(dir_path); bool b_save = cv::imwrite(file_name, image); + if (b_save) + { + sendDataToExport(QString::fromStdString(file_name)); + //qDebug() << "Save pic successfully"; + } } } }