69 lines
1.5 KiB
C++
Raw Normal View History

2024-11-26 16:24:50 +08:00
#include "BCIManager.h"
#include <QFile>
#include <QApplication>
#include <QDebug>
BCIManager::BCIManager(QObject *parent)
: QObject{parent}
{
}
bool BCIManager::startLinkerPrograme()
{
QString strPath = QApplication::applicationDirPath().append("/cmd.txt");
QFile file(strPath);
if (!file.open(QIODevice::ReadOnly))
{
qDebug() << file.errorString();
return false;
}
QString strContent;
QTextStream in(&file);
while (!in.atEnd())
{
strContent = in.readLine();
if(!strContent.isEmpty())
{
break;
}
}
if(strContent.isEmpty())
{
qDebug() << "cmd is empty";
return false;
}
//启动进程
//QString strCmd = QApplication::applicationDirPath().append("/BCILinker/SunnyLinkTool/") + strContent;
QString strCmd = QString("./") + strContent;
qDebug() << strCmd;
if(nullptr == m_pCmd)
{
m_pCmd = new QProcess(this);
connect(m_pCmd, &QProcess::readyReadStandardOutput, this, &BCIManager::slotLinkerProgrameReadyReadStandardOutput);
connect(m_pCmd, &QProcess::readyReadStandardError, this, &BCIManager::slotLinkerProgrameReadyReadStandardError);
}
m_pCmd->start(strCmd);
}
void BCIManager::slotLinkerProgrameReadyReadStandardOutput()
{
if(m_pCmd)
{
qDebug() << m_pCmd->readAllStandardOutput();
}
}
void BCIManager::slotLinkerProgrameReadyReadStandardError()
{
if(m_pCmd)
{
qDebug() << m_pCmd->readAllStandardError();
}
}