|
|
|
@ -3,28 +3,32 @@
|
|
|
|
|
#include "QtCore\qtextstream.h"
|
|
|
|
|
#include<string>
|
|
|
|
|
|
|
|
|
|
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<string, float> &averageData, int index)
|
|
|
|
|
{
|
|
|
|
|
XMLDocument doc;
|
|
|
|
|
tinyxml2::XMLDocument doc;
|
|
|
|
|
//char xmlPath[256];
|
|
|
|
|
XMLError error;
|
|
|
|
|
map<string, float> data;
|
|
|
|
@ -63,9 +75,9 @@ bool _ExportDataInfo::getAverageData(map<string, float> &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))
|
|
|
|
|
{
|
|
|
|
|