Compare commits
43 Commits
4594c913e0
...
v1.1.1
Author | SHA1 | Date | |
---|---|---|---|
effe41bac9 | |||
4968942cc2 | |||
769626581f | |||
0e97ce7dc2 | |||
34334676fc | |||
853787cd4b | |||
a932ed5471 | |||
c338884fc7 | |||
ed6df98653 | |||
9eb458c4c5 | |||
202e83268b | |||
8f26bfee0f | |||
1af136e39d | |||
a550d55004 | |||
a37a22d3f9 | |||
a8941f4ef4 | |||
746565dbe0 | |||
79906df12e | |||
edf1d105e7 | |||
6c4b02cb56 | |||
04d5061d79 | |||
042e6dfa38 | |||
e523d3cc2c | |||
927197d0d1 | |||
72cb738af5 | |||
0fb38013f7 | |||
5f1376cf1e | |||
5db7b4224e | |||
7c7adc94e6 | |||
89c2d3a8ae | |||
c2b52aa91d | |||
329c770aa0 | |||
cdb045b72b | |||
6d43cf4c9f | |||
4caa0c0d83 | |||
4d2d38e45c | |||
9a55ce18e4 | |||
223c7a8f8d | |||
ce72d3d14d | |||
8b66c47e49 | |||
4ff3b0efdf | |||
1fd2269753 | |||
a8994423f4 |
@@ -48,8 +48,7 @@ bool GitClient::gitCloneCustomerRepository() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCritical() << "ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT="
|
Utils::printCriticalErrorMsg(QString("ERROR CLONE RESULT HAS WRONG FORMAT. CLONE_RESULT=") + result);
|
||||||
<< result;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -96,7 +95,7 @@ bool GitClient::gitCheckoutBranch() {
|
|||||||
Command c(gitCommand);
|
Command c(gitCommand);
|
||||||
return c.execute(m_customerRepository); // execute command in customerRepo
|
return c.execute(m_customerRepository); // execute command in customerRepo
|
||||||
}
|
}
|
||||||
qCritical() << "ERROR" << m_customerRepository << "DOES NOT EXIST";
|
Utils::printCriticalErrorMsg(QString("ERROR ") + m_customerRepository + " DOES NOT EXIST");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,13 +107,10 @@ bool GitClient::gitCloneAndCheckoutBranch() {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
// m_worker->terminateUpdateProcess();
|
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
} else {
|
|
||||||
// TODO
|
|
||||||
//m_worker->terminateUpdateProcess();
|
|
||||||
}
|
}
|
||||||
|
Utils::printCriticalErrorMsg(QString("CLONE ") + m_repositoryPath + " AND CHECKOUT FAILED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,24 +127,37 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
|
|||||||
Command c(gitCommand);
|
Command c(gitCommand);
|
||||||
if (c.execute(m_customerRepository)) { // execute command in local customerRepo
|
if (c.execute(m_customerRepository)) { // execute command in local customerRepo
|
||||||
QString s = c.getCommandResult().trimmed();
|
QString s = c.getCommandResult().trimmed();
|
||||||
|
Utils::printInfoMsg("GIT DIFF RESULT " + s);
|
||||||
|
|
||||||
QStringList lines = Update::split(s, '\n');
|
QStringList lines = Update::split(s, '\n');
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
// each line has the format "etc/psa_config/DC2C_print01.json | 1 +
|
// each line has the format "etc/psa_config/DC2C_print01.json | 1 +
|
||||||
// or the format "etc/psa_config/DC2C_print01.json (new) | 1 +
|
// or the format "etc/psa_config/DC2C_print01.json (new) | 1 +
|
||||||
// the filenames are relativ to the repository
|
// the filenames are relativ to the repository
|
||||||
for (int i = 0; i < lines.size(); ++i) {
|
for (int i = 0; i < lines.size(); ++i) {
|
||||||
// TODO: koennte auch (delete) kommen ?
|
QString const &line = lines.at(i);
|
||||||
int newIndex = lines.at(i).indexOf("(new)"); // for new files
|
int newIndex = line.indexOf("(new"); // for new files
|
||||||
// int goneIndex = lines.at(i).indexOf("(gone)"); // for removed files
|
int goneIndex = line.indexOf("(gone"); // for removed files
|
||||||
|
int modeIndex = line.indexOf("(mode");
|
||||||
|
int pipeIndex = line.indexOf('|');
|
||||||
if (newIndex != -1) {
|
if (newIndex != -1) {
|
||||||
QString fileName = lines.at(i).mid(0, newIndex).trimmed();
|
QString file = line.left(newIndex).trimmed();
|
||||||
fileNames << fileName;
|
qInfo() << "FILE (NEW)" << file;
|
||||||
} else {
|
fileNames << file;
|
||||||
int pipeIndex = lines.at(i).indexOf('|');
|
} else
|
||||||
if (pipeIndex != -1) {
|
if (modeIndex != -1) {
|
||||||
QString fileName = lines.at(i).mid(0, pipeIndex).trimmed();
|
QString const file = line.left(modeIndex).trimmed();
|
||||||
fileNames << fileName;
|
qInfo() << "FILE (MODE)" << file;
|
||||||
}
|
fileNames << file;
|
||||||
|
} else
|
||||||
|
if (goneIndex != -1) {
|
||||||
|
QString const file = line.left(goneIndex).trimmed();
|
||||||
|
qCritical() << "FILE (GONE)" << file;
|
||||||
|
} else
|
||||||
|
if (pipeIndex != -1) {
|
||||||
|
QString const file = line.left(pipeIndex).trimmed();
|
||||||
|
qInfo() << "FILE (PIPE)" << file;
|
||||||
|
fileNames << file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fileNames.isEmpty()) {
|
if (!fileNames.isEmpty()) {
|
||||||
@@ -164,8 +173,7 @@ std::optional<QStringList> GitClient::gitDiff(QString const &commits) {
|
|||||||
*/
|
*/
|
||||||
std::optional<QString> GitClient::gitFetch() {
|
std::optional<QString> GitClient::gitFetch() {
|
||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
|
qInfo() << "BRANCH NAME" << m_branchName;
|
||||||
qCritical() << "BRANCH NAME" << m_branchName;
|
|
||||||
|
|
||||||
Command c("git fetch");
|
Command c("git fetch");
|
||||||
if (c.execute(m_customerRepository)) {
|
if (c.execute(m_customerRepository)) {
|
||||||
@@ -198,26 +206,29 @@ std::optional<QString> GitClient::gitFetch() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
"regex-match for commits");
|
"no regex-match for commits");
|
||||||
|
Utils::printCriticalErrorMsg("NO REGEX MATCH FOR COMMITS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
QString("unkown branch name ") + m_branchName);
|
QString("unkown branch name ") + m_branchName);
|
||||||
|
Utils::printCriticalErrorMsg("UNKNOWN BRANCH NAME " + m_branchName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch",
|
||||||
QString("wrong format for result of 'git fetch' ") + s);
|
QString("wrong format for result of 'git fetch' ") + s);
|
||||||
|
Utils::printCriticalErrorMsg(QString("WRONG FORMAT FOR RESULT OF 'GIT FETCH' ") + s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch", "empty result for 'git fetch'");
|
||||||
"empty result for 'git fetch'");
|
Utils::printCriticalErrorMsg("EMPTY RESULT FOR 'GIT FETCH'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emit m_worker->showErrorMessage("git fetch",
|
emit m_worker->showErrorMessage("git fetch", QString("repository ") + m_customerRepository + " does not exist");
|
||||||
QString("repository ") + m_customerRepository + " does not exist");
|
Utils::printCriticalErrorMsg(QString("REPOSITORY ") + m_customerRepository + " DOES NOT EXIST");
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -238,7 +249,7 @@ bool GitClient::gitPull() {
|
|||||||
qInfo() << "PULLED INTO" << m_customerRepository;
|
qInfo() << "PULLED INTO" << m_customerRepository;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
qCritical() << "PULL INTO" << m_customerRepository << "FAILED";
|
Utils::printCriticalErrorMsg(QString("PULL INTO " + m_customerRepository + " FAILED"));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -257,13 +268,15 @@ QString GitClient::gitLastCommit(QString fileName) {
|
|||||||
if (QDir(m_customerRepository).exists()) {
|
if (QDir(m_customerRepository).exists()) {
|
||||||
QString const filePath
|
QString const filePath
|
||||||
= QDir::cleanPath(m_customerRepository + QDir::separator() + fileName);
|
= QDir::cleanPath(m_customerRepository + QDir::separator() + fileName);
|
||||||
QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName);
|
if (QFile(filePath).exists()) {
|
||||||
Command c("bash");
|
QString const gitCommand = QString("git log %1 | head -n 1").arg(fileName);
|
||||||
if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) {
|
Command c("bash");
|
||||||
QString const r = c.getCommandResult();
|
if (c.execute(m_customerRepository, QStringList() << "-c" << gitCommand)) {
|
||||||
int const idx = r.indexOf("commit ");
|
QString const r = c.getCommandResult();
|
||||||
if (idx != -1) {
|
int const idx = r.indexOf("commit ");
|
||||||
return r.mid(idx + 8).trimmed();
|
if (idx != -1) {
|
||||||
|
return r.mid(idx + 8).trimmed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -148,6 +148,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
int const bytesToWrite = strlen(request.toStdString().c_str());
|
int const bytesToWrite = strlen(request.toStdString().c_str());
|
||||||
strncpy(buf, request.toStdString().c_str(), sizeof(buf)-1);
|
strncpy(buf, request.toStdString().c_str(), sizeof(buf)-1);
|
||||||
|
|
||||||
|
int loop = 0;
|
||||||
int bytesWritten = 0;
|
int bytesWritten = 0;
|
||||||
while (bytesWritten < bytesToWrite) {
|
while (bytesWritten < bytesToWrite) {
|
||||||
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
int n = ::sendto(sockfd, buf+bytesWritten, bytesToWrite-bytesWritten, 0, NULL, 0);
|
||||||
@@ -155,14 +156,18 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
bytesWritten += n;
|
bytesWritten += n;
|
||||||
} else {
|
} else {
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
|
if (++loop < 10) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("TIMEOUT (") + strerror(errno) + ")");
|
QString("WRITE TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
} else
|
} else
|
||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
QString("WRITE INTERRUPTED BY SIGNAL (1) (") + strerror(errno) + ")");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,6 +182,7 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
|
|
||||||
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT ") + buf);
|
printInfoMessage(port, clientIP, clientPort, QString("MESSAGE SENT ") + buf);
|
||||||
|
|
||||||
|
loop = 0;
|
||||||
bzero(buf, sizeof(buf));
|
bzero(buf, sizeof(buf));
|
||||||
int bytesToRead = sizeof(buf)-1;
|
int bytesToRead = sizeof(buf)-1;
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
@@ -196,8 +202,12 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
} else
|
} else
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
|
if (++loop < 10) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
printErrorMessage(port, clientIP, clientPort,
|
printErrorMessage(port, clientIP, clientPort,
|
||||||
QString("TIMEOUT (") + strerror(errno) + ")");
|
QString("READ TIMEOUT %1(").arg(loop) + strerror(errno) + ")");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -214,8 +224,8 @@ IsmasClient::sendRequestReceiveResponse(int port, QString const &request) {
|
|||||||
if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) {
|
if (int idx = response.indexOf("{\"error\":\"ISMAS is offline\"}")) {
|
||||||
response = response.mid(0, idx);
|
response = response.mid(0, idx);
|
||||||
} else
|
} else
|
||||||
if (response == "RECORD SAVED") {
|
if (response.contains("RECORD")) { // RECORD SAVED or RECORD WRITE ABORTED
|
||||||
printInfoMessage(port, clientIP, clientPort, "IGNORED 'RECORD SAVED' RESPONSE");
|
printInfoMessage(port, clientIP, clientPort, QString("IGNORED '") + response + "' RESPONSE");
|
||||||
::close(sockfd);
|
::close(sockfd);
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
@@ -283,6 +293,15 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IsmasClient::errorGitClone(int percent, QString const &info, QString const &version) {
|
||||||
|
return updateNewsToIsmas("U0003",
|
||||||
|
percent,
|
||||||
|
RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"CLONE CUSTOMER REPOSITORY FAILED",
|
||||||
|
info.toStdString().c_str(),
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
|
QString IsmasClient::backendConnected(QString const &info, QString const &version) {
|
||||||
return updateNewsToIsmas("U0010",
|
return updateNewsToIsmas("U0010",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
@@ -734,11 +753,42 @@ QString IsmasClient::sanityCheckFailed(int resultCode, QString reason, QString c
|
|||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::updateOfPSAFailed(int resultCode, QString reason, QString const &version) {
|
QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString const &version) {
|
||||||
return updateNewsToIsmas("U0003",
|
return updateNewsToIsmas("U0003",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
resultCode,
|
resultCode,
|
||||||
"UPDATE ERROR",
|
"JSON-PARSE-ERROR",
|
||||||
|
reason.toStdString().c_str(),
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) {
|
||||||
|
m_progressInPercent = 0;
|
||||||
|
if (resultCode == RESULT_CODE::SUCCESS) {
|
||||||
|
return updateNewsToIsmas("U0002",
|
||||||
|
m_progressInPercent,
|
||||||
|
RESULT_CODE::SUCCESS,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
"(re-)set WAIT state",
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
if (resultCode == RESULT_CODE::INSTALL_ERROR) {
|
||||||
|
return updateNewsToIsmas("U0003",
|
||||||
|
m_progressInPercent,
|
||||||
|
resultCode,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
|
reason.toStdString().c_str(),
|
||||||
|
version.toStdString().c_str());
|
||||||
|
}
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString IsmasClient::updateOfPSAFailed(int resultCode, QString step,
|
||||||
|
QString reason, QString const &version) {
|
||||||
|
return updateNewsToIsmas("U0003",
|
||||||
|
m_progressInPercent,
|
||||||
|
resultCode,
|
||||||
|
step.toStdString().c_str(),
|
||||||
reason.toStdString().c_str(),
|
reason.toStdString().c_str(),
|
||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
struct PSAInstalled {
|
struct PSAInstalled {
|
||||||
struct Tariff {
|
struct Tariff {
|
||||||
QString name;
|
QString name;
|
||||||
@@ -12,6 +14,7 @@ struct PSAInstalled {
|
|||||||
int zone;
|
int zone;
|
||||||
int size;
|
int size;
|
||||||
QString blob;
|
QString blob;
|
||||||
|
QString lastCommit;
|
||||||
QString info;
|
QString info;
|
||||||
QString loadTime;
|
QString loadTime;
|
||||||
} tariff;
|
} tariff;
|
||||||
@@ -144,6 +147,7 @@ public:
|
|||||||
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
QString cloneAndCheckoutCustomerRepository(QString const &info, QString const &version = QString()); // clone and checkout customer repository
|
||||||
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
QString checkoutBranch(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
QString errorBackendNotConnected(QString const &info, QString const &version = QString()); // checkout branch
|
||||||
|
QString errorGitClone(int percent, QString const &info, QString const &version = QString());
|
||||||
QString backendConnected(QString const &info, QString const &version = QString());
|
QString backendConnected(QString const &info, QString const &version = QString());
|
||||||
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
QString updateTriggerSet(QString const &info, QString const &version = QString());
|
||||||
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
QString errorUpdateTrigger(QString const &info, QString const &version = QString());
|
||||||
@@ -154,8 +158,10 @@ public:
|
|||||||
// and update accepted
|
// and update accepted
|
||||||
QString updateOfPSASucceeded(QString const &version = QString()); // update process succeeded
|
QString updateOfPSASucceeded(QString const &version = QString()); // update process succeeded
|
||||||
QString updateOfPSAContinues(QString currentStage, QString currentStageInfo, QString const &version = QString());
|
QString updateOfPSAContinues(QString currentStage, QString currentStageInfo, QString const &version = QString());
|
||||||
QString updateOfPSAFailed(int resultCode, QString reason, QString const &version = QString());
|
QString updateOfPSAFailed(int resultCode, QString step, QString reason, QString const &version = QString());
|
||||||
QString sanityCheckFailed(int resultCode, QString reason, QString const &version = QString());
|
QString sanityCheckFailed(int resultCode, QString reason, QString const &version = QString());
|
||||||
|
QString jsonParseFailed(int resultCode, QString reason, QString const &version = QString());
|
||||||
|
std::optional<QString> finalResult(int resultCode, QString reason, QString const &version = QString());
|
||||||
|
|
||||||
QString updateOfPSASendVersion(PSAInstalled const &psa);
|
QString updateOfPSASendVersion(PSAInstalled const &psa);
|
||||||
|
|
||||||
|
137
mainwindow.cpp
137
mainwindow.cpp
@@ -12,10 +12,12 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
, m_worker(worker)
|
, m_worker(worker)
|
||||||
, m_width(52) {
|
, m_width(70)
|
||||||
|
, m_progressRunning(false)
|
||||||
|
, m_progressValue(0) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->updateProgress->setRange(1, 100);
|
ui->updateProgress->setRange(0, 100);
|
||||||
ui->updateProgress->reset();
|
ui->updateProgress->reset();
|
||||||
|
|
||||||
QStringList lst;
|
QStringList lst;
|
||||||
@@ -30,26 +32,16 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
ui->updateStatus->setText(lst.join('\n'));
|
ui->updateStatus->setText(lst.join('\n'));
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
|
|
||||||
ui->reserved_1->setVisible(false);
|
|
||||||
ui->reserved_2->setVisible(false);
|
|
||||||
ui->reserved_3->setVisible(false);
|
|
||||||
ui->reserved_4->setVisible(false);
|
|
||||||
ui->reserved_5->setVisible(false);
|
|
||||||
ui->reserved_6->setVisible(false);
|
|
||||||
|
|
||||||
m_startTimer = new QTimer(this);
|
m_startTimer = new QTimer(this);
|
||||||
connect(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
|
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(update()));
|
||||||
m_startTimer->setSingleShot(true);
|
m_startTimer->setSingleShot(true);
|
||||||
m_startTimer->start(5 * 1000);
|
m_startTimer->start(1000);
|
||||||
|
|
||||||
m_exitTimer = new QTimer(this);
|
m_exitTimer = new QTimer(this);
|
||||||
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
|
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
|
||||||
m_exitTimer->setSingleShot(true);
|
m_exitTimer->setSingleShot(true);
|
||||||
m_exitTimer->start(1800 * 1000);
|
m_exitTimer->start(1800 * 1000);
|
||||||
|
|
||||||
connect(m_startTimer, SIGNAL(timeout()), ui->start, SLOT(click()));
|
|
||||||
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
|
|
||||||
connect(ui->start, SIGNAL(clicked()), m_worker, SLOT(update()));
|
|
||||||
connect(ui->exit, SIGNAL(clicked()), this, SLOT(onQuit()));
|
connect(ui->exit, SIGNAL(clicked()), this, SLOT(onQuit()));
|
||||||
connect(m_worker, SIGNAL(disableExit()), this, SLOT(onDisableExit()));
|
connect(m_worker, SIGNAL(disableExit()), this, SLOT(onDisableExit()));
|
||||||
connect(m_worker, SIGNAL(enableExit()), this, SLOT(onEnableExit()));
|
connect(m_worker, SIGNAL(enableExit()), this, SLOT(onEnableExit()));
|
||||||
@@ -57,6 +49,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
connect(m_worker, SIGNAL(restartExitTimer()), this, SLOT(onRestartExitTimer()));
|
connect(m_worker, SIGNAL(restartExitTimer()), this, SLOT(onRestartExitTimer()));
|
||||||
connect(m_worker, SIGNAL(appendText(QString, QString)), this, SLOT(onAppendText(QString, QString)));
|
connect(m_worker, SIGNAL(appendText(QString, QString)), this, SLOT(onAppendText(QString, QString)));
|
||||||
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)), this, SLOT(onShowErrorMessage(QString,QString)));
|
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)), this, SLOT(onShowErrorMessage(QString,QString)));
|
||||||
|
connect(m_worker, SIGNAL(replaceLast(QString, QString)), this, SLOT(onReplaceLast(QString,QString)));
|
||||||
|
|
||||||
ui->updateStatus->setText(lst.join('\n'));
|
ui->updateStatus->setText(lst.join('\n'));
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
@@ -70,9 +63,55 @@ MainWindow::~MainWindow() {
|
|||||||
|
|
||||||
void MainWindow::customEvent(QEvent *event) {
|
void MainWindow::customEvent(QEvent *event) {
|
||||||
if (event->type() == ProgressEvent::type()) {
|
if (event->type() == ProgressEvent::type()) {
|
||||||
int progress = ((ProgressEvent *)(event))->progressPercent();
|
ProgressEvent *pevent = (ProgressEvent *)event;
|
||||||
ui->updateProgress->setValue(progress);
|
int const progress = pevent->progressPercent();
|
||||||
|
QObject const *sender = pevent->sender();
|
||||||
|
if (sender == this) {
|
||||||
|
switch(progress) {
|
||||||
|
case 0: {
|
||||||
|
ui->updateProgress->reset();
|
||||||
|
} break;
|
||||||
|
case START_PROGRESS_LOOP: {
|
||||||
|
m_progressRunning = true;
|
||||||
|
ui->updateProgress->reset();
|
||||||
|
m_progressValue = 10;
|
||||||
|
QApplication::postEvent(this, new ProgressEvent(this, m_progressValue));
|
||||||
|
} break;
|
||||||
|
case STOP_PROGRESS_LOOP: {
|
||||||
|
m_progressRunning = false;
|
||||||
|
m_progressValue -= 10;
|
||||||
|
m_worker->setProgress(m_progressValue/10);
|
||||||
|
} break;
|
||||||
|
default: {
|
||||||
|
if (m_progressRunning) {
|
||||||
|
m_progressValue = progress;
|
||||||
|
ui->updateProgress->setValue(progress/10);
|
||||||
|
QApplication::postEvent(this, new ProgressEvent(this, progress+10));
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (sender == m_worker) {
|
||||||
|
switch(progress) {
|
||||||
|
case 0: {
|
||||||
|
ui->updateProgress->reset();
|
||||||
|
} break;
|
||||||
|
case START_PROGRESS_LOOP: {
|
||||||
|
QApplication::postEvent(this, new ProgressEvent(this, START_PROGRESS_LOOP));
|
||||||
|
} break;
|
||||||
|
case STOP_PROGRESS_LOOP: {
|
||||||
|
QApplication::postEvent(this, new ProgressEvent(this, STOP_PROGRESS_LOOP));
|
||||||
|
} break;
|
||||||
|
default:{
|
||||||
|
ui->updateProgress->setValue(progress);
|
||||||
|
}}
|
||||||
|
} else {
|
||||||
|
qCritical() << "!!! UNKNOWN SENDER !!!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QThread::yieldCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onStopStartTimer() {
|
void MainWindow::onStopStartTimer() {
|
||||||
@@ -89,7 +128,7 @@ void MainWindow::onEnableExit() {
|
|||||||
|
|
||||||
void MainWindow::onRestartExitTimer() {
|
void MainWindow::onRestartExitTimer() {
|
||||||
m_exitTimer->stop();
|
m_exitTimer->stop();
|
||||||
m_exitTimer->start(10 * 1000);
|
m_exitTimer->start(60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onQuit() {
|
void MainWindow::onQuit() {
|
||||||
@@ -100,25 +139,59 @@ void MainWindow::onQuit() {
|
|||||||
|
|
||||||
void MainWindow::onAppendText(QString text, QString suffix) {
|
void MainWindow::onAppendText(QString text, QString suffix) {
|
||||||
QString editText = ui->updateStatus->toPlainText();
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
QStringList lines = editText.split('\n');
|
if (!suffix.isNull() && suffix.size() > 0) {
|
||||||
for (int i=0; i<lines.size(); ++i) {
|
qInfo() << "TEXT" << text << "SUFFIX" << suffix;
|
||||||
qCritical() << lines.at(i);
|
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
|
||||||
}
|
editText += QString("\n").leftJustified(m_width-3, '=');
|
||||||
if (suffix.contains("[SUCCESS]")) {
|
editText += " ";
|
||||||
editText += QString("\n").leftJustified(m_width-3, '=');
|
}
|
||||||
editText += QString("\n").leftJustified(m_width-12) + " [SUCCESS]";
|
editText += (QString("\n") + text).leftJustified(m_width - (2 + suffix.size()) ) + suffix;
|
||||||
} else
|
|
||||||
if (suffix.contains(" [fail]")) {
|
|
||||||
editText += QString("\n").leftJustified(m_width-3, '=');
|
|
||||||
editText += QString("\n").leftJustified(m_width-9) + " [fail]";
|
|
||||||
} else {
|
} else {
|
||||||
editText += text.leftJustified(m_width-9) + suffix;
|
editText += text.leftJustified(m_width-9);
|
||||||
ui->updateStatus->setPlainText(editText);
|
|
||||||
}
|
}
|
||||||
ui->updateStatus->setText(editText);
|
|
||||||
|
Utils::printLineEditInfo(editText.split('\n'));
|
||||||
|
|
||||||
|
ui->updateStatus->setPlainText(editText.trimmed());
|
||||||
|
ui->updateStatus->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||||
|
qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix;
|
||||||
|
|
||||||
|
QString editText = ui->updateStatus->toPlainText();
|
||||||
|
QStringList lines = editText.split('\n');
|
||||||
|
if (lines.size() > 0) {
|
||||||
|
lines.removeLast();
|
||||||
|
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||||
|
lines += text.leftJustified(m_width-10) + suffix;
|
||||||
|
} else {
|
||||||
|
lines += text.leftJustified(m_width-10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils::printLineEditInfo(lines);
|
||||||
|
|
||||||
|
ui->updateStatus->setText(lines.join('\n').trimmed());
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||||
QMessageBox::critical(this, title, text, QMessageBox::Ok);
|
text = text.leftJustified(50, ' ');
|
||||||
|
QMessageBox msgBox(QMessageBox::NoIcon, title,
|
||||||
|
text, QMessageBox::Ok,
|
||||||
|
nullptr, Qt::FramelessWindowHint);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
msgBox.defaultButton()->setVisible(false);
|
||||||
|
|
||||||
|
QTimer *t = new QTimer(this);
|
||||||
|
connect(t, SIGNAL(timeout()), msgBox.defaultButton(), SLOT(click()));
|
||||||
|
t->setSingleShot(true);
|
||||||
|
t->start(5 * 1000);
|
||||||
|
|
||||||
|
if(msgBox.exec() == QMessageBox::Ok) {
|
||||||
|
// do something
|
||||||
|
} else {
|
||||||
|
// do something else
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
10
mainwindow.h
10
mainwindow.h
@@ -20,8 +20,14 @@ public:
|
|||||||
MainWindow(Worker *worker, QWidget *parent = nullptr);
|
MainWindow(Worker *worker, QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
static const int START_PROGRESS_LOOP = -1;
|
||||||
|
static const int STOP_PROGRESS_LOOP = -2;
|
||||||
|
|
||||||
|
int progressValue() const { return m_progressValue; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAppendText(QString, QString);
|
void onAppendText(QString, QString suffix = "");
|
||||||
|
void onReplaceLast(QString, QString suffix = "");
|
||||||
void onShowErrorMessage(QString, QString);
|
void onShowErrorMessage(QString, QString);
|
||||||
void onStopStartTimer();
|
void onStopStartTimer();
|
||||||
void onRestartExitTimer();
|
void onRestartExitTimer();
|
||||||
@@ -37,5 +43,7 @@ private:
|
|||||||
int m_width;
|
int m_width;
|
||||||
QTimer *m_startTimer;
|
QTimer *m_startTimer;
|
||||||
QTimer *m_exitTimer;
|
QTimer *m_exitTimer;
|
||||||
|
bool m_progressRunning;
|
||||||
|
int m_progressValue;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
110
mainwindow.ui
110
mainwindow.ui
@@ -19,116 +19,44 @@
|
|||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget class="QWidget" name="">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>11</x>
|
<x>10</x>
|
||||||
<y>11</y>
|
<y>10</y>
|
||||||
<width>781</width>
|
<width>781</width>
|
||||||
<height>461</height>
|
<height>461</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="0">
|
<item row="3" column="2">
|
||||||
<widget class="QPushButton" name="start">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Terminus</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Start</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QPushButton" name="exit">
|
<widget class="QPushButton" name="exit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Exit</string>
|
<string>Exit</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="3" column="1">
|
||||||
<widget class="QPushButton" name="reserved_1">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
|
||||||
<widget class="QPushButton" name="reserved_2">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="4">
|
|
||||||
<widget class="QPushButton" name="reserved_3">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="5">
|
|
||||||
<widget class="QPushButton" name="reserved_4">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="6">
|
|
||||||
<widget class="QPushButton" name="reserved_6">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="7">
|
|
||||||
<widget class="QPushButton" name="reserved_5">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="8">
|
|
||||||
<widget class="QTextEdit" name="updateStatus">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Noto Sans</family>
|
|
||||||
<pointsize>8</pointsize>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="8">
|
|
||||||
<widget class="QProgressBar" name="updateProgress">
|
<widget class="QProgressBar" name="updateProgress">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0" rowspan="3" colspan="3">
|
||||||
|
<widget class="QTextEdit" name="updateStatus">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Misc Fixed</family>
|
||||||
|
<pointsize>11</pointsize>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
QEvent::Type ProgressEvent::customEventType = QEvent::None;
|
QEvent::Type ProgressEvent::customEventType = QEvent::None;
|
||||||
|
|
||||||
ProgressEvent::ProgressEvent(int progressPercent)
|
ProgressEvent::ProgressEvent(QObject const *sender, int progressPercent)
|
||||||
: QEvent(ProgressEvent::type())
|
: QEvent(ProgressEvent::type())
|
||||||
|
, m_sender(sender)
|
||||||
, m_progressPercent(progressPercent) {
|
, m_progressPercent(progressPercent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,12 +5,16 @@
|
|||||||
|
|
||||||
class ProgressEvent : public QEvent {
|
class ProgressEvent : public QEvent {
|
||||||
|
|
||||||
|
QObject const *m_sender;
|
||||||
int m_progressPercent;
|
int m_progressPercent;
|
||||||
public:
|
public:
|
||||||
explicit ProgressEvent(int progressPercent);
|
explicit ProgressEvent(QObject const *sender, int progressPercent);
|
||||||
virtual ~ProgressEvent();
|
virtual ~ProgressEvent();
|
||||||
static QEvent::Type type();
|
static QEvent::Type type();
|
||||||
|
|
||||||
|
QObject const *sender() { return m_sender; }
|
||||||
|
QObject const *sender() const { return m_sender; }
|
||||||
|
|
||||||
void setProgress(int progressPercent) { m_progressPercent = progressPercent; }
|
void setProgress(int progressPercent) { m_progressPercent = progressPercent; }
|
||||||
int progressPercent() { return m_progressPercent; }
|
int progressPercent() { return m_progressPercent; }
|
||||||
int progressPercent() const { return m_progressPercent; }
|
int progressPercent() const { return m_progressPercent; }
|
||||||
|
73
update.cpp
73
update.cpp
@@ -8,6 +8,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
//#include <iostream>
|
//#include <iostream>
|
||||||
//#include <fstream>
|
//#include <fstream>
|
||||||
@@ -350,21 +351,25 @@ bool Update::downloadBinaryToDC(QString const &bFile) const {
|
|||||||
10 : bl_stopBL() // leave bl and start (the new) application
|
10 : bl_stopBL() // leave bl and start (the new) application
|
||||||
*/
|
*/
|
||||||
bool Update::updateBinary(char const *fileToSendToDC) {
|
bool Update::updateBinary(char const *fileToSendToDC) {
|
||||||
qInfo() << "updating device controller binary" << fileToSendToDC;
|
qInfo() << "UPDATING DEVICE CONTROLLER BINARY" << fileToSendToDC;
|
||||||
QFile fn(fileToSendToDC);
|
QFile fn(fileToSendToDC);
|
||||||
bool r;
|
bool r;
|
||||||
if ((r = fn.exists()) == true) {
|
if ((r = fn.exists()) == true) {
|
||||||
QString const linkTarget = fn.symLinkTarget();
|
QFileInfo fi(fn);
|
||||||
QFileInfo fi(linkTarget);
|
qInfo() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ")";
|
||||||
qInfo() << " updating binary (size=" << linkTarget << fi.size() << ")";
|
if ((r = updateDC(fileToSendToDC)) == true) {
|
||||||
if ((r = updateDC(linkTarget)) == true) {
|
qCritical() << QString(80, '*');
|
||||||
qInfo() << " updating binary (size=" << linkTarget << fi.size() << ") done";
|
qInfo() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ") DONE";
|
||||||
|
qCritical() << QString(80, '*');
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "updating binary (size=" << linkTarget << fi.size() << ")... FAILED";
|
qCritical() << QString(80, '*');
|
||||||
|
qCritical() << " UPDATING BINARY" << fi.fileName() << "(size=" << fi.size() << ") FAILED";
|
||||||
|
qCritical() << QString(80, '*');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "symlink" << fileToSendToDC
|
qCritical() << QString(80, '*');
|
||||||
<< "does not exist -> NO UPDATE OF DC FIRMWARE";
|
qCritical() << fileToSendToDC << "does not exist -> NO UPDATE OF DC FIRMWARE";
|
||||||
|
qCritical() << QString(80, '*');
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -514,7 +519,6 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// ACHTUNG !!!
|
// ACHTUNG !!!
|
||||||
//
|
//
|
||||||
@@ -523,11 +527,6 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
bool serialOpened = false;
|
bool serialOpened = false;
|
||||||
bool serialOpen = false;
|
bool serialOpen = false;
|
||||||
|
|
||||||
if (filesToWorkOn.size() == 0) {
|
|
||||||
qCritical() << "NOTHING TO UPDATE";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!serialOpen) {
|
if (!serialOpen) {
|
||||||
if (!isSerialOpen()) { // open serial only if not already open
|
if (!isSerialOpen()) { // open serial only if not already open
|
||||||
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) == false) {
|
if ((serialOpened = openSerial(baudrateMap.value(m_baudrate), m_baudrate, m_serialInterface)) == false) {
|
||||||
@@ -537,18 +536,23 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
serialOpen = true;
|
serialOpen = true;
|
||||||
qCritical() << "SERIAL OPEN" << m_serialInterface << "(BAUDRATE=" << m_baudrate << ")";
|
qInfo() << "SERIAL OPEN" << m_serialInterface << "(BAUDRATE=" << m_baudrate << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool res = false;
|
||||||
QList<QString>::const_iterator it;
|
QList<QString>::const_iterator it;
|
||||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||||
bool res = false;
|
m_worker->startProgressLoop();
|
||||||
QString fToWorkOn = (*it).trimmed();
|
QString fToWorkOn = (*it).trimmed();
|
||||||
|
fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + fToWorkOn);
|
||||||
|
|
||||||
if (fToWorkOn.contains("dc2c", Qt::CaseInsensitive) &&
|
static const QRegularExpression version("^.*dc2c[.][0-9][0-9][.][0-9][0-9][.]bin.*$");
|
||||||
fToWorkOn.endsWith(".bin", Qt::CaseInsensitive)) {
|
if (fToWorkOn.contains(version)) {
|
||||||
|
|
||||||
|
qInfo() << QString(80, '*');
|
||||||
|
qInfo() << "DO-UPDATE FILE-TO-WORK-ON" << fToWorkOn;
|
||||||
|
qInfo() << QString(80, '*');
|
||||||
|
|
||||||
qDebug() << "sending sw/hw-requests...";
|
|
||||||
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
||||||
// current SW/HW-versions
|
// current SW/HW-versions
|
||||||
m_hw->request_DC2_SWversion();
|
m_hw->request_DC2_SWversion();
|
||||||
@@ -558,12 +562,16 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
|
|
||||||
QString const hwVersion = m_hw->dc_getHWversion().toLower();
|
QString const hwVersion = m_hw->dc_getHWversion().toLower();
|
||||||
QString const fwVersion = m_hw->dc_getSWversion().toLower();
|
QString const fwVersion = m_hw->dc_getSWversion().toLower();
|
||||||
|
|
||||||
qInfo() << "current dc-hardware-version" << hwVersion;
|
qInfo() << "current dc-hardware-version" << hwVersion;
|
||||||
qInfo() << "current dc-firmware-version" << fwVersion;
|
qInfo() << "current dc-firmware-version" << fwVersion;
|
||||||
|
|
||||||
QFile fn(fToWorkOn);
|
QFile fn(fToWorkOn);
|
||||||
QFileInfo linkTarget(fn.symLinkTarget());
|
QFileInfo finfo(fn);
|
||||||
if (!linkTarget.exists()) { // check for broken link
|
if (!fn.exists()) { // check for broken link
|
||||||
|
qCritical() << QString(80, '*');
|
||||||
|
qCritical() << "FILE-TO-WORK-ON" << fn << "DOES NOT EXIST";
|
||||||
|
qCritical() << QString(80, '*');
|
||||||
res = false;
|
res = false;
|
||||||
} else {
|
} else {
|
||||||
if (false) {
|
if (false) {
|
||||||
@@ -574,13 +582,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
} else {
|
} else {
|
||||||
res = true;
|
res = true;
|
||||||
|
|
||||||
qCritical() << "downloading" << fToWorkOn.trimmed() << "->"
|
qInfo() << "DOWNLOADING" << finfo.completeBaseName() << "TO DC";
|
||||||
<< linkTarget.completeBaseName() << "to DC";
|
|
||||||
#if UPDATE_DC == 1
|
#if UPDATE_DC == 1
|
||||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||||
QThread::sleep(1); // wait to be sure that there are no more
|
QThread::sleep(1); // wait to be sure that there are no more
|
||||||
// commands sent to dc-hardware
|
// commands sent to dc-hardware
|
||||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
qInfo() << "SET AUTO-REQUEST=FALSE";
|
||||||
|
|
||||||
if ((res = updateBinary(fToWorkOn.toStdString().c_str())) == true) {
|
if ((res = updateBinary(fToWorkOn.toStdString().c_str())) == true) {
|
||||||
qCritical() << "downloaded binary" << fToWorkOn;
|
qCritical() << "downloaded binary" << fToWorkOn;
|
||||||
@@ -591,13 +598,13 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
qInfo() << "SET AUTO-REQUEST=TRUE";
|
||||||
qDebug() << "WAIT 10 SECS TO RECEIVE RESPONSES...";
|
qInfo() << "WAIT 10 SECS TO RECEIVE RESPONSES...";
|
||||||
|
|
||||||
QThread::sleep(10); // wait to be sure that responses
|
QThread::sleep(10); // wait to be sure that responses
|
||||||
// have been received
|
// have been received
|
||||||
qCritical() << "updated dc-hardware-version" << m_hw->dc_getHWversion();
|
qInfo() << "updated dc-hardware-version" << m_hw->dc_getHWversion();
|
||||||
qCritical() << "updated dc-firmware-version" << m_hw->dc_getSWversion();
|
qInfo() << "updated dc-firmware-version" << m_hw->dc_getSWversion();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,10 +667,16 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
|
m_worker->stopProgressLoop();
|
||||||
|
m_worker->setProgress(100);
|
||||||
|
|
||||||
|
if (res == false) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
} // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
|
||||||
|
|
||||||
m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON
|
||||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||||
|
|
||||||
return true;
|
return res;
|
||||||
}
|
}
|
||||||
|
46
utils.cpp
46
utils.cpp
@@ -1,8 +1,9 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "message_handler.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
int Utils::read1stLineOfFile(QString fileName) {
|
int Utils::read1stLineOfFile(QString fileName) {
|
||||||
QFile f(fileName);
|
QFile f(fileName);
|
||||||
@@ -33,3 +34,46 @@ QString Utils::zoneName(quint8 i) {
|
|||||||
}
|
}
|
||||||
return "N/A";
|
return "N/A";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Utils::printCriticalErrorMsg(QString const &errorMsg) {
|
||||||
|
qCritical() << QString(80, '!');
|
||||||
|
qCritical() << errorMsg;
|
||||||
|
qCritical() << QString(80, '!');
|
||||||
|
}
|
||||||
|
|
||||||
|
void Utils::printInfoMsg(QString const &infoMsg) {
|
||||||
|
qCritical() << QString(80, '=');
|
||||||
|
qCritical() << infoMsg;
|
||||||
|
qCritical() << QString(80, '=');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Utils::printLineEditInfo(QStringList const &lines) {
|
||||||
|
if (getDebugLevel() == LOG_DEBUG) {
|
||||||
|
for (int i=0; i<lines.size(); ++i) {
|
||||||
|
qInfo() << lines.at(i);
|
||||||
|
} qInfo() << ""; qInfo() << "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Utils::getTariffLoadTime(QString fileName) {
|
||||||
|
QFileInfo fInfo(fileName);
|
||||||
|
if (fInfo.exists()) {
|
||||||
|
QDateTime lastModifiedTime = fInfo.lastModified();
|
||||||
|
if (lastModifiedTime.isValid()) {
|
||||||
|
return lastModifiedTime.toString(Qt::ISODateWithMs);
|
||||||
|
} else {
|
||||||
|
printCriticalErrorMsg(fileName + " HAS INVALID MODIFIED-TIME");
|
||||||
|
QDateTime birthTime = fInfo.birthTime();
|
||||||
|
if (birthTime.isValid()) {
|
||||||
|
return birthTime.toString(Qt::ISODateWithMs);
|
||||||
|
} else {
|
||||||
|
printCriticalErrorMsg(fileName + " HAS INVALID BIRTH-TIME");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printCriticalErrorMsg(fileName + " DOES NOT EXIST");
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
7
utils.h
7
utils.h
@@ -3,11 +3,18 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
int read1stLineOfFile(QString fileName);
|
int read1stLineOfFile(QString fileName);
|
||||||
QString zoneName(quint8 i);
|
QString zoneName(quint8 i);
|
||||||
|
void printCriticalErrorMsg(QString const &errorMsg);
|
||||||
|
void printInfoMsg(QString const &infoMsg);
|
||||||
|
void printLineEditInfo(QStringList const &lines);
|
||||||
|
QString getTariffLoadTime(QString fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // UTILS_H_INCLUDED
|
#endif // UTILS_H_INCLUDED
|
||||||
|
849
worker.cpp
849
worker.cpp
File diff suppressed because it is too large
Load Diff
22
worker.h
22
worker.h
@@ -32,6 +32,9 @@ enum class UPDATE_STATUS : quint8 {
|
|||||||
ISMAS_WAIT_STATE_CHECK_SUCCESS,
|
ISMAS_WAIT_STATE_CHECK_SUCCESS,
|
||||||
ISMAS_RESPONSE_RECEIVED,
|
ISMAS_RESPONSE_RECEIVED,
|
||||||
BACKEND_CONNECTED,
|
BACKEND_CONNECTED,
|
||||||
|
BACKEND_CHECK,
|
||||||
|
BACKEND_CHECK_FAILURE,
|
||||||
|
ISMAS_BACKEND_CHECK_FAILURE,
|
||||||
BACKEND_NOT_CONNECTED,
|
BACKEND_NOT_CONNECTED,
|
||||||
UPDATE_TRIGGER_SET,
|
UPDATE_TRIGGER_SET,
|
||||||
UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
UPDATE_TRIGGER_NOT_SET_OR_WRONG,
|
||||||
@@ -59,6 +62,7 @@ enum class UPDATE_STATUS : quint8 {
|
|||||||
DEVICE_CONTROLLER_UPDATE_SUCCESS,
|
DEVICE_CONTROLLER_UPDATE_SUCCESS,
|
||||||
JSON_UPDATE,
|
JSON_UPDATE,
|
||||||
JSON_UPDATE_FAILURE,
|
JSON_UPDATE_FAILURE,
|
||||||
|
JSON_PARSE_FAILURE,
|
||||||
JSON_UPDATE_SUCCESS,
|
JSON_UPDATE_SUCCESS,
|
||||||
UPDATE_PROCESS_SUCCESS,
|
UPDATE_PROCESS_SUCCESS,
|
||||||
UPDATE_PROCESS_FAILURE,
|
UPDATE_PROCESS_FAILURE,
|
||||||
@@ -67,7 +71,13 @@ enum class UPDATE_STATUS : quint8 {
|
|||||||
ISMAS_UPDATE_INFO_CONFIRM_SUCCESS,
|
ISMAS_UPDATE_INFO_CONFIRM_SUCCESS,
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM,
|
ISMAS_CURRENT_PSA_STATUS_CONFIRM,
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM_FAILURE,
|
ISMAS_CURRENT_PSA_STATUS_CONFIRM_FAILURE,
|
||||||
ISMAS_CURRENT_PSA_STATUS_CONFIRM_SUCCESS
|
ISMAS_CURRENT_PSA_STATUS_CONFIRM_SUCCESS,
|
||||||
|
ISMAS_SANITY_CHECK_OK,
|
||||||
|
ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
|
PSA_UPDATE_FILES_FAILED,
|
||||||
|
GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
|
ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
|
SAVE_LOG_FILES_FAILED
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UpdateStatus {
|
struct UpdateStatus {
|
||||||
@@ -126,6 +136,8 @@ class Worker : public QObject {
|
|||||||
int m_returnCode;
|
int m_returnCode;
|
||||||
|
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
|
int m_progressValue;
|
||||||
|
bool m_withoutIsmasDirectPort;
|
||||||
|
|
||||||
bool executeOpkgCommand(QString opkgCommand);
|
bool executeOpkgCommand(QString opkgCommand);
|
||||||
QString getOsVersion() const;
|
QString getOsVersion() const;
|
||||||
@@ -138,8 +150,6 @@ class Worker : public QObject {
|
|||||||
|
|
||||||
qint64 getFileSize(QString const &fileName) const;
|
qint64 getFileSize(QString const &fileName) const;
|
||||||
|
|
||||||
void setProgress(int progress);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const QString UPDATE_STEP_OK;
|
static const QString UPDATE_STEP_OK;
|
||||||
static const QString UPDATE_STEP_DONE;
|
static const QString UPDATE_STEP_DONE;
|
||||||
@@ -159,6 +169,9 @@ public:
|
|||||||
~Worker();
|
~Worker();
|
||||||
|
|
||||||
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
||||||
|
void setProgress(int progress);
|
||||||
|
void startProgressLoop();
|
||||||
|
void stopProgressLoop();
|
||||||
|
|
||||||
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
||||||
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
||||||
@@ -180,7 +193,8 @@ public:
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void appendText(QString, QString);
|
void appendText(QString, QString suffix = "");
|
||||||
|
void replaceLast(QString, QString);
|
||||||
void showErrorMessage(QString title, QString description);
|
void showErrorMessage(QString title, QString description);
|
||||||
void stopStartTimer();
|
void stopStartTimer();
|
||||||
void restartExitTimer();
|
void restartExitTimer();
|
||||||
|
Reference in New Issue
Block a user