Stop the running command after disconnected

pull/14/head
wh201906 4 years ago
parent a3e6aa787b
commit a7985c5c89

@ -23,11 +23,14 @@ void Util::processOutput(QString output)
void Util::execCMD(QString cmd)
{
qDebug() << cmd;
emit write(cmd + "\r\n");
if(isRunning)
emit write(cmd + "\r\n");
}
QString Util::execCMDWithOutput(QString cmd, unsigned long waitTime)
{
if(!isRunning)
return "";
QTime currTime = QTime::currentTime();
QTime targetTime = QTime::currentTime().addMSecs(waitTime);
isRequiringOutput = true;
@ -61,3 +64,8 @@ void Util::setClientType(Util::ClientType clientType)
{
this->clientType = clientType;
}
void Util::setRunningState(bool st)
{
this->isRunning = st;
}

@ -31,9 +31,11 @@ public:
public slots:
void processOutput(QString output);
void setClientType(Util::ClientType clientType);
void setRunningState(bool st);
private:
bool isRequiringOutput;
bool isRunning;
QString* requiredOutput;
QTime timeStamp;
ClientType clientType;

@ -875,6 +875,7 @@ void MainWindow::signalInit()
connect(this, &MainWindow::connectPM3, pm3, &PM3Process::connectPM3);
connect(pm3, &PM3Process::PM3StatedChanged, this, &MainWindow::onPM3StateChanged);
connect(pm3, &PM3Process::PM3StatedChanged, util, &Util::setRunningState);
connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill);
connect(util, &Util::write, pm3, &PM3Process::write);

Loading…
Cancel
Save