Compare commits
No commits in common. "1ef9853876406500ea75caaa2ac452e09db97762" and "a45e552d9043459f9456bf266248573d78801481" have entirely different histories.
1ef9853876
...
a45e552d90
@ -15,7 +15,7 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
# In order to do so, uncomment the following line.
|
# In order to do so, uncomment the following line.
|
||||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||||
VERSION=1.3.0
|
VERSION=1.2.0
|
||||||
|
|
||||||
INCLUDEPATH += plugins
|
INCLUDEPATH += plugins
|
||||||
|
|
||||||
|
@ -120,10 +120,7 @@ QStringList GitClient::gitShowReason() {
|
|||||||
// %h: commit (short form)
|
// %h: commit (short form)
|
||||||
// %s: commit message
|
// %s: commit message
|
||||||
// %cI: commit date, strict ISO 8601 format
|
// %cI: commit date, strict ISO 8601 format
|
||||||
// Note: use master branch. By convention, there is a ChangeLog file
|
Command c("git show -s --format=\"c=%h m=%s d=%cI\"");
|
||||||
// in the root of the repository, which has to be always the last file
|
|
||||||
// to be checked in when the customer repository somehow changed.
|
|
||||||
Command c("git show origin/master -s --format=\"c=%h m=%s d=%cI\"");
|
|
||||||
if (c.execute(m_customerRepository)) {
|
if (c.execute(m_customerRepository)) {
|
||||||
QString const s = c.getCommandResult().trimmed();
|
QString const s = c.getCommandResult().trimmed();
|
||||||
int const c = s.indexOf("c=");
|
int const c = s.indexOf("c=");
|
||||||
|
@ -616,9 +616,8 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
|||||||
"}"
|
"}"
|
||||||
"},"
|
"},"
|
||||||
"\"SOFTWARE\": {"
|
"\"SOFTWARE\": {"
|
||||||
"\"APISM\" : {"
|
"\"RAUC\" : \"%s\","
|
||||||
"\"VERSION\" : \"%s\""
|
"\"OPKG\" : \"%s\","
|
||||||
"},"
|
|
||||||
"\"ATBQT\" : {"
|
"\"ATBQT\" : {"
|
||||||
"\"VERSION\" : \"%s\""
|
"\"VERSION\" : \"%s\""
|
||||||
"}"
|
"}"
|
||||||
@ -746,7 +745,8 @@ QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) {
|
|||||||
psa.dc.gitBlob.toStdString().c_str(),
|
psa.dc.gitBlob.toStdString().c_str(),
|
||||||
psa.dc.gitLastCommit.toStdString().c_str(),
|
psa.dc.gitLastCommit.toStdString().c_str(),
|
||||||
|
|
||||||
psa.sw.apismVersion.toStdString().c_str(),
|
psa.sw.raucVersion.toStdString().c_str(),
|
||||||
|
psa.sw.opkgVersion.toStdString().c_str(),
|
||||||
psa.sw.atbQTVersion.toStdString().c_str(),
|
psa.sw.atbQTVersion.toStdString().c_str(),
|
||||||
|
|
||||||
psa.pluginVersion.deviceController.toStdString().c_str(),
|
psa.pluginVersion.deviceController.toStdString().c_str(),
|
||||||
@ -829,7 +829,7 @@ QString IsmasClient::updateOfPSAActivated(QString const &version) { // sent ev
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString IsmasClient::updateOfPSASucceeded(QString const &version) {
|
QString IsmasClient::updateOfPSASucceeded(QString const &version) {
|
||||||
m_progressInPercent = 100;
|
m_progressInPercent = 0;
|
||||||
return updateNewsToIsmas("U0001",
|
return updateNewsToIsmas("U0001",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
RESULT_CODE::SUCCESS,
|
RESULT_CODE::SUCCESS,
|
||||||
@ -857,13 +857,13 @@ QString IsmasClient::jsonParseFailed(int resultCode, QString reason, QString con
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) {
|
std::optional<QString> IsmasClient::finalResult(int resultCode, QString reason, QString const &version) {
|
||||||
m_progressInPercent = 100;
|
m_progressInPercent = 0;
|
||||||
if (resultCode == RESULT_CODE::SUCCESS) {
|
if (resultCode == RESULT_CODE::SUCCESS) {
|
||||||
return updateNewsToIsmas("U0002",
|
return updateNewsToIsmas("U0002",
|
||||||
m_progressInPercent,
|
m_progressInPercent,
|
||||||
resultCode,
|
RESULT_CODE::SUCCESS,
|
||||||
"FINAL-UPDATE-RESULT",
|
"FINAL-UPDATE-RESULT",
|
||||||
reason.toStdString().c_str(),
|
"(re-)set WAIT state",
|
||||||
version.toStdString().c_str());
|
version.toStdString().c_str());
|
||||||
}
|
}
|
||||||
if (resultCode == RESULT_CODE::INSTALL_ERROR) {
|
if (resultCode == RESULT_CODE::INSTALL_ERROR) {
|
||||||
|
@ -46,7 +46,8 @@ struct PSAInstalled {
|
|||||||
} dc;
|
} dc;
|
||||||
|
|
||||||
struct SoftWare {
|
struct SoftWare {
|
||||||
QString apismVersion;
|
QString raucVersion;
|
||||||
|
QString opkgVersion;
|
||||||
QString atbQTVersion;
|
QString atbQTVersion;
|
||||||
} sw;
|
} sw;
|
||||||
|
|
||||||
@ -96,7 +97,8 @@ struct PSAInstalled {
|
|||||||
dc.gitLastCommit = "N/A";
|
dc.gitLastCommit = "N/A";
|
||||||
dc.size = -1;
|
dc.size = -1;
|
||||||
|
|
||||||
sw.apismVersion = "N/A";
|
sw.raucVersion = "N/A";
|
||||||
|
sw.opkgVersion = "N/A";
|
||||||
sw.atbQTVersion = "N/A";
|
sw.atbQTVersion = "N/A";
|
||||||
|
|
||||||
pluginVersion.deviceController = "N/A";
|
pluginVersion.deviceController = "N/A";
|
||||||
|
@ -38,10 +38,8 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
lst << QString("Machine number : %1 ").arg(m_worker->machineNr()).leftJustified(m_width-3);
|
lst << QString("Machine number : %1 ").arg(m_worker->machineNr()).leftJustified(m_width-3);
|
||||||
lst << QString("Customer number : %1 ").arg(m_worker->customerNr()).leftJustified(m_width-3);
|
lst << QString("Customer number : %1 ").arg(m_worker->customerNr()).leftJustified(m_width-3);
|
||||||
lst << QString("Zone number : %1 (%2)").arg(m_worker->zoneNr()).arg(Utils::zoneName(m_worker->zoneNr())).leftJustified(m_width-3);
|
lst << QString("Zone number : %1 (%2)").arg(m_worker->zoneNr()).arg(Utils::zoneName(m_worker->zoneNr())).leftJustified(m_width-3);
|
||||||
lst << QString("APISM version : %1").arg(m_worker->apismVersion()).leftJustified(m_width-3);
|
|
||||||
lst << QString("").leftJustified(m_width-3, '=');
|
lst << QString("").leftJustified(m_width-3, '=');
|
||||||
|
|
||||||
|
|
||||||
ui->updateStatus->setText(lst.join('\n'));
|
ui->updateStatus->setText(lst.join('\n'));
|
||||||
ui->updateStatus->setEnabled(true);
|
ui->updateStatus->setEnabled(true);
|
||||||
|
|
||||||
|
329
worker.cpp
329
worker.cpp
@ -57,6 +57,8 @@ Worker::Worker(hwinf *hw,
|
|||||||
, m_osVersion(getOsVersion())
|
, m_osVersion(getOsVersion())
|
||||||
, m_atbqtVersion(getATBQTVersion())
|
, m_atbqtVersion(getATBQTVersion())
|
||||||
, m_cpuSerial(getCPUSerial())
|
, m_cpuSerial(getCPUSerial())
|
||||||
|
, m_raucVersion(getRaucVersion())
|
||||||
|
, m_opkgVersion(getOpkgVersion())
|
||||||
, m_pluginVersionATBDeciceController(getPluginVersion("/opt/app/ATBAPP/plugins/libATBDeviceControllerPlugin.so"))
|
, m_pluginVersionATBDeciceController(getPluginVersion("/opt/app/ATBAPP/plugins/libATBDeviceControllerPlugin.so"))
|
||||||
, m_pluginVersionIngenicoISelf(getPluginVersion("/opt/app/ATBAPP/plugins/libIngenicoISelf_CCPlugin.so"))
|
, m_pluginVersionIngenicoISelf(getPluginVersion("/opt/app/ATBAPP/plugins/libIngenicoISelf_CCPlugin.so"))
|
||||||
, m_pluginVersionMobilisisCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin.so"))
|
, m_pluginVersionMobilisisCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin.so"))
|
||||||
@ -74,16 +76,6 @@ Worker::Worker(hwinf *hw,
|
|||||||
|
|
||||||
QDir::setCurrent(m_workingDirectory);
|
QDir::setCurrent(m_workingDirectory);
|
||||||
|
|
||||||
// restart apism to make sure it is running ?
|
|
||||||
// Command c("systemctl restart apism");
|
|
||||||
// if (c.execute("/tmp")) {
|
|
||||||
// QThread::sleep(10); // give APISM some time to reconnect
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (std::optional<QString> v = getApismVersion()) {
|
|
||||||
m_apismVersion = v.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
|
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||||
qInfo() << "OS VERSION ................." << m_osVersion;
|
qInfo() << "OS VERSION ................." << m_osVersion;
|
||||||
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
|
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
|
||||||
@ -96,7 +88,6 @@ Worker::Worker(hwinf *hw,
|
|||||||
qInfo() << "ZONE_NR ...................." << m_zoneNr;
|
qInfo() << "ZONE_NR ...................." << m_zoneNr;
|
||||||
qInfo() << "BRANCH_NAME ................" << m_branchName;
|
qInfo() << "BRANCH_NAME ................" << m_branchName;
|
||||||
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
|
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
|
||||||
qInfo() << "APISM VERSION .............." << m_apismVersion;
|
|
||||||
|
|
||||||
this->moveToThread(&m_workerThread);
|
this->moveToThread(&m_workerThread);
|
||||||
m_workerThread.start();
|
m_workerThread.start();
|
||||||
@ -150,8 +141,20 @@ void Worker::update() {
|
|||||||
|
|
||||||
void Worker::privateUpdate() {
|
void Worker::privateUpdate() {
|
||||||
m_updateProcessRunning = true;
|
m_updateProcessRunning = true;
|
||||||
|
|
||||||
bool sentIsmasLastVersionNotification = false;
|
bool sentIsmasLastVersionNotification = false;
|
||||||
|
|
||||||
|
//emit appendText("\nRestart APISM ...");
|
||||||
|
//startProgressLoop();
|
||||||
|
//Command c("systemctl restart apism");
|
||||||
|
//if (c.execute("/tmp")) {
|
||||||
|
// QThread::sleep(10); // give APISM some time to reconnect
|
||||||
|
// stopProgressLoop();
|
||||||
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_DONE);
|
||||||
|
//} else {
|
||||||
|
// stopProgressLoop();
|
||||||
|
// emit replaceLast("Restart APISM ...", UPDATE_STEP_FAIL);
|
||||||
|
//}
|
||||||
|
|
||||||
emit disableExit();
|
emit disableExit();
|
||||||
|
|
||||||
@ -205,110 +208,122 @@ void Worker::privateUpdate() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_ismasClient.setProgressInPercent(10);
|
m_ismasClient.setProgressInPercent(10);
|
||||||
if (updateTriggerSet()) {
|
if (backendConnected()) {
|
||||||
m_ismasClient.setProgressInPercent(20);
|
m_ismasClient.setProgressInPercent(20);
|
||||||
if (customerEnvironment()) {
|
if (updateTriggerSet()) {
|
||||||
m_ismasClient.setProgressInPercent(30);
|
m_ismasClient.setProgressInPercent(30);
|
||||||
if (filesToUpdate()) {
|
if (customerEnvironment()) {
|
||||||
// send message to ISMAS about files which have been
|
|
||||||
// checked in into git repository
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
|
||||||
QString("Files to update: ") + m_filesToUpdate.join(','));
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
||||||
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
|
||||||
m_updateStatus.m_statusDescription));
|
|
||||||
m_ismasClient.setProgressInPercent(40);
|
m_ismasClient.setProgressInPercent(40);
|
||||||
if (updateFiles(50)) {
|
if (filesToUpdate()) {
|
||||||
|
// send message to ISMAS about files which have been
|
||||||
|
// checked in into git repository
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECK_FILES_TO_UPDATE_SUCCESS,
|
||||||
|
QString("Files to update: ") + m_filesToUpdate.join(','));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
m_ismasClient.setProgressInPercent(50);
|
m_ismasClient.setProgressInPercent(50);
|
||||||
if (syncCustomerRepositoryAndFS()) {
|
if (updateFiles(50)) {
|
||||||
m_ismasClient.setProgressInPercent(60);
|
m_ismasClient.setProgressInPercent(60);
|
||||||
if (sendIsmasLastVersionNotification()) {
|
if (syncCustomerRepositoryAndFS()) {
|
||||||
m_ismasClient.setProgressInPercent(70);
|
m_ismasClient.setProgressInPercent(70);
|
||||||
sentIsmasLastVersionNotification = true;
|
if (sendIsmasLastVersionNotification()) {
|
||||||
if (saveLogFile()) {
|
|
||||||
m_ismasClient.setProgressInPercent(80);
|
m_ismasClient.setProgressInPercent(80);
|
||||||
|
sentIsmasLastVersionNotification = true;
|
||||||
|
if (saveLogFile()) {
|
||||||
|
m_ismasClient.setProgressInPercent(90);
|
||||||
|
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSASucceeded(""));
|
m_ismasClient.updateOfPSASucceeded(""));
|
||||||
|
|
||||||
// mark update as activated -> this resets the WAIT button
|
// mark update as activated -> this resets the WAIT button
|
||||||
m_ismasClient.setProgressInPercent(95);
|
m_ismasClient.setProgressInPercent(95);
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAActivated());
|
m_ismasClient.updateOfPSAActivated());
|
||||||
|
|
||||||
m_returnCode = 0;
|
m_returnCode = 0;
|
||||||
|
} else {
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
||||||
|
QString("Saving log files failed"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"SAVE-LOG-FILES",
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
m_returnCode = -11;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::SAVE_LOG_FILES_FAILED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
||||||
QString("Saving log files failed"));
|
QString("Sending ISMAS last version failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"SAVE-LOG-FILES",
|
"ISMAS-SEND-LAST-VERSION",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -11;
|
m_returnCode = -10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SEND_LAST_VERSION_FAILED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
||||||
QString("Sending ISMAS last version failed"));
|
QString("Syncing files to update failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"ISMAS-SEND-LAST-VERSION",
|
"RSYNC-UPDATE-FILES",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -10;
|
m_returnCode = -9;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::RSYNC_UPDATES_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
||||||
QString("Syncing files to update failed"));
|
QString("Updating files failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"RSYNC-UPDATE-FILES",
|
"UPDATE-FILES",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -9;
|
m_returnCode = -8;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::PSA_UPDATE_FILES_FAILED,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
||||||
QString("Updating files failed"));
|
QString("No files to update"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"UPDATE-FILES",
|
"FETCH-FILES-TO-UPDATE",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -8;
|
m_returnCode = -7;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
||||||
QString("No files to update"));
|
QString("Configuring customer environment failed"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"FETCH-FILES-TO-UPDATE",
|
"GIT-CHECKOUT-BRANCH",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -7;
|
m_returnCode = -6;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
||||||
QString("Configuring customer environment failed"));
|
QString("ISMAS update trigger wrong"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"GIT-CHECKOUT-BRANCH",
|
"CHECK-UPDATE-TRIGGER",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -6;
|
m_returnCode = -5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
QString("ISMAS update trigger wrong"));
|
QString("ISMAS backend not available"));
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
m_ismasClient.updateOfPSAFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
"CHECK-UPDATE-TRIGGER",
|
"ISMAS-BACKEND-CHECK",
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus.m_statusDescription));
|
||||||
m_returnCode = -5;
|
m_returnCode = -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,6 +337,7 @@ void Worker::privateUpdate() {
|
|||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_FAILURE,
|
||||||
QString("Update process failed"));
|
QString("Update process failed"));
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
m_updateStatus.m_statusDescription)) {
|
m_updateStatus.m_statusDescription)) {
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
@ -330,8 +346,9 @@ void Worker::privateUpdate() {
|
|||||||
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
emit appendText(QString("UPDATE "), UPDATE_STEP_SUCCESS);
|
||||||
|
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::UPDATE_PROCESS_SUCCESS,
|
||||||
QString("Update process succeeded. Reset WAIT."));
|
QString("Update process succeeded"));
|
||||||
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
if (std::optional<QString> s = m_ismasClient.finalResult(IsmasClient::RESULT_CODE::SUCCESS,
|
||||||
|
"FINAL-UPDATE-RESULT",
|
||||||
m_updateStatus.m_statusDescription)) {
|
m_updateStatus.m_statusDescription)) {
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
QString("#M=APISM#C=CMD_EVENT#J=") + s.value());
|
||||||
@ -348,62 +365,137 @@ void Worker::privateUpdate() {
|
|||||||
emit restartExitTimer();
|
emit restartExitTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<QString> Worker::getApismVersion() {
|
bool Worker::backendConnected() {
|
||||||
for (int repeat = 0; repeat < 10; ++repeat) {
|
// deactivated: REQ_SELF does not really help. Observation was that even
|
||||||
qInfo() << "REPEAT" << repeat << "In getApismVersion() -> #M=APISM#C=REQ_SELF#J={}";
|
// id ISMAS is reported as 'true', a following check of the update-trigger
|
||||||
std::optional<QString> result
|
// button has no access to ISMAS.
|
||||||
= IsmasClient::sendRequestReceiveResponse(
|
return true;
|
||||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
|
||||||
if (result) {
|
emit appendText("\nConnecting backend ...");
|
||||||
QString msg = result.value();
|
|
||||||
qInfo() << "In getApismVersion() -> APISM response" << msg;
|
if (false) { // so linker removes dead code
|
||||||
QJsonParseError parseError;
|
for (int repeat = 0; repeat < 100; ++repeat) {
|
||||||
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
qInfo() << "REPEAT" << repeat << "In backendConnected() -> #M=APISM#C=REQ_SELF#J={}";
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
startProgressLoop();
|
||||||
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
std::optional<QString> result
|
||||||
<< parseError.error << parseError.errorString();
|
= IsmasClient::sendRequestReceiveResponse(
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_SELF#J={}");
|
||||||
QString("(2) INVALID JSON %1 %2 %3")
|
if (result) {
|
||||||
.arg(msg)
|
stopProgressLoop();
|
||||||
.arg(parseError.error)
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
.arg(parseError.errorString()));
|
setProgress(progress);
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
QString msg = result.value();
|
||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
qInfo() << "In backendConnected() -> APISM response" << msg;
|
||||||
m_updateStatus.m_statusDescription));
|
QJsonParseError parseError;
|
||||||
return std::nullopt;
|
QJsonDocument document(QJsonDocument::fromJson(msg.toUtf8(), &parseError));
|
||||||
}
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
if (!document.isObject()) {
|
qCritical() << "(1) INVALID JSON MSG: PARSING FAILED (msg=" << msg << "):"
|
||||||
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
<< parseError.error << parseError.errorString();
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
setProgress(100);
|
||||||
QString("NOT A JSON-OBJECT %1").arg(msg));
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
QString("(2) INVALID JSON %1 %2 %3")
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
.arg(msg)
|
||||||
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
.arg(parseError.error)
|
||||||
m_updateStatus.m_statusDescription));
|
.arg(parseError.errorString()));
|
||||||
return std::nullopt;
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
}
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
QJsonObject obj = document.object();
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
m_updateStatus.m_statusDescription));
|
||||||
if (keys.size() != 1) {
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
return false;
|
||||||
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
}
|
||||||
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
if (!document.isObject()) {
|
||||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
qCritical() << "FILE IS NOT A JSON OBJECT!";
|
||||||
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
setProgress(100);
|
||||||
m_updateStatus.m_statusDescription));
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::JSON_PARSE_FAILURE,
|
||||||
emit showErrorMessage("apism response", m_updateStatus.m_statusDescription);
|
QString("NOT A JSON-OBJECT %1").arg(msg));
|
||||||
return std::nullopt;
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.jsonParseFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
setProgress(progress + 1);
|
||||||
|
|
||||||
|
QJsonObject obj = document.object();
|
||||||
|
QStringList keys = obj.keys().filter("CMD_GET_APISMSTATUS_RESPONSE");
|
||||||
|
if (keys.size() == 1) {
|
||||||
|
QString const key = keys.at(0);
|
||||||
|
QJsonValue v = obj.value(key);
|
||||||
|
if (v.isObject()) {
|
||||||
|
obj = v.toObject();
|
||||||
|
bool ismas = obj.value("ISMAS").toBool();
|
||||||
|
QString status = obj.value("Broker").toString();
|
||||||
|
qInfo() << "REPEAT" << repeat << "In backendConnected() Broker=<"
|
||||||
|
<< status << ">, ISMAS=<" << (ismas ? "true>" : "false>");
|
||||||
|
if (ismas) {
|
||||||
|
if (status == "Connected") {
|
||||||
|
// do not send, as this would result in a corrupted wait button
|
||||||
|
// but update the user-interface
|
||||||
|
setProgress(100);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_OK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK,
|
||||||
|
QString ("REPEAT %1 Broker=<").arg(repeat)
|
||||||
|
+ status + ">, ISMAS=<" + (ismas ? "true>" : "false>"));
|
||||||
|
//IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
// QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
// m_ismasClient.updateOfPSAContinues("BACKEND-CHECK", m_updateStatus.m_statusDescription));
|
||||||
|
|
||||||
|
qInfo() << "BACKEND-CHECK" << m_updateStatus.m_statusDescription;
|
||||||
|
emit showErrorMessage("Check backend connection", m_updateStatus.m_statusDescription);
|
||||||
|
QThread::sleep(6);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
setProgress(100);
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
|
"CMD_GET_APISM_STATUS_RESPONSE KEY NOT A JSON-OBJECT");
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setProgress(100);
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_CHECK_FAILURE,
|
||||||
|
"CMD_GET_APISMSTATUS_RESPONSE KEY NOT AVAILABLE");
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.sanityCheckFailed(IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||||
|
m_updateStatus.m_statusDescription));
|
||||||
|
emit showErrorMessage("check backend connection", m_updateStatus.m_statusDescription);
|
||||||
|
emit replaceLast("Connecting backend ...", UPDATE_STEP_FAIL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
QString const key = keys.at(0);
|
stopProgressLoop();
|
||||||
QJsonValue v = obj.value(key);
|
int progress = (m_mainWindow->progressValue()/10) + 10;
|
||||||
return v.toObject().value("Version").toString();
|
setProgress(progress);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
QThread::sleep(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setProgress(100);
|
||||||
|
|
||||||
|
emit replaceLast("Connecting backend", UPDATE_STEP_FAIL);
|
||||||
|
emit showErrorMessage("Error", "Backend not available");
|
||||||
|
|
||||||
|
m_updateStatus = UpdateStatus(UPDATE_STATUS::BACKEND_NOT_CONNECTED,
|
||||||
|
QString("NO BACKEND CONNECTION"));
|
||||||
|
IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||||
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||||
|
m_ismasClient.errorBackendNotConnected(m_updateStatus.m_statusDescription, ""));
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||||
@ -1120,7 +1212,8 @@ PSAInstalled Worker::getPSAInstalled() {
|
|||||||
psaInstalled.dc.gitLastCommit = "N/A";
|
psaInstalled.dc.gitLastCommit = "N/A";
|
||||||
psaInstalled.dc.size = -1;
|
psaInstalled.dc.size = -1;
|
||||||
|
|
||||||
psaInstalled.sw.apismVersion = m_apismVersion;
|
psaInstalled.sw.raucVersion = m_raucVersion;
|
||||||
|
psaInstalled.sw.opkgVersion = m_opkgVersion;
|
||||||
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
||||||
|
|
||||||
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
||||||
|
8
worker.h
8
worker.h
@ -9,8 +9,6 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include "worker_thread.h"
|
#include "worker_thread.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "git/git_client.h"
|
#include "git/git_client.h"
|
||||||
@ -90,6 +88,8 @@ class Worker : public QObject {
|
|||||||
QString const m_osVersion;
|
QString const m_osVersion;
|
||||||
QString const m_atbqtVersion;
|
QString const m_atbqtVersion;
|
||||||
QString const m_cpuSerial;
|
QString const m_cpuSerial;
|
||||||
|
QString const m_raucVersion;
|
||||||
|
QString const m_opkgVersion;
|
||||||
QString const m_pluginVersionATBDeciceController;
|
QString const m_pluginVersionATBDeciceController;
|
||||||
QString const m_pluginVersionIngenicoISelf;
|
QString const m_pluginVersionIngenicoISelf;
|
||||||
QString const m_pluginVersionMobilisisCalc;
|
QString const m_pluginVersionMobilisisCalc;
|
||||||
@ -111,7 +111,6 @@ class Worker : public QObject {
|
|||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
int m_progressValue;
|
int m_progressValue;
|
||||||
bool m_withoutIsmasDirectPort;
|
bool m_withoutIsmasDirectPort;
|
||||||
QString m_apismVersion;
|
|
||||||
|
|
||||||
bool executeOpkgCommand(QString opkgCommand);
|
bool executeOpkgCommand(QString opkgCommand);
|
||||||
QString getOsVersion() const;
|
QString getOsVersion() const;
|
||||||
@ -156,7 +155,6 @@ public:
|
|||||||
int machineNr() const { return m_machineNr; }
|
int machineNr() const { return m_machineNr; }
|
||||||
int customerNr() const { return m_customerNr; }
|
int customerNr() const { return m_customerNr; }
|
||||||
int zoneNr() const { return m_zoneNr; }
|
int zoneNr() const { return m_zoneNr; }
|
||||||
QString apismVersion() const { return m_apismVersion; }
|
|
||||||
|
|
||||||
//friend QDebug operator<<(QDebug debug, Worker const &w) {
|
//friend QDebug operator<<(QDebug debug, Worker const &w) {
|
||||||
// Q_UNUSED(w);
|
// Q_UNUSED(w);
|
||||||
@ -181,6 +179,7 @@ public slots:
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
bool backendConnected();
|
||||||
bool updateTriggerSet();
|
bool updateTriggerSet();
|
||||||
bool customerEnvironment();
|
bool customerEnvironment();
|
||||||
bool filesToUpdate();
|
bool filesToUpdate();
|
||||||
@ -192,7 +191,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
PSAInstalled getPSAInstalled();
|
PSAInstalled getPSAInstalled();
|
||||||
void privateUpdate();
|
void privateUpdate();
|
||||||
std::optional<QString> getApismVersion();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WORKER_H_INCLUDED
|
#endif // WORKER_H_INCLUDED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user