1.退回上一笔的改动

2.添加try catch块
3.设置生成pdb文件并且关闭优化
CigaretteSH
Jinhuan 2 months ago
parent 318000820f
commit bec1a3e4d0

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -215,7 +215,7 @@
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp14</LanguageStandard> <LanguageStandard>stdcpp14</LanguageStandard>
<Optimization>MaxSpeed</Optimization> <Optimization>Disabled</Optimization>
<SupportJustMyCode>false</SupportJustMyCode> <SupportJustMyCode>false</SupportJustMyCode>
<DisableSpecificWarnings>4819;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4819;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
@ -223,7 +223,7 @@
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile> <OutputFile>$(OutDir)\$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;Ws2_32.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)OpenCV455Simple\win64\vc15\lib;$(ProjectDir)Pylon6.2\lib\Win64;$(ProjectDir)MvIMPACT\lib\win64;$(ProjectDir)MVS3.2.1\lib\win64;$(ProjectDir)modbus;Ws2_32.lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>opencv_world455.lib;modbus.lib;mvDeviceManager.lib;MvCameraControl.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>
</IgnoreSpecificDefaultLibraries> </IgnoreSpecificDefaultLibraries>

@ -310,124 +310,138 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& dat
void ExportDataThread::run() void ExportDataThread::run()
{ {
while (!b_quit || (b_quit && (!export_XMLData_Info_queue->isEmpty() || readyToSendZip || !tmpListToZip.isEmpty()))) { try {
_XMLExportDataInfo element; while (!b_quit || (b_quit && (!export_XMLData_Info_queue->isEmpty() || readyToSendZip || !tmpListToZip.isEmpty()))) {
if (!export_XMLData_Info_queue->isEmpty()) { _XMLExportDataInfo element;
export_XMLData_Info_queue->take(element); if (!export_XMLData_Info_queue->isEmpty()) {
export_XMLData_Info_queue->take(element);
if (element.cameraId != -1 && flag) {
char buf[256]; if (element.cameraId != -1 && flag) {
memset(buf, 0, 256); char buf[256];
QString xmlPath = QString(EXPORTDATA_FILE).arg(element.cameraId); memset(buf, 0, 256);
QString filePath = g_conf_path.config_path + "/" + xmlPath; QString xmlPath = QString(EXPORTDATA_FILE).arg(element.cameraId);
sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId); QString filePath = g_conf_path.config_path + "/" + xmlPath;
insertXMLNode(buf, element); sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId);
QString remotePath = "/tmp/" + xmlPath; insertXMLNode(buf, element);
ConnectServer(filePath, remotePath); QString remotePath = "/tmp/" + xmlPath;
ConnectServer(filePath, remotePath);
}
} }
}
if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) { if ((b_quit || (!timer->isActive() && !readyToSendZip)) && (!tmpListToZip.isEmpty())) {
listToZip.unite(tmpListToZip); listToZip.unite(tmpListToZip);
tmpListToZip.clear(); tmpListToZip.clear();
zipTimeStamp.append(lastTimeStamp[0]); zipTimeStamp.append(lastTimeStamp[0]);
lastTimeStamp.clear(); lastTimeStamp.clear();
readyToSendZip = true; readyToSendZip = true;
} }
if (readyToSendZip && !listToZip.isEmpty()) { if (readyToSendZip && !listToZip.isEmpty()) {
QString remotePath; QString remotePath;
QStringList zipFilePaths; QStringList zipFilePaths;
QStringList fileList; QStringList fileList;
QString okStr = "1"; QString okStr = "1";
QProcess process(0); QProcess process(0);
//QDateTime now_ts = QDateTime::currentDateTime(); //QDateTime now_ts = QDateTime::currentDateTime();
QStringList argsNg; QStringList argsNg;
QStringList argsOk; QStringList argsOk;
//条盒TJ 小盒BJ //条盒TJ 小盒BJ
/*zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip"); /*zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip"); zipFilePaths.append(g_conf_path.save_pics_path + "/" + "416_BJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt"); fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ng.txt");
fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");*/ fileList.append(g_conf_path.save_pics_path + "/" + zipTimeStamp[0] + "ok.txt");*/
zipFilePaths.append("416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip"); zipFilePaths.append("416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_0.zip");
zipFilePaths.append("416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip"); zipFilePaths.append("416_TJ_" + zipTimeStamp[0] + "-00_" + zipTimeStamp[0] + "-59_1.zip");
fileList.append(zipTimeStamp[0] + "ng.txt"); fileList.append(zipTimeStamp[0] + "ng.txt");
fileList.append(zipTimeStamp[0] + "ok.txt"); fileList.append(zipTimeStamp[0] + "ok.txt");
zipTimeStamp.clear(); zipTimeStamp.clear();
QFile* file[2] = { NULL }; QFile* file[2] = { NULL };
QFile fileNg(fileList[0]); file[0] = new QFile(fileList[0]);
QFile fileOk(fileList[1]); file[1] = new QFile(fileList[1]);
fileNg.open(QIODevice::WriteOnly); // QFile fileNg(fileList[0]);
fileOk.open(QIODevice::WriteOnly); // QFile fileOk(fileList[1]);
QTextStream ngStream(fileNg); file[0]->open(QIODevice::WriteOnly);
QTextStream okStream(fileOk); file[1]->open(QIODevice::WriteOnly);
argsNg.append("a"); QTextStream ngStream(file[0]);
argsNg.append(zipFilePaths[0]); QTextStream okStream(file[1]);
argsOk.append("a"); argsNg.append("a");
argsOk.append(zipFilePaths[1]); argsNg.append(zipFilePaths[0]);
// create zip file argsOk.append("a");
QMapIterator<QString, bool> iterator(listToZip); argsOk.append(zipFilePaths[1]);
while (iterator.hasNext()) {
iterator.next(); // create zip file
if (iterator.value()) { QMapIterator<QString, bool> iterator(listToZip);
ngStream << iterator.key() << endl; while (iterator.hasNext()) {
iterator.next();
if (iterator.value()) {
ngStream << iterator.key() << endl;
}
else {
okStream << iterator.key() << endl;
}
} }
else { argsNg.append("-i@" + fileList[0]);
okStream << iterator.key() << endl; argsNg.append("-mx=3");
argsOk.append("-i@" + fileList[1]);
argsOk.append("-mx=3");
file[0]->close();
file[1]->close();
for (int i = 0; i < zipFilePaths.size(); i++) {
if (file[i]->size() == 0) {
continue;
}
process.start(QApplication::applicationDirPath() + "/7z.exe", i == 0 ? argsNg : argsOk);
process.waitForStarted();
process.waitForFinished();
//QString out = QString::fromLocal8Bit(process.readAllStandardOutput());
//qDebug() << out;
remotePath = zipFilePaths[i].mid(zipFilePaths[i].indexOf("image") - 1);
qDebug() << remotePath;
ConnectServer(zipFilePaths[i], remotePath);
QFile file(zipFilePaths[i]);
file.remove();
} }
file[0]->remove();
file[1]->remove();
listToZip.clear();
readyToSendZip = false;
} }
argsNg.append("-i@" + fileList[0]); }
argsNg.append("-mx=3"); flag = false;
argsOk.append("-i@" + fileList[1]);
argsOk.append("-mx=3");
fileNg.close();
fileOk.close();
for (int i = 0; i < zipFilePaths.size(); i++) { for (int index = 0; index < NumberOfSupportedCameras; index++) {
if (file[i]->size() == 0) { pDocument[index]->~XMLDocument();
continue;
}
process.start(QApplication::applicationDirPath() + "/7z.exe", i == 0 ? argsNg : argsOk);
process.waitForStarted();
process.waitForFinished();
//QString out = QString::fromLocal8Bit(process.readAllStandardOutput());
//qDebug() << out;
remotePath = zipFilePaths[i].mid(zipFilePaths[i].indexOf("image") - 1);
qDebug() << remotePath;
ConnectServer(zipFilePaths[i], remotePath);
QFile file(zipFilePaths[i]);
file.remove();
}
fileNg.remove();
fileOk.remove();
listToZip.clear();
readyToSendZip = false;
} }
}
flag = false;
for (int index = 0; index < NumberOfSupportedCameras; index++) { if (hftp != NULL) {
pDocument[index]->~XMLDocument(); InternetCloseHandle(hftp);
hftp = NULL;
}
if (hftp != NULL) {
InternetCloseHandle(hint);
hint = NULL;
}
} }
catch (const std::exception& e) {
if (hftp != NULL) { // 注意std::exception通常不捕获由运行时错误引发的异常
InternetCloseHandle(hftp); // 但这里是为了演示catch块的结构
hftp = NULL; std::cerr << __FUNCTION__<<"捕获到异常: " << e.what() << std::endl;
} }
if (hftp != NULL) { catch (...) {
InternetCloseHandle(hint); // 使用省略号(...)可以捕获所有类型的异常,这是一种通用的捕获方式
hint = NULL; std::cerr << "捕获到未知类型的异常" << std::endl;
} }
} }

@ -389,9 +389,13 @@ void SyncWorkThread::run()
// emit display_check_total(local_camera_number, ++(frame_total[local_camera_number])); // emit display_check_total(local_camera_number, ++(frame_total[local_camera_number]));
} }
} }
catch (cv::Exception& e) catch (const std::exception& e) {
{ // 注意std::exception通常不捕获由运行时错误引发的异常
const char* err_msg = e.what(); // 但这里是为了演示catch块的结构
std::cout << "exception caught: " << err_msg << std::endl; std::cerr << __FUNCTION__<<"捕获到异常: " << e.what() << std::endl;
}
catch (...) {
// 使用省略号(...)可以捕获所有类型的异常,这是一种通用的捕获方式
std::cerr << "捕获到未知类型的异常" << std::endl;
} }
} }

@ -25,41 +25,52 @@ void threadSend::stop()
void threadSend::run() void threadSend::run()
{ {
while (isLoop) try {
{ while (isLoop)
_UDPSendInfo UDPSendInfo; {
Local_UDP_Info_queue->take(UDPSendInfo); _UDPSendInfo UDPSendInfo;
switch (UDPSendInfo.FrameID) { Local_UDP_Info_queue->take(UDPSendInfo);
case info_frame: { switch (UDPSendInfo.FrameID) {
sendData(&UDPSendInfo, dataport); case info_frame: {
break; sendData(&UDPSendInfo, dataport);
} break;
case speed_frame: { }
sendSpeed(&UDPSendInfo, dataport); case speed_frame: {
break; sendSpeed(&UDPSendInfo, dataport);
} break;
case kick_frame: { }
sendKick(&UDPSendInfo, dataport); case kick_frame: {
break; sendKick(&UDPSendInfo, dataport);
} break;
case ok_frame: { }
sendOK(&UDPSendInfo, dataport); case ok_frame: {
break; sendOK(&UDPSendInfo, dataport);
} break;
case ng_frame: { }
sendNG(&UDPSendInfo, dataport); case ng_frame: {
break; sendNG(&UDPSendInfo, dataport);
} break;
case total_frame: { }
sendTotal(&UDPSendInfo, dataport); case total_frame: {
break; sendTotal(&UDPSendInfo, dataport);
} break;
case image_frame: { }
sendImage(&UDPSendInfo, imageport); case image_frame: {
break; sendImage(&UDPSendInfo, imageport);
} break;
}
}
} }
} }
catch (const std::exception& e) {
// 注意std::exception通常不捕获由运行时错误引发的异常
// 但这里是为了演示catch块的结构
std::cerr << __FUNCTION__<<"捕获到异常: " << e.what() << std::endl;
}
catch (...) {
// 使用省略号(...)可以捕获所有类型的异常,这是一种通用的捕获方式
std::cerr << "捕获到未知类型的异常" << std::endl;
}
} }
void threadSend::sendData(_UDPSendInfo* UDPSendInfo, int port) void threadSend::sendData(_UDPSendInfo* UDPSendInfo, int port)

@ -64,30 +64,39 @@ bool threadSendTCP::connectTCP() {
void threadSendTCP::run() void threadSendTCP::run()
{ {
try {
#ifdef __TCPClient #ifdef __TCPClient
if (!connectTCP()) if (!connectTCP())
{
qDebug() << "TCP connect error!";
}
#endif
while (isLoop) {
_TCPSendInfo TCPSendInfo;
Local_TCP_Info_queue->take(TCPSendInfo);
num++;
sendData(&TCPSendInfo, num);
#ifdef __TCPServer
if (ClientStatus == QAbstractSocket::ConnectedState)
{ {
sendData(&TCPSendInfo, num); qDebug() << "TCP connect error!";
} }
#endif
while (isLoop) {
_TCPSendInfo TCPSendInfo;
Local_TCP_Info_queue->take(TCPSendInfo);
num++;
sendData(&TCPSendInfo, num);
#ifdef __TCPServer
if (ClientStatus == QAbstractSocket::ConnectedState)
{
sendData(&TCPSendInfo, num);
}
#endif #endif
#ifdef __TCPClient #ifdef __TCPClient
sendData(&TCPSendInfo, num); sendData(&TCPSendInfo, num);
#endif #endif
//mySocket->write("Hello! here is tcp client!\n"); //mySocket->write("Hello! here is tcp client!\n");
//mySocket->flush(); //mySocket->flush();
}
}
catch (const std::exception& e) {
// 注意std::exception通常不捕获由运行时错误引发的异常
// 但这里是为了演示catch块的结构
std::cerr << __FUNCTION__<<"捕获到异常: " << e.what() << std::endl;
}
catch (...) {
// 使用省略号(...)可以捕获所有类型的异常,这是一种通用的捕获方式
std::cerr << "捕获到未知类型的异常" << std::endl;
} }
} }

@ -321,9 +321,13 @@ void WorkThread::run()
#endif #endif
} }
} }
catch (cv::Exception& e) catch (const std::exception& e) {
{ // 注意std::exception通常不捕获由运行时错误引发的异常
const char* err_msg = e.what(); // 但这里是为了演示catch块的结构
std::cout << "exception caught: " << err_msg << std::endl; std::cerr << __FUNCTION__<<"捕获到异常: " << e.what() << std::endl;
}
catch (...) {
// 使用省略号(...)可以捕获所有类型的异常,这是一种通用的捕获方式
std::cerr << "捕获到未知类型的异常" << std::endl;
} }
} }

Loading…
Cancel
Save