ATBUpdateTool/UpdatePTUDevCtrl/process/update_dc_command.cpp
2025-03-07 12:20:40 +01:00

66 lines
2.2 KiB
C++

#include "process/update_dc_command.h"
#include "worker.h"
#include "utils_internal.h"
UpdateDCCommand::UpdateDCCommand(QString const &command,
Worker *worker,
int nextCommandIndex,
int start_timeout,
int finish_timeout)
: UpdateCommand(command, worker, nextCommandIndex, start_timeout, finish_timeout) {
}
void UpdateDCCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
Worker *w = worker();
if (w) {
w->summaryTimer()->start();
}
return UpdateCommand::finished(exitCode, exitStatus);
}
void UpdateDCCommand::readyReadStandardOutput() {
QProcess *p = (QProcess *)sender();
if (p) {
Worker *w = worker();
if (w) {
QString s = p->readAllStandardOutput();
int i = -1;
if ((i = s.indexOf("<DC-VERSION>")) != -1) {
s = s.mid(i+12).trimmed();
if ((i = s.indexOf("\"")) != -1) {
s = s.mid(i+1);
if ((i = s.indexOf("\"")) != -1) {
s = s.mid(0, i).trimmed();
}
}
// emit w->showDcDownload(s);
} else
if ((i = s.indexOf("<DC-PROGRESS>")) != -1) {
bool ok;
int v = s.mid(i+13).trimmed().toInt(&ok);
if (ok) {
emit w->setDcDownloadProgress(v);
emit w->insertText(s.mid(0,i) + "\n");
}
} else
if ((i = s.indexOf("<DC-UPDATE-FINISH>")) != -1) {
emit w->showUpdateDCFirmware(internal::UPDATE_DC_FIRMARE_SUCCESS);
// QThread::sleep(3);
// emit w->summary();
// qApp->exit(0);
} else
if ((i = s.indexOf("<DC-UPDATE-SUCCESS>")) != -1) {
// TODO
emit w->summary();
} else
if ((i = s.indexOf("<DC-UPDATE-FAILURE>")) != -1) {
emit w->summary();
//qApp->exit(-1);
} else {
emit w->insertText(s);
}
m_commandResult += s;
}
}
}