Manual-Labeling-Tool/Manual-Labeling-Client/Manual-Label-Tool-Widget/WindConverTools.cpp

81 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "WindConverTools.h"
#include "WidgetSettingClass.h"
#include <QFileInfo>
#include <QProcess>
nc2windataTool::nc2windataTool(QString Inncfilepath, QString InwindBinPath, LAMPDataManagerDialog* IndatamanagerDiglog)
{
this->ncfilepath = Inncfilepath;
this->windBinPath = InwindBinPath;
this->datamanagerDiglog = IndatamanagerDiglog;
}
nc2windataTool::~nc2windataTool()
{
}
int32_t nc2windataTool::Excute()
{
WidgetSettingClass& config = WidgetSettingClass::instance();
QString pythonPath = config.getWindTool_PythonEnvPath();
QString nc2windToolPath = config.getWindTool_nc2WindDataToolPath();
QString dllPath = config.getWindReaddLLApplicationPath();
// 2. 检查文件是否存在
if (!QFileInfo(pythonPath).exists()) {
qDebug() << u8"错误Python解释器路径不存在 -" << pythonPath;
return -1;
}
if (!QFileInfo(nc2windToolPath).exists()) {
qDebug() << u8"错误Python脚本路径不存在 -" << nc2windToolPath;
return -1;
}
if (!QFileInfo(ncfilepath).exists()) {
qDebug() << u8"错误:参数文件路径不存在 -" << ncfilepath;
return -1;
}
if (!QFileInfo(dllPath).exists()) {
qDebug() << u8"错误:程序库文件路径不存在 -" << dllPath;
return -1;
}
// 构建参数列表
QStringList arguments;
arguments
//<< "/c"
//<< pythonPath
<< nc2windToolPath // Python脚本路径
<< "-i" << ncfilepath
<< "-o" << windBinPath
<< "-d" << dllPath;
// 连接finished信号到成员槽函数
//connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
// this, &nc2windataTool::on_process_finished);
m_process= new QProcess(this);
//m_process->execute("cmd.exe", arguments);
m_process->start(pythonPath, arguments);
if (!m_process->waitForStarted(3000)) { // 等待进程启动超时3秒
qDebug() << u8"启动失败:" << m_process->errorString();
}
else {
qDebug() << u8"进程已启动...";
}
return 0;
}
void nc2windataTool::on_process_finished(int exitCode, QProcess::ExitStatus exitStatus)
{
if (!QFileInfo(windBinPath).exists()) {
qDebug() << u8"错误:结果文件不存在 -" << windBinPath;
return ;
}
// 数据加载
// LAMPDataManagerDialog* IndatamanagerDiglog
}