Compare commits
9 Commits
6fc62863c1
...
2ab485454c
Author | SHA1 | Date | |
---|---|---|---|
2ab485454c | |||
cbb81b7260 | |||
487bbb8160 | |||
d36c7c1f72 | |||
cf3e1d61dd | |||
e12181dc5a | |||
d1b3b81972 | |||
ac03f4ae91 | |||
0c0debb790 |
@ -55,6 +55,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
QString connectionStatus{internal::ISMAS_NOT_CONNECTED};
|
QString connectionStatus{internal::ISMAS_NOT_CONNECTED};
|
||||||
QString updateRequestStatus{internal::UPDATE_NOT_REQUESTED};
|
QString updateRequestStatus{internal::UPDATE_NOT_REQUESTED};
|
||||||
|
|
||||||
|
{
|
||||||
QDebug debug = qCritical();
|
QDebug debug = qCritical();
|
||||||
|
|
||||||
int tries = 10;
|
int tries = 10;
|
||||||
@ -113,7 +115,7 @@ int main(int argc, char **argv) {
|
|||||||
if (internal::customerRepoExists() == false) {
|
if (internal::customerRepoExists() == false) {
|
||||||
// if the customer repository does not exists, it does not matter is
|
// if the customer repository does not exists, it does not matter is
|
||||||
// ISMAS is connected or how the setting for the WAIT-button is.
|
// ISMAS is connected or how the setting for the WAIT-button is.
|
||||||
updateRequestStatus = internal::NO_CUSTOMER_REPOSITORY;
|
updateRequestStatus = internal::UPDATE_INITIAL;
|
||||||
} else {
|
} else {
|
||||||
if (connectionStatus == internal::ISMAS_CONNECTED) {
|
if (connectionStatus == internal::ISMAS_CONNECTED) {
|
||||||
if (std::optional<QString> result
|
if (std::optional<QString> result
|
||||||
@ -172,6 +174,7 @@ int main(int argc, char **argv) {
|
|||||||
if (parser.isSet(ismasConnectOption)) {
|
if (parser.isSet(ismasConnectOption)) {
|
||||||
debug.noquote() << connectionStatus;
|
debug.noquote() << connectionStatus;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
@ -326,6 +326,7 @@ HEADERS += \
|
|||||||
commandline_parser.h \
|
commandline_parser.h \
|
||||||
work_process_list.h \
|
work_process_list.h \
|
||||||
$${_PRO_FILE_PWD_}/../common/include/utils_internal.h \
|
$${_PRO_FILE_PWD_}/../common/include/utils_internal.h \
|
||||||
|
$${_PRO_FILE_PWD_}/../common/include/log_line_entry.h \
|
||||||
$${_PRO_FILE_PWD_}/../common/ismas/ApismClient.h \
|
$${_PRO_FILE_PWD_}/../common/ismas/ApismClient.h \
|
||||||
$${_PRO_FILE_PWD_}/../common/ismas/ApismTcpClient.h \
|
$${_PRO_FILE_PWD_}/../common/ismas/ApismTcpClient.h \
|
||||||
$${_PRO_FILE_PWD_}/../common/ismas/ISMASData.h \
|
$${_PRO_FILE_PWD_}/../common/ismas/ISMASData.h \
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "utils_internal.h"
|
#include "utils_internal.h"
|
||||||
|
#include "log_line_entry.h"
|
||||||
#include "progress_event.h"
|
#include "progress_event.h"
|
||||||
#include "update_dc_event.h"
|
#include "update_dc_event.h"
|
||||||
#include "process/update_command.h"
|
#include "process/update_command.h"
|
||||||
@ -25,6 +26,42 @@
|
|||||||
#define SYNCHRONIZE_REPOSITORY 6
|
#define SYNCHRONIZE_REPOSITORY 6
|
||||||
#define UPDATE_DC 7
|
#define UPDATE_DC 7
|
||||||
|
|
||||||
|
#define CHECK_ISMAS_CONNECT_PERCENT_START ( 1)
|
||||||
|
#define CHECK_ISMAS_CONNECT_PERCENT_END (10)
|
||||||
|
|
||||||
|
#define CHECK_UPDATE_REQUEST_PERCENT_START (10)
|
||||||
|
#define CHECK_UPDATE_REQUEST_PERCENT_END (20)
|
||||||
|
|
||||||
|
#define UPDATE_GIT_PERCENT_START (20)
|
||||||
|
#define UPDATE_GIT_PERCENT_END (21)
|
||||||
|
|
||||||
|
#define UPDATE_OPKG_NOACTION_PERCENT_START (21)
|
||||||
|
#define UPDATE_OPKG_NOACTION_PERCENT_END (25)
|
||||||
|
|
||||||
|
#define UPDATE_OPKG_PERCENT_START (25)
|
||||||
|
#define UPDATE_OPKG_PERCENT_END (40)
|
||||||
|
|
||||||
|
#define UPDATE_DOWNLOAD_JSON_START (40)
|
||||||
|
#define UPDATE_DOWNLOAD_JSON_END (49)
|
||||||
|
|
||||||
|
#define UPDATE_SYNC_START (49)
|
||||||
|
#define UPDATE_SYNC_END (50)
|
||||||
|
|
||||||
|
#define UPDATE_DOWNLOAD_DC_START (50)
|
||||||
|
#define UPDATE_DOWNLOAD_DC_END (100)
|
||||||
|
|
||||||
|
void MainWindow::onFileChanged(QString const& /*f*/) {
|
||||||
|
static int i = 30;
|
||||||
|
ui->updateProgress->setValue(++i);
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) << "YYYYYYYYYYYYYYYYYY file changed" << i;
|
||||||
|
|
||||||
|
// TODO: daten an ISMAS senden
|
||||||
|
}
|
||||||
|
|
||||||
|
QProgressBar *MainWindow::progressBar() {
|
||||||
|
return ui ? ui->updateProgress : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@ -32,10 +69,15 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
, m_worker(worker)
|
, m_worker(worker)
|
||||||
, m_width(60)
|
, m_width(60)
|
||||||
, m_progressRunning(false)
|
, m_progressRunning(false)
|
||||||
, m_updateStep(UpdateDcEvent::UpdateStep::NONE) {
|
, m_updateStep(UpdateDcEvent::UpdateStep::NONE)
|
||||||
|
, m_updateLog("/opt/app/tools/atbupdate/update.log") { // TODO: in ini-file eintragen
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
if (!m_updateLog.open(QIODevice::ReadWrite | QIODevice::Unbuffered)) {
|
||||||
|
qCritical() << "ERROR can not open" << m_updateLog.fileName();
|
||||||
|
}
|
||||||
|
|
||||||
m_updateSteps.resize(8);
|
m_updateSteps.resize(8);
|
||||||
m_updateSteps[CHECK_BACKEND_CONNECTION] = "Check backend connection (ISMAS) ";
|
m_updateSteps[CHECK_BACKEND_CONNECTION] = "Check backend connection (ISMAS) ";
|
||||||
m_updateSteps[CHECK_UPDATE_REQUEST] = "Check update request ";
|
m_updateSteps[CHECK_UPDATE_REQUEST] = "Check update request ";
|
||||||
@ -274,6 +316,7 @@ void MainWindow::onShowTariffUpdate(QString) {
|
|||||||
void MainWindow::onShowISMASConnectivity(QString status) {
|
void MainWindow::onShowISMASConnectivity(QString status) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
|
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
|
||||||
|
|
||||||
|
QString stepResult;
|
||||||
QString s = m_updateSteps[CHECK_BACKEND_CONNECTION].trimmed();
|
QString s = m_updateSteps[CHECK_BACKEND_CONNECTION].trimmed();
|
||||||
|
|
||||||
bool const custRepoExists = internal::customerRepoExists();
|
bool const custRepoExists = internal::customerRepoExists();
|
||||||
@ -281,24 +324,46 @@ void MainWindow::onShowISMASConnectivity(QString status) {
|
|||||||
if (status.contains(UpdateCommand::ISMAS_CONNECTED, Qt::CaseInsensitive)) {
|
if (status.contains(UpdateCommand::ISMAS_CONNECTED, Qt::CaseInsensitive)) {
|
||||||
if (custRepoExists) {
|
if (custRepoExists) {
|
||||||
s += " <font color='Green'>connected</font>";
|
s += " <font color='Green'>connected</font>";
|
||||||
|
stepResult = "ISMAS connected";
|
||||||
} else {
|
} else {
|
||||||
s += " <font color='Green'>connected (initial configuration)</font>";
|
s += " <font color='Green'>connected (initial configuration)</font>";
|
||||||
|
stepResult = "ISMAS connected (initial configuration)";
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
|
if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
|
||||||
s += " <font color='Blue'>NOT CONNECTED</font>";
|
s += " <font color='Blue'>NOT CONNECTED</font>";
|
||||||
|
stepResult = "ISMAS not connected";
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
|
if (status.contains(UpdateCommand::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
|
||||||
s += " <font color='Green'>connecting</font>";
|
s += " <font color='Green'>connecting</font>";
|
||||||
|
stepResult = "connecting ISMAS";
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) {
|
if (status.contains(UpdateCommand::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) {
|
||||||
if (custRepoExists) {
|
if (custRepoExists) {
|
||||||
s += " <font color='Red'>NOT CONNECTED. STOP</font>";
|
s += " <font color='Red'>NOT CONNECTED. STOP</font>";
|
||||||
|
stepResult = "ISMAS not connected";
|
||||||
} else {
|
} else {
|
||||||
s += " <font color='Red'>not connected. (initial configuration)</font>";
|
s += " <font color='Red'>not connected. (initial configuration)</font>";
|
||||||
|
stepResult = "ISMAS not connected (initial configuration)";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
s += " <font color='Red'>UNKNOWN STATUS</font>";
|
s += " <font color='Red'>UNKNOWN STATUS</font>";
|
||||||
|
stepResult = "unknown status";
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LogLineEntry logLine =
|
||||||
|
initLogLineEntry(1, // receiver
|
||||||
|
QDateTime::currentDateTime().toString(Qt::ISODate).toUtf8().constData(),
|
||||||
|
_ISMAS_CONTINUE,
|
||||||
|
0, // eventState
|
||||||
|
CHECK_ISMAS_CONNECT_PERCENT_START,
|
||||||
|
ISMAS::RESULT_CODE::E_SUCCESS,
|
||||||
|
"show ISMAS connectivity", // step
|
||||||
|
stepResult.toUtf8().constData()); // stepResult
|
||||||
|
|
||||||
|
int w = 0;
|
||||||
|
if ((w = m_updateLog.write((char *)(&logLine), sizeof(logLine))) != sizeof(logLine)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "ERROR only" << w << "bytes written";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updateSteps[CHECK_BACKEND_CONNECTION] = s;
|
m_updateSteps[CHECK_BACKEND_CONNECTION] = s;
|
||||||
@ -307,6 +372,20 @@ void MainWindow::onShowISMASConnectivity(QString status) {
|
|||||||
s += m_updateSteps[i] + "<br />";
|
s += m_updateSteps[i] + "<br />";
|
||||||
}
|
}
|
||||||
ui->stepLabel->setText(s);
|
ui->stepLabel->setText(s);
|
||||||
|
|
||||||
|
logLine =
|
||||||
|
initLogLineEntry(1, // receiver
|
||||||
|
QDateTime::currentDateTime().toString(Qt::ISODate).toUtf8().constData(),
|
||||||
|
_ISMAS_CONTINUE,
|
||||||
|
0, // eventState
|
||||||
|
CHECK_ISMAS_CONNECT_PERCENT_END,
|
||||||
|
ISMAS::RESULT_CODE::E_SUCCESS,
|
||||||
|
"show ISMAS connectivity", // step
|
||||||
|
stepResult.toUtf8().constData()); // stepResult
|
||||||
|
|
||||||
|
if ((w = m_updateLog.write((char *)(&logLine), sizeof(logLine))) != sizeof(logLine)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "ERROR only" << w << "bytes written";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onShowCustRepoStatus(QString status) {
|
void MainWindow::onShowCustRepoStatus(QString status) {
|
||||||
@ -458,6 +537,7 @@ void MainWindow::onShowUpdateDCFirmware(QString status) {
|
|||||||
void MainWindow::onShowUpdateRequest(QString status) {
|
void MainWindow::onShowUpdateRequest(QString status) {
|
||||||
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
|
// qCritical() << __func__ << ":" << __LINE__ << "status" << status;
|
||||||
|
|
||||||
|
//ui->updateProgress->setValue(CHECK_UPDATE_REQUEST_PERCENT_START);
|
||||||
QString s = m_updateSteps[CHECK_UPDATE_REQUEST].trimmed();
|
QString s = m_updateSteps[CHECK_UPDATE_REQUEST].trimmed();
|
||||||
|
|
||||||
bool const custRepoExists = internal::customerRepoExists();
|
bool const custRepoExists = internal::customerRepoExists();
|
||||||
@ -469,17 +549,20 @@ void MainWindow::onShowUpdateRequest(QString status) {
|
|||||||
s += " <font color='Blue'>not requested (initial configuration)</font>";
|
s += " <font color='Blue'>not requested (initial configuration)</font>";
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::UPDATE_REQUESTED, Qt::CaseInsensitive)) {
|
if (status.contains(internal::UPDATE_REQUESTED, Qt::CaseInsensitive)) {
|
||||||
if (custRepoExists) {
|
if (custRepoExists) {
|
||||||
s += " <font color='Green'>requested</font>";
|
s += " <font color='Green'>requested</font>";
|
||||||
} else {
|
} else {
|
||||||
s += " <font color='Blue'>requested (initial configuration)</font>";
|
s += " <font color='Blue'>requested (initial configuration)</font>";
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::UPDATE_NOT_NECESSARY, Qt::CaseInsensitive)) {
|
if (status.contains(internal::UPDATE_INITIAL, Qt::CaseInsensitive)) {
|
||||||
|
s += " <font color='Green'>requested (initial configuration)</font>";
|
||||||
|
} else
|
||||||
|
if (status.contains(internal::UPDATE_NOT_NECESSARY, Qt::CaseInsensitive)) {
|
||||||
s += " <font color='Green'>not necessary</font>";
|
s += " <font color='Green'>not necessary</font>";
|
||||||
} else
|
} else
|
||||||
if (status.contains(UpdateCommand::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
|
if (status.contains(internal::NO_CUSTOMER_REPOSITORY, Qt::CaseInsensitive)) {
|
||||||
s += " <font color='Blue'>UNKNOWN (ISMAS not connected)</font>";
|
s += " <font color='Blue'>UNKNOWN (ISMAS not connected)</font>";
|
||||||
} else {
|
} else {
|
||||||
s += " <font color='Red'>UNKNOWN</font>";
|
s += " <font color='Red'>UNKNOWN</font>";
|
||||||
@ -491,6 +574,7 @@ void MainWindow::onShowUpdateRequest(QString status) {
|
|||||||
s += m_updateSteps[i] + "<br />";
|
s += m_updateSteps[i] + "<br />";
|
||||||
}
|
}
|
||||||
ui->stepLabel->setText(s);
|
ui->stepLabel->setText(s);
|
||||||
|
//ui->updateProgress->setValue(CHECK_UPDATE_REQUEST_PERCENT_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onShowISMASChecks(QString) {
|
void MainWindow::onShowISMASChecks(QString) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -39,6 +40,7 @@ public:
|
|||||||
void setUpdateStep(UpdateDcEvent::UpdateStep updateStep) { m_updateStep = updateStep; }
|
void setUpdateStep(UpdateDcEvent::UpdateStep updateStep) { m_updateStep = updateStep; }
|
||||||
|
|
||||||
QString targetDcVersion() {return m_targetDcVersion; }
|
QString targetDcVersion() {return m_targetDcVersion; }
|
||||||
|
QProgressBar *progressBar();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onAppendText(QString, QString suffix = "");
|
void onAppendText(QString, QString suffix = "");
|
||||||
@ -69,6 +71,7 @@ public slots:
|
|||||||
void onSetDcDownloadProgress(int);
|
void onSetDcDownloadProgress(int);
|
||||||
void onShowSummary(QString);
|
void onShowSummary(QString);
|
||||||
void onSummary();
|
void onSummary();
|
||||||
|
void onFileChanged(QString const&);
|
||||||
#if EMERGENCY_LEAVE_BL==1
|
#if EMERGENCY_LEAVE_BL==1
|
||||||
void emergencyLeaveBL();
|
void emergencyLeaveBL();
|
||||||
#endif
|
#endif
|
||||||
@ -103,5 +106,6 @@ private:
|
|||||||
|
|
||||||
QVector<QString> m_updateSteps{};
|
QVector<QString> m_updateSteps{};
|
||||||
|
|
||||||
|
QFile m_updateLog;
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -34,6 +34,9 @@ void CheckUpdateActivationCommand::readyReadStandardOutput() {
|
|||||||
} else
|
} else
|
||||||
if (s == internal::NO_CUSTOMER_REPOSITORY) {
|
if (s == internal::NO_CUSTOMER_REPOSITORY) {
|
||||||
emit w->showUpdateRequest(internal::NO_CUSTOMER_REPOSITORY);
|
emit w->showUpdateRequest(internal::NO_CUSTOMER_REPOSITORY);
|
||||||
|
} else
|
||||||
|
if (s == internal::UPDATE_INITIAL) {
|
||||||
|
emit w->showUpdateRequest(internal::UPDATE_INITIAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "utils.h" // deprecated
|
#include "utils.h" // deprecated
|
||||||
#include "utils_internal.h"
|
#include "utils_internal.h"
|
||||||
|
#include "log_line_entry.h"
|
||||||
#include "process/command.h"
|
#include "process/command.h"
|
||||||
#include "process/update_command.h"
|
#include "process/update_command.h"
|
||||||
#include "process/check_ismas_connectivity_command.h"
|
#include "process/check_ismas_connectivity_command.h"
|
||||||
@ -193,7 +195,28 @@ Worker::Worker(int customerNr,
|
|||||||
, m_dcDownloadJsonFiles(new Command(
|
, m_dcDownloadJsonFiles(new Command(
|
||||||
QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())))
|
QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())))
|
||||||
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
|
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
|
||||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
, m_withoutIsmasDirectPort(false) /* useful for testing */
|
||||||
|
, m_updateLog("/opt/app/tools/atbupdate/update.log") // TODO: in ini-file eintragen
|
||||||
|
, m_updateLogBackup("/opt/app/tools/atbupdate/updateBackup.log") { // TODO: in ini-file eintragen
|
||||||
|
|
||||||
|
if (!m_updateLog.exists()) {
|
||||||
|
qCritical() << "ERROR" << m_updateLog.fileName() << "does not exist";
|
||||||
|
} else {
|
||||||
|
if (!m_updateLog.open(QIODevice::ReadWrite | QIODevice::Unbuffered)) {
|
||||||
|
qCritical() << "ERROR can not open" << m_updateLog.fileName();
|
||||||
|
} else {
|
||||||
|
m_updateLog.resize(0);
|
||||||
|
m_fileWatcher.addPath(QFileInfo(m_updateLog).absoluteFilePath());
|
||||||
|
connect(&m_fileWatcher, SIGNAL(fileChanged(QString const&)), this, SLOT(onFileChanged(QString const&)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_updateLogBackup.open(QIODevice::ReadWrite | QIODevice::Unbuffered)) {
|
||||||
|
qCritical() << "ERROR can not open" << m_updateLogBackup.fileName();
|
||||||
|
} else {
|
||||||
|
m_updateLogBackup.resize(0);
|
||||||
|
m_updateLogBackup.close();
|
||||||
|
}
|
||||||
|
|
||||||
// *** check ISMAS connectivity ***
|
// *** check ISMAS connectivity ***
|
||||||
// NOTE: if the customer repository does not exist, then it does not matter
|
// NOTE: if the customer repository does not exist, then it does not matter
|
||||||
@ -202,8 +225,8 @@ Worker::Worker(int customerNr,
|
|||||||
int next = 1;
|
int next = 1;
|
||||||
m_workList.push_back(
|
m_workList.push_back(
|
||||||
std::make_unique<CheckIsmasConnectivityCommand>(
|
std::make_unique<CheckIsmasConnectivityCommand>(
|
||||||
QString("echo ATBUpdateCheck --ismas-connected")
|
//QString("echo ATBUpdateCheck --ismas-connected")
|
||||||
//QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected")
|
QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected")
|
||||||
, this, ++next));
|
, this, ++next));
|
||||||
|
|
||||||
// *** check if update activated in ISMAS ***
|
// *** check if update activated in ISMAS ***
|
||||||
@ -211,8 +234,8 @@ Worker::Worker(int customerNr,
|
|||||||
// if the update has been activated via ISMAS.
|
// if the update has been activated via ISMAS.
|
||||||
m_workList.push_back(
|
m_workList.push_back(
|
||||||
std::make_unique<CheckUpdateActivationCommand>(
|
std::make_unique<CheckUpdateActivationCommand>(
|
||||||
QString("echo ATBUpdateCheck --update-requested")
|
// QString("echo ATBUpdateCheck --update-requested")
|
||||||
//QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested")
|
QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested")
|
||||||
, this, ++next));
|
, this, ++next));
|
||||||
|
|
||||||
// *** check and fetch git-customer repository ***
|
// *** check and fetch git-customer repository ***
|
||||||
@ -257,8 +280,8 @@ Worker::Worker(int customerNr,
|
|||||||
// send device-controller firmware down to device-controller-hardware
|
// send device-controller firmware down to device-controller-hardware
|
||||||
m_workList.push_back(
|
m_workList.push_back(
|
||||||
std::make_unique<UpdateDCCommand>(
|
std::make_unique<UpdateDCCommand>(
|
||||||
// QString("echo ATBUpdateDC")
|
QString("echo ATBUpdateDC")
|
||||||
QString("/opt/app/tools/atbupdate/ATBUpdateDC")
|
// QString("/opt/app/tools/atbupdate/ATBUpdateDC")
|
||||||
, this, ++next));
|
, this, ++next));
|
||||||
|
|
||||||
// show/send software-status
|
// show/send software-status
|
||||||
@ -301,10 +324,91 @@ Worker::~Worker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
struct LogLineEntry {
|
||||||
|
char receiver; // 1 receiver can be: ISMAS
|
||||||
|
char reason[5]; // 6 SW_UP
|
||||||
|
char timestamp[19]; // 25 ISO-format: 1900-xx-xxT00:00:00
|
||||||
|
char eventId; // 26
|
||||||
|
char event[5]; // 31
|
||||||
|
/*
|
||||||
|
Note:
|
||||||
|
! After U0002 immer ein CMD_SENDVERSION
|
||||||
|
! Only U0002 and U0003 finish the Update process.
|
||||||
|
! U0001: Update finished but not activated
|
||||||
|
! U0002: Update finished and activated
|
||||||
|
! U0003: Update finished but FAILed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0
|
||||||
|
// #define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0
|
||||||
|
// #define _ISMAS_NO_UPDATE_NECESSARY "M0100" // empty WAIT-button (""), ResultCode: 0
|
||||||
|
// #define _ISMAS_FAILURE "U0003" // FAIL
|
||||||
|
// #define _ISMAS_CONTINUE "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
|
||||||
|
// #define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT"
|
||||||
|
// #define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button
|
||||||
|
char eventState; // 32
|
||||||
|
char percent; // 33 percent in progressbar of update-tool
|
||||||
|
char resultCode; // 34
|
||||||
|
char step[40]; // 74 step executed
|
||||||
|
char stepResult[40];// 114 result for step
|
||||||
|
char version[14]; // 128
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void Worker::onFileChanged(QString const& fname) {
|
||||||
|
|
||||||
|
QFile f(fname);
|
||||||
|
//if (m_updateLog.fileName().contains(fname)) {
|
||||||
|
// if (f.exists() && m_updateLogBackup.exists()) {
|
||||||
|
if (!m_updateLogBackup.open(QIODevice::ReadWrite | QIODevice::Unbuffered)) {
|
||||||
|
qCritical() << "ERROR can not open" << m_updateLogBackup.fileName();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
|
QByteArray const &backup = m_updateLogBackup.readAll();
|
||||||
|
QByteArray const &data = f.readAll();
|
||||||
|
int const diff = data.size() - backup.size();
|
||||||
|
if (diff > 0) {
|
||||||
|
QByteArray const &newLines = data.mid(backup.size());
|
||||||
|
int const size = newLines.size();
|
||||||
|
if (size > 0) {
|
||||||
|
LogLineEntry logLine;
|
||||||
|
int pos = 0;
|
||||||
|
while (pos < size) {
|
||||||
|
QByteArray const &a = newLines.mid(pos, sizeof(logLine));
|
||||||
|
if (a.size() == sizeof(logLine)) {
|
||||||
|
memcpy(&logLine, a.data(), sizeof(logLine));
|
||||||
|
|
||||||
|
qCritical() << " reason:" << QString(QByteArray(logLine.reason, sizeof(logLine.reason)));
|
||||||
|
qCritical() << " timestamp:" << QString(QByteArray(logLine.timestamp, sizeof(logLine.timestamp)));
|
||||||
|
qCritical() << " event:" << QString(QByteArray(logLine.event, sizeof(logLine.event)));
|
||||||
|
qCritical() << " step:" << QString(QByteArray(logLine.step, sizeof(logLine.step)));
|
||||||
|
qCritical() << "stepResult:" << QString(QByteArray(logLine.stepResult, sizeof(logLine.stepResult)));
|
||||||
|
qCritical() << " percent:" << (int)logLine.percent;
|
||||||
|
|
||||||
|
displayProgressInMainWindow(logLine.percent);
|
||||||
|
}
|
||||||
|
pos += sizeof(logLine);
|
||||||
|
}
|
||||||
|
m_updateLogBackup.write(newLines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.close();
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
m_updateLogBackup.close();
|
||||||
|
// TODO: daten an ISMAS senden
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::displayProgressInMainWindow(int progress) {
|
void Worker::displayProgressInMainWindow(int progress) {
|
||||||
if (m_mainWindow) {
|
if (m_mainWindow) {
|
||||||
QApplication::postEvent(m_mainWindow,
|
QProgressBar *progressBar = m_mainWindow->progressBar();
|
||||||
new ProgressEvent(this, progress));
|
if (progressBar) {
|
||||||
|
progressBar->setValue(progress);
|
||||||
|
}
|
||||||
|
//QApplication::postEvent(m_mainWindow,
|
||||||
|
// new ProgressEvent(this, progress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
@ -522,6 +523,7 @@ private slots:
|
|||||||
bool syncCustomerRepositoryAndFS();
|
bool syncCustomerRepositoryAndFS();
|
||||||
// bool sendIsmasLastVersionNotification(int progress);
|
// bool sendIsmasLastVersionNotification(int progress);
|
||||||
bool saveLogFile();
|
bool saveLogFile();
|
||||||
|
void onFileChanged(QString const&);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readyReadStandardOutput();
|
void readyReadStandardOutput();
|
||||||
@ -535,6 +537,9 @@ private:
|
|||||||
|
|
||||||
QDateTime m_start;
|
QDateTime m_start;
|
||||||
QByteArray m_standardOutput;
|
QByteArray m_standardOutput;
|
||||||
|
QFileSystemWatcher m_fileWatcher;
|
||||||
|
QFile m_updateLog;
|
||||||
|
QFile m_updateLogBackup;
|
||||||
|
|
||||||
static const QMap<UPDATE_STEP, const char*> smap;
|
static const QMap<UPDATE_STEP, const char*> smap;
|
||||||
|
|
||||||
|
69
common/include/log_line_entry.h
Normal file
69
common/include/log_line_entry.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#ifndef LOG_LINE_ENTRY_H_INCLUDED
|
||||||
|
#define LOG_LINE_ENTRY_H_INCLUDED
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
struct LogLineEntry {
|
||||||
|
char receiver; // 1 receiver can be: ISMAS
|
||||||
|
char reason[5]; // 6 SW_UP
|
||||||
|
char timestamp[19]; // 25 ISO-format: 1900-xx-xxT00:00:00
|
||||||
|
char eventId; // 26
|
||||||
|
char event[5]; // 31
|
||||||
|
/*
|
||||||
|
Note:
|
||||||
|
! After U0002 immer ein CMD_SENDVERSION
|
||||||
|
! Only U0002 and U0003 finish the Update process.
|
||||||
|
! U0001: Update finished but not activated
|
||||||
|
! U0002: Update finished and activated
|
||||||
|
! U0003: Update finished but FAILed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// #define _ISMAS_DONE "U0001" // 100%, Check: Resultcode: 0
|
||||||
|
// #define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button (""), ResultCode: 0
|
||||||
|
// #define _ISMAS_NO_UPDATE_NECESSARY "M0100" // empty WAIT-button (""), ResultCode: 0
|
||||||
|
// #define _ISMAS_FAILURE "U0003" // FAIL
|
||||||
|
// #define _ISMAS_CONTINUE "U0010" // %-values: Update laeuft, Resultcodes entsprechend laufender Schritt
|
||||||
|
// #define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT"
|
||||||
|
// #define _ISMAS_TEST_TRIGGER "U0099" // check the WAIT-button
|
||||||
|
char eventState; // 32
|
||||||
|
char percent; // 33 percent in progressbar of update-tool
|
||||||
|
char resultCode; // 34
|
||||||
|
char step[40]; // 74 step executed
|
||||||
|
char stepResult[40];// 114 result for step
|
||||||
|
char version[13]; // 127
|
||||||
|
char dummy; // 128
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static LogLineEntry initLogLineEntry(
|
||||||
|
char const receiver,
|
||||||
|
char const timestamp[19],
|
||||||
|
char const event[5],
|
||||||
|
char const eventState,
|
||||||
|
char const percent,
|
||||||
|
char const resultCode,
|
||||||
|
char const step[40],
|
||||||
|
char const stepResult[40],
|
||||||
|
char const eventId = 0,
|
||||||
|
char const reason[5] = "SW_UP",
|
||||||
|
char const version[14] = "") {
|
||||||
|
LogLineEntry e;
|
||||||
|
memset(&e, 0, sizeof(e));
|
||||||
|
|
||||||
|
e.receiver = receiver;
|
||||||
|
std::memcpy(e.reason, reason, std::min(sizeof(e.reason), strlen(reason)));
|
||||||
|
std::memcpy(e.timestamp, timestamp, std::min(sizeof(e.timestamp), strlen(timestamp)));
|
||||||
|
e.eventId = eventId;
|
||||||
|
std::memcpy(e.event, event, std::min(sizeof(e.event), strlen(event)));
|
||||||
|
e.eventState = eventState;
|
||||||
|
e.percent = percent;
|
||||||
|
e.resultCode = resultCode;
|
||||||
|
std::memcpy(e.step, step, std::min(sizeof(e.step), strlen(step)));
|
||||||
|
std::memcpy(e.stepResult, stepResult, std::min(sizeof(e.stepResult), strlen(stepResult)));
|
||||||
|
std::memcpy(e.version, version, std::min(sizeof(e.version), strlen(version)));
|
||||||
|
e.dummy = '\0';
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LOG_LINE_ENTRY_H_INCLUDED
|
@ -9,6 +9,7 @@ namespace internal {
|
|||||||
|
|
||||||
static constexpr const char *UPDATE_NOT_NECESSARY{"not necessary"};
|
static constexpr const char *UPDATE_NOT_NECESSARY{"not necessary"};
|
||||||
static constexpr const char *UPDATE_NOT_REQUESTED{"not requested"};
|
static constexpr const char *UPDATE_NOT_REQUESTED{"not requested"};
|
||||||
|
static constexpr const char *UPDATE_INITIAL{"initial update"};
|
||||||
static constexpr const char *UPDATE_REQUESTED{"requested"};
|
static constexpr const char *UPDATE_REQUESTED{"requested"};
|
||||||
|
|
||||||
static constexpr const char *NO_CUSTOMER_REPOSITORY{"no customer repository"};
|
static constexpr const char *NO_CUSTOMER_REPOSITORY{"no customer repository"};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user