From af83c11f7355ab6ceb6a851d71dbbc5f72f655ca Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 18 Feb 2025 14:54:41 +0100 Subject: [PATCH] Changes for ATBUpdateOpkg --- UpdatePTUDevCtrl/mainwindow.cpp | 84 ++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 6 deletions(-) diff --git a/UpdatePTUDevCtrl/mainwindow.cpp b/UpdatePTUDevCtrl/mainwindow.cpp index f1725bf..e7cae63 100644 --- a/UpdatePTUDevCtrl/mainwindow.cpp +++ b/UpdatePTUDevCtrl/mainwindow.cpp @@ -95,6 +95,8 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent) connect(m_worker, SIGNAL(showUpdateRequest(QString)),this,SLOT(onShowUpdateRequest(QString))); connect(m_worker, SIGNAL(showCustRepoStatus(QString)),this,SLOT(onShowCustRepoStatus(QString))); connect(m_worker, SIGNAL(showExecOpkgStatus(QString)),this,SLOT(onShowExecOpkgStatus(QString))); + connect(m_worker, SIGNAL(showExecOpkgCommand(QString)),this,SLOT(onShowExecOpkgCommand(QString))); + connect(m_worker, SIGNAL(showExecOpkgOverallResult(QString, bool)),this,SLOT(onShowExecOpkgOverallResult(QString,bool))); connect(m_worker, SIGNAL(showDownloadDCJsonFilesStatus(QString)),this,SLOT(onShowDownloadDCJsonFilesStatus(QString))); connect(m_worker, SIGNAL(showSyncCustRepoStatus(QString)),this,SLOT(onShowSyncCustRepoStatus(QString))); connect(m_worker, SIGNAL(showUpdateDCFirmware(QString)),this,SLOT(onShowUpdateDCFirmware(QString))); @@ -149,11 +151,12 @@ void MainWindow::onShowTariffUpdate(QString) { void MainWindow::onShowISMASConnectivity(QString status) { // ausgabe: connected, not connected, connecting + m_stepLabelChopCount = 0; qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); - QString tmp("backend connection (ISMAS) "); + QString tmp("Check backend connection (ISMAS) "); int len = m_showLineLength - tmp.length(); while (--len > 0) { tmp += " "; @@ -184,6 +187,10 @@ void MainWindow::onShowISMASConnectivity(QString status) { s += QString( "%1 UNKNOWN STATUS
").arg(tmp); } + m_stepLabelChopCount = -s.length(); + s += "Check update request"; + m_stepLabelChopCount += s.length(); + ui->stepLabel->setText(s); } @@ -191,8 +198,9 @@ void MainWindow::onShowCustRepoStatus(QString status) { qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); - QString tmp("customer repository "); + QString tmp("Check customer repository "); int len = m_showLineLength - tmp.length(); while (--len > 0) { tmp += " "; @@ -204,6 +212,10 @@ void MainWindow::onShowCustRepoStatus(QString status) { s += QString( "%1 UNKNOWN STATUS
").arg(tmp); } + m_stepLabelChopCount = -s.length(); + s += "Install SW packets (dry run)"; + m_stepLabelChopCount += s.length(); + ui->stepLabel->setText(s); } @@ -228,12 +240,57 @@ void MainWindow::onShowExecOpkgStatus(QString status) { ui->stepLabel->setText(s); } +void MainWindow::onShowExecOpkgCommand(QString cmd) { + qCritical() << __func__ << ":" << __LINE__ << "cmd" << cmd; + + if (cmd.back() != QChar('\n')) { + cmd += "\n"; + } + onInsertText(cmd); +} + +void MainWindow::onShowExecOpkgOverallResult(QString status, bool noaction) { + qCritical() << __func__ << ":" << __LINE__ << "status" << status; + + QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); + + QString tmp = noaction ? "Install SW packets (dry run) " : "Install SW packets "; + int len = m_showLineLength - tmp.length(); + + while (--len > 0) { + tmp += " "; + } + + if (status.contains(internal::EXEC_OPKG_COMMANDS_SUCCESS, Qt::CaseInsensitive)) { + s += QString("%1 success
").arg(tmp); + } else + if (status.contains(internal::EXEC_OPKG_COMMANDS_FAIL, Qt::CaseInsensitive)) { + s += QString("%1 %2
").arg(tmp).arg(internal::EXEC_OPKG_COMMANDS_FAIL); + } else { + s += QString( "%1 UNKNOWN STATUS
").arg(tmp); + } + + if (noaction) { + m_stepLabelChopCount = -s.length(); + s += "Install SW packets"; + m_stepLabelChopCount += s.length(); + } else { + m_stepLabelChopCount = -s.length(); + s += "Install DC configuration"; + m_stepLabelChopCount += s.length(); + } + + ui->stepLabel->setText(s); +} + void MainWindow::onShowDownloadDCJsonFilesStatus(QString status) { qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); - QString tmp = "configure device controller "; + QString tmp = "Install DC configuration "; int len = m_showLineLength - tmp.length(); while (--len > 0) { @@ -246,6 +303,10 @@ void MainWindow::onShowDownloadDCJsonFilesStatus(QString status) { s += QString( "%1 UNKNOWN STATUS
").arg(tmp); } + m_stepLabelChopCount = -s.length(); + s += "Synchronize repository/filesystem"; + m_stepLabelChopCount += s.length(); + ui->stepLabel->setText(s); } @@ -253,8 +314,9 @@ void MainWindow::onShowSyncCustRepoStatus(QString status) { qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); - QString tmp = "synchronize repository/filesystem "; + QString tmp = "Synchronize repository/filesystem "; int len = m_showLineLength - tmp.length(); while (--len > 0) { @@ -267,6 +329,10 @@ void MainWindow::onShowSyncCustRepoStatus(QString status) { s += QString( "%1 UNKNOWN STATUS
").arg(tmp); } + m_stepLabelChopCount = -s.length(); + s += "Update DC"; + m_stepLabelChopCount += s.length(); + ui->stepLabel->setText(s); } @@ -274,8 +340,9 @@ void MainWindow::onShowUpdateDCFirmware(QString status) { qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); - QString tmp = "device controller update "; + QString tmp = "Update DC "; int len = m_showLineLength - tmp.length(); while (--len > 0) { @@ -297,8 +364,9 @@ void MainWindow::onShowUpdateRequest(QString status) { qCritical() << __func__ << ":" << __LINE__ << "status" << status; QString s = ui->stepLabel->text(); + s.chop(m_stepLabelChopCount); - QString tmp = "update request "; + QString tmp = "Check update request "; int len = m_showLineLength - tmp.length(); while (--len > 0) { @@ -330,6 +398,10 @@ void MainWindow::onShowUpdateRequest(QString status) { s += QString( "%1 UNKNOWN
").arg(tmp); } + m_stepLabelChopCount = -s.length(); + s += "Check customer repository"; + m_stepLabelChopCount += s.length(); + ui->stepLabel->setText(s); }