Modified to make uploading pic to remote works

main
Flamingo 1 year ago
parent 7d33939aa1
commit 4c319c9ae5

@ -245,6 +245,9 @@ Cigarette::Cigarette(QWidget *parent)
//±£´æͼƬÏß³Ì //±£´æͼƬÏß³Ì
saveThread.init(); saveThread.init();
#ifdef __ExportData
connect(&saveThread, &SaveThread::sendDataToExport, &exportDataThread, &ExportDataThread::GetDataFromSaveThread);
#endif
saveThread.start_work(); saveThread.start_work();
#ifdef __UDPSend #ifdef __UDPSend
sThread.init(UDP_Info_queue, g_sys_conf.MonitorIP, g_sys_conf.MonitorPort); sThread.init(UDP_Info_queue, g_sys_conf.MonitorIP, g_sys_conf.MonitorPort);
@ -258,8 +261,8 @@ Cigarette::Cigarette(QWidget *parent)
#ifdef __ExportData #ifdef __ExportData
exportDataThread.init(); exportDataThread.init();
exportDataThread.start_work();
connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette); connect(this, &Cigarette::sendMsgToExportData, &exportDataThread, &ExportDataThread::EDrecMsgFromCigarette);
exportDataThread.start_work();
#endif #endif
m_PLCDevice = new PLCDevice; m_PLCDevice = new PLCDevice;

@ -258,7 +258,7 @@ void ExportDataThread::check_save_dir(std::string dir_path)
string tempPath = dir_path.substr(0, pos + 1); string tempPath = dir_path.substr(0, pos + 1);
FtpCreateDirectoryA(hftp, tempPath.c_str()); 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 destFileName = remotePath.substr(pos + 1);
string tempPath = remotePath.substr(0, pos + 1); string tempPath = remotePath.substr(0, pos + 1);
check_save_dir(tempPath); 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; 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<string>& files) { void ExportDataThread::GetFiles(string path, std::vector<string>& files) {
//文件句柄 //文件句柄
@ -334,6 +341,7 @@ void ExportDataThread::GetFiles(string path, std::vector<string>& files) {
} }
} }
/*
BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) { BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) {
DWORD dwBytesReturn = 0; DWORD dwBytesReturn = 0;
DWORD UploadDataSize = 0; DWORD UploadDataSize = 0;
@ -371,3 +379,4 @@ BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) {
CloseHandle(hFile); CloseHandle(hFile);
return TRUE; return TRUE;
} }
*/

@ -135,4 +135,5 @@ public:
public slots: public slots:
void EDrecMsgFromCigarette(); void EDrecMsgFromCigarette();
void GetDataFromSaveThread(QString filePath);
}; };

@ -20,7 +20,7 @@ class SaveThread : public QThread
{ {
Q_OBJECT Q_OBJECT
signals: signals:
void sendDataToExport(QString filePath);
public: public:
SaveThread(QObject *parent = 0): QThread(parent) SaveThread(QObject *parent = 0): QThread(parent)
@ -47,6 +47,7 @@ public:
{ {
b_quit = true; b_quit = true;
} }
protected: protected:
void run() void run()
{ {
@ -62,6 +63,11 @@ protected:
std::string dir_path = file_name.substr(0, found); std::string dir_path = file_name.substr(0, found);
check_save_dir(dir_path); check_save_dir(dir_path);
bool b_save = cv::imwrite(file_name, image); bool b_save = cv::imwrite(file_name, image);
if (b_save)
{
sendDataToExport(QString::fromStdString(file_name));
//qDebug() << "Save pic successfully";
}
} }
} }
} }

Loading…
Cancel
Save