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

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

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

Loading…
Cancel
Save