diff --git a/Cigarette/Cigarette.vcxproj b/Cigarette/Cigarette.vcxproj
index 5d0c458..2953400 100644
--- a/Cigarette/Cigarette.vcxproj
+++ b/Cigarette/Cigarette.vcxproj
@@ -133,7 +133,7 @@
true
true
stdcpp14
- MaxSpeed
+ Disabled
false
4819;%(DisableSpecificWarnings)
@@ -141,7 +141,7 @@
Console
$(OutDir)\$(ProjectName).exe
$(QTDIR)\lib;$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;%(AdditionalLibraryDirectories)
- false
+ true
qtmain.lib;Qt5Core.lib;Qt5Widgets.lib;Qt5Gui.lib;opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;Qt5Network.lib;%(AdditionalDependencies)
diff --git a/Cigarette/Cleanthread.cpp b/Cigarette/Cleanthread.cpp
index 0ac1315..b00aeb9 100644
--- a/Cigarette/Cleanthread.cpp
+++ b/Cigarette/Cleanthread.cpp
@@ -64,8 +64,8 @@ void CleanWorkThread::doWork()
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100/freeSize)) / (qint64)totalDiskSpace.QuadPart;
dirSize = DirFileSize(dir) / gb;
- delDays = g_sys_conf.save_days;
- while ((spaceSize < 1) && (delDays >= 0)) { //磁盘剩余空间小于百分之十
+ //delDays = g_sys_conf.save_days;
+ while ((spaceSize < 1) && (delDays > 1)) { //磁盘剩余空间小于百分之十
CleanImageFile(dir, delDays--);
GetDiskFreeSpaceEx(strDriver, &freeDiskSpaceAvailable, &totalDiskSpace, &totalFreeDiskSpace);
spaceSize = ((qint64)totalFreeDiskSpace.QuadPart * (100 / freeSize)) / (qint64)totalDiskSpace.QuadPart;
diff --git a/Cigarette/cigarette.cpp b/Cigarette/cigarette.cpp
index d295934..0d40355 100644
--- a/Cigarette/cigarette.cpp
+++ b/Cigarette/cigarette.cpp
@@ -20,7 +20,7 @@ ConfPath g_conf_path;
SysConf g_sys_conf; //ϵͳò
ModbusConf g_modbus_conf; //modbusַ
-PLCDevice * m_PLCDevice;
+PLCDevice* m_PLCDevice;
bool g_plc_dialog_open; //ǷplcöԻ
QDateTime g_ts_start;
@@ -1229,7 +1229,7 @@ void Cigarette::OnDBClickNGHub(int Num)
QString file_path = g_conf_path.save_pics_path;
std::replace(file_path.begin(), file_path.end(), '/', '\\');
- ostr << "explorer "<< file_path.toLocal8Bit().constData() << "\\ng\\" << (now_ts.toString("yyyy-MM-dd")).toStdString()<< "\\" << Num+1 << "\\" << 1;
+ ostr << "explorer "<< file_path.toLocal8Bit().constData() << "\\ng\\" << (now_ts.toString("yyyy-MM-dd")).toStdString()<< "\\" << Num+1;
std::string str = ostr.str();
//std::cout << "===>" << str << std::endl;
system(str.c_str());
diff --git a/Cigarette/common.h b/Cigarette/common.h
index b0389af..d2b9e6d 100644
--- a/Cigarette/common.h
+++ b/Cigarette/common.h
@@ -20,7 +20,7 @@
//#define DOUBLE_FEED_BACK //һngηngź
#endif
//#define identify_Hik_YSXID//ʶYSXID
-//#define __ExportData // ݵXMLĵ
+#define __ExportData // ݵXMLĵ
//#define DRAW_RECT // 껭
#define Queue_Size 15
@@ -34,7 +34,7 @@
#endif
// ļ
-#define CONFPATH "conf_path.txt"
+#define CONFPATH "D:/Release/conf_path.txt"
//#define CONFIGURE_FILE "D:/conf/conf.txt"
// תǶļ
#define ROTATE_FILE "rotate.txt"
diff --git a/Cigarette/exportData.cpp b/Cigarette/exportData.cpp
index 4e13b83..66ed26d 100644
--- a/Cigarette/exportData.cpp
+++ b/Cigarette/exportData.cpp
@@ -3,28 +3,32 @@
#include "QtCore\qtextstream.h"
#include
+Cigarette* cg;
extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue;
extern ConfPath g_conf_path;
ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
{
- char xmlPath[256];
+ //char xmlPath[256];
+ cg->read_conf(g_conf_path);
+
for (int index = 0; index < NumberOfSupportedCameras; index++)
{
XMLError error;
- pDocument[index] = new XMLDocument();
- memset(xmlPath, 0, 256);
+ pDocument[index] = new tinyxml2::XMLDocument();
+ //memset(xmlPath, 0, 256);
QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
//sprintf(xmlPath, EXPORTDATA_FILE, index);
QString filePath = g_conf_path.config_path + "/" + xmlPath;
- error = pDocument[index]->LoadFile(filePath.toStdString().c_str());
+
+ error = pDocument[index]->LoadFile(filePath.toLocal8Bit().constData());
if (error != XML_SUCCESS)
{
XMLDeclaration* declaration = pDocument[index]->NewDeclaration();
pDocument[index]->InsertFirstChild(declaration);
XMLElement* root = pDocument[0]->NewElement("Root");
pDocument[0]->InsertEndChild(root);
- pDocument[index]->SaveFile(filePath.toStdString().c_str());
+ pDocument[index]->SaveFile(filePath.toLocal8Bit().constData());
}
/*
_ExportDataInfo data;
@@ -33,6 +37,14 @@ ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
data.timeCost = "3ms";
insertXMLNode(xmlPath, data);
*/
+
+ _XMLExportDataInfo data;
+ data.cameraId = index;
+ data.cameraTotal = 3;
+ data.TotalCheckNum = 1000;
+ data.TotalKickNum = 900;
+ data.AcquisitionSpeed = "3ms";
+ insertXMLNode(filePath.toLocal8Bit().constData(), data);
}
}
@@ -55,7 +67,7 @@ void ExportDataThread::stop()
bool _ExportDataInfo::getAverageData(map &averageData, int index)
{
- XMLDocument doc;
+ tinyxml2::XMLDocument doc;
//char xmlPath[256];
XMLError error;
map data;
@@ -63,9 +75,9 @@ bool _ExportDataInfo::getAverageData(map &averageData, int index)
QString xmlPath = QString(EXPORTDATA_FILE).arg(index);
//sprintf(xmlPath, EXPORTDATA_FILE, index);
QString filePath = g_conf_path.config_path + "/" + xmlPath;
- error = doc.LoadFile(filePath.toStdString().c_str());
+ error = doc.LoadFile(filePath.toLocal8Bit().constData());
if (error != XML_SUCCESS)
- if (doc.LoadFile(filePath.toStdString().c_str()) != 0)
+ if (doc.LoadFile(filePath.toLocal8Bit().constData()) != 0)
{
cout << "load xml file failed" << endl;
return false;
@@ -140,6 +152,49 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _ExportDataInfo& data)
return pDocument[data.cameraId]->SaveFile(xmlPath);
}
+int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& data)
+{
+ XMLElement* root = pDocument[data.cameraId]->RootElement();
+
+ if (root == NULL) {
+ root = pDocument[data.cameraId]->NewElement("Root");
+ pDocument[data.cameraId]->InsertEndChild(root);
+ pDocument[data.cameraId]->SaveFile(xmlPath);
+ }
+
+ XMLElement* CameraNode = pDocument[data.cameraId]->NewElement("Camera");
+ CameraNode->SetAttribute("Id", data.cameraId);
+ CameraNode->SetAttribute("Count ", data.cameraTotal);
+ root->InsertEndChild(CameraNode);
+
+ //XMLElement* IsNG = pDocument[data.cameraId]->NewElement("IsNG");
+ //XMLText* IsNGText = pDocument[data.cameraId]->NewText(data.isNg ? "TRUE" : "FALSE");
+ //IsNG->InsertEndChild(IsNGText);
+ //CameraNode->InsertEndChild(IsNG);
+
+ //XMLElement* timeCost = pDocument[data.cameraId]->NewElement("TimeCost");
+ //timeCost->InsertEndChild(pDocument[data.cameraId]->NewText(data.timeCost.c_str()));
+ //CameraNode->InsertEndChild(timeCost);
+
+ XMLElement* TotalCheckNum = pDocument[data.cameraId]->NewElement("TotalCheckNum");
+ std::string temp_str = std::to_string(data.TotalCheckNum);
+ const char* temp_char = temp_str.c_str();
+ TotalCheckNum->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char));
+ CameraNode->InsertEndChild(TotalCheckNum);
+
+ XMLElement* TotalKickNum = pDocument[data.cameraId]->NewElement("TotalKickNum");
+ temp_str = std::to_string(data.TotalKickNum);
+ temp_char = temp_str.c_str();
+ TotalKickNum->InsertEndChild(pDocument[data.cameraId]->NewText(temp_char));
+ CameraNode->InsertEndChild(TotalKickNum);
+
+ XMLElement* AcquisitionSpeed = pDocument[data.cameraId]->NewElement("AcquisitionSpeed");
+ AcquisitionSpeed->InsertEndChild(pDocument[data.cameraId]->NewText(data.AcquisitionSpeed.c_str()));
+ CameraNode->InsertEndChild(AcquisitionSpeed);
+
+ return pDocument[data.cameraId]->SaveFile(xmlPath);
+}
+
void ExportDataThread::run()
{
while (!b_quit) {
@@ -150,7 +205,7 @@ void ExportDataThread::run()
memset(buf, 0, 256);
QString xmlPath = QString(EXPORTDATA_FILE).arg(element.cameraId);
QString filePath = g_conf_path.config_path + "/" + xmlPath;
- sprintf(buf, filePath.toStdString().c_str(), element.cameraId);
+ sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId);
insertXMLNode(buf, element);
}
}
@@ -173,7 +228,9 @@ void ExportDataThread::check_save_dir(std::string dir_path)
}
if (!b_find)
{
- QString dir_str = QString::fromStdString(dir_path);
+ //QString dir_str = QString::fromStdString(dir_path);
+ QString dir_str = QString::fromLocal8Bit(QByteArray::fromRawData(dir_path.c_str(), dir_path.size()));
+
QDir dir;
if (!dir.exists(dir_str))
{
diff --git a/Cigarette/exportData.h b/Cigarette/exportData.h
index 6271dda..3af5ae1 100644
--- a/Cigarette/exportData.h
+++ b/Cigarette/exportData.h
@@ -9,11 +9,46 @@
#include "basecamera.h"
#include "tinyxml2.h"
#include "common.h"
+#include "cigarette.h"
#define EXPORTDATA_FILE "camera%1_data_info.xml"
using namespace tinyxml2;
+class _XMLExportDataInfo {
+public:
+ // ܵͳ
+ int TotalCheckNum; // ܼ
+ int TotalKickNum; //
+ double PassRate; // ϸ
+ double KickRate; //
+ //
+ long long cameraTotal;
+ int cameraId;
+ int okNum; // ok
+ int ngNum; // ng
+ int kickNum; // ʵͨʱΪ
+ string AcquisitionSpeed; // ɼٶ
+ int jdNum[20]; // ʶ
+ string DetectSpeed; // ٶ
+
+ _XMLExportDataInfo() {
+ // ܵͳ
+ TotalCheckNum = 0; // ܼ
+ TotalKickNum = 0; //
+ PassRate = 0.0; // ϸ
+ KickRate = 0.0; //
+ //
+ cameraId = -1;
+ okNum = 0; // ok
+ ngNum = 0; // ng
+ kickNum = 0; // ʵͨʱΪ
+ AcquisitionSpeed = "0ms"; // ɼٶ
+ for (int i = 0; i < 20; i++) jdNum[i] = 0; // ʶ
+ DetectSpeed = "0ms"; // ٶ
+ }
+};
+
class _ExportDataInfo
{
struct JdPoint //
@@ -77,6 +112,7 @@ public:
void start_work();
void stop();
int insertXMLNode(const char* xmlPath, _ExportDataInfo& data);
+ int insertXMLNode(const char* xmlPath, _XMLExportDataInfo& data);
protected:
void run();
void check_save_dir(std::string dir_path);
diff --git a/Cigarette/workthread.cpp b/Cigarette/workthread.cpp
index 1ac0c4d..676ef2b 100644
--- a/Cigarette/workthread.cpp
+++ b/Cigarette/workthread.cpp
@@ -218,13 +218,14 @@ void WorkThread::run()
+ 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) + ".jpg";
+ g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
- /*m = vec_out[index].clone();
- file_name = "D:/image/" +
- now_ts.toString("yyyy-MM-dd") +
- "/" + QString::number(local_camera_number + 1) +
- "/ng_result/" + QString::number(index) + "/" +
- now_ts.toString("yyyy-MM-dd_HH-mm-ss_zzz_") + "_" + QString::number(index) + ".bmp";*/
+ m = vec_out[index].clone();
+ file_name = g_conf_path.save_pics_path + "/ng_result/" +
+ 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";;
//g_save_queue->put(std::make_pair(file_name.toStdString(), m));
g_save_queue->put(std::make_pair(file_name.toLocal8Bit().constData(), m));
}