diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp index 66ed26da..0caa9e58 100644 --- a/Cigarette/exportData.cpp +++ b/Cigarette/exportData.cpp @@ -1,7 +1,12 @@ #include "exportData.h" #include "QtCore\qfile.h" #include "QtCore\qtextstream.h" -#include +#include +#include +#include +#include +#include +#include Cigarette* cg; extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue; @@ -207,6 +212,43 @@ void ExportDataThread::run() QString filePath = g_conf_path.config_path + "/" + xmlPath; sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId); insertXMLNode(buf, element); + // + // Ftp transfer demo + // + QNetworkAccessManager manager; + QUrl url; + /* 设置通讯协议 */ + url.setScheme("ftp"); + /* 设置用户名 */ + url.setUserName("xxx"); + /* 设置密码 */ + url.setPassword("xxxxxx"); + /* 设置主机,也可以是域名 */ + url.setHost("127.0.0.1"); + /* 设置端口号,一般为21 */ + url.setPort(21); + /* 设置路径 */ + url.setPath("/tmp/" + xmlPath); + + /* 装载本地文件 */ + QFile file(filePath); + file.open(QIODevice::ReadOnly); + /* 读取本地文件数据 */ + QByteArray data = file.readAll(); + file.close(); + + QNetworkRequest request(url); + /* 上传数据,上传成功后会在远端创建/tmp/hello.png文件 */ + QNetworkReply* reply = manager.put(request, data); + + //QEventLoop eventLoop; + //QObject::connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit())); + /* 进入等待,但事件循环依然进行 */ + //eventLoop.exec(); + + //if (reply->error() != QNetworkReply::NoError) { + // qDebug() << "Error: " << reply->errorString(); + //} } } diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp index 676ef2b3..1f6066b6 100644 --- a/Cigarette/workthread.cpp +++ b/Cigarette/workthread.cpp @@ -6,6 +6,7 @@ #include "threadSend.h" #include #include "exportData.h" +#include extern AlgJd alg_jd[NumberOfSupportedCameras]; //检测胶点的AI算法 extern ConfPath g_conf_path; @@ -149,11 +150,25 @@ void WorkThread::run() UDPSendInfo.JD = jd_no; bool IsNG = false; + int ngReason = 0; + QMap ng_reason_maps; + ng_reason_maps[0] = "unknow"; + ng_reason_maps[1] = "less_than_setting"; + ng_reason_maps[2] = "too_diff_from_model"; + ng_reason_maps[3] = "out_of_setting_range"; for(int index=0;indexput(std::make_pair(file_name.toLocal8Bit().constData(), m)); m = vec_out[index].clone(); @@ -225,7 +250,8 @@ void WorkThread::run() now_ts.toString("yyyy-MM-dd") + "/" + QString::number(local_camera_number + 1) + "/" + QString::number(index + 1) + "/" + now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + QString::number(local_camera_number + 1) + - "#" + "_" + QString::number(index + 1) + ".bmp";; + "#" + "_" + QString::number(index + 1) + "_" + ng_reason_maps[ngReason] + + ".bmp";; //g_save_queue->put(std::make_pair(file_name.toStdString(), m)); g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m)); }