Compare commits
141 Commits
v1.3._25_
...
1acec4d876
| Author | SHA1 | Date | |
|---|---|---|---|
| 1acec4d876 | |||
| 46c481b862 | |||
| 8945ead5d6 | |||
| bc064c38c6 | |||
| f741fb96f9 | |||
| 8d1c719626 | |||
| b5389a599e | |||
| ea2f42beed | |||
| 22e751e197 | |||
| 05c7d11ef8 | |||
| 63dc70dda9 | |||
| e5ab9b98cd | |||
| 4477647acf | |||
| d64b029a2d | |||
| e24022a612 | |||
| 60d78790ba | |||
| 543e712c62 | |||
| 8402fde6b5 | |||
| f15cc636c6 | |||
| adaa12395e | |||
| 853c29e448 | |||
| 78c214ceb4 | |||
| 88bec387c5 | |||
| 05b68f21c2 | |||
| 9ca394db46 | |||
| 0d268a1d9d | |||
| da102b5ed0 | |||
| 7031c0e349 | |||
| c528ce377d | |||
| 5e7c848fca | |||
| 3165d77f49 | |||
| f0d2d5f958 | |||
| 1da4c3b224 | |||
| f1cedbf1d5 | |||
| 0933274c82 | |||
| 2aa676f18c | |||
| 6c0d49b90c | |||
| 18d04d15cf | |||
| b81120f8dc | |||
| 8b2fcb25db | |||
| 698cf74516 | |||
| 20681b0d6c | |||
| 763647c145 | |||
| 4aad14b181 | |||
| 0a03228dea | |||
| 23551066c1 | |||
| 24f2ba7c44 | |||
| 2ed6768953 | |||
| a1327388bc | |||
| 8d18ae10fe | |||
| 31bc2d0fa2 | |||
| 175b8fd3a1 | |||
| a57fa6c31e | |||
| c22c924e38 | |||
| bdc64920a2 | |||
| 7bc9fa0c04 | |||
| 334da1fe4a | |||
| e5054582c2 | |||
| bbd287c92b | |||
| 5c152c9dc2 | |||
| 367ffaa3a1 | |||
| 2fd004f249 | |||
| 721a156fce | |||
| b7576d04e1 | |||
| 753954ecd7 | |||
| df7cabe2c1 | |||
| cfca8d2ef4 | |||
| 829932f29d | |||
| 8968667c23 | |||
| a5e0154757 | |||
| f346390631 | |||
| c77fa097c1 | |||
| 074e60d8dc | |||
| 8eff6e5d10 | |||
| 4233ca8637 | |||
| 68fc83ba67 | |||
| 052028afe8 | |||
| a240711946 | |||
| 75fdca95d9 | |||
| 9b087f62f9 | |||
| 7d38cc1269 | |||
| f5baad16d5 | |||
| b35e6812aa | |||
| d7e709d997 | |||
| 4d93aa1392 | |||
| b0f1e0a493 | |||
| 0dffc1d1c2 | |||
| 3581dd4b1d | |||
| 8d2d7bbb15 | |||
| e2e7c0772d | |||
| 807cea1042 | |||
| 80712964ef | |||
| 978e98b2ee | |||
| 44c2820130 | |||
| 123f22cd21 | |||
| b60af1a4fc | |||
| bb3ecc4b76 | |||
| fa30fe045b | |||
| bae014822d | |||
| 6c472b542e | |||
| 7578746d2f | |||
| 0b1ed62df1 | |||
| 76ec41c291 | |||
| 630cd36f13 | |||
| cbe8bb7aeb | |||
| e04636e3f7 | |||
| 728185ddb9 | |||
| aaa485e2fc | |||
| 9a9480035b | |||
| 0a43654f9b | |||
| 4dba36a420 | |||
| f9ce6a6c1b | |||
| c2c6bc3f8a | |||
| 8c02ebcf15 | |||
| 100bfd63ab | |||
| 23ff4977d9 | |||
| 8da6443833 | |||
| 6b3ebde2b5 | |||
| 41392a98e3 | |||
| 1c9bb11f0b | |||
| ec0e687c21 | |||
| e040e784fc | |||
| d2300b87c6 | |||
| 0dff2ece75 | |||
| db24853062 | |||
| 530ea33460 | |||
| 005e4d249f | |||
| 1c0786e28c | |||
| 0aa8d9ba5a | |||
| 1ecb844b64 | |||
| 9a687e6628 | |||
| 979afa37d3 | |||
| 1e1820724d | |||
| d90954c6eb | |||
| cf77d0ff76 | |||
| 73d02d214a | |||
| 6a67d8e9b0 | |||
| 30d8cc3684 | |||
| bc9ebb7d68 | |||
| e6f6d43bf2 | |||
| 854c8b9706 |
@@ -0,0 +1,3 @@
|
||||
tags
|
||||
*.tags
|
||||
*.user
|
||||
+1
-1
@@ -6,7 +6,7 @@ plugin-directory="/usr/lib/"
|
||||
working-directory="/opt/app/tools/atbupdate/"
|
||||
|
||||
[PLUGINS]
|
||||
plugin-name="libCAmaster.so"
|
||||
plugin-name="libCAslave.so"
|
||||
|
||||
[FLAGS]
|
||||
no-psa-hardware-update=false
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
SUBDIRS = DownloadDCFirmware DownloadDCJsonFiles UpdatePTUDevCtrl
|
||||
@@ -0,0 +1,96 @@
|
||||
QT += core gui
|
||||
QT += widgets serialport network
|
||||
|
||||
TARGET = ATBDownloadDCFirmware
|
||||
|
||||
VERSION="0.1.0"
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
}
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
# keep comments, as /* fall through */
|
||||
QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
CONFIG += link_pkgconfig
|
||||
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
|
||||
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
|
||||
INCLUDEPATH += $$PTU5BASEPATH/qt/libs/devicecontroller/include
|
||||
LIBS += -L$$PTU5BASEPATH/qt/libs/devicecontroller/library
|
||||
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
|
||||
# add qmqtt lib
|
||||
#LIBS += -lQt5Qmqtt
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++17
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
ARCH = DesktopLinux
|
||||
DEFINES+=DesktopLinux
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
sender_thread.cpp \
|
||||
receiver_thread.cpp \
|
||||
worker_thread.cpp \
|
||||
../common/src/message_handler.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
sender_thread.h \
|
||||
receiver_thread.h \
|
||||
worker_thread.h \
|
||||
../common/include/message_handler.h
|
||||
|
||||
OTHER_FILES += \
|
||||
ATBDownloadDCFirmware.ini
|
||||
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
##########################################################################################
|
||||
# for running program on target through QtCreator
|
||||
contains( CONFIG, PTU5 ) {
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/app/tools/atbupdate/
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QFileInfo>
|
||||
#include <QThread>
|
||||
|
||||
#include "../common/include/message_handler.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
#else
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QByteArray const value = qgetenv("LC_ALL");
|
||||
if (value != "C") {
|
||||
qputenv("LC_ALL", "C");
|
||||
}
|
||||
// qputenv("XDG_RUNTIME_DIR", "/var/run/user/0");
|
||||
|
||||
openlog("ATB-UPDATE-DC-FIRMWARE", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setApplicationName("ATBUpdateTool");
|
||||
QApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
atbInstallMessageHandler(atbDebugOutput);
|
||||
setDebugLevel(LOG_NOTICE);
|
||||
}
|
||||
|
||||
QThread::currentThread()->setObjectName("main thread");
|
||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||
|
||||
MainWindow mw;
|
||||
|
||||
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
//mw.showFullScreen();
|
||||
|
||||
qCritical() << "SHOW";
|
||||
|
||||
mw.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -0,0 +1,347 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_serial(new QSerialPort(this))
|
||||
, m_width(70) {
|
||||
|
||||
this->setStatusBar(new QStatusBar(this));
|
||||
QFont f;
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
f.setWeight(QFont::Bold);
|
||||
f.setFamily("Misc Fixed");
|
||||
f.setPixelSize(12);
|
||||
this->statusBar()->setFont(f);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
openSerialPort();
|
||||
|
||||
//ui->updateProgress->setRange(0, 100);
|
||||
//ui->updateProgress->reset();
|
||||
|
||||
#if 0
|
||||
QStringList lst;
|
||||
QString start = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
lst << QString("Start: ") + start.leftJustified(m_width-10);
|
||||
lst << QString("").leftJustified(m_width-3, '=');
|
||||
lst << QString("Update tool version: %1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME).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("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, '=');
|
||||
|
||||
ui->updateStatus->setText(lst.join('\n'));
|
||||
ui->updateStatus->setEnabled(true);
|
||||
// ui->updateStatus->installEventFilter(this);
|
||||
|
||||
m_startTimer = new QTimer(this);
|
||||
connect(m_startTimer, SIGNAL(timeout()), m_worker, SLOT(start()));
|
||||
m_startTimer->setSingleShot(true);
|
||||
m_startTimer->start(1000);
|
||||
|
||||
m_exitTimer = new QTimer(this);
|
||||
connect(m_exitTimer, SIGNAL(timeout()), ui->exit, SLOT(click()));
|
||||
m_exitTimer->setSingleShot(true);
|
||||
m_exitTimer->start(1800 * 1000);
|
||||
|
||||
connect(ui->exit, SIGNAL(clicked()),this,SLOT(onQuit()));
|
||||
connect(m_worker, SIGNAL(disableExit()),this,SLOT(onDisableExit()));
|
||||
connect(m_worker, SIGNAL(enableExit()),this,SLOT(onEnableExit()));
|
||||
connect(m_worker, SIGNAL(stopStartTimer()),this,SLOT(onStopStartTimer()));
|
||||
connect(m_worker, SIGNAL(restartExitTimer()),this,SLOT(onRestartExitTimer()));
|
||||
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(showStatusMessage(QString,QString)),this, SLOT(onShowStatusMessage(QString,QString)));
|
||||
connect(m_worker, SIGNAL(showErrorMessage(QStringList)),this, SLOT(onShowErrorMessage(QStringList)));
|
||||
connect(m_worker, SIGNAL(showStatusMessage(QString,QString)),this, SLOT(onShowStatusMessage(QString,QString)));
|
||||
connect(m_worker, SIGNAL(replaceLast(QString,QString)),this,SLOT(onReplaceLast(QString,QString)));
|
||||
connect(m_worker, SIGNAL(replaceLast(QStringList,QString)),this, SLOT(onReplaceLast(QStringList,QString)));
|
||||
#endif
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
//delete m_startTimer;
|
||||
//delete m_exitTimer;
|
||||
closeSerialPort();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool MainWindow::openSerialPort() {
|
||||
// const SettingsDialog::Settings p = m_settings->settings();
|
||||
m_serial->setPortName("");
|
||||
m_serial->setBaudRate(QSerialPort::Baud115200);
|
||||
m_serial->setDataBits(QSerialPort::DataBits::Data8);
|
||||
m_serial->setParity(QSerialPort::Parity::NoParity);
|
||||
m_serial->setStopBits(QSerialPort::StopBits::OneStop);
|
||||
m_serial->setFlowControl(QSerialPort::FlowControl::NoFlowControl);
|
||||
if (m_serial->open(QIODevice::ReadWrite)) {
|
||||
//m_console->setEnabled(true);
|
||||
//m_console->setLocalEchoEnabled(p.localEchoEnabled);
|
||||
//m_ui->actionConnect->setEnabled(false);
|
||||
//m_ui->actionDisconnect->setEnabled(true);
|
||||
//m_ui->actionConfigure->setEnabled(false);
|
||||
//showStatusMessage(tr("Connected to %1 : %2, %3, %4, %5, %6")
|
||||
// .arg(p.name, p.stringBaudRate, p.stringDataBits,
|
||||
// p.stringParity, p.stringStopBits, p.stringFlowControl));
|
||||
return true;
|
||||
} else {
|
||||
//QMessageBox::critical(this, tr("Error"), m_serial->errorString());
|
||||
|
||||
//showStatusMessage(tr("Open error"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MainWindow::closeSerialPort() {
|
||||
if (m_serial->isOpen()) {
|
||||
m_serial->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
//m_console->setEnabled(false);
|
||||
//m_ui->actionConnect->setEnabled(true);
|
||||
//m_ui->actionDisconnect->setEnabled(false);
|
||||
//m_ui->actionConfigure->setEnabled(true);
|
||||
//showStatusMessage(tr("Disconnected"));
|
||||
}
|
||||
|
||||
#if 0
|
||||
void MainWindow::customEvent(QEvent *event) {
|
||||
if (event->type() == ProgressEvent::type()) {
|
||||
ProgressEvent *pevent = (ProgressEvent *)event;
|
||||
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, 1));
|
||||
} 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);
|
||||
// ueberpruefen: hauptfenster schickt sich selber ein event
|
||||
// QApplication::postEvent(this, new ProgressEvent(this, progress));
|
||||
// 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() {
|
||||
m_startTimer->stop();
|
||||
}
|
||||
|
||||
void MainWindow::onDisableExit() {
|
||||
ui->exit->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::onEnableExit() {
|
||||
ui->exit->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::onRestartExitTimer() {
|
||||
m_exitTimer->stop();
|
||||
m_exitTimer->start(5 * 1000);
|
||||
|
||||
scrollDownTextEdit();
|
||||
ui->updateStatus->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::onQuit() {
|
||||
m_exitTimer->stop();
|
||||
int errorCode = 0;
|
||||
|
||||
qCritical()
|
||||
<< QString("ON QUIT: CURRENT STEP %1")
|
||||
.arg(m_worker->getSmap()[m_worker->currentStep()]);
|
||||
|
||||
// TODO: replace SEND_LAST_VERSION with UPDATE_SUCCEEDED
|
||||
if (m_worker->currentStep() != Worker::UPDATE_STEP::SEND_LAST_VERSION) {
|
||||
errorCode = -1;
|
||||
}
|
||||
qCritical() << QString("ON QUIT: EXIT CODE %1").arg(errorCode);
|
||||
qApp->exit(errorCode);
|
||||
}
|
||||
|
||||
void MainWindow::scrollDownTextEdit() {
|
||||
// Utils::printInfoMsg(QString("SCROLL-DOWN-TEXT_EDIT CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
|
||||
ui->updateStatus->setEnabled(true);
|
||||
|
||||
QTextCursor tmpCursor = ui->updateStatus->textCursor();
|
||||
tmpCursor.movePosition(QTextCursor::End);
|
||||
ui->updateStatus->setTextCursor(tmpCursor);
|
||||
ui->updateStatus->ensureCursorVisible();
|
||||
}
|
||||
|
||||
void MainWindow::onAppendText(QString text, QString suffix) {
|
||||
// Utils::printInfoMsg(QString("ON APPEND CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
scrollDownTextEdit();
|
||||
|
||||
if (!suffix.isNull() && suffix.size() > 0) {
|
||||
//qInfo() << "TEXT" << text << "SUFFIX" << suffix;
|
||||
if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) {
|
||||
ui->updateStatus->insertPlainText(QString("\n").leftJustified(m_width-3, '=') + " ");
|
||||
// editText += QString("\n").leftJustified(m_width-3, '=');
|
||||
// editText += " ";
|
||||
}
|
||||
QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix;
|
||||
ui->updateStatus->insertPlainText(add);
|
||||
// editText += add;
|
||||
} else {
|
||||
QString const &add = text.leftJustified(m_width-9);
|
||||
ui->updateStatus->insertPlainText(add);
|
||||
//editText += add;
|
||||
}
|
||||
|
||||
// debug
|
||||
// QString editText = ui->updateStatus->toPlainText();
|
||||
// Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
|
||||
// ui->updateStatus->setText(editText.trimmed());
|
||||
|
||||
scrollDownTextEdit();
|
||||
}
|
||||
|
||||
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
|
||||
// Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
int const s = newTextLines.size();
|
||||
if (s > 0) {
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
|
||||
QString newText;
|
||||
if (lines.size() >= s) {
|
||||
for (int i = 0; i < s; ++i) {
|
||||
lines.removeLast();
|
||||
}
|
||||
if (lines.size() > 0) {
|
||||
newText = lines.join('\n');
|
||||
newText += '\n';
|
||||
}
|
||||
QStringList newLines;
|
||||
for (int i = 0; i < s; ++i) {
|
||||
if (i == 0 && !suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10) + suffix);
|
||||
} else {
|
||||
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10));
|
||||
}
|
||||
}
|
||||
lines += newLines;
|
||||
newText += newLines.join(' ');
|
||||
}
|
||||
|
||||
ui->updateStatus->setText(newText);
|
||||
Utils::printLineEditInfo(lines);
|
||||
scrollDownTextEdit();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
|
||||
// Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
|
||||
// + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
|
||||
if (lines.size() > 0) {
|
||||
// removing the last line is really meant for refreshing the last line
|
||||
// with a string very similar than the original one, typically only
|
||||
// followed by a suffix.
|
||||
if (lines.last().contains(text)) {
|
||||
lines.removeLast();
|
||||
}
|
||||
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
|
||||
QString const add = text.leftJustified(m_width-10) + suffix;
|
||||
if (!add.isEmpty()) {
|
||||
lines += text.leftJustified(m_width-10) + suffix;
|
||||
}
|
||||
} else {
|
||||
QString const add = text.leftJustified(m_width-10);
|
||||
if (!add.isEmpty()) {
|
||||
lines += text.leftJustified(m_width-10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Utils::printLineEditInfo(lines);
|
||||
ui->updateStatus->setText(lines.join('\n').trimmed());
|
||||
scrollDownTextEdit();
|
||||
}
|
||||
|
||||
void MainWindow::onShowMessage(QString title, QString text) {
|
||||
this->statusBar()->clearMessage();
|
||||
this->statusBar()->showMessage( // timeout: 10000
|
||||
QString(title + " " + text).leftJustified(80, ' '), 10000);
|
||||
}
|
||||
|
||||
void MainWindow::onShowErrorMessage(QString title, QString text) {
|
||||
onShowMessage(title, text);
|
||||
}
|
||||
|
||||
void MainWindow::onShowStatusMessage(QString title, QString text) {
|
||||
onShowMessage(title, text);
|
||||
}
|
||||
|
||||
void MainWindow::onShowErrorMessage(QStringList lst) {
|
||||
if (lst.size() >= 2) {
|
||||
onShowMessage(lst.at(0), lst.at(1));
|
||||
}
|
||||
if (lst.size() == 1) {
|
||||
onShowMessage(lst.at(0), "");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShowStatusMessage(QStringList lst) {
|
||||
if (lst.size() >= 2) {
|
||||
onShowMessage(lst.at(0), lst.at(1));
|
||||
}
|
||||
if (lst.size() == 1) {
|
||||
onShowMessage(lst.at(0), "");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QStatusBar>
|
||||
#include <QWidget>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
//void onAppendText(QString, QString suffix = "");
|
||||
//void onReplaceLast(QStringList, QString suffix = "");
|
||||
//void onReplaceLast(QString, QString suffix = "");
|
||||
//void onShowErrorMessage(QString, QString);
|
||||
//void onShowStatusMessage(QString, QString);
|
||||
//void onShowErrorMessage(QStringList);
|
||||
//void onShowStatusMessage(QStringList);
|
||||
//void onStopStartTimer();
|
||||
//void onRestartExitTimer();
|
||||
//void onEnableExit();
|
||||
//void onDisableExit();
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
// void onQuit();
|
||||
|
||||
private:
|
||||
// void scrollDownTextEdit();
|
||||
// void onShowMessage(QString, QString);
|
||||
|
||||
bool openSerialPort();
|
||||
bool closeSerialPort();
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QSerialPort *m_serial;
|
||||
// Worker *m_worker;
|
||||
int const m_width;
|
||||
// QTimer *m_startTimer;
|
||||
// QTimer *m_exitTimer;
|
||||
// bool m_progressRunning;
|
||||
//int m_progressValue;
|
||||
// UpdateDcEvent::UpdateStep m_updateStep;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Code Pro</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>781</width>
|
||||
<height>441</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" rowspan="3" colspan="2">
|
||||
<widget class="QTextEdit" name="updateStatus">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Misc Fixed</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "worker_thread.h"
|
||||
|
||||
WorkerThread::WorkerThread(QObject *parent)
|
||||
: QThread(parent) {
|
||||
}
|
||||
|
||||
WorkerThread::~WorkerThread() {
|
||||
|
||||
}
|
||||
|
||||
void WorkerThread::run() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef WORKER_THREAD_H_INCLUDED
|
||||
#define WORKER_THREAD_H_INCLUDED
|
||||
|
||||
#include <QThread>
|
||||
|
||||
class WorkerThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WorkerThread(QObject *parent = nullptr);
|
||||
~WorkerThread();
|
||||
|
||||
|
||||
private:
|
||||
void run() override;
|
||||
|
||||
bool m_quit = false;
|
||||
};
|
||||
|
||||
#endif // WORKER_THREAD_H_INCLUDED
|
||||
@@ -0,0 +1,102 @@
|
||||
QT += core
|
||||
QT += serialport network
|
||||
|
||||
TARGET = ATBDownloadDCJsonFiles
|
||||
|
||||
VERSION="0.1.0"
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
}
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
|
||||
!contains(CONFIG, INCLUDEINTERFACES) {
|
||||
INCLUDEINTERFACES=/opt/ptu5/opt/DCLibraries/include
|
||||
}
|
||||
|
||||
INCLUDEPATH += \
|
||||
plugins \
|
||||
$${INCLUDEINTERFACES} \
|
||||
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
||||
$${_PRO_FILE_PWD_}/../../ATBUpdateTool/common/include
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
# keep comments, as /* fall through */
|
||||
QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
CONFIG += link_pkgconfig
|
||||
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
|
||||
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
|
||||
INCLUDEPATH += $$PTU5BASEPATH/qt/libs/devicecontroller/include
|
||||
LIBS += -L$$PTU5BASEPATH/qt/libs/devicecontroller/library
|
||||
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
|
||||
# add qmqtt lib
|
||||
#LIBS += -lQt5Qmqtt
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++17
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
ARCH = DesktopLinux
|
||||
DEFINES+=DesktopLinux
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
../UpdatePTUDevCtrl/message_handler.cpp \
|
||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||
update.cpp \
|
||||
../../ATBUpdateTool/common/src/System.cpp
|
||||
|
||||
HEADERS += \
|
||||
../UpdatePTUDevCtrl/message_handler.h \
|
||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||
update.h \
|
||||
../../ATBUpdateTool/common/include/System.h
|
||||
|
||||
OTHER_FILES += \
|
||||
ATBDownloadDCJsonFiles.ini
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# for running program on target through QtCreator
|
||||
contains( CONFIG, PTU5 ) {
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/app/tools/atbupdate/
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 5.0.2, 2024-02-28T16:01:22. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{6a494cc5-6dea-4681-86fc-d47b9761a1f4}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="bool" key="EditorConfiguration.UseIndenter">false</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.CTest">false</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.AnalyzeOpenFiles">true</value>
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">3</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">GenericLinuxOsType</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Yocto i.MX6-ATB-PTU5</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Yocto i.MX6-ATB-PTU5</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{804f60e1-6e88-41af-b072-9f5c6a606099}</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments">CONFIG+=PTU5</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand">/usr/bin/make</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand">/usr/bin/make</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Yocto_i_MX6_ATB_PTU5-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinux.CheckForFreeDiskSpaceStep</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||
<value type="QString" key="RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck">/</value>
|
||||
<value type="qlonglong" key="RemoteLinux.CheckForFreeDiskSpaceStep.RequiredSpace">5242880</value>
|
||||
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinux.KillAppStep</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedFiles"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedHosts"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedRemotePaths"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.RunConfiguration.LastDeployedSysroots"/>
|
||||
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedLocalTimes"/>
|
||||
<valuelist type="QVariantList" key="RemoteLinux.LastDeployedRemoteTimes"/>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">DeployToGenericLinux</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">1</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DownloadDCJsonFiles</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">RemoteLinuxRunConfiguration:/opt/ptu5/opt/DownloadDCJsonFiles/DownloadDCJsonFiles.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey">/opt/ptu5/opt/DownloadDCJsonFiles/DownloadDCJsonFiles.pro</value>
|
||||
<value type="int" key="RemoteLinux.EnvironmentAspect.Version">1</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.X11Forwarding">:0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.1</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.12 GCC 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.12 GCC 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.51212.gcc_64_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/opt/ptu5/opt/build-DownloadDCJsonFiles-Desktop_Qt_5_12_12_GCC_64bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">2</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
@@ -0,0 +1,145 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QByteArray>
|
||||
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "commandline_parser.h"
|
||||
#include "utils.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
|
||||
//#include <unistd.h>
|
||||
//#include <errno.h>
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
#else
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
int read1stLineOfFile(QString fileName) {
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
return in.readLine().toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
QByteArray const value = qgetenv("LC_ALL");
|
||||
if (value != "C") {
|
||||
qputenv("LC_ALL", "C");
|
||||
}
|
||||
// qputenv("XDG_RUNTIME_DIR", "/var/run/user/0");
|
||||
|
||||
openlog("ATB-DL-JSON", LOG_PERROR | LOG_PID | LOG_CONS, LOG_USER);
|
||||
|
||||
QCoreApplication a(argc, argv);
|
||||
QCoreApplication::setApplicationName("ATBDownloadDCJsonFiles");
|
||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
||||
|
||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||
atbInstallMessageHandler(atbDebugOutput);
|
||||
setDebugLevel(LOG_NOTICE);
|
||||
}
|
||||
|
||||
CommandLineParser parser;
|
||||
parser.process(a);
|
||||
parser.readSettings();
|
||||
|
||||
QString repositoryUrl = parser.repositoryUrl();
|
||||
QString plugInDir = parser.plugInDir();
|
||||
QString plugInName = parser.plugInName();
|
||||
QString workingDir = parser.workingDir();
|
||||
QString iniFileName = parser.iniFileName();
|
||||
bool const dryRun = parser.dryRun();
|
||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||
bool const showYoctoVersion = parser.yoctoVersion();
|
||||
bool const showYoctoInstallStatus = parser.yoctoInstallStatus();
|
||||
bool const showExtendedVersion = parser.extendedVersion();
|
||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||
|
||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
int const machineNr = read1stLineOfFile("/mnt/system_data/machine_nr");
|
||||
int const customerNr = read1stLineOfFile("/mnt/system_data/cust_nr");
|
||||
int const zoneNr = read1stLineOfFile("/mnt/system_data/zone_nr");
|
||||
QString const branchName = (zoneNr != 0)
|
||||
? QString("zg1/zone%1").arg(zoneNr) : "master";
|
||||
|
||||
qInfo() << "pwd ......................" << rtPath;
|
||||
qInfo() << "repositoryUrl ............" << repositoryUrl;
|
||||
qInfo() << "plugInDir ................" << plugInDir;
|
||||
qInfo() << "plugInName ..............." << plugInName;
|
||||
qInfo() << "workingDir ..............." << workingDir;
|
||||
qInfo() << "dryRun ..................." << dryRun;
|
||||
qInfo() << "noUpdatePsaHardware ......" << noUpdatePsaHardware;
|
||||
qInfo() << "alwaysDownloadConfig ....." << alwaysDownloadConfig;
|
||||
qInfo() << "alwaysDownloadDC ........." << alwaysDownloadDC;
|
||||
qInfo() << "showYoctoVersion ........." << showYoctoVersion;
|
||||
qInfo() << "showYoctoInstallStatus ..." << showYoctoInstallStatus;
|
||||
qInfo() << "showExtendedVersion ......" << showExtendedVersion;
|
||||
qInfo() << "iniFileName .............." << iniFileName;
|
||||
qInfo() << "extended-version ........." << APP_EXTENDED_VERSION;
|
||||
qInfo() << "machineNr ................" << machineNr;
|
||||
qInfo() << "customerNr ..............." << customerNr;
|
||||
qInfo() << "zoneNr ..................." << zoneNr;
|
||||
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString const customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
|
||||
qCritical() << "Using customer repository" << customerRepo;
|
||||
|
||||
// always execute contents of opkg_commands-file
|
||||
QStringList filesToUpdate;
|
||||
|
||||
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/psa_config"));
|
||||
|
||||
if (dir.exists()) {
|
||||
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
|
||||
if (!jsons.isEmpty()) {
|
||||
for (QStringList::size_type i=0; i<jsons.size(); ++i) {
|
||||
filesToUpdate << QDir::cleanPath(QString("etc/psa_config/") + jsons.at(i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "DIRECTORY" << dir << "DOES NOT EXIST";
|
||||
return -1;
|
||||
}
|
||||
|
||||
qCritical() << "JSON FILES TO UPDATE" << filesToUpdate;
|
||||
|
||||
Update update(customerRepo,
|
||||
QString::number(customerNr),
|
||||
branchName,
|
||||
plugInDir,
|
||||
plugInName,
|
||||
workingDir);
|
||||
|
||||
update.doUpdate(filesToUpdate);
|
||||
|
||||
//return a.exec();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
#include "message_handler.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <cstring>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageLogContext>
|
||||
|
||||
|
||||
static char const *DBG_NAME[] = { "DBG ", "WARN ", "CRIT ", "FATAL", "INFO " };
|
||||
static bool installedMsgHandler = false;
|
||||
static int debugLevel = LOG_NOTICE;
|
||||
|
||||
int getDebugLevel() { return debugLevel; }
|
||||
void setDebugLevel(int newDebugLevel) {
|
||||
debugLevel = newDebugLevel;
|
||||
}
|
||||
|
||||
bool messageHandlerInstalled() {
|
||||
return installedMsgHandler;
|
||||
}
|
||||
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler) {
|
||||
installedMsgHandler = (handler != 0);
|
||||
static QtMessageHandler prevHandler = nullptr;
|
||||
if (handler) {
|
||||
prevHandler = qInstallMessageHandler(handler);
|
||||
return prevHandler;
|
||||
} else {
|
||||
return qInstallMessageHandler(prevHandler);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Print message according to given debug level.
|
||||
///
|
||||
/// \note Install this function using qInstallMsgHandler().
|
||||
///
|
||||
/// int main(int argc, char **argv) {
|
||||
/// installMsgHandler(atbDebugOutput);
|
||||
/// QApplication app(argc, argv);
|
||||
/// ...
|
||||
/// return app.exec();
|
||||
/// }
|
||||
///
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||
Q_UNUSED(context);
|
||||
QString const localMsg = QString(DBG_NAME[type]) + msg.toLocal8Bit();
|
||||
|
||||
switch (debugLevel) {
|
||||
case LOG_DEBUG: { // debug-level message
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
} break;
|
||||
case LOG_INFO: { // informational message
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_NOTICE: { // normal, but significant, condition
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_WARNING: { // warning conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ERR: { // error conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_CRIT: { // critical conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ALERT: { // action must be taken immediately
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_EMERG: { // system is unusable
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
//fprintf(stderr, "%s No ErrorLevel defined! %s\n",
|
||||
// datetime.toStdString().c_str(), msg.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_HANDLER_H_INCLUDED
|
||||
#define MESSAGE_HANDLER_H_INCLUDED
|
||||
|
||||
#include <QtGlobal>
|
||||
#ifdef __linux__
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
int getDebugLevel();
|
||||
void setDebugLevel(int newDebugLevel);
|
||||
|
||||
bool messageHandlerInstalled();
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const char *);
|
||||
void atbDebugOutput(QtMsgType type, const char *msg);
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &);
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
#endif
|
||||
|
||||
#endif // MESSAGE_HANDLER_H_INCLUDED
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
#ifndef COMMAND_H_INCLUDED
|
||||
#define COMMAND_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QProcess>
|
||||
|
||||
|
||||
class Command : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
QString m_command;
|
||||
QString m_commandResult;
|
||||
int m_waitForStartTimeout;
|
||||
int m_waitForFinishTimeout;
|
||||
int m_exitCode;
|
||||
public:
|
||||
explicit Command(QString const &command,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
QString getCommandResult() const;
|
||||
QString command() const { return m_command; }
|
||||
|
||||
bool execute(QString workingDirectory, QStringList args = QStringList());
|
||||
int exitCode() const { return m_exitCode; }
|
||||
|
||||
private slots:
|
||||
void readyReadStandardOutput();
|
||||
void readyReadStandardError();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
};
|
||||
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
@@ -0,0 +1,390 @@
|
||||
#include "update.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QTemporaryFile>
|
||||
#include <QDebug>
|
||||
#include <QTextStream>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegExp>
|
||||
|
||||
#if defined (Q_OS_UNIX) || defined (Q_OS_LINUX)
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QScopedPointer>
|
||||
#include <QDir>
|
||||
#include <QThread>
|
||||
#include <QDateTime>
|
||||
#include <QPluginLoader>
|
||||
#include <QMap>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
|
||||
static const QMap<QString, int> baudrateMap = {
|
||||
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
|
||||
{"57600" , 4}, {"115200" , 5}
|
||||
};
|
||||
|
||||
QPluginLoader Update::pluginLoader;
|
||||
|
||||
hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
||||
hwinf *hw = nullptr;
|
||||
if (plugInDir.exists()) {
|
||||
QString pluginLibName(fname);
|
||||
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
|
||||
QFileInfo info(pluginLibName);
|
||||
if (info.exists()) {
|
||||
pluginLibName = plugInDir.absoluteFilePath(pluginLibName);
|
||||
pluginLoader.setFileName(pluginLibName);
|
||||
// static QPluginLoader pluginLoader(pluginLibName);
|
||||
if (!pluginLoader.load()) {
|
||||
qCritical() << "in directory" << plugInDir.absolutePath();
|
||||
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
||||
qCritical() << pluginLoader.errorString();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
||||
qCritical() << "loadDCPlugin() plugin file name:" << pluginLoader.fileName();
|
||||
|
||||
if (!pluginLoader.isLoaded()) {
|
||||
qCritical() << pluginLoader.errorString();
|
||||
exit(-2);
|
||||
}
|
||||
QObject *plugin = pluginLoader.instance();
|
||||
if (!plugin) {
|
||||
qCritical() << "cannot start instance";
|
||||
exit(-3);
|
||||
}
|
||||
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
||||
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
||||
exit(-4);
|
||||
}
|
||||
} else {
|
||||
qCritical() << pluginLibName << "does not exist";
|
||||
exit(-5);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
||||
<< "does not exist";
|
||||
exit(-6);
|
||||
}
|
||||
return hw;
|
||||
}
|
||||
|
||||
bool Update::unloadDCPlugin() {
|
||||
if (pluginLoader.unload()) {
|
||||
qCritical() << "unloaded plugin" << pluginLoader.fileName();
|
||||
// Note: will re-instantiate the library !
|
||||
// QObject *rootObject = pluginLoader.instance();
|
||||
// if (rootObject) {
|
||||
// qCritical() << "reloaded plugin: root object again available";
|
||||
// return false;
|
||||
// }
|
||||
// qCritical()unloaded plugin: root object gone";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
class hwapi;
|
||||
Update::Update(QString customerRepository,
|
||||
QString customerNrStr,
|
||||
QString branchName,
|
||||
QString plugInDir,
|
||||
QString pluginName,
|
||||
QString workingDir,
|
||||
bool dryRun,
|
||||
QObject *parent,
|
||||
char const *serialInterface,
|
||||
char const *baudrate)
|
||||
: QObject(parent)
|
||||
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||
, m_serialInterface(serialInterface)
|
||||
, m_baudrate(baudrate)
|
||||
, m_customerRepository(customerRepository)
|
||||
, m_customerNrStr(customerNrStr)
|
||||
, m_branchName(branchName)
|
||||
, m_pluginName(pluginName)
|
||||
, m_workingDir(workingDir)
|
||||
, m_dryRun(dryRun)
|
||||
, m_sys_areDCdataValid(false) {
|
||||
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
|
||||
} else {
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
break;
|
||||
}
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
|
||||
#if 0
|
||||
QObject const *obj = m_hw->getAPI();
|
||||
Q_ASSERT(obj != nullptr);
|
||||
|
||||
QDebug critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadStatus() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)),
|
||||
this,
|
||||
SLOT(onReportDCDownloadStatus(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
|
||||
critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadSuccess() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
|
||||
SLOT(onReportDCDownloadSuccess(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
|
||||
critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadFailure() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
|
||||
SLOT(onReportDCDownloadFailure(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Update::~Update() {
|
||||
// unloadDCPlugin();
|
||||
}
|
||||
|
||||
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
||||
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
||||
return false;
|
||||
}
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
bool res = false;
|
||||
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
qCritical() <<
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res= updateConfig(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||
|
||||
uint8_t jsonNr = 0;
|
||||
|
||||
QString const &fName = jsonFileNames[i];
|
||||
|
||||
if (fName.endsWith("conf.json")) {
|
||||
jsonNr = 1;
|
||||
} else
|
||||
if (fName.endsWith("device.json")) {
|
||||
jsonNr = 2;
|
||||
} else
|
||||
if (fName.endsWith("cash.json")) {
|
||||
jsonNr = 3;
|
||||
} else {
|
||||
QRegularExpressionMatch match;
|
||||
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
|
||||
int idx = fName.indexOf(re, 0, &match);
|
||||
if (idx != -1) {
|
||||
QString captured = match.captured(match.lastCapturedIndex());
|
||||
bool ok = false;
|
||||
int n = captured.toInt(&ok);
|
||||
if (ok) {
|
||||
jsonNr = n + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonNr != 0) {
|
||||
#if 0
|
||||
m_hw->sys_requestJsonVersions(jsonNr);
|
||||
QThread::msleep(500);
|
||||
|
||||
char buf[64];
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
m_hw->sys_getJsonVersions(jsonNr, buf);
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
|
||||
QString const installedVersion(buf);
|
||||
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||
|
||||
qCritical() << "installed version:" << installedVersion;
|
||||
qCritical() << " file version:" << fileVersion;
|
||||
|
||||
if (installedVersion == fileVersion) {
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::downloadJson(enum FileTypeJson type,
|
||||
int templateIdx,
|
||||
QString jsFileToSendToDC) const {
|
||||
|
||||
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
|
||||
QStringList lst;
|
||||
bool ready = false;
|
||||
int nTry = 25;
|
||||
while ((ready = m_hw->sys_ready4sending()) == false) {
|
||||
QThread::msleep(200);
|
||||
if (--nTry <= 0) {
|
||||
qCritical() << "SYS NOT READY FOR SENDING AFTER 5 SECONDS";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
QString msg;
|
||||
lst.clear();
|
||||
if (ready) {
|
||||
QFile file(jsFileToSendToDC);
|
||||
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
|
||||
if (file.exists()) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
if (fi.size() > 0 && fi.size() <= 800) {
|
||||
QByteArray ba = file.readAll();
|
||||
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
|
||||
// nrOfTemplate=1...32 if kindOfFile==6
|
||||
// content = content of the Json file, max 800byte ascii signs
|
||||
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templateIdx,
|
||||
(uint8_t *)ba.data())) {
|
||||
|
||||
/*
|
||||
* Note: the machine id is contained in DC2C_conf.json.
|
||||
* The idea was to use this to check if the download of
|
||||
* the json-file was correct. It did not work, as the
|
||||
* update of the PSA (to reflect a change in the
|
||||
* machine id) did not happen immediately.
|
||||
*
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
|
||||
// testing
|
||||
m_hw->request_ReadbackMachineID();
|
||||
QThread::msleep(500);
|
||||
|
||||
uint8_t data[64];
|
||||
memset(data, 0x00, sizeof(data));
|
||||
uint8_t length = 0;
|
||||
|
||||
m_hw->readback_machineIDdata(&length, data);
|
||||
|
||||
QThread::msleep(500);
|
||||
|
||||
QByteArray ba((const char*)data, length);
|
||||
|
||||
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
|
||||
*/
|
||||
|
||||
ret = true;
|
||||
} else {
|
||||
qCritical() << QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
|
||||
}
|
||||
} else {
|
||||
qCritical() << QString("SIZE OF %1 TOO BIG (%2 BYTES)").arg(jsFileToSendToDC).arg(fi.size());
|
||||
}
|
||||
} else {
|
||||
qCritical() << QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING";
|
||||
}
|
||||
} else {
|
||||
qCritical() << (QString(jsFileToSendToDC) + " DOES NOT EXIST");
|
||||
}
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Update::updatePrinterTemplate(int templateIdx, QString jsFile) const {
|
||||
return downloadJson(FileTypeJson::PRINTER, templateIdx, jsFile);
|
||||
}
|
||||
|
||||
bool Update::updateConfig(QString jsFile) {
|
||||
return downloadJson(FileTypeJson::CONFIG, 0, jsFile);
|
||||
}
|
||||
|
||||
bool Update::updateCashConf(QString jsFile) {
|
||||
return downloadJson(FileTypeJson::CASH, 0, jsFile);
|
||||
}
|
||||
|
||||
bool Update::updateDeviceConf(QString jsFile) {
|
||||
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
#ifndef UPDATE_H_INCLUDED
|
||||
#define UPDATE_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QByteArray>
|
||||
#include <QProcess>
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
#else
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
class Update : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
hwinf *m_hw = nullptr;
|
||||
char const *m_serialInterface;
|
||||
char const *m_baudrate;
|
||||
QString m_customerRepository;
|
||||
QString m_customerNrStr;
|
||||
QString m_branchName;
|
||||
QString m_pluginName;
|
||||
QString m_workingDir;
|
||||
bool m_maintenanceMode;
|
||||
bool m_dryRun;
|
||||
bool m_sys_areDCdataValid;
|
||||
|
||||
static QPluginLoader pluginLoader;
|
||||
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
|
||||
|
||||
static hwinf *loadDCPlugin(QDir const &plugInDir, QString const &fn);
|
||||
static bool unloadDCPlugin();
|
||||
static QStringList split(QString line, QChar sep = ',');
|
||||
|
||||
|
||||
explicit Update(QString customerRepository,
|
||||
QString customerNrStr,
|
||||
QString branchName,
|
||||
QString plugInDir,
|
||||
QString pluginName,
|
||||
QString workingDir,
|
||||
bool dryRun = false,
|
||||
QObject *parent = nullptr,
|
||||
char const *serialInterface = SERIAL_PORT,
|
||||
char const *baudrate = "115200");
|
||||
|
||||
virtual ~Update() override;
|
||||
|
||||
bool doUpdate(QStringList const &jsonFilesToDownload);
|
||||
|
||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||
bool updateConfig(QString jsFileToSendToDC);
|
||||
bool updateCashConf(QString jsFileToSendToDC);
|
||||
bool updateDeviceConf(QString jsFileToSendToDC);
|
||||
|
||||
bool downloadJson(enum FileTypeJson type, int templateIdx,
|
||||
QString jsFileToSendToDC) const;
|
||||
|
||||
|
||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
||||
/*
|
||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
||||
|
||||
hwinf *hw() { return m_hw; }
|
||||
hwinf const *hw() const { return m_hw; }
|
||||
|
||||
//QString customerId() { return m_customerId; }
|
||||
//QString const customerId() const { return m_customerId; }
|
||||
|
||||
QString branchName() { return m_branchName; }
|
||||
QString const branchName() const { return m_branchName; }
|
||||
|
||||
//QString repositoryPath() { return m_repositoryPath; }
|
||||
//QString const repositoryPath() const { return m_repositoryPath; }
|
||||
|
||||
private:
|
||||
static QString jsonType(enum FileTypeJson type);
|
||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||
void closeSerial() const;
|
||||
bool isSerialOpen() const;
|
||||
bool resetDeviceController() const;
|
||||
QByteArray loadBinaryDCFile(QString filename) const;
|
||||
bool downloadBinaryToDC(QString const &bFile) const;
|
||||
bool updateBinary(QString const &fileToSendToDC);
|
||||
QStringList getDcSoftAndHardWareVersion();
|
||||
QString getFileVersion(QString const& jsonFile);
|
||||
|
||||
private slots:
|
||||
void readyReadStandardOutput();
|
||||
void readyReadStandardError();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void onReportDCDownloadStatus(QString const &status);
|
||||
void onReportDCDownloadSuccess(QString const &msg);
|
||||
void onReportDCDownloadFailure(QString const &errorMsg);
|
||||
*/
|
||||
};
|
||||
#endif // UPDATE_H_INCLUDED
|
||||
@@ -92,8 +92,20 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
# Changes:
|
||||
# (1) the ini-File now uses the libCAmaster.so.
|
||||
# 1.3._25_: Again special version for szeged, using interface.h, version 4.4.
|
||||
VERSION="1.3._25_"
|
||||
|
||||
# 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged)
|
||||
# Set hash-value in EVENT-objects. Set location (project), version
|
||||
# and info in send-last-version.
|
||||
# If the customer repository does not exist, then do not check the
|
||||
# ISMAS trigger, but proceed with the update procedure. Otherwise,
|
||||
# check the ISMAS update-trigger as first step.
|
||||
# If the current time is between 0.00 - 4.00 o'clock, then a wrong
|
||||
# trigger-value will result in an UPDATE_STEP_NOT_NECESSARY.
|
||||
# Move final processing to subclass UpdateProcessRunning.
|
||||
# Disable EXIT-button for the whole update-process, except for the
|
||||
# checking of the ISMAS-trigger-button (aka WAIT-button).
|
||||
# 1.4.1 : Sync files in the customer repository (under ./etc) as the very
|
||||
# first step
|
||||
VERSION="1.4.1"
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||
@@ -107,7 +119,6 @@ VERSION="1.3._25_"
|
||||
# ISMAS eine entsprechende Meldung anzeigen als Teil von SEND-LAST-VERSION.
|
||||
# Wenn der WAIT-button aktiv ist, dann werden zumindest die opkg-commands
|
||||
# ausgefuehrt.
|
||||
# 4: rsync: immer alle Dateien soiegeln (bis auf opkg-commands)
|
||||
# 5: Falls das Tool mal abstuerzt, dann einen Signal-Handler (fuer TERM)
|
||||
# installieren, sodass zumnidest SEND-LAST-VERSION mit rausgeht.
|
||||
# 6: rsync: explizites Binary, nicht das in busybox enthaltene.
|
||||
@@ -123,9 +134,6 @@ VERSION="1.3._25_"
|
||||
# Stellung des WAIT-Button. Grund: es koennte sein, dass andernfalls ein
|
||||
# PSA weit hiter anderen steht, und dann ploetzlich einmal alle vorher-
|
||||
# gehenden Aenderungen anzieht, die gar nicht fuer ihn gemeint waren.
|
||||
# 10: Bei einer Neuinstallation (Neuhauser) immer JSON files runterladen,
|
||||
# Tariff-Files syncen (d.h. nur wenn noch kein Repo vorhanden ist), und
|
||||
# zwar auch ohne WAIT-Button.
|
||||
# 11: Das Edit-Fenster teilen um die Anzeige zu verbessern.
|
||||
# 12: Bei einem Update muss immer ersichtlich sein, warum es ueberhaupt
|
||||
# angestossen wurde. Steht kein "WAIT" im ISMAS-Trigger, dann kann man
|
||||
@@ -179,7 +187,7 @@ DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
# keep comments, as /* fall through */
|
||||
QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
@@ -239,6 +247,7 @@ HEADERS += \
|
||||
process/command.h \
|
||||
message_handler.h \
|
||||
worker.h \
|
||||
interfaces.h \
|
||||
commandline_parser.h \
|
||||
plugins/interfaces.h
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
QT += core gui
|
||||
QT += widgets serialport network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = ATBUpdateTool
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# 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.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
# 1.3.6 : Do not update device-controller/json files, but have the library
|
||||
# (in a later step) do that.
|
||||
# Fixed sending messages to ISMAS.
|
||||
# Always execute contents of opkg_commands-file (even if there are no
|
||||
# changes).
|
||||
# 1.3.7 : Wait forever for git-commands to finish in QProcess executing such
|
||||
# a command.
|
||||
# 1.3.8 : Remove accessing opkg_commands under file-system-path /etc/psa_update.
|
||||
# Activate download of json-configuration files.
|
||||
# 1.3.9 : Fix sendLastVersion: use configured branch and not master branch in
|
||||
# git show origin/master -s --format="c=%h m=%s d=%cI" ==>
|
||||
# git show origin/zg1/zone1 -s --format="c=%h m=%s d=%cI"
|
||||
# Use dynamic values for os-release and apism-version when sending
|
||||
# last version info.
|
||||
# 1.3.10: Fix premature killing opkg-commands: detected timeout of 100s was
|
||||
# too small when updating apism.
|
||||
# Fix display of UPDATE_SUCCESS when opkg_command fails. Detected when
|
||||
# updating apsim failed.
|
||||
# 1.3.11: Integrate version of ATBUpdateTool in SendLastVersion-ISMAS-message.
|
||||
# 1.3.12: Add command parameters for output of yocto-infos about ATBUpdateTool.
|
||||
# Use 'git pull' instead of 'git fetch'.
|
||||
# Use 'git clone --filter=blob:none' instead of 'git clone' to speed
|
||||
# up cloning of customer repository.
|
||||
# 1.3.13: Fix: if the customer repository is corrupted, remove it and re-clone
|
||||
# the repository (without checking the ISMAS-trigger (WAIT-)button.
|
||||
# 1.3.14: Add additional check for sanity of customer repository using
|
||||
# "git fsck".
|
||||
# Stream-lined code of update process: massive refactoring.
|
||||
# Added functionality: If WAIT button is not active, then an existing
|
||||
# customer repository will be repaired, or a not existing repository
|
||||
# will be cloned. The process stops then.
|
||||
# However, if the WAIT button is active, the at least the commands in
|
||||
# opkg_commands will be executed. Changed files in the customer
|
||||
# repository will be worked on: tariff-files will be synced with the
|
||||
# local filesystem, json-files will be downloaded to firmware.
|
||||
# The device-controller firmware will be handled in a later version.
|
||||
# 1.3.15: Bug fixes found during testing.
|
||||
# Do not disable Exit-button during update-process.
|
||||
# Removed worker-thread with an own event-loop: only the GUI thread
|
||||
# has an event loop. Tested JSON-downloads several times successfully
|
||||
# (using the slave lib where the CA helper tool was active as master).
|
||||
# Turned previous worker-object into its own thread, but without any
|
||||
# own event-loop (so it cannot block anything inside the CA-plugin).
|
||||
# 1.3.16: Bug fixes found during testing.
|
||||
# 1.3.17: Add ATBUpdateTool.ini and custom command line parser. Settings
|
||||
# given in ATBUpdateTool.ini can be overwritten on the command-line.
|
||||
# 1.3.18: Bug fixes found during testing.
|
||||
# 1.3.19: Bug fixes found during testing.
|
||||
# 1.3.20: Bug fixes found during testing.
|
||||
# 1.3.21: Bug fixes found during testing:
|
||||
# Fix directory of ATBUpdateTool.ini to be the working directory of
|
||||
# the application rather than just ".".
|
||||
# Check existance of etc-directory inside customer repository.
|
||||
# Check for valid ISMAS trigger (button) 15x (=90s).
|
||||
# NOTE: if the customer repository is cloned (or repaired and cloned
|
||||
# again), and if the settings always-download-config=true and
|
||||
# always-download-dc=true in the ATBUpdateTool.ini file, the download
|
||||
# the printer-json files and the device controller file, even without
|
||||
# an activated ISMAS trigger (button). The tariff-files are rsynced to
|
||||
# the local filesystem for such clone.
|
||||
# Set new filename for device controller: dc2c.bin.
|
||||
# 1.3.22: Bug fixes found during testing:
|
||||
# Fix the path-names of the json-files and the device-controller.
|
||||
# Set automatic download of json-file in ATBUpdateTool.ini file for
|
||||
# a fresh clone of the repository.
|
||||
# 1.3.23: Added a 'break' to prevent a possible endless loop when checking if
|
||||
# the device is alive.
|
||||
#
|
||||
# NOTE: The versioning info has to be shifted up by one version, i.e. what
|
||||
# happened for 1.3.23 was actually done in 1.3.24.
|
||||
# 1.3.24
|
||||
#
|
||||
# 1.3._24_: Special version for szeged using a old dc-controller (4.42):
|
||||
# Changes:
|
||||
# (1) the ini-File now uses the libCAmaster.so.
|
||||
# 1.3._25_: Again special version for szeged, using interface.h, version 4.4.
|
||||
# 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged)
|
||||
# Set hash-value in EVENT-objects. Set location (project), version
|
||||
# and info in send-last-version.
|
||||
# If the customer repository does not exist, then do not check the
|
||||
# ISMAS trigger, but proceed with the update procedure. Otherwise,
|
||||
# check the ISMAS update-trigger as first step.
|
||||
# If the current time is between 0.00 - 4.00 o'clock, then a wrong
|
||||
# trigger-value will result in an UPDATE_STEP_NOT_NECESSARY.
|
||||
# Move final processing to subclass UpdateProcessRunning.
|
||||
# Disable EXIT-button for the whole update-process, except for the
|
||||
# checking of the ISMAS-trigger-button (aka WAIT-button).
|
||||
# 1.4.1 : Sync files in the customer repository (under ./etc) as the very
|
||||
# first step
|
||||
# 1.4.2 : Do not check if <repo_dir>/etc/psa_tariff and /etc/psa_tariff are
|
||||
# the same after an rsync. They might be noy after a change of the
|
||||
# customer-number.
|
||||
# 1.4.3 : Use global directory for device-controller interfaces.h-file.
|
||||
# 1.4.4 : Add additional debug messages when downloading json-files.
|
||||
# Move rsyncing of the customer-repository after the actual fetching
|
||||
# of the repository. Otherwise, the update of, for instance
|
||||
# tariff-files, would always be a step behind.
|
||||
# 1.4.5 : In case a new branch has been created in a remote
|
||||
# customer-repository (e.g. origin/zg1/zone101), then fetch/pull
|
||||
# this branch before switching to this now locally existen branch.
|
||||
# : Improve output of GUI/Console and messages sent to ISMAS.
|
||||
# : Fix: do not send the json-files to dc in any case. Bug introduced
|
||||
# when pulling new branch, but branch already existed locally.
|
||||
# 1.4.6 : No exit()-call if loading CA-plugin fails.
|
||||
# Check m_hw (pointer to CA-(Slave)Plugin) before its use.
|
||||
# Only exit() if firmware is configured to be possibly updated, but
|
||||
# loading the CA-plugin failed.
|
||||
VERSION="1.4.7"
|
||||
# PLANNED TODOS:
|
||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||
# geklont), aber zusaetzlich werden alle verfuegbaren Dateien als neu
|
||||
# angesehen und die entsprechenden Aktionen durchgefuehrt: tariff-files
|
||||
# spiegeln, json-files laden und dc laden. Also VORSICHT: das repository
|
||||
# muss in diesem fall wirklich in ordnung sein.
|
||||
# 3: Wurde keine Datei geaendert, kein initiales Clone und der WAIT-button
|
||||
# nicht aktiv, so (passiert natuerlich nichts) kann man davon ausgehen,
|
||||
# dass es sich um ein automatisches Update handelt. Dann koennte man im
|
||||
# ISMAS eine entsprechende Meldung anzeigen als Teil von SEND-LAST-VERSION.
|
||||
# Wenn der WAIT-button aktiv ist, dann werden zumindest die opkg-commands
|
||||
# ausgefuehrt.
|
||||
# 5: Falls das Tool mal abstuerzt, dann einen Signal-Handler (fuer TERM)
|
||||
# installieren, sodass zumnidest SEND-LAST-VERSION mit rausgeht.
|
||||
# 6: rsync: explizites Binary, nicht das in busybox enthaltene.
|
||||
# 7: Versionen der Json-Files lassen sich auslesen.
|
||||
# Problem: Einstellungen in den Json-Files lassen sich auch mittels
|
||||
# Funktionen in der CD-Library ueberschreiben. Damit ist dann wieder nicht
|
||||
# mehr so klar, was jetzt eigentlich aktiv ist.
|
||||
# 8: m_alwaysDownloadConfig und m_alwaysDownloadDC: vorbereitet: man koennte
|
||||
# es so arrangieren, dass der DC plus die Json-files im Repository immer
|
||||
# runtergeladen werden, obwohl sich im Repository gar nicts veraendert
|
||||
# hat. Eeventuell nuetzlich beim initialen Setuo eines PSA.
|
||||
# 9: Das Kunden-Repository sollte immer gezogen werden, unabhaengig von der
|
||||
# Stellung des WAIT-Button. Grund: es koennte sein, dass andernfalls ein
|
||||
# PSA weit hiter anderen steht, und dann ploetzlich einmal alle vorher-
|
||||
# gehenden Aenderungen anzieht, die gar nicht fuer ihn gemeint waren.
|
||||
# 11: Das Edit-Fenster teilen um die Anzeige zu verbessern.
|
||||
# 12: Bei einem Update muss immer ersichtlich sein, warum es ueberhaupt
|
||||
# angestossen wurde. Steht kein "WAIT" im ISMAS-Trigger, dann kann man
|
||||
# davon ausgehen, dass es sich um ein automatisches Update handelt.
|
||||
# In jedem Fall wird bei einem automatischen Update, bei dem der WAIT-
|
||||
# Button nicht gesetzt war, ein "OK" gesendet, falls sonst nichts weiter
|
||||
# zu tun ist. Beachte aber: wir haben auch noch den Fall, dass eine SD-
|
||||
# Karte gesteckt wird. In diesem Fall wird ein komplettes Update gefahren,
|
||||
# und zwar explizit auch ohne WAIT-Button.
|
||||
# Am Ende eines Updates steht im ISMAS entweder ein "OK" oder ein "FAIL".
|
||||
# 13: SendLastVersion: fuer jedes erfolgreich installierte Paket eine
|
||||
# Send-Last-Version-Nachricht an ISMAS. Dadurch entsteht im ISMAS eine
|
||||
# History (Christian darueber informieren).
|
||||
# 14: Installiert werden nur Dateien, die neu sind oder geaendert wurden.
|
||||
# Nicht etwas Dateien, die geloescht wurden: sicherstellen, dass man hier
|
||||
# immer direkt im repository arbeitet, nicht auf dem Filesystem.
|
||||
# Ferner: der DeviceController heisst dc2c.bin, auch fuer die Jsons
|
||||
# sind Dtandard-Namen vergeben. Alternativ: alle vorhandenen Jsons
|
||||
# werden runtergeladen: Thomas ist eh fuer deren Inhalte verantworlich.
|
||||
# WICHTIG: immer ueberpruefen, ob die Dateien im Customer-Repository
|
||||
# wirklich die richtigen Dateien sind.
|
||||
# 15: Der WAIT-Button laesst sich auf WAIT zuruecksetzen (etwa wenn git
|
||||
# selber Probleme hatte).
|
||||
# 16: Der Download-Thread sollte sowohl die auto-Variable auf false setzen
|
||||
# als auch den cycle-Timer stoppen, damit sichergestellt ist, dass der
|
||||
# Download des DC nicht gestoert wird.
|
||||
|
||||
|
||||
win32 {
|
||||
BUILD_DATE=$$system("date /t")
|
||||
BUILD_TIME=$$system("time /t")
|
||||
} else {
|
||||
BUILD_DATE=$$system("date +%d-%m-%y")
|
||||
BUILD_TIME=$$system("date +%H:%M:%S")
|
||||
}
|
||||
|
||||
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
|
||||
|
||||
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
|
||||
|
||||
INCLUDEPATH += plugins
|
||||
|
||||
CONFIG += c++17
|
||||
# CONFIG -= app_bundle
|
||||
|
||||
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
|
||||
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
|
||||
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
|
||||
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
# keep comments, as /* fall through */
|
||||
QMAKE_CXXFLAGS += -C
|
||||
QMAKE_CXXFLAGS += -g
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
CONFIG += link_pkgconfig
|
||||
lessThan(QT_MAJOR_VERSION, 5): PKGCONFIG += qextserialport
|
||||
QMAKE_CXXFLAGS += -O2 -std=c++17 # for GCC >= 4.7
|
||||
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
|
||||
INCLUDEPATH += $$PTU5BASEPATH/qt/libs/devicecontroller/include
|
||||
LIBS += -L$$PTU5BASEPATH/qt/libs/devicecontroller/library
|
||||
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
|
||||
LIBS += -lCAslave
|
||||
LIBS += -lCAmaster
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
lessThan(QT_MAJOR_VERSION, 5): CONFIG += extserialport
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++17
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
ARCH = DesktopLinux
|
||||
DEFINES+=DesktopLinux
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
progress_event.cpp \
|
||||
update_dc_event.cpp \
|
||||
mainwindow.cpp \
|
||||
utils.cpp \
|
||||
update.cpp \
|
||||
git/git_client.cpp \
|
||||
ismas/ismas_client.cpp \
|
||||
process/command.cpp \
|
||||
message_handler.cpp \
|
||||
worker.cpp \
|
||||
commandline_parser.cpp
|
||||
|
||||
HEADERS += \
|
||||
update.h \
|
||||
progress_event.h \
|
||||
update_dc_event.h \
|
||||
utils.h \
|
||||
mainwindow.h \
|
||||
git/git_client.h \
|
||||
apism/ismas_data.h \
|
||||
ismas/ismas_client.h \
|
||||
process/command.h \
|
||||
message_handler.h \
|
||||
worker.h \
|
||||
commandline_parser.h
|
||||
|
||||
OTHER_FILES += \
|
||||
ATBUpdateTool.ini
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
|
||||
##########################################################################################
|
||||
# for running program on target through QtCreator
|
||||
contains( CONFIG, PTU5 ) {
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/app/tools/atbupdate/
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
}
|
||||
@@ -128,12 +128,20 @@ void CommandLineParser::readSettings() {
|
||||
QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption);
|
||||
QString const iniFileName = m_parser.value(m_iniFileNameOption);
|
||||
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||
qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||
|
||||
if (!m_iniFileName.isEmpty()) {
|
||||
if (QFile(m_iniFileName).exists()) {
|
||||
QSettings settings(m_iniFileName, QSettings::IniFormat);
|
||||
QStringList keys = settings.allKeys();
|
||||
for (QString const &key: keys) {
|
||||
QVariant v = settings.value(key);
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> " << v.toString();
|
||||
|
||||
if (key.contains("repository-url")) {
|
||||
m_repositoryUrl = v.toString();
|
||||
} else
|
||||
@@ -166,8 +174,14 @@ void CommandLineParser::readSettings() {
|
||||
} else
|
||||
if (key.contains("plugin-name")) {
|
||||
m_plugInName = v.toString();
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> (UNKNOWN) " << v.toString();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName
|
||||
<< "DOES NOT EXIST";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,7 +252,9 @@ bool CommandLineParser::extendedVersion() {
|
||||
bool CommandLineParser::alwaysDownloadConfig() {
|
||||
if (m_parser.isSet(m_alwaysDownloadConfigOption)) {
|
||||
m_alwaysDownloadConfig = m_parser.value(m_alwaysDownloadConfigOption);
|
||||
qCritical() << "m_alwaysDownloadConfigOption IS SET" << m_alwaysDownloadConfig;
|
||||
}
|
||||
qCritical() << "m_alwaysDownloadConfig" << m_alwaysDownloadConfig;
|
||||
return m_alwaysDownloadConfig == "false" ? false : true;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -6,6 +6,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
GitClient::GitClient(QString const &customerNrStr,
|
||||
@@ -192,7 +193,7 @@ QStringList GitClient::gitShowReason(QString branchName) {
|
||||
int const m = s.indexOf("m=");
|
||||
int const d = s.indexOf("d=");
|
||||
|
||||
QString msg = IsmasClient::getReasonForLastSendVersion();
|
||||
QString msg{""}; // IsmasClient::getReasonForLastSendVersion();
|
||||
QString commit{""}, date{""};
|
||||
|
||||
if (c != -1) {
|
||||
@@ -204,9 +205,9 @@ QStringList GitClient::gitShowReason(QString branchName) {
|
||||
start = m + 2;
|
||||
if (d >= start) {
|
||||
length = d - start;
|
||||
msg += " (";
|
||||
// msg = " (";
|
||||
msg = s.mid(start, length).trimmed();
|
||||
msg += ")";
|
||||
// msg += ")";
|
||||
|
||||
start = d + 2;
|
||||
date = s.mid(start);
|
||||
@@ -290,6 +291,100 @@ bool GitClient::gitFsck() {
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
bool GitClient::branchExistsRemotely() {
|
||||
bool remoteBranchExists = false;
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
qInfo() << "BRANCH NAME" << m_branchName;
|
||||
QString const cmd = QString("git ls-remote --exit-code --heads origin %1").arg(m_branchName);
|
||||
Command c(cmd);
|
||||
if (c.execute(m_customerRepository)) {
|
||||
// expected result: c16c833c8778c1b3691a74afee5a469177e4e69b refs/heads/zg1/zone1000
|
||||
QString const s = c.getCommandResult().trimmed();
|
||||
|
||||
|
||||
if (!s.isEmpty()) {
|
||||
// the result is only one line
|
||||
if ((remoteBranchExists = s.contains(m_branchName)) == true) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") branch"
|
||||
<< m_branchName << "EXISTS REMOTELY. (" << s << ")";
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(QString("EMPTY RESULT FOR CMD %1").arg(cmd));
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(QString("FAILED TO EXEC '%1'").arg(cmd));
|
||||
}
|
||||
}
|
||||
return remoteBranchExists;
|
||||
}
|
||||
|
||||
bool GitClient::branchExistsLocally() {
|
||||
Command c("git branch -l");
|
||||
if (c.execute(m_customerRepository)) {
|
||||
QString const s = c.getCommandResult().trimmed();
|
||||
if (!s.isEmpty()) {
|
||||
QStringList lines = Update::split(s, '\n');
|
||||
if (!lines.empty()) {
|
||||
for (int i=0; i < lines.size(); ++i) {
|
||||
QString line = lines.at(i);
|
||||
// expected: * [new branch] zg1/zone12 -> origin/zg1/zone12"
|
||||
if (line.contains(m_branchName)) {
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("BRANCH-NAME %1 CONTAINED IN RESULT %2").arg(m_branchName).arg(s));
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("BRANCH-NAME %1 NOT CONTAINED IN RESULT %2").arg(m_branchName).arg(s));
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("'git branch -l' RETURNED NO LINES"));
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("'git branch -l' RETURNED EMPTY RESULT"));
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_worker) {
|
||||
QStringList lst(QString("FAILED TO EXEC 'git branch -l'"));
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitClient::gitPullNewBranches() {
|
||||
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
Command c("git pull");
|
||||
if (c.execute(m_customerRepository)) {
|
||||
QString const s = c.getCommandResult().trimmed();
|
||||
// expected: Already up-to-date.
|
||||
if (!s.isEmpty()) {
|
||||
QStringList lst;
|
||||
QString msg(QString("GIT-PULL-NEW-BRANCH. RESULT=%1").arg(s));
|
||||
if (m_worker) {
|
||||
m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::PULL_NEW_BRANCH;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Hat sich nichts geaendert, so werden auch keine Commits <>..<> angezeigt
|
||||
*/
|
||||
@@ -316,6 +411,31 @@ std::optional<QString> GitClient::gitPull() {
|
||||
// 6ed893f..5d9882c zg1/zone2 -> origin/zg1/zone2
|
||||
// 4384d17..77045d8 zg1/zone3 -> origin/zg1/zone3
|
||||
// 89d2812..36a0d74 zg1/zone5 -> origin/zg1/zone5
|
||||
//
|
||||
// More exactly:
|
||||
// remote: Counting objects: 382, done.
|
||||
// remote: Compressing objects: 100% (203/203), done.
|
||||
// remote: Total 278 (delta 177), reused 103 (delta 59)
|
||||
// Receiving objects: 100% (278/278), 4.89 MiB | 539 KiB/s, done.
|
||||
// Resolving deltas: 100% (177/177), completed with 40 local objects.
|
||||
// From ssh://longair@pacific.mpi-cbg.de/srv/git/fiji
|
||||
// 3036acc..9eb5e40 debian-release-20081030 -> origin/debian-release-20081030
|
||||
// * [new branch] debian-release-20081112 -> origin/debian-release-20081112
|
||||
// * [new branch] debian-release-20081112.1 -> origin/debian-release-20081112.1
|
||||
// 3d619e7..6260626 master -> origin/master
|
||||
//
|
||||
// The most important bits here are the lines like these:
|
||||
//
|
||||
// 3036acc..9eb5e40 debian-release-20081030 -> origin/debian-release-20081030
|
||||
// * [new branch] debian-release-20081112 -> origin/debian-release-20081112
|
||||
//
|
||||
// The first line of these two shows that your remote-tracking branch
|
||||
// origin/debian-release-20081030 has been advanced from the commit 3036acc to 9eb5e40.
|
||||
// The bit before the arrow is the name of the branch in the remote repository.
|
||||
// The second line similarly show that since we last did this, a new remote tracking
|
||||
// branch has been created. (git fetch may also fetch new tags if they have appeared
|
||||
// in the remote repository.)
|
||||
|
||||
bool found = false;
|
||||
for (int i=0; i < lines.size(); ++i) {
|
||||
if (lines.at(i).contains(m_branchName)) {
|
||||
@@ -57,6 +57,10 @@ class GitClient : public QObject {
|
||||
static QString gitBlob(QString fileName);
|
||||
QString gitCommitForBlob(QString blob);
|
||||
bool gitIsFileTracked(QString file2name);
|
||||
|
||||
bool branchExistsRemotely();
|
||||
bool branchExistsLocally();
|
||||
bool gitPullNewBranches();
|
||||
};
|
||||
|
||||
#endif // GIT_CLIENT_H_INCLUDED
|
||||
@@ -384,7 +384,7 @@ QString IsmasClient::errorBackendNotConnected(QString const &info,
|
||||
QString const &version) {
|
||||
return updateNewsToIsmas("U0003",
|
||||
m_progressInPercent,
|
||||
RESULT_CODE::INSTALL_ERROR,
|
||||
RESULT_CODE::ISMAS_NO_CONNECTION_ERROR,
|
||||
"CHECK BACKEND CONNECTIVITY",
|
||||
info.toStdString().c_str(),
|
||||
version.toStdString().c_str());
|
||||
@@ -394,7 +394,7 @@ QString IsmasClient::errorGitClone(QString const &info,
|
||||
QString const &version) {
|
||||
return updateNewsToIsmas("U0003",
|
||||
m_progressInPercent,
|
||||
RESULT_CODE::INSTALL_ERROR,
|
||||
RESULT_CODE::GIT_CLONE_ERROR,
|
||||
"CLONE CUSTOMER REPOSITORY FAILED",
|
||||
info.toStdString().c_str(),
|
||||
version.toStdString().c_str());
|
||||
@@ -442,7 +442,7 @@ QString IsmasClient::updateTriggerSet(QString const &info, QString const &versio
|
||||
QString IsmasClient::errorUpdateTrigger(QString const &info, QString const &version) {
|
||||
return updateNewsToIsmas("U0003",
|
||||
m_progressInPercent,
|
||||
RESULT_CODE::INSTALL_ERROR,
|
||||
RESULT_CODE::ISMAS_TRIGGER_ERROR,
|
||||
"CHECK UPDATE TRIGGER",
|
||||
info.toStdString().c_str(),
|
||||
version.toStdString().c_str());
|
||||
@@ -145,13 +145,47 @@ public:
|
||||
DIRECT_PORT = 7778
|
||||
};
|
||||
|
||||
|
||||
enum RESULT_CODE {
|
||||
SUCCESS=0,
|
||||
// if between 00:00 - 04:00 Wait-button state not WAIT, then we assume
|
||||
// that's an automatic nightly (not-necessary) update
|
||||
NO_UPDATE_NECESSARY=1,
|
||||
BACKUP_FAILED=2,
|
||||
WRONG_PACKAGE=3,
|
||||
INSTALL_ERROR=4};
|
||||
// if APISM reports the ISMAS is not available (15x, 6s delay each)
|
||||
ISMAS_NO_CONNECTION_ERROR=2,
|
||||
// if not within 00:00-04:00 and WAIT-button was not in state WAIT
|
||||
ISMAS_TRIGGER_ERROR=3,
|
||||
// cloning git repo. not possible
|
||||
GIT_CLONE_ERROR=4,
|
||||
// pulling from remote git server not possible
|
||||
GIT_PULL_ERROR=5,
|
||||
// fetching from remote git server not possible
|
||||
GIT_FETCH_ERROR=6,
|
||||
// merging fetched data not possible
|
||||
GIT_MERGE_ERROR=7,
|
||||
// check sanity of local customer-repository failed
|
||||
GIT_CHECK_REPOSITORY_ERROR=8,
|
||||
// switch/checkout of branch (i.e. zone) on error
|
||||
GIT_SWITCH_BRANCH_ERROR=9,
|
||||
// fetch/pull of new branch failed. the new branch was not available
|
||||
// when installing via SD-card followed by intial clone during the
|
||||
// update process.
|
||||
GIT_FETCH_NEW_BRANCH_ERROR=10,
|
||||
// error computing git-blob hash-value
|
||||
GIT_HASH_ERROR=11,
|
||||
// update for general json files failed.
|
||||
JSON_FILES_UPDATE_ERROR=12,
|
||||
// error downloading config-json-files to device controller
|
||||
JSON_FILES_DOWNLOAD_ERROR=13,
|
||||
// error downloading device-controller
|
||||
DC_DOWNLOAD_ERROR=14,
|
||||
// error rsyncing json/ini-files to local filesystem
|
||||
RSYN_ERROR=15,
|
||||
// HASH_VALUE_ERROR=14,
|
||||
// HW_COMPATIBILITY_ERROR=15,
|
||||
OPKG_COMMANDS_ERROR=16,
|
||||
// CLEANUP_ERROR=18,
|
||||
UPDATE_IN_ERROR_STATE=99
|
||||
};
|
||||
|
||||
enum REASON {
|
||||
TIME_TRIGGERED = 0,
|
||||
@@ -9,7 +9,7 @@
|
||||
#endif
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "plugins/interfaces.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
#include "commandline_parser.h"
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -130,7 +130,9 @@ int main(int argc, char *argv[]) {
|
||||
if (!QDir(plugInDir).exists()) {
|
||||
qCritical() << plugInDir
|
||||
<< "does not exists, but has to contain dc-library";
|
||||
exit(-1);
|
||||
if (noUpdatePsaHardware == false) {
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
// before loading the library, delete all possible shared memory segments
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "utils.h"
|
||||
#include "progress_event.h"
|
||||
#include "update_dc_event.h"
|
||||
#include "plugins/interfaces.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#include "message_handler.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <cstring>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageLogContext>
|
||||
|
||||
|
||||
static char const *DBG_NAME[] = { "DBG ", "WARN ", "CRIT ", "FATAL", "INFO " };
|
||||
static bool installedMsgHandler = false;
|
||||
static int debugLevel = LOG_NOTICE;
|
||||
|
||||
int getDebugLevel() { return debugLevel; }
|
||||
void setDebugLevel(int newDebugLevel) {
|
||||
debugLevel = newDebugLevel;
|
||||
}
|
||||
|
||||
bool messageHandlerInstalled() {
|
||||
return installedMsgHandler;
|
||||
}
|
||||
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler) {
|
||||
installedMsgHandler = (handler != 0);
|
||||
static QtMessageHandler prevHandler = nullptr;
|
||||
if (handler) {
|
||||
prevHandler = qInstallMessageHandler(handler);
|
||||
return prevHandler;
|
||||
} else {
|
||||
return qInstallMessageHandler(prevHandler);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Print message according to given debug level.
|
||||
///
|
||||
/// \note Install this function using qInstallMsgHandler().
|
||||
///
|
||||
/// int main(int argc, char **argv) {
|
||||
/// installMsgHandler(atbDebugOutput);
|
||||
/// QApplication app(argc, argv);
|
||||
/// ...
|
||||
/// return app.exec();
|
||||
/// }
|
||||
///
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||
Q_UNUSED(context);
|
||||
QString const localMsg = QString(DBG_NAME[type]) + msg.toLocal8Bit();
|
||||
|
||||
switch (debugLevel) {
|
||||
case LOG_DEBUG: { // debug-level message
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
} break;
|
||||
case LOG_INFO: { // informational message
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_NOTICE: { // normal, but significant, condition
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_WARNING: { // warning conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ERR: { // error conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_CRIT: { // critical conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ALERT: { // action must be taken immediately
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_EMERG: { // system is unusable
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
//fprintf(stderr, "%s No ErrorLevel defined! %s\n",
|
||||
// datetime.toStdString().c_str(), msg.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_HANDLER_H_INCLUDED
|
||||
#define MESSAGE_HANDLER_H_INCLUDED
|
||||
|
||||
#include <QtGlobal>
|
||||
#ifdef __linux__
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
int getDebugLevel();
|
||||
void setDebugLevel(int newDebugLevel);
|
||||
|
||||
bool messageHandlerInstalled();
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const char *);
|
||||
void atbDebugOutput(QtMsgType type, const char *msg);
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &);
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
#endif
|
||||
|
||||
#endif // MESSAGE_HANDLER_H_INCLUDED
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "command.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QDateTime>
|
||||
|
||||
Command::Command(QString const &command, int start_timeout, int finish_timeout)
|
||||
: m_command(command.trimmed())
|
||||
, m_commandResult("")
|
||||
, m_waitForStartTimeout(start_timeout)
|
||||
, m_waitForFinishTimeout(finish_timeout)
|
||||
, m_exitCode(-1) {
|
||||
}
|
||||
|
||||
QString Command::getCommandResult() const {
|
||||
return m_commandResult;
|
||||
}
|
||||
|
||||
void Command::readyReadStandardOutput() {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
m_commandResult += p->readAllStandardOutput();
|
||||
// qCritical() << m_commandResult;
|
||||
}
|
||||
|
||||
void Command::readyReadStandardError() {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
QByteArray buf = p->readAllStandardError();
|
||||
qCritical() << buf;
|
||||
}
|
||||
|
||||
void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
// read all remaining data sent to the process, just in case
|
||||
QString d = p->readAllStandardOutput();
|
||||
if (!d.isEmpty()) {
|
||||
m_commandResult += d;
|
||||
}
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardOutput()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||
}
|
||||
|
||||
bool Command::execute(QString workingDirectory, QStringList args) {
|
||||
|
||||
if (!QDir::setCurrent(workingDirectory)) {
|
||||
qCritical() << "SET WORKING_DIRECTORY" << workingDirectory
|
||||
<< "FAILED FOR" << m_command;
|
||||
return false;
|
||||
}
|
||||
|
||||
QScopedPointer<QProcess> p(new QProcess(this));
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
p->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||
|
||||
if (!args.isEmpty()) {
|
||||
qDebug() << "START COMMAND" << m_command << "WITH ARGS" << args
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command, args);
|
||||
} else {
|
||||
qDebug() << "START COMMAND" << m_command
|
||||
<< "IN" << p->workingDirectory();
|
||||
p->start(m_command);
|
||||
}
|
||||
|
||||
qint64 const start = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
|
||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||
qDebug() << "PROCESS" << m_command << "STARTED IN" << p->workingDirectory();
|
||||
if (p->state() == QProcess::ProcessState::Running) {
|
||||
qDebug() << "PROCESS" << m_command << "RUNNING IN" << p->workingDirectory();
|
||||
// wait forever for git/opkg-commands to finish
|
||||
int wait = m_waitForFinishTimeout;
|
||||
if (m_command.trimmed().startsWith("git", Qt::CaseInsensitive) ||
|
||||
m_command.trimmed().startsWith("opkg", Qt::CaseInsensitive)) {
|
||||
wait = -1;
|
||||
}
|
||||
bool const no_timeout = p->waitForFinished(wait);
|
||||
if (no_timeout) {
|
||||
qDebug() << "PROCESS" << m_command << "FINISHED IN" << p->workingDirectory();
|
||||
if (p->exitStatus() == QProcess::NormalExit) {
|
||||
if ((m_exitCode = p->exitCode()) == 0) {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qDebug() << "EXECUTED" << m_command
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
return true;
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "EXECUTED" << m_command
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "with code" << m_exitCode
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command << "CRASHED with code"
|
||||
<< p->exitCode()
|
||||
<< QString("(after %1ms)").arg(end-start)
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command
|
||||
<< "DID NOT FINISH WITH" << wait
|
||||
<< "MS IN" << p->workingDirectory()
|
||||
<< QString("(runtime %1ms)").arg(end-start);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "WRONG PROCESS STATE" << p->state()
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
} else {
|
||||
qint64 const end = QDateTime::currentDateTime().toMSecsSinceEpoch();
|
||||
qCritical() << "PROCESS" << m_command << "TIMEOUT AT START"
|
||||
<< QString("(runtime %1ms)").arg(end-start)
|
||||
<< "IN" << p->workingDirectory();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
#include "plugins/interfaces.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QScopedPointer>
|
||||
@@ -52,7 +52,6 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
||||
qCritical() << "in directory" << plugInDir.absolutePath();
|
||||
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
||||
qCritical() << pluginLoader.errorString();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
||||
@@ -60,25 +59,20 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
||||
|
||||
if (!pluginLoader.isLoaded()) {
|
||||
qCritical() << pluginLoader.errorString();
|
||||
exit(-2);
|
||||
}
|
||||
QObject *plugin = pluginLoader.instance();
|
||||
if (!plugin) {
|
||||
qCritical() << "cannot start instance";
|
||||
exit(-3);
|
||||
}
|
||||
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
||||
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
||||
exit(-4);
|
||||
}
|
||||
} else {
|
||||
qCritical() << pluginLibName << "does not exist";
|
||||
exit(-5);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
||||
<< "does not exist";
|
||||
exit(-6);
|
||||
}
|
||||
return hw;
|
||||
}
|
||||
@@ -98,6 +92,7 @@ bool Update::unloadDCPlugin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
class hwapi;
|
||||
Update::Update(Worker *worker,
|
||||
QString customerRepository,
|
||||
QString customerNrStr,
|
||||
@@ -122,60 +117,105 @@ Update::Update(Worker *worker,
|
||||
, m_dryRun(dryRun)
|
||||
, m_sys_areDCdataValid(false) {
|
||||
|
||||
//int tries = 20;
|
||||
//while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
// if (--tries < 0) {
|
||||
// qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
// break;
|
||||
// }
|
||||
// m_hw->dc_autoRequest(true);
|
||||
// QThread::msleep(500);
|
||||
//}
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin not loaded";
|
||||
} else {
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
break;
|
||||
}
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
//qCritical() << "UPDATE: m_sys_areDCDataValid ..." << m_sys_areDCdataValid;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
|
||||
//qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface;
|
||||
//qInfo() << "UPDATE: m_baudrate ..." << m_baudrate;
|
||||
//qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository;
|
||||
//qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr;
|
||||
//qInfo() << "UPDATE: m_branchName ..........." << m_branchName;
|
||||
//qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName;
|
||||
//qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir;
|
||||
#if 0
|
||||
QObject const *obj = m_hw->getAPI();
|
||||
Q_ASSERT(obj != nullptr);
|
||||
|
||||
QDebug critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadStatus() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)),
|
||||
this,
|
||||
SLOT(onReportDCDownloadStatus(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
|
||||
critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadSuccess() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
|
||||
SLOT(onReportDCDownloadSuccess(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
|
||||
critical = qCritical();
|
||||
critical << "connect() to onReportDCDownloadFailure() ...";
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
|
||||
SLOT(onReportDCDownloadFailure(QString const &)))) {
|
||||
critical << "FAILED";
|
||||
} else critical << "DONE";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Update::~Update() {
|
||||
}
|
||||
|
||||
void Update::onReportDCDownloadStatus(QString const &status) {
|
||||
emit m_worker->showStatusMessage("DL", status);
|
||||
}
|
||||
|
||||
void Update::onReportDCDownloadSuccess(QString const &msg) {
|
||||
qCritical() << "msg" << msg;
|
||||
}
|
||||
|
||||
void Update::onReportDCDownloadFailure(QString const &errorMsg) {
|
||||
qCritical() << "msg" << errorMsg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// br is a index into a table, used for historical reasons.
|
||||
bool Update::openSerial(int br, QString baudrate, QString comPort) const {
|
||||
qDebug() << "opening serial" << br << baudrate << comPort << "...";
|
||||
if (m_hw->dc_openSerial(br, baudrate, comPort, 1) == true) { // 1 for connect
|
||||
Utils::printInfoMsg(
|
||||
if (m_hw) {
|
||||
qDebug() << "opening serial" << br << baudrate << comPort << "...";
|
||||
if (m_hw->dc_openSerial(br, baudrate, comPort, 1) == true) { // 1 for connect
|
||||
Utils::printInfoMsg(
|
||||
QString("OPENING SERIAL %1").arg(br)
|
||||
+ " " + baudrate + " " + comPort + "...OK");
|
||||
|
||||
// m_hw->dc_autoRequest(true);
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1);
|
||||
|
||||
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
|
||||
return true;
|
||||
}
|
||||
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("OPENING SERIAL %1").arg(br)
|
||||
+ " " + baudrate + " " + comPort + "...OK");
|
||||
|
||||
// m_hw->dc_autoRequest(true);
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1);
|
||||
|
||||
Utils::printInfoMsg(QString("IS PORT OPEN %1").arg(m_hw->dc_isPortOpen()));
|
||||
return true;
|
||||
+ " " + baudrate + " " + comPort + "...FAILED");
|
||||
}
|
||||
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("OPENING SERIAL %1").arg(br)
|
||||
+ " " + baudrate + " " + comPort + "...FAILED");
|
||||
return false;
|
||||
}
|
||||
|
||||
void Update::closeSerial() const {
|
||||
qInfo() << "CLOSED SERIAL" << m_baudrate << m_serialInterface;
|
||||
m_hw->dc_closeSerial();
|
||||
if (m_hw) {
|
||||
m_hw->dc_closeSerial();
|
||||
}
|
||||
}
|
||||
|
||||
bool Update::isSerialOpen() const {
|
||||
return m_hw->dc_isPortOpen();
|
||||
return m_hw ? m_hw->dc_isPortOpen() : false;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -354,82 +394,121 @@ bool Update::downloadJson(enum FileTypeJson type,
|
||||
int templateIdx,
|
||||
QString jsFileToSendToDC) const {
|
||||
|
||||
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
|
||||
bool ready = false;
|
||||
int nTry = 25;
|
||||
while ((ready = m_hw->sys_ready4sending()) == false) {
|
||||
QThread::msleep(200);
|
||||
if (--nTry <= 0) {
|
||||
Utils::printCriticalErrorMsg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
if (ready) {
|
||||
QFile file(jsFileToSendToDC);
|
||||
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
|
||||
if (file.exists()) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
if (fi.size() <= 800) {
|
||||
QByteArray ba = file.readAll();
|
||||
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
|
||||
// nrOfTemplate=1...32 if kindOfFile==6
|
||||
// content = content of the Json file, max 800byte ascii signs
|
||||
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templateIdx,
|
||||
(uint8_t *)ba.data())) {
|
||||
if (m_hw) {
|
||||
m_hw->dc_autoRequest(true); // downloading Json needs the AutoEmission flag
|
||||
qDebug() << "SET AUTO-REQUEST=TRUE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
|
||||
/*
|
||||
* Note: the machine id is contained in DC2C_conf.json.
|
||||
* The idea was to use this to check if the download of
|
||||
* the json-file was correct. It did not work, as the
|
||||
* update of the PSA (to reflect a change in the
|
||||
* machine id) did not happen immediately.
|
||||
*
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
QStringList lst;
|
||||
bool ready = false;
|
||||
int nTry = 25;
|
||||
while ((ready = m_hw->sys_ready4sending()) == false) {
|
||||
QThread::msleep(200);
|
||||
if (--nTry <= 0) {
|
||||
QString msg("SYS NOT READY FOR SENDING AFTER 5 SECONDS");
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
|
||||
// testing
|
||||
m_hw->request_ReadbackMachineID();
|
||||
QThread::msleep(500);
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t data[64];
|
||||
memset(data, 0x00, sizeof(data));
|
||||
uint8_t length = 0;
|
||||
QString msg;
|
||||
lst.clear();
|
||||
if (ready) {
|
||||
QFile file(jsFileToSendToDC);
|
||||
QFileInfo fi(jsFileToSendToDC); // max. size of template file is 800 bytes
|
||||
if (file.exists()) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
if (fi.size() > 0 && fi.size() <= 800) {
|
||||
QByteArray ba = file.readAll();
|
||||
// kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer
|
||||
// nrOfTemplate=1...32 if kindOfFile==6
|
||||
// content = content of the Json file, max 800byte ascii signs
|
||||
if (m_hw->sys_sendJsonFileToDc((uint8_t)(type),
|
||||
templateIdx,
|
||||
(uint8_t *)ba.data())) {
|
||||
|
||||
m_hw->readback_machineIDdata(&length, data);
|
||||
/*
|
||||
* Note: the machine id is contained in DC2C_conf.json.
|
||||
* The idea was to use this to check if the download of
|
||||
* the json-file was correct. It did not work, as the
|
||||
* update of the PSA (to reflect a change in the
|
||||
* machine id) did not happen immediately.
|
||||
*
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
|
||||
QThread::msleep(500);
|
||||
// testing
|
||||
m_hw->request_ReadbackMachineID();
|
||||
QThread::msleep(500);
|
||||
|
||||
QByteArray ba((const char*)data, length);
|
||||
uint8_t data[64];
|
||||
memset(data, 0x00, sizeof(data));
|
||||
uint8_t length = 0;
|
||||
|
||||
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
|
||||
*/
|
||||
m_hw->readback_machineIDdata(&length, data);
|
||||
|
||||
ret = true;
|
||||
QThread::msleep(500);
|
||||
|
||||
QByteArray ba((const char*)data, length);
|
||||
|
||||
qCritical() << length << "MACHINE ID =" << ba.toHex(':');
|
||||
*/
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
|
||||
ret = true;
|
||||
} else {
|
||||
msg = QString("ERROR SEND JSON-FILE %1 TO DC").arg(file.fileName());
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg = QString("SIZE OF %1 TOO BIG (%2 BYTES)").arg(jsFileToSendToDC).arg(fi.size());
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("SIZE OF %1 TOO BIG (%2 BYTES)")
|
||||
.arg(jsFileToSendToDC).arg(fi.size()));
|
||||
msg = QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING";
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString("CAN NOT OPEN ") + jsFileToSendToDC + " FOR READING");
|
||||
}
|
||||
} else {
|
||||
Utils::printCriticalErrorMsg(
|
||||
QString(jsFileToSendToDC) + " DOES NOT EXIST");
|
||||
}
|
||||
}
|
||||
msg = QString(jsFileToSendToDC) + " DOES NOT EXIST";
|
||||
Utils::printCriticalErrorMsg(msg);
|
||||
lst << msg;
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
if (m_worker) {
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< Worker::UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
qDebug() << "SET AUTO-REQUEST=FALSE";
|
||||
QThread::sleep(1); // make sure the auto-request flag is acknowledged
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -485,24 +564,26 @@ void Update::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
}
|
||||
|
||||
QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::sleep(1); // make sure the timer-slots are active
|
||||
if (m_hw) {
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::sleep(1); // make sure the timer-slots are active
|
||||
|
||||
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
||||
// current SW/HW-versions
|
||||
m_hw->request_DC2_SWversion();
|
||||
m_hw->request_DC2_HWversion();
|
||||
QThread::sleep(1);
|
||||
}
|
||||
for (int i=0; i < 3; ++i) { // send explicit reuests to get
|
||||
// current SW/HW-versions
|
||||
m_hw->request_DC2_SWversion();
|
||||
m_hw->request_DC2_HWversion();
|
||||
QThread::sleep(1);
|
||||
}
|
||||
|
||||
QString const &hwVersion = m_hw->dc_getHWversion().toLower().trimmed();
|
||||
QString const &swVersion = m_hw->dc_getSWversion().toLower().trimmed();
|
||||
QString const &hwVersion = m_hw->dc_getHWversion().toLower().trimmed();
|
||||
QString const &swVersion = m_hw->dc_getSWversion().toLower().trimmed();
|
||||
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1); // make sure the timer-slots are inactive
|
||||
m_hw->dc_autoRequest(false);
|
||||
QThread::sleep(1); // make sure the timer-slots are inactive
|
||||
|
||||
if (!hwVersion.isEmpty() && !swVersion.isEmpty()) {
|
||||
return QStringList() << hwVersion << swVersion;
|
||||
if (!hwVersion.isEmpty() && !swVersion.isEmpty()) {
|
||||
return QStringList() << hwVersion << swVersion;
|
||||
}
|
||||
}
|
||||
|
||||
return QStringList() << "DC HW-version not available"
|
||||
@@ -590,25 +671,104 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
//if (m_sys_areDCdataValid == false) {
|
||||
// qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
// return false;
|
||||
//}
|
||||
|
||||
if (!m_hw) {
|
||||
Utils::printInfoMsg("CA-PLUGIN NOT LOADED");
|
||||
return false;
|
||||
}
|
||||
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
if (--tries < 0) {
|
||||
Utils::printCriticalErrorMsg("ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED");
|
||||
return false;
|
||||
}
|
||||
Utils::printCriticalErrorMsg("DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED");
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
bool res = false;
|
||||
bool dcDownloadPossible = true;
|
||||
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
m_worker->startProgressLoop();
|
||||
|
||||
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
if (fToWorkOn.endsWith("/dc2c.bin") && dcDownloadPossible) {
|
||||
#if 0
|
||||
// download for dc possible only once
|
||||
// download of device-controller should always be the last step
|
||||
dcDownloadPossible = false;
|
||||
|
||||
if (fToWorkOn.contains("dc2c.bin")) {
|
||||
if (!m_hw->dcDownloadRequest(fToWorkOn)) { // initiate download process
|
||||
qCritical() << "DOWNLOAD-REQUEST-ERROR FOR" << fToWorkOn;
|
||||
continue;
|
||||
}
|
||||
|
||||
QThread::sleep(2);
|
||||
|
||||
int tries = 5;
|
||||
while (!m_hw->dcDownloadRunning()) { // may take some time
|
||||
if (--tries < 0) {
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD NOT RUNNING";
|
||||
break;
|
||||
}
|
||||
QThread::sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD RUNNING";
|
||||
|
||||
QThread::sleep(2);
|
||||
|
||||
tries = 5;
|
||||
while (!m_hw->dcDownloadReportThreadStart()) { // may take some time
|
||||
if (--tries < 0) {
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD NOT STARTED";
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD STARTED";
|
||||
|
||||
QThread::sleep(2);
|
||||
|
||||
tries = 5;
|
||||
while (!m_hw->dcDownloadReportRunning()) { // may take some time
|
||||
if (--tries < 0) {
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT NOT RUNNING";
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT RUNNING";
|
||||
|
||||
tries = 1200;
|
||||
while (m_hw->dcDownloadReportRunning()) {
|
||||
QThread::msleep(1000);
|
||||
if (--tries < 0) {
|
||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||
<< "(" << __func__ << ":" << __LINE__
|
||||
<< ") DOWNLOAD REPORT STILL RUNNING AFTER 20mins";
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
bool updateBinaryRes = true;
|
||||
|
||||
// CONSOLE()
|
||||
|
||||
#if 0
|
||||
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||
QThread::sleep(1); // wait to be sure that there are no more
|
||||
// commands sent to dc-hardware
|
||||
@@ -637,65 +797,65 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
res = updateBinaryRes;
|
||||
|
||||
} else {
|
||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
Utils::printInfoMsg(
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res= updateConfig(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = true;
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
Utils::printInfoMsg(
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res= updateConfig(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
||||
++displayIndex;
|
||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||
Worker::UPDATE_STEP_DONE);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = false;
|
||||
}
|
||||
// m_worker->stopProgressLoop();
|
||||
// m_worker->setProgress(100);
|
||||
|
||||
if (res == false) {
|
||||
break;
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <QProcess>
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include "plugins/interfaces.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
@@ -94,6 +94,8 @@ private slots:
|
||||
void readyReadStandardOutput();
|
||||
void readyReadStandardError();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
||||
void onReportDCDownloadStatus(QString const &status);
|
||||
void onReportDCDownloadSuccess(QString const &msg);
|
||||
void onReportDCDownloadFailure(QString const &errorMsg);
|
||||
};
|
||||
#endif // UPDATE_H_INCLUDED
|
||||
@@ -30,6 +30,85 @@ int Utils::read1stLineOfFile(QString fileName) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString Utils::getLocation(QString fileName) {
|
||||
QString location("N/A");
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
QString const &line = in.readLine();
|
||||
if (line.indexOf("Project", Qt::CaseInsensitive) != -1) {
|
||||
int const c = line.indexOf(":");
|
||||
if (c != -1) {
|
||||
location = line.mid(c+1);
|
||||
if (!location.isEmpty()) {
|
||||
location = location.replace(QChar(','), QString(""));
|
||||
return location.replace(QChar('"'), QString("")).trimmed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
QString Utils::getTariffVersion(QString fileName) {
|
||||
QString version("N/A");
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
QString const &line = in.readLine();
|
||||
if (line.indexOf("Version", Qt::CaseInsensitive) != -1) {
|
||||
int const c = line.indexOf(":");
|
||||
if (c != -1) {
|
||||
version = line.mid(c+1);
|
||||
if (!version.isEmpty()) {
|
||||
version = version.replace(QChar(','), QString(""));
|
||||
return version.replace(QChar('"'), QString("")).trimmed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
QString Utils::getTariffInfo(QString fileName) {
|
||||
QString info("N/A");
|
||||
QFile f(fileName);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&f);
|
||||
in.setCodec("UTF-8");
|
||||
while(!in.atEnd()) {
|
||||
QString const &line = in.readLine();
|
||||
if (line.indexOf("Info", Qt::CaseInsensitive) != -1) {
|
||||
int const c = line.indexOf(":");
|
||||
if (c != -1) {
|
||||
info = line.mid(c+1);
|
||||
if (!info.isEmpty()) {
|
||||
info = info.replace(QChar(','), QString(""));
|
||||
return info.replace(QChar('"'), QString("")).trimmed();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
|
||||
}
|
||||
|
||||
QString Utils::zoneName(quint8 i) {
|
||||
static constexpr char const *zName[] = {
|
||||
"",
|
||||
@@ -201,21 +280,24 @@ bool Utils::sameFilesInDirs(QDir const &dir1, QDir const &dir2,
|
||||
fileNameLst2 << i2.next().fileName();
|
||||
}
|
||||
|
||||
QString dirPath1 = dir1.absolutePath();
|
||||
QString dirPath2 = dir2.absolutePath();
|
||||
|
||||
if (fileNameLst1.isEmpty()) {
|
||||
qCritical() << "DIR1" << dir1.dirName() << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
qCritical() << "DIR1" << dirPath1 << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
return false;
|
||||
}
|
||||
if (fileNameLst2.isEmpty()) {
|
||||
qCritical() << "DIR1" << dir2.dirName() << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
qCritical() << "DIR1" << dirPath2 << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
return false;
|
||||
}
|
||||
if (fileNameLst1 != fileNameLst2) {
|
||||
printCriticalErrorMsg(dir1.dirName() + " AND " + dir2.dirName()
|
||||
printCriticalErrorMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " DIFFER: [" + fileNameLst1.join(',') + "],["
|
||||
+ fileNameLst2.join(',') + "]");
|
||||
return false;
|
||||
} else {
|
||||
printInfoMsg(dir1.dirName() + " AND " + dir2.dirName()
|
||||
printInfoMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " ARE EQUAL: [" + fileNameLst1.join(',') + "]");
|
||||
}
|
||||
|
||||
@@ -231,21 +313,21 @@ bool Utils::sameFilesInDirs(QDir const &dir1, QDir const &dir2,
|
||||
}
|
||||
|
||||
if (gitBlobLst1.isEmpty()) {
|
||||
qCritical() << "DIR1" << dir1.dirName() << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
qCritical() << "DIR1" << dirPath1 << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
return false;
|
||||
}
|
||||
if (gitBlobLst2.isEmpty()) {
|
||||
qCritical() << "DIR1" << dir2.dirName() << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
qCritical() << "DIR1" << dirPath2 << " DOES NOT CONTAIN EXPECTED FILES";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gitBlobLst1 != gitBlobLst2) {
|
||||
printCriticalErrorMsg(dir1.dirName() + " AND " + dir2.dirName()
|
||||
printCriticalErrorMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " DIFFER: [" + gitBlobLst1.join(',') + "],["
|
||||
+ gitBlobLst2.join(',') + "]");
|
||||
return false;
|
||||
} else {
|
||||
printInfoMsg(dir1.dirName() + " AND " + dir2.dirName()
|
||||
printInfoMsg(dirPath1 + " AND " + dirPath2
|
||||
+ " CONTAIN SAME GIT-BLOBS FOR FILES: [" + fileNameLst1.join(',') + "]");
|
||||
|
||||
}
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
namespace Utils {
|
||||
int read1stLineOfFile(QString fileName);
|
||||
QString getLocation(QString fileName);
|
||||
QString getTariffVersion(QString fileName);
|
||||
QString getTariffInfo(QString fileName);
|
||||
QString zoneName(quint8 i);
|
||||
void printCriticalErrorMsg(QString const &errorMsg, bool upper=false, bool lower=false);
|
||||
void printCriticalErrorMsg(QStringList const &errorMsg);
|
||||
@@ -17,9 +17,10 @@
|
||||
#include <QJsonParseError>
|
||||
#include <Qt>
|
||||
#include <QScopedPointer>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "plugins/interfaces.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
#include "ismas/ismas_client.h"
|
||||
#include "progress_event.h"
|
||||
#include "mainwindow.h"
|
||||
@@ -56,6 +57,9 @@ const QMap<UPDATE_STEP, const char*> Worker::smap (
|
||||
INSERT_ELEMENT(UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER),
|
||||
INSERT_ELEMENT(UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER),
|
||||
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH),
|
||||
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH),
|
||||
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::CHECKOUT_BRANCH_FAILURE),
|
||||
@@ -96,12 +100,15 @@ const QMap<UPDATE_STEP, const char*> Worker::smap (
|
||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_SUCCESS),
|
||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_FINALIZE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_NOT_NECESSARY),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_ACTIVATED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::FINISHED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::DEBUG),
|
||||
INSERT_ELEMENT(UPDATE_STEP::ERROR)
|
||||
INSERT_ELEMENT(UPDATE_STEP::ERROR),
|
||||
INSERT_ELEMENT(UPDATE_STEP::NONE)
|
||||
#undef INSERT_ELEMENT
|
||||
});
|
||||
|
||||
@@ -140,6 +147,7 @@ Worker::Worker(int customerNr,
|
||||
, m_serialInterface(serialInterface)
|
||||
, m_baudrate(baudrate)
|
||||
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
||||
, m_versionInfo(QStringList())
|
||||
, m_osVersion(getOsVersion())
|
||||
, m_atbqtVersion(getATBQTVersion())
|
||||
, m_atbUpdateToolVersion(getATBUpdateToolVersion())
|
||||
@@ -161,6 +169,17 @@ Worker::Worker(int customerNr,
|
||||
|
||||
// TODO: turn object into singleton
|
||||
instance = this;
|
||||
m_lastFailedUpdateStep = UPDATE_STEP::NONE;
|
||||
|
||||
if (m_noUpdatePsaHardware == false) {
|
||||
m_update = new Update(this,
|
||||
QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr),
|
||||
m_customerNrStr,
|
||||
m_branchName,
|
||||
m_pluginDir,
|
||||
m_pluginName,
|
||||
m_workingDirectory);
|
||||
}
|
||||
|
||||
this->setObjectName("worker-object");
|
||||
QDir::setCurrent(m_workingDirectory);
|
||||
@@ -169,6 +188,10 @@ Worker::Worker(int customerNr,
|
||||
}
|
||||
|
||||
Worker::~Worker() {
|
||||
if (m_update != nullptr) {
|
||||
delete m_update;
|
||||
m_update = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::displayProgressInMainWindow(int progress) {
|
||||
@@ -254,15 +277,72 @@ void Worker::privateUpdate() {
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::STARTED));
|
||||
|
||||
QScopedPointer<UpdateProcessRunning> upr(new UpdateProcessRunning(this));
|
||||
QStringList lst;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHECK UPDATE TRIGGER
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// NOTE: make sure that nothing is sent to ISMAS during updateTriggerSet
|
||||
ISMAS() << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
|
||||
m_ismasTriggerActive = false;
|
||||
m_updateNotNecessary = false;
|
||||
|
||||
if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository
|
||||
m_ismasTriggerActive = updateTriggerSet();
|
||||
if (m_ismasTriggerActive == false) {
|
||||
QDateTime const ¤t = QDateTime::currentDateTime();
|
||||
m_automaticUpdate = (current.time().hour() < 4);
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
|
||||
qCritical() << "***";
|
||||
qCritical() << "privateUpdate ............. m_versionInfo:" << m_versionInfo;
|
||||
qCritical() << "privateUpdate ......... m_automaticUpdate:" << m_automaticUpdate;
|
||||
|
||||
if (m_automaticUpdate) { // update has been triggered within [00:00:00, 00:03:59]
|
||||
m_updateNotNecessary = true;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate)));
|
||||
|
||||
qCritical() << "privateUpdate m_ismasTriggerStatusMessage:"
|
||||
<< QStringList(m_ismasTriggerStatusMessage);
|
||||
qCritical() << "***";
|
||||
|
||||
// the customer-repository does exist, and the ISMAS-trigger is
|
||||
// *NOT* "WAIT", but from 00:00:00 - 00:03:59 this counts as an
|
||||
// automatic update
|
||||
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
// trigger message to ISMAS and CONSOLE
|
||||
ISMAS(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
|
||||
// overwrite m_lastFailedUpdateStep
|
||||
m_lastFailedUpdateStep = UPDATE_STEP::NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
qCritical() << "***";
|
||||
|
||||
// the customer-repository does exist, but the ISMAS-trigger is
|
||||
// *NOT* "WAIT", so STOP the update procedure
|
||||
return;
|
||||
}
|
||||
// the customer-repository does exist, and the ISMAS-trigger is "WAIT",
|
||||
// so continue the update procedure
|
||||
} else {
|
||||
// the customer-repository does not exist, so PROCEED with the
|
||||
// update procedure, even if ISMAS-trigger is not correctly set ("WAIT")
|
||||
}
|
||||
|
||||
emit this->disableExit();
|
||||
|
||||
QDir customerRepository(m_customerRepository);
|
||||
QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/"));
|
||||
|
||||
CONSOLE() << UPDATE_STEP::CHECK_SANITY;
|
||||
CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY);
|
||||
|
||||
m_clone = false;
|
||||
m_repairClone = false;
|
||||
m_initialClone = false;
|
||||
m_pulledNewBranch = false;
|
||||
// the customer repository is cloned or
|
||||
// repaired/re-cloned without checking the
|
||||
// ISMAS-trigger (WAIT-)button.
|
||||
@@ -281,26 +361,27 @@ void Worker::privateUpdate() {
|
||||
|
||||
if (isRepositoryCorrupted()) { // a not-existing repository is not meant
|
||||
// to be corrupted
|
||||
CONSOLE() << UPDATE_STEP::CHECK_SANITY_FAILURE;
|
||||
CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY_FAILURE);
|
||||
if ((continueUpdate = repairCorruptedRepository()) == true) {
|
||||
m_repairClone = true;
|
||||
CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS;
|
||||
CONSOLE() << (ISMAS() << UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS);
|
||||
} else {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CONSOLE() << UPDATE_STEP::CHECK_SANITY_SUCCESS;
|
||||
CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY_SUCCESS);
|
||||
|
||||
if (continueUpdate) {
|
||||
if ((continueUpdate = customerRepository.exists()) == false) {
|
||||
m_initialClone = (m_repairClone == false);
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY);
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY));
|
||||
for (int i = 0; i < 5; ++i) { // try to checkout git repository
|
||||
setProgress(i); // and switch to branch
|
||||
if (m_gc.gitCloneAndCheckoutBranch()) {
|
||||
if (!isRepositoryCorrupted()) {
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY_SUCCESS));
|
||||
continueUpdate = true;
|
||||
m_clone = true;
|
||||
@@ -311,7 +392,7 @@ void Worker::privateUpdate() {
|
||||
}
|
||||
|
||||
if (continueUpdate == false) {
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY_FAILURE));
|
||||
GUI() << (ISMAS() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CLONE_REPOSITORY_FAILURE)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,23 +406,18 @@ void Worker::privateUpdate() {
|
||||
|
||||
CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY;
|
||||
if (isRepositoryCorrupted()) {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_FAILURE));
|
||||
ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_REPOSITORY_FAILURE)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
|
||||
CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_SUCCESS;
|
||||
setProgress(_CHECKOUT_REPOSITORY_SUCCESS);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHECK UPDATE TRIGGER
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
m_ismasTriggerActive = false;
|
||||
if (m_clone == false) {
|
||||
if ((continueUpdate = updateTriggerSet()) == false) {
|
||||
if (m_ismasTriggerActive == false) {
|
||||
return;
|
||||
} else {
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS));
|
||||
@@ -353,9 +429,6 @@ void Worker::privateUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "**** m_ismasTriggerActive:" << m_ismasTriggerActive;
|
||||
qCritical() << "**** m_clone:" << m_clone;
|
||||
|
||||
if (m_ismasTriggerActive == false) {// make it explicit again: only if the
|
||||
// ismas trigger is active ('WAIT'),
|
||||
// then proceed
|
||||
@@ -374,7 +447,9 @@ void Worker::privateUpdate() {
|
||||
if ((continueUpdate = customerEnvironment()) == false) {
|
||||
return;
|
||||
}
|
||||
CONSOLE() << UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS;
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS]));
|
||||
ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH);
|
||||
setProgress(_CHECKOUT_BRANCH_SUCCESS);
|
||||
|
||||
|
||||
@@ -386,9 +461,23 @@ void Worker::privateUpdate() {
|
||||
if ((continueUpdate = filesToUpdate()) == false) {
|
||||
return;
|
||||
}
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS));
|
||||
m_versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS]));
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY));
|
||||
setProgress(_UPDATE_REPOSITORY_SUCCESS);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (R)SYNC THE REPOSITORY WITH THE LOCAL FILEYSTEM
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = syncCustomerRepositoryAndFS()) == false) {
|
||||
return;
|
||||
}
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS]));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS));
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -398,7 +487,8 @@ void Worker::privateUpdate() {
|
||||
if ((continueUpdate = execOpkgCommands()) == false) {
|
||||
return;
|
||||
}
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS);
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS]));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::EXEC_OPKG_COMMANDS);
|
||||
setProgress(_EXEC_OPKG_COMMAND_SUCCESS);
|
||||
|
||||
|
||||
@@ -410,22 +500,10 @@ void Worker::privateUpdate() {
|
||||
if ((continueUpdate = downloadFilesToPSAHardware()) == false) {
|
||||
return;
|
||||
}
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS);
|
||||
lst = QStringList(QString(smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS]));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE));
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (R)SYNC THE REPOSITORY WITH THE LOCAL FILEYSTEM
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
if ((continueUpdate = syncCustomerRepositoryAndFS()) == false) {
|
||||
return;
|
||||
}
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS));
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FUTURE: SAVE LOG FILES
|
||||
@@ -437,28 +515,8 @@ void Worker::privateUpdate() {
|
||||
// ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS_SUCCESS));
|
||||
setProgress(_SAVE_LOGS_SUCCESS);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FINAL MESSAGES (PART 1)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_SUCCEEDED));
|
||||
setProgress(_UPDATE_SUCCEEDED);
|
||||
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_ACTIVATED));
|
||||
setProgress(_UPDATE_ACTIVATED);
|
||||
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::FINISHED));
|
||||
setProgress(_FINISHED);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FINAL MESSAGES (PART 2): SEND-LAST-VERSION
|
||||
// (destructor of struct UpdateProcessRunning)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// final messages: see destructor of UpdateProcessRunning subclass
|
||||
m_lastFailedUpdateStep = UPDATE_STEP::NONE;
|
||||
}
|
||||
|
||||
bool Worker::updateTriggerSet() {
|
||||
@@ -466,11 +524,15 @@ bool Worker::updateTriggerSet() {
|
||||
// (WAIT-button) is activated even in case of initial checkout
|
||||
static const QString func = "UPDATE-TRIGGER-SET";
|
||||
|
||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
||||
return true;
|
||||
}
|
||||
// if (m_withoutIsmasDirectPort) { // useful for testing
|
||||
// return true;
|
||||
//}
|
||||
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
|
||||
m_ismasTriggerStatusMessage.clear();
|
||||
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER);
|
||||
|
||||
bool const automaticUpdate = (QDateTime::currentDateTime().time().hour() < 4);
|
||||
|
||||
QString triggerValue("NOT CHECKED YET");
|
||||
static constexpr int const repeats = 15;
|
||||
@@ -480,10 +542,10 @@ bool Worker::updateTriggerSet() {
|
||||
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
||||
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
||||
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << s));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
} else {
|
||||
QStringList lst = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat));
|
||||
// GUI(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat)));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
}
|
||||
|
||||
@@ -492,7 +554,8 @@ bool Worker::updateTriggerSet() {
|
||||
Command c("systemctl restart apism");
|
||||
if (c.execute("/tmp")) {
|
||||
QThread::sleep(20); // give APISM some time to reconnect
|
||||
CONSOLE(QStringList(func) << "RESTART APISM DONE") << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << "RESTART APISM DONE"));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,31 +564,35 @@ bool Worker::updateTriggerSet() {
|
||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
||||
|
||||
QString const &msg = QString("APISM RESPONSE(%1)=(").arg(repeat) + result.value() + ")";
|
||||
CONSOLE(QStringList(func) << msg) << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << msg));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument document(QJsonDocument::fromJson(result.value().toUtf8(), &parseError));
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
QStringList lst(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||
.arg(msg)
|
||||
.arg(parseError.error)
|
||||
.arg(parseError.errorString())
|
||||
.arg(parseError.offset));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||
.arg(msg)
|
||||
.arg(parseError.error)
|
||||
.arg(parseError.errorString())
|
||||
.arg(parseError.offset));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
if (!document.isObject()) {
|
||||
QStringList lst(QString("not a json-object %1").arg(result.value()));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("not a json-object %1").arg(result.value()));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject obj = document.object();
|
||||
|
||||
// always look for an 'error' first
|
||||
if (obj.contains("error")) {
|
||||
QStringList lst(obj.value("error").toString());
|
||||
CONSOLE(QStringList(lst)) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE;
|
||||
m_ismasTriggerStatusMessage = QStringList(obj.value("error").toString());
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
CONSOLE(QStringList(lst)) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
}
|
||||
@@ -540,31 +607,35 @@ bool Worker::updateTriggerSet() {
|
||||
int const customerNr = obj.value("Custom_ID").toInt(-1);
|
||||
int const machineNr = obj.value("Device_ID").toInt(-1);
|
||||
if (customerNr != m_customerNr) {
|
||||
QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
.arg(customerNr).arg(m_customerNr));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
.arg(customerNr).arg(m_customerNr));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
if (machineNr != m_machineNr) {
|
||||
QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
.arg(machineNr).arg(m_machineNr));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
.arg(machineNr).arg(m_machineNr));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
QStringList lst(QString("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID (LINE=%1)").arg(__LINE__));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID KEY NOT A JSON-OBJECT");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT A JSON-OBJECT (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID KEY NOT AVAILABLE");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT AVAILABLE (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.contains("Fileupload")) {
|
||||
@@ -573,56 +644,86 @@ bool Worker::updateTriggerSet() {
|
||||
obj = v.toObject();
|
||||
if (obj.contains("TRG")) {
|
||||
if ((triggerValue = obj.value("TRG").toString()) == "WAIT") {
|
||||
m_ismasTriggerStatusMessage = QStringList("ISMAS_UPDATE-TRIGGER SET TO WAIT");
|
||||
m_ismasTriggerActive = true;
|
||||
return m_ismasTriggerActive;
|
||||
} else
|
||||
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||
QStringList lst(QString("%1 empty update trigger (%2)").arg(repeat).arg(repeats-repeat));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("%1 EMPTY UPDATE TRIGGER (%2)").arg(repeat).arg(repeats-repeat));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
if (m_clone) {
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)));
|
||||
// if the customer repository has just been cloned
|
||||
break; // it is OK the ISMAS trigger might not be 'WAIT'
|
||||
} else {
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
return false; // it is OK the ISMAS trigger might not be 'WAIT'
|
||||
}
|
||||
// not a clone and empty update-trigger
|
||||
if (automaticUpdate) {
|
||||
// do not inform ISMAS in case of automatic update, because the
|
||||
// update is not necessary as the trigger-button is not set to WAIT.
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE));
|
||||
return false;
|
||||
}
|
||||
|
||||
CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
} else {
|
||||
// if the download-button once has the wrong value, it will never recover
|
||||
// if the download-button once has a wrong value, it will never recover
|
||||
if (m_clone) {
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE='%1' != 'WAIT'").arg(triggerValue));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
if (automaticUpdate) {
|
||||
// do not inform ISMAS in case of automatic update
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE));
|
||||
} else {
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)));
|
||||
}
|
||||
} else {
|
||||
QStringList lst(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE='%1' != 'WAIT'").arg(triggerValue));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
if (automaticUpdate) {
|
||||
// do not inform ISMAS in case of automatic update
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE));
|
||||
} else {
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("TRG key not available");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRG key not available (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Fileupload not a json-object");
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not a json-object (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst(QString("Fileupload not available"));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
break;
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not available (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst = QStringList(QString("no ISMAS response"));
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("no ISMAS response (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_initialClone == false) {
|
||||
if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) {
|
||||
QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,15 +737,43 @@ bool Worker::customerEnvironment() {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CHECKOUT_BRANCH));
|
||||
|
||||
if (QDir(m_customerRepository).exists()) {
|
||||
if (m_clone == false) {
|
||||
if (m_gc.branchExistsRemotely()) {
|
||||
QString msg;
|
||||
QStringList lst;
|
||||
if (!m_gc.branchExistsLocally()) {
|
||||
lst.clear();
|
||||
msg = QString("PULLING OF NEW BRANCH " + m_branchName + " DOES NOT EXIST LOCALLY");
|
||||
lst << msg;
|
||||
CONSOLE(lst) << UPDATE_STEP::PULL_NEW_BRANCH;
|
||||
if (!m_gc.gitPullNewBranches()) {
|
||||
lst.clear();
|
||||
msg = QString("PULLING OF NEW BRANCH " + m_branchName + " FAILED");
|
||||
lst << msg;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::PULL_NEW_BRANCH_FAILURE)));
|
||||
return false;
|
||||
} else {
|
||||
lst.clear();
|
||||
msg = QString("PULLING OF NEW BRANCH " + m_branchName + " SUCCESS");
|
||||
lst << msg;
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS)));
|
||||
m_pulledNewBranch = true;
|
||||
}
|
||||
} else {
|
||||
m_pulledNewBranch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_gc.gitCheckoutBranch()) {
|
||||
return true;
|
||||
} else {
|
||||
QStringList lst(QString("CHECKOUT OF " + m_customerRepository + "FAILED"));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECKOUT_BRANCH_FAILURE)));
|
||||
}
|
||||
} else {// cannot happen
|
||||
QStringList lst(QString(m_customerRepository + " DOES NOT EXIST"));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE));
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECKOUT_BRANCH_FAILURE)));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -659,7 +788,7 @@ bool Worker::filesToUpdate() {
|
||||
// always execute contents of opkg_commands-file
|
||||
m_filesToUpdate << "etc/psa_update/opkg_commands";
|
||||
|
||||
if (m_clone && m_alwaysDownloadConfig) {
|
||||
if ((m_clone || m_pulledNewBranch) && m_alwaysDownloadConfig) {
|
||||
// always download all json-config files, even if none of them have been
|
||||
// changed in the git repository. useful for first installation.
|
||||
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
|
||||
@@ -673,7 +802,7 @@ bool Worker::filesToUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
if (m_clone && m_alwaysDownloadDC) {
|
||||
if ((m_clone || m_pulledNewBranch) && m_alwaysDownloadConfig) {
|
||||
// always download the last dc-binary, even if not changed in the
|
||||
// git repository. useful for first installation.
|
||||
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/dc"));
|
||||
@@ -694,12 +823,12 @@ bool Worker::filesToUpdate() {
|
||||
}
|
||||
m_filesToUpdate.removeDuplicates();
|
||||
|
||||
qCritical() << __PRETTY_FUNCTION__ << "FILES-TO-UPDATE" << m_filesToUpdate;
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") FILES-TO-UPDATE" << m_filesToUpdate;
|
||||
|
||||
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE);
|
||||
setProgress(_FILES_TO_UPDATE);
|
||||
} else {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_FAILURE));
|
||||
ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::UPDATE_REPOSITORY_FAILURE)));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -807,7 +936,7 @@ bool Worker::execOpkgCommands() {
|
||||
}
|
||||
} else {
|
||||
m_displayIndex = 1;
|
||||
ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE));
|
||||
ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE)));
|
||||
GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE;
|
||||
setProgress(_EXEC_OPKG_COMMAND_FAILURE);
|
||||
return false;
|
||||
@@ -827,18 +956,11 @@ bool Worker::downloadFilesToPSAHardware() {
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE);
|
||||
|
||||
if (m_noUpdatePsaHardware == false) {
|
||||
if (computeFilesToDownload()) {
|
||||
CONSOLE(m_filesToDownload) << UPDATE_STEP::FILES_TO_DOWNLOAD;
|
||||
if (computeFilesToDownload() > 0) {
|
||||
QStringList lst = m_filesToDownload;
|
||||
ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::FILES_TO_DOWNLOAD);
|
||||
|
||||
Update update(this,
|
||||
QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr),
|
||||
m_customerNrStr,
|
||||
m_branchName,
|
||||
m_pluginDir,
|
||||
m_pluginName,
|
||||
m_workingDirectory);
|
||||
|
||||
if (update.doUpdate(m_displayIndex, m_filesToDownload)) {
|
||||
if (m_update && m_update->doUpdate(m_displayIndex, m_filesToDownload)) {
|
||||
// prepared for use: at the moment, the dc-library does not work
|
||||
// as expected.
|
||||
|
||||
@@ -847,10 +969,11 @@ bool Worker::downloadFilesToPSAHardware() {
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE;
|
||||
|
||||
CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -930,14 +1053,16 @@ bool Worker::syncCustomerRepositoryAndFS() {
|
||||
QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff"));
|
||||
QDir dir2("/etc/psa_tariff");
|
||||
if (Utils::sameFilesInDirs(dir1, dir2)) {
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS));
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
return true;
|
||||
CONSOLE() << QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff")
|
||||
<< "AND /etc/psa_tariff ARE DIFFERENT: CHANGED CUSTOMER-NUMBER?";
|
||||
}
|
||||
CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS;
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE));
|
||||
ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE)));
|
||||
setProgress(_SYNC_CUSTOMER_REPOSITORY_FAILURE);
|
||||
return false;
|
||||
}
|
||||
@@ -970,7 +1095,7 @@ QString Worker::getATBUpdateToolYoctoVersion() {
|
||||
|
||||
QString Worker::getAPISMYoctoVersion() {
|
||||
if (QFile::exists("/var/lib/opkg/status")) {
|
||||
QString const cmd = QString("echo -n $(cat /var/lib/opkg/status | grep -A1 apism | tail -n 1 | cut -d':' -f2 | cut -d' ' -f2)");
|
||||
QString const cmd = QString("echo -n $(cat /var/lib/opkg/status | grep -A1 -e apism[[:space:]]*$ | tail -n 1 | cut -d':' -f2 | cut -d' ' -f2)");
|
||||
Command c("bash");
|
||||
if (c.execute("/tmp", QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult(); // 1.4.1.0-r4
|
||||
@@ -1001,6 +1126,17 @@ QString Worker::getAPISMYoctoInstallationStatus() {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getDCVersionPreparedForDownload(QString const &filename) {
|
||||
if (QFile::exists(filename)) { // <customer-repo/etc/dc/dc2c.bin>
|
||||
QString const cmd = QString("strings %1 | grep -e DC2[Cc]\\. | head -n1").arg(filename);
|
||||
Command c("bash");
|
||||
if (c.execute("/tmp", QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult(); // DC2c.04.42 14.09.2023
|
||||
}
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
|
||||
QString Worker::getATBQTVersion() const {
|
||||
QString const cmd = QString("echo -n $(/opt/app/ATBAPP/ATBQT -v | head -n 2 | cut -d':' -f2)");
|
||||
@@ -1118,17 +1254,53 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
QString absPathName;
|
||||
QString absPathNameRepository;
|
||||
|
||||
psaInstalled.versionInfo.lastCommit = "";
|
||||
psaInstalled.versionInfo.reason = "";
|
||||
psaInstalled.versionInfo.created = "";
|
||||
psaInstalled.versionInfo.lastCommit = "N/A";
|
||||
psaInstalled.versionInfo.reason = "N/A";
|
||||
psaInstalled.versionInfo.created = "N/A";
|
||||
|
||||
QStringList versionInfo = m_gc.gitShowReason(m_branchName);
|
||||
if (versionInfo.size() == 3) {
|
||||
psaInstalled.versionInfo.lastCommit = versionInfo.at(0);
|
||||
psaInstalled.versionInfo.reason = versionInfo.at(1);
|
||||
psaInstalled.versionInfo.created = versionInfo.at(2);
|
||||
if (m_versionInfo.size() == 3) {
|
||||
QString const &lastCommit = m_versionInfo.at(0);
|
||||
QString reason = m_versionInfo.at(1);
|
||||
QDateTime const dt = QDateTime::fromString(m_versionInfo.at(2), Qt::ISODate);
|
||||
QString version{""};
|
||||
QString date{""};
|
||||
if (dt.isValid()) {
|
||||
date += " ";
|
||||
date += dt.date().toString(Qt::ISODate);
|
||||
}
|
||||
static const QRegularExpression re("^\\s*(\\d+)\\.(\\d+)\\.(\\d+)(.*$)");
|
||||
QRegularExpressionMatch match = re.match(reason);
|
||||
if (match.hasMatch()) {
|
||||
int const lastCapturedIndex = match.lastCapturedIndex();
|
||||
if (lastCapturedIndex >= 1) {
|
||||
version += " v";
|
||||
version += match.captured(1); // major
|
||||
}
|
||||
if (lastCapturedIndex >= 2) {
|
||||
version += ".";
|
||||
version += match.captured(2); // minor
|
||||
}
|
||||
if (lastCapturedIndex >= 3) {
|
||||
version += ".";
|
||||
version += match.captured(3); // patch
|
||||
}
|
||||
if (lastCapturedIndex >= 4) { // rest after version
|
||||
reason = match.captured(4);
|
||||
}
|
||||
}
|
||||
|
||||
psaInstalled.versionInfo.lastCommit = QString("%1%2").arg(lastCommit).arg(version);
|
||||
psaInstalled.versionInfo.reason = reason;
|
||||
psaInstalled.versionInfo.created = m_versionInfo.at(2);
|
||||
}
|
||||
|
||||
//qCritical() << "";
|
||||
//qCritical() << "VERSION-INFO";
|
||||
//qCritical() << "LAST-COMMIT" << psaInstalled.versionInfo.lastCommit;
|
||||
//qCritical() << "REASON" << psaInstalled.versionInfo.reason;
|
||||
//qCritical() << "CREATED" << psaInstalled.versionInfo.created;
|
||||
//qCritical() << "";
|
||||
|
||||
if (m_zoneNr != 0) {
|
||||
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
||||
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
||||
@@ -1139,10 +1311,10 @@ PSAInstalled Worker::getPSAInstalled() {
|
||||
psaInstalled.tariff.size = getFileSize(absPathName);
|
||||
psaInstalled.tariff.zone = m_zoneNr;
|
||||
psaInstalled.tariff.loadTime = Utils::getTariffLoadTime(absPathName);
|
||||
psaInstalled.tariff.project = Utils::getLocation(absPathName);
|
||||
psaInstalled.tariff.version = Utils::getTariffVersion(absPathName);
|
||||
psaInstalled.tariff.info = Utils::getTariffInfo(absPathName);
|
||||
}
|
||||
psaInstalled.tariff.project = "Szeged";
|
||||
psaInstalled.tariff.info = "N/A";
|
||||
psaInstalled.tariff.version = "N/A";
|
||||
|
||||
psaInstalled.hw.linuxVersion = getOsVersion();
|
||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
||||
@@ -26,84 +26,101 @@
|
||||
#define SERIAL_PORT "ttyUSB0"
|
||||
#endif
|
||||
|
||||
#define _ISMAS_DONE "U0001" // 100%
|
||||
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button ("")
|
||||
/*
|
||||
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_FAILURE "U0003" // FAIL
|
||||
#define _ISMAS_CONTINUE "U0010" // %-values
|
||||
#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
|
||||
|
||||
#define _STARTED (1)
|
||||
#define _CHECK_SANITY (2)
|
||||
#define _CHECK_SANITY_FAILURE (3)
|
||||
#define _CHECK_SANITY_SUCCESS (4)
|
||||
#define _REPOSITORY_RECOVERED_FAILURE (5)
|
||||
#define _REPOSITORY_RECOVERED_SUCCESS (6)
|
||||
#define _CHECK_REPOSITORY (7)
|
||||
#define _CHECK_REPOSITORY_FAILURE (8)
|
||||
#define _CHECK_REPOSITORY_SUCCESS (9)
|
||||
#define _CLONE_REPOSITORY (10)
|
||||
#define _CLONE_REPOSITORY_FAILURE (11)
|
||||
#define _CLONE_REPOSITORY_SUCCESS (12)
|
||||
#define _CHECKOUT_REPOSITORY (13)
|
||||
#define _CHECKOUT_REPOSITORY_FAILURE (14)
|
||||
#define _CHECKOUT_REPOSITORY_SUCCESS (15)
|
||||
#define _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER (16)
|
||||
#define _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER (17)
|
||||
#define _CHECK_ISMAS_TRIGGER (19)
|
||||
#define _CHECK_ISMAS_TRIGGER_WRONG_VALUE (20)
|
||||
#define _CHECK_ISMAS_TRIGGER_SUCCESS (21)
|
||||
#define _CHECK_ISMAS_TRIGGER_FAILURE (22)
|
||||
#define _CHECKOUT_BRANCH (23)
|
||||
#define _CHECKOUT_BRANCH_FAILURE (24)
|
||||
#define _CHECKOUT_BRANCH_SUCCESS (25)
|
||||
#define _UPDATE_REPOSITORY (26)
|
||||
#define _UPDATE_REPOSITORY_FAILURE (28)
|
||||
#define _UPDATE_REPOSITORY_SUCCESS (29)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES (30)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (36)
|
||||
#define _FILES_TO_UPDATE (37)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (38)
|
||||
#define _FILES_TO_DOWNLOAD (39)
|
||||
#define _EXEC_OPKG_COMMANDS (41)
|
||||
#define _EXEC_OPKG_COMMAND_1 (42)
|
||||
#define _EXEC_OPKG_COMMAND_2 (43)
|
||||
#define _EXEC_OPKG_COMMAND_3 (44)
|
||||
#define _EXEC_OPKG_COMMAND_4 (45)
|
||||
#define _EXEC_OPKG_COMMAND_5 (46)
|
||||
#define _EXEC_OPKG_COMMAND_6 (47)
|
||||
#define _EXEC_OPKG_COMMAND_7 (48)
|
||||
#define _EXEC_OPKG_COMMAND_8 (49)
|
||||
#define _EXEC_OPKG_COMMAND_9 (50)
|
||||
#define _EXEC_OPKG_COMMAND_LAST (51)
|
||||
#define _EXEC_OPKG_COMMAND_FAILURE (52)
|
||||
#define _EXEC_OPKG_COMMAND_SUCCESS (53)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (54)
|
||||
#define _DOWNLOAD_CONFIG_FILE (55)
|
||||
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (56)
|
||||
#define _DOWNLOAD_CONFIG_FILE_FAILURE (57)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER (65)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (87)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (88)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (89)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY (90)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (91)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (92)
|
||||
#define _SAVE_LOGS (93)
|
||||
#define _SAVE_LOGS_FAILURE (94)
|
||||
#define _SAVE_LOGS_SUCCESS (95)
|
||||
#define _SEND_LAST_VERSION (96)
|
||||
#define _UPDATE_SUCCEEDED (97)
|
||||
#define _UPDATE_FAILED (98)
|
||||
#define _UPDATE_ACTIVATED (99)
|
||||
#define _CHECK_ISMAS_TRIGGER (2)
|
||||
#define _CHECK_SANITY (3)
|
||||
#define _CHECK_SANITY_FAILURE (4)
|
||||
#define _CHECK_SANITY_SUCCESS (5)
|
||||
#define _REPOSITORY_RECOVERED_FAILURE (6)
|
||||
#define _REPOSITORY_RECOVERED_SUCCESS (7)
|
||||
#define _CHECK_REPOSITORY (8)
|
||||
#define _CHECK_REPOSITORY_FAILURE (9)
|
||||
#define _CHECK_REPOSITORY_SUCCESS (10)
|
||||
#define _CLONE_REPOSITORY (11)
|
||||
#define _CLONE_REPOSITORY_FAILURE (12)
|
||||
#define _CLONE_REPOSITORY_SUCCESS (13)
|
||||
#define _CHECKOUT_REPOSITORY (14)
|
||||
#define _CHECKOUT_REPOSITORY_FAILURE (15)
|
||||
#define _CHECKOUT_REPOSITORY_SUCCESS (16)
|
||||
#define _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER (17)
|
||||
#define _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER (18)
|
||||
#define _CHECK_ISMAS_TRIGGER_WRONG_VALUE (19)
|
||||
#define _CHECK_ISMAS_TRIGGER_SUCCESS (20)
|
||||
#define _CHECK_ISMAS_TRIGGER_FAILURE (21)
|
||||
#define _PULL_NEW_BRANCH (22)
|
||||
#define _PULL_NEW_BRANCH_FAILURE (23)
|
||||
#define _PULL_NEW_BRANCH_SUCCESS (24)
|
||||
#define _CHECKOUT_BRANCH (25)
|
||||
#define _CHECKOUT_BRANCH_FAILURE (26)
|
||||
#define _CHECKOUT_BRANCH_SUCCESS (27)
|
||||
#define _UPDATE_REPOSITORY (28)
|
||||
#define _UPDATE_REPOSITORY_FAILURE (29)
|
||||
#define _UPDATE_REPOSITORY_SUCCESS (30)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES (31)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (32)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY (33)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (34)
|
||||
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (35)
|
||||
#define _FILES_TO_UPDATE (36)
|
||||
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (37)
|
||||
#define _FILES_TO_DOWNLOAD (38)
|
||||
#define _EXEC_OPKG_COMMANDS (39)
|
||||
#define _EXEC_OPKG_COMMAND_1 (40)
|
||||
#define _EXEC_OPKG_COMMAND_2 (41)
|
||||
#define _EXEC_OPKG_COMMAND_3 (42)
|
||||
#define _EXEC_OPKG_COMMAND_4 (43)
|
||||
#define _EXEC_OPKG_COMMAND_5 (44)
|
||||
#define _EXEC_OPKG_COMMAND_6 (45)
|
||||
#define _EXEC_OPKG_COMMAND_7 (46)
|
||||
#define _EXEC_OPKG_COMMAND_8 (47)
|
||||
#define _EXEC_OPKG_COMMAND_9 (48)
|
||||
#define _EXEC_OPKG_COMMAND_LAST (49)
|
||||
#define _EXEC_OPKG_COMMAND_FAILURE (50)
|
||||
#define _EXEC_OPKG_COMMAND_SUCCESS (51)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (60)
|
||||
#define _DOWNLOAD_CONFIG_FILE (61)
|
||||
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (62)
|
||||
#define _DOWNLOAD_CONFIG_FILE_FAILURE (63)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER (64)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (85)
|
||||
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (86)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (87)
|
||||
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (88)
|
||||
#define _SAVE_LOGS (92)
|
||||
#define _SAVE_LOGS_FAILURE (93)
|
||||
#define _SAVE_LOGS_SUCCESS (94)
|
||||
#define _SEND_LAST_VERSION (95)
|
||||
#define _UPDATE_FINALIZE (95)
|
||||
#define _UPDATE_SUCCEEDED (96)
|
||||
#define _UPDATE_FAILED (97)
|
||||
#define _UPDATE_ACTIVATED (98)
|
||||
#define _UPDATE_NOT_NECESSARY (99)
|
||||
#define _FINISHED (100)
|
||||
#define _DEBUG (1000)
|
||||
#define _ERROR (1001)
|
||||
#define _NONE (1002)
|
||||
|
||||
#define _SEND_LAST_VERSION_CORRECTION (4)
|
||||
#define _UPDATE_SUCCEEDED_CORRECTION (3)
|
||||
#define _UPDATE_FAILED_CORRECTION (2)
|
||||
#define _UPDATE_ACTIVATED_CORRECTION (1)
|
||||
#define _SEND_LAST_VERSION_CORRECTION (5)
|
||||
#define _UPDATE_SUCCEEDED_CORRECTION (4)
|
||||
#define _UPDATE_FAILED_CORRECTION (3)
|
||||
#define _UPDATE_ACTIVATED_CORRECTION (2)
|
||||
#define _UPDATE_NOT_NECESSARY_CORRECTION (1)
|
||||
|
||||
#define ISMAS_UPDATE_REQUESTS (10)
|
||||
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
||||
@@ -132,6 +149,7 @@ class Worker : public QThread{
|
||||
QString const m_baudrate;
|
||||
IsmasClient m_ismasClient;
|
||||
GitClient m_gc;
|
||||
QStringList m_versionInfo;
|
||||
QString const m_osVersion;
|
||||
QString const m_atbqtVersion;
|
||||
QString const m_atbUpdateToolVersion;
|
||||
@@ -155,6 +173,10 @@ class Worker : public QThread{
|
||||
bool m_initialClone = false;
|
||||
bool m_repairClone = false;
|
||||
bool m_ismasTriggerActive = false;
|
||||
bool m_updateNotNecessary = false;
|
||||
bool m_automaticUpdate = false;
|
||||
bool m_pulledNewBranch = false;
|
||||
QStringList m_ismasTriggerStatusMessage;
|
||||
|
||||
MainWindow *m_mainWindow;
|
||||
bool m_withoutIsmasDirectPort;
|
||||
@@ -198,10 +220,50 @@ class Worker : public QThread{
|
||||
}
|
||||
|
||||
virtual ~UpdateProcessRunning() {
|
||||
m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE()
|
||||
<< UPDATE_STEP::SEND_LAST_VERSION));
|
||||
m_worker->stopProgressLoop();
|
||||
|
||||
if (m_worker->m_lastFailedUpdateStep == UPDATE_STEP::NONE) {
|
||||
if (m_worker->m_updateNotNecessary) {
|
||||
QStringList lst = m_worker->m_ismasTriggerStatusMessage;
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_NOT_NECESSARY));
|
||||
} else {
|
||||
QStringList lst(QString(m_worker->smap[UPDATE_STEP::UPDATE_SUCCEEDED]));
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << UPDATE_STEP::UPDATE_SUCCEEDED));
|
||||
m_worker->setProgress(_UPDATE_SUCCEEDED);
|
||||
|
||||
lst = QStringList(QString(m_worker->smap[UPDATE_STEP::UPDATE_ACTIVATED]));
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << UPDATE_STEP::UPDATE_ACTIVATED));
|
||||
m_worker->setProgress(_UPDATE_ACTIVATED);
|
||||
|
||||
lst = QStringList(QString(m_worker->smap[UPDATE_STEP::FINISHED]));
|
||||
m_worker->CONSOLE(lst) << UPDATE_STEP::FINISHED;
|
||||
m_worker->setProgress(_FINISHED);
|
||||
}
|
||||
} else {
|
||||
// QStringList lst = m_worker->m_ismasTriggerStatusMessage;
|
||||
QStringList lst;
|
||||
UPDATE_STEP last = m_worker->m_lastFailedUpdateStep;
|
||||
if (m_worker->smap.contains(last)) {
|
||||
lst << QString(" (last failed step: %1)").arg(m_worker->smap[last]);
|
||||
} else {
|
||||
lst << QString(" (last failed step unknown: %1)").arg((int)(last));
|
||||
}
|
||||
m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_FAILED));
|
||||
}
|
||||
|
||||
if (m_worker->m_automaticUpdate) {
|
||||
QStringList lst(QString(m_worker->smap[UPDATE_STEP::SEND_LAST_VERSION]));
|
||||
lst << "AUTOMATIC UPDATE";
|
||||
if (m_worker->m_updateNotNecessary) {
|
||||
lst << "UPDATE NOT NECESSARY";
|
||||
}
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< UPDATE_STEP::SEND_LAST_VERSION));
|
||||
} else {
|
||||
QStringList lst(QString(m_worker->smap[UPDATE_STEP::SEND_LAST_VERSION]));
|
||||
m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst)
|
||||
<< UPDATE_STEP::SEND_LAST_VERSION));
|
||||
}
|
||||
m_worker->stopProgressLoop();
|
||||
m_worker->m_updateProcessRunning = false;
|
||||
emit m_worker->enableExit();
|
||||
emit m_worker->restartExitTimer();
|
||||
@@ -233,6 +295,9 @@ public:
|
||||
CHECK_ISMAS_TRIGGER_FAILURE = _CHECK_ISMAS_TRIGGER_FAILURE,
|
||||
INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER,
|
||||
INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER,
|
||||
PULL_NEW_BRANCH = _PULL_NEW_BRANCH,
|
||||
PULL_NEW_BRANCH_FAILURE = _PULL_NEW_BRANCH_FAILURE,
|
||||
PULL_NEW_BRANCH_SUCCESS = _PULL_NEW_BRANCH_SUCCESS,
|
||||
CHECKOUT_BRANCH = _CHECKOUT_BRANCH,
|
||||
CHECKOUT_BRANCH_SUCCESS = _CHECKOUT_BRANCH_SUCCESS,
|
||||
CHECKOUT_BRANCH_FAILURE = _CHECKOUT_BRANCH_FAILURE,
|
||||
@@ -273,12 +338,15 @@ public:
|
||||
SAVE_LOGS_SUCCESS = _SAVE_LOGS_SUCCESS,
|
||||
SAVE_LOGS_FAILURE = _SAVE_LOGS_FAILURE,
|
||||
SEND_LAST_VERSION = _SEND_LAST_VERSION,
|
||||
UPDATE_FINALIZE = _UPDATE_FINALIZE,
|
||||
UPDATE_SUCCEEDED = _UPDATE_SUCCEEDED,
|
||||
UPDATE_ACTIVATED = _UPDATE_ACTIVATED,
|
||||
UPDATE_NOT_NECESSARY = _UPDATE_NOT_NECESSARY,
|
||||
UPDATE_FAILED = _UPDATE_FAILED,
|
||||
FINISHED = _FINISHED,
|
||||
DEBUG = _DEBUG,
|
||||
ERROR = _ERROR
|
||||
ERROR = _ERROR,
|
||||
NONE = _NONE
|
||||
};
|
||||
|
||||
private:
|
||||
@@ -289,6 +357,8 @@ private:
|
||||
static Worker *instance;
|
||||
QStringList m_opkgCommands;
|
||||
Update *m_update = nullptr;
|
||||
hwinf *m_hw = nullptr;
|
||||
UPDATE_STEP m_lastFailedUpdateStep = UPDATE_STEP::NONE;
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
@@ -317,6 +387,7 @@ public:
|
||||
static QString getATBUpdateToolYoctoInstallationStatus();
|
||||
static QString getAPISMYoctoVersion();
|
||||
static QString getAPISMYoctoInstallationStatus();
|
||||
static QString getDCVersionPreparedForDownload(QString const &filename);
|
||||
|
||||
static const QString UPDATE_STEP_OK;
|
||||
static const QString UPDATE_STEP_DONE;
|
||||
@@ -346,6 +417,8 @@ public:
|
||||
void displayProgressInMainWindow(int progress);
|
||||
void startProgressLoop();
|
||||
void stopProgressLoop();
|
||||
void setHW(hwinf *hw) { m_hw = hw; }
|
||||
hwinf *getHW() { return m_hw; }
|
||||
|
||||
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
||||
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
||||
@@ -405,6 +478,8 @@ private:
|
||||
QStringList lst = QStringList(smap[step]);
|
||||
|
||||
switch (step) {
|
||||
case UPDATE_STEP::NONE: {
|
||||
} break;
|
||||
case UPDATE_STEP::STARTED: {
|
||||
Utils::printUpdateStatusMsg(
|
||||
debug,
|
||||
@@ -496,6 +571,18 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
|
||||
break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH: {
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
} break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE: {
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
} break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS: {
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECKOUT_BRANCH:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
@@ -612,6 +699,10 @@ private:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_NOT_NECESSARY:
|
||||
lst << instance->m_debugMsg;
|
||||
Utils::printUpdateStatusMsg(debug, lst);
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_FAILED:
|
||||
break;
|
||||
case UPDATE_STEP::FINISHED:
|
||||
@@ -642,48 +733,111 @@ private:
|
||||
}
|
||||
|
||||
Worker::instance->m_currentStep = step;
|
||||
QStringList lst = QStringList(smap[step]);
|
||||
// QStringList lst = QStringList(smap[step]);
|
||||
|
||||
switch (step) {
|
||||
case UPDATE_STEP::NONE: {
|
||||
} break;
|
||||
case UPDATE_STEP::STARTED: {
|
||||
ismasClient.setProgressInPercent(_STARTED);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_REPOSITORY:
|
||||
ismasClient.setProgressInPercent(_CHECK_REPOSITORY);
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS:
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_REPOSITORY_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_SANITY:
|
||||
case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CHECK_REPOSITORY_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_CHECKOUT_REPOSITORY_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECK_REPOSITORY],
|
||||
QString("REPOSITORY %1 AND BRANCH %2 OK")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_REPOSITORY_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_CHECK_REPOSITORY_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_CHECKOUT_REPOSITORY_FAILURE,
|
||||
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
|
||||
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
|
||||
QString("REPOSITORY %1 and BRANCH %2 ***NOT OK***")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_SANITY: {
|
||||
ismasClient.setProgressInPercent(_CHECK_SANITY);
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_SANITY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CHECK_SANITY_SUCCESS);
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_SANITY_FAILURE:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_CHECK_SANITY_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECK_SANITY],
|
||||
QString("SANITY OF %1 (BRANCH %2) OK")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_SANITY_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_CHECK_SANITY_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS:
|
||||
break;
|
||||
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::CLONE_REPOSITORY:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_CHECK_SANITY_FAILURE,
|
||||
IsmasClient::RESULT_CODE::GIT_CHECK_REPOSITORY_ERROR,
|
||||
smap[UPDATE_STEP::CHECK_SANITY],
|
||||
QString("SANITY OF %1 and BRANCH %2 ***NOT*** OK")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_SUCCESS);
|
||||
} break;
|
||||
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_FAILURE);
|
||||
} break;
|
||||
case UPDATE_STEP::CLONE_REPOSITORY: {
|
||||
ismasClient.setProgressInPercent(_CLONE_REPOSITORY);
|
||||
break;
|
||||
} break;
|
||||
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CLONE_REPOSITORY_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0010",
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_CLONE_REPOSITORY_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::CLONE_REPOSITORY],
|
||||
QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
ismasUpdateNews);
|
||||
} break;
|
||||
@@ -692,67 +846,196 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0003",
|
||||
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
|
||||
_CLONE_REPOSITORY_FAILURE,
|
||||
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
smap[step],
|
||||
IsmasClient::RESULT_CODE::GIT_CLONE_ERROR,
|
||||
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
|
||||
QString("CLONING REPOSITORY %1 OR CHECKING OUT BRANCH %2 FAILED")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECKOUT_REPOSITORY:
|
||||
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY);
|
||||
break;
|
||||
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS:
|
||||
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_SUCCESS);
|
||||
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.cloneAndCheckoutCustomerRepository(
|
||||
QString("CHECKED OUT REPOSITORY %1 AND CHECKED OUT BRANCH %2")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName())));
|
||||
break;
|
||||
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE:
|
||||
.arg(instance->m_gc.branchName()),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"));
|
||||
} break;
|
||||
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_FAILURE);
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER);
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_SUCCESS);
|
||||
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateTriggerSet("ISMAS TRIGGER SET", ""));
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE:
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
|
||||
_CHECKOUT_REPOSITORY_FAILURE,
|
||||
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
|
||||
smap[UPDATE_STEP::CHECKOUT_REPOSITORY],
|
||||
QString("%1: CHECKING OUT BRANCH %2 FAILED")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER: {
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, //
|
||||
_CHECK_ISMAS_TRIGGER_SUCCESS,
|
||||
(instance->m_updateNotNecessary)
|
||||
? IsmasClient::RESULT_CODE::NO_UPDATE_NECESSARY
|
||||
: IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS],
|
||||
instance->m_updateNotNecessary
|
||||
? QString("NO-UPDATE-NECESSARY (%1:%2)")
|
||||
.arg(instance->m_customerRepository)
|
||||
.arg(instance->m_gc.branchName()).toStdString().c_str()
|
||||
: QString("ISMAS-TRIGGER ON WAIT").toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE: {
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_TEST_TRIGGER, // U0099
|
||||
_CHECK_ISMAS_TRIGGER_WRONG_VALUE,
|
||||
IsmasClient::RESULT_CODE::ISMAS_TRIGGER_ERROR,
|
||||
smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0003",
|
||||
_ISMAS_TEST_TRIGGER, // U0099
|
||||
_CHECK_ISMAS_TRIGGER_FAILURE,
|
||||
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
smap[step],
|
||||
IsmasClient::RESULT_CODE::ISMAS_TRIGGER_ERROR,
|
||||
smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER:
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER: {
|
||||
ismasClient.setProgressInPercent(_INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER);
|
||||
break;
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER: {
|
||||
ismasClient.setProgressInPercent(_INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH: {
|
||||
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_PULL_NEW_BRANCH,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
}
|
||||
break;
|
||||
case UPDATE_STEP::CHECKOUT_BRANCH:
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH_FAILURE);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010 -> even on error: U0002/3 are sent only once
|
||||
_PULL_NEW_BRANCH_FAILURE,
|
||||
IsmasClient::RESULT_CODE::GIT_PULL_ERROR,
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
}
|
||||
break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_PULL_NEW_BRANCH_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE, // U0010
|
||||
_PULL_NEW_BRANCH_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
}
|
||||
break;
|
||||
case UPDATE_STEP::CHECKOUT_BRANCH: {
|
||||
ismasClient.setProgressInPercent(_CHECKOUT_BRANCH);
|
||||
break;
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0010",
|
||||
_CHECKOUT_BRANCH_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_CHECKOUT_BRANCH_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
@@ -761,9 +1044,10 @@ private:
|
||||
"U0010",
|
||||
_CHECKOUT_BRANCH_SUCCESS,
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -772,12 +1056,13 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0003",
|
||||
_ISMAS_FAILURE, // U0003
|
||||
_CHECKOUT_BRANCH_FAILURE,
|
||||
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
smap[step],
|
||||
IsmasClient::RESULT_CODE::GIT_SWITCH_BRANCH_ERROR,
|
||||
smap[UPDATE_STEP::CHECKOUT_BRANCH],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1
|
||||
? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -911,12 +1196,23 @@ private:
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS: {
|
||||
ismasClient.setProgressInPercent(_EXEC_OPKG_COMMAND_SUCCESS);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[UPDATE_STEP::EXEC_OPKG_COMMANDS],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE: {
|
||||
ismasClient.setProgressInPercent(_EXEC_OPKG_COMMAND_FAILURE);
|
||||
@@ -925,10 +1221,10 @@ private:
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_FAILURE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
IsmasClient::RESULT_CODE::OPKG_COMMANDS_ERROR,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -952,9 +1248,9 @@ private:
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -969,9 +1265,9 @@ private:
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -989,9 +1285,9 @@ private:
|
||||
_ISMAS_CONTINUE,
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -1011,7 +1307,7 @@ private:
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -1029,12 +1325,12 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0001", // WAIT-button set to 100%
|
||||
_ISMAS_DONE, // WAIT-button set to 100%
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -1043,12 +1339,26 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0002", // reset WAIT-button to "" (empty string)
|
||||
_ISMAS_SET_WAIT_OK, // U0002
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::SUCCESS,
|
||||
smap[step],
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
case UPDATE_STEP::UPDATE_NOT_NECESSARY: {
|
||||
ismasClient.setProgressInPercent(_UPDATE_NOT_NECESSARY + _UPDATE_NOT_NECESSARY_CORRECTION);
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
_ISMAS_SET_WAIT_OK, // U0002
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::NO_UPDATE_NECESSARY,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -1057,12 +1367,12 @@ private:
|
||||
QString const &ismasUpdateNews =
|
||||
QString("#M=APISM#C=CMD_EVENT#J=") +
|
||||
ismasClient.updateNewsToIsmas(
|
||||
"U0003",
|
||||
_ISMAS_FAILURE, // U0003 is sent only once
|
||||
ismasClient.getProgressInPercent(),
|
||||
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
||||
smap[step],
|
||||
IsmasClient::RESULT_CODE::UPDATE_IN_ERROR_STATE,
|
||||
smap[UPDATE_STEP::UPDATE_FINALIZE],
|
||||
instance->m_ismasMsg.join(' ').toStdString().c_str(),
|
||||
"");
|
||||
instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A");
|
||||
ismasClient.sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DB_PORT, ismasUpdateNews);
|
||||
} break;
|
||||
@@ -1089,6 +1399,8 @@ private:
|
||||
Worker::instance->m_currentStep = step;
|
||||
|
||||
switch (step) {
|
||||
case UPDATE_STEP::NONE: {
|
||||
} break;
|
||||
case UPDATE_STEP::STARTED:
|
||||
break;
|
||||
case UPDATE_STEP::CHECK_REPOSITORY:
|
||||
@@ -1145,6 +1457,12 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER:
|
||||
break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH:
|
||||
break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_FAILURE:
|
||||
break;
|
||||
case UPDATE_STEP::PULL_NEW_BRANCH_SUCCESS:
|
||||
break;
|
||||
case UPDATE_STEP::CHECKOUT_BRANCH:
|
||||
emit worker->appendText("\nPrepare customer environment ...");
|
||||
break;
|
||||
@@ -1263,6 +1581,8 @@ private:
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_ACTIVATED:
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_NOT_NECESSARY:
|
||||
break;
|
||||
case UPDATE_STEP::UPDATE_FAILED:
|
||||
emit worker->appendText(QString("UPDATE "), UPDATE_STEP_FAIL);
|
||||
break;
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class System : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
explicit System(QObject *parent = 0);
|
||||
|
||||
static QString errorMsg;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
static bool checkForSDCard();
|
||||
static bool umountSDCard();
|
||||
|
||||
static bool checkForUSBStick();
|
||||
static QString getUSBMountPath();
|
||||
static QString getUSBDeviceName();
|
||||
static bool umountUSBStick();
|
||||
|
||||
static bool test_mount(const QString& dev, const QString &mountpoint);
|
||||
static bool test_dir(const QString& dir);
|
||||
|
||||
static quint32 getFreeDiskSpace(const QString& dev);
|
||||
static quint32 getFreeDiskSpaceSDCard();
|
||||
static bool isSDCardWritable();
|
||||
static quint32 getFreeDiskSpaceUSBStick();
|
||||
static bool isUSBStickWritable();
|
||||
|
||||
static quint8 createLogFileBackup(const QString & targzfile, const QString &filelistfile = "");
|
||||
static QString getSDCardMountPath();
|
||||
static QString getSDCardDeviceName();
|
||||
|
||||
static QString getUniqueDeviceId();
|
||||
|
||||
static QString getErrorMessage();
|
||||
|
||||
static QString readStringFromFile(const QString & filename);
|
||||
static int readIntFromFile(const QString & filename);
|
||||
|
||||
static QString getPTU4SerialNumber();
|
||||
static QString getPTU4MACAddress();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SYSTEM_H
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#ifndef MESSAGE_HANDLER_H_INCLUDED
|
||||
#define MESSAGE_HANDLER_H_INCLUDED
|
||||
|
||||
#include <QtGlobal>
|
||||
#ifdef __linux__
|
||||
#include <syslog.h>
|
||||
#endif
|
||||
|
||||
int getDebugLevel();
|
||||
void setDebugLevel(int newDebugLevel);
|
||||
|
||||
bool messageHandlerInstalled();
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const char *);
|
||||
void atbDebugOutput(QtMsgType type, const char *msg);
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
// typedef void (*QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &);
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
|
||||
#endif
|
||||
|
||||
#endif // MESSAGE_HANDLER_H_INCLUDED
|
||||
@@ -0,0 +1,647 @@
|
||||
#include "System.h"
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
|
||||
//#include "version.h"
|
||||
|
||||
|
||||
QString System::errorMsg = "";
|
||||
|
||||
System::System(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to return error message.
|
||||
*
|
||||
*/
|
||||
QString System::getErrorMessage()
|
||||
{
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to check if a writable SD-card is in the cardslot.
|
||||
*
|
||||
* This function only checks a certain path or a mount entry. It does not mount
|
||||
* a SD-card, this must be provided by the OS (automounter).
|
||||
*
|
||||
* returns 1 if a SD-card is available, 0 otherwise.
|
||||
*/
|
||||
bool System::checkForSDCard()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
return true;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (!test_mount(getSDCardDeviceName(), getSDCardMountPath())) {
|
||||
qDebug() << "check for SD-card failed: \n"
|
||||
<< " device name is: " << getSDCardDeviceName()
|
||||
<< " mount path is: " << getSDCardMountPath();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function for umount sd-card.
|
||||
*
|
||||
*/
|
||||
bool System::umountSDCard()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
return true;
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QString commandString = "umount " + getSDCardMountPath();
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::umountSDCard(): ERROR: waitForStarted()";
|
||||
return false;
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::umountSDCard(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
QByteArray bytes = process.readAll();
|
||||
QStringList lines = QString(bytes).split("\n");
|
||||
foreach (QString line, lines) {
|
||||
qDebug() << "System::umountSDCard() line: " << line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function for umount usb-stick.
|
||||
*
|
||||
*/
|
||||
bool System::umountUSBStick()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
return true;
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QString commandString = "umount " + getUSBMountPath();
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::umountUSBStick(): ERROR: waitForStarted()";
|
||||
return false;
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::umountUSBStick(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
QByteArray bytes = process.readAll();
|
||||
QStringList lines = QString(bytes).split("\n");
|
||||
foreach (QString line, lines) {
|
||||
qDebug() << "System::umountUSBStick() line: " << line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* test, if a certain device is already mounted
|
||||
*
|
||||
* e.g. a mounted SD-card on PTU4:
|
||||
* - device is '/dev/mmcblk0p1'
|
||||
* - mount path is '/media/mmcblk0p1'
|
||||
*
|
||||
* e.g. a mounted USB-Stick on PTU4:
|
||||
* - device is '/dev/sda'
|
||||
* - mount path is '/media/sda'
|
||||
*/
|
||||
bool System::test_mount(const QString& dev, const QString& mountpoint)
|
||||
{
|
||||
bool mounted = false;
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
qDebug() << "System::test_mount() dev = " << dev;
|
||||
qDebug() << "System::test_mount() mountpoint = " << mountpoint;
|
||||
|
||||
//normalize mountpoint: (mountpoint is without trailing '/')
|
||||
QString tmp_mountpoint = QString(mountpoint).remove(QRegExp("/*$"));
|
||||
|
||||
QString commandString = "mount";
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::test_mount(): ERROR: waitForStarted()";
|
||||
return false;
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::test_mount(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
QByteArray bytes = process.readAll();
|
||||
QStringList lines = QString(bytes).split("\n");
|
||||
foreach (QString line, lines) {
|
||||
//qDebug() << "System::test_mount() line: " << line;
|
||||
|
||||
//if (line.contains(dev)) qDebug() << "System::test_mount() line contains dev";
|
||||
//if (line.contains(tmp_mountpoint)) qDebug() << "System::test_mount() line contains mountpoint";
|
||||
|
||||
if (line.contains(dev) && line.contains(tmp_mountpoint)) {
|
||||
qDebug() << "System::test_mount(): " << dev << " is mounted on " << tmp_mountpoint;
|
||||
mounted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return mounted;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* test, if a certain directory is existing and readable
|
||||
*/
|
||||
bool System::test_dir(const QString& dir)
|
||||
{
|
||||
QFileInfo fileInfo(dir);
|
||||
if (! fileInfo.isDir() ) { return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool System::checkForUSBStick()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
if (QFileInfo(getUSBMountPath()).isDir())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
if (getUSBMountPath().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief SupportSystem::getUSBMountPath
|
||||
* @return path where a USB storage device is mounted.
|
||||
*
|
||||
* Note, do not return an empty string ("") here because a calling method (which could not be
|
||||
* identified till now) is relying on this!
|
||||
*/
|
||||
QString System::getUSBMountPath()
|
||||
{
|
||||
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
return QDir::homePath().append("/APconfigTest/USB");
|
||||
#endif
|
||||
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
QStringList mountLine;
|
||||
|
||||
qDebug() << "System::getUSBMountPath()";
|
||||
|
||||
QRegExp devRegExp = QRegExp("dev/sd*", Qt::CaseSensitive, QRegExp::WildcardUnix);
|
||||
QRegExp mountRegExp = QRegExp("media/sd*", Qt::CaseSensitive, QRegExp::WildcardUnix);
|
||||
|
||||
QString commandString = "mount";
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::getUSBMountPath(): ERROR: waitForStarted()";
|
||||
return "";
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::getUSBMountPath(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
QByteArray bytes = process.readAll();
|
||||
QStringList lines = QString(bytes).split("\n");
|
||||
foreach (QString line, lines) {
|
||||
qDebug() << "System::getUSBMountPath() line: " << line;
|
||||
|
||||
if (line.contains(devRegExp) && line.contains(mountRegExp)) {
|
||||
|
||||
qDebug() << " -> this line is a usb storage device mount" << line;
|
||||
|
||||
mountLine = line.split(' ');
|
||||
if (mountLine.size() > 3) {
|
||||
qDebug() << "System::getUSBMountPath(): " << mountLine.at(0) << " is mounted on " << mountLine.at(2);
|
||||
return mountLine.at(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "System::getUSBMountPath() no mounted usb device found!";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to check if a mounted sd-card is writable.
|
||||
*
|
||||
* Note: the caller must ensure (e.g. by calling checkForSDCard()) that a
|
||||
* sd-card is mounted.
|
||||
*
|
||||
*/
|
||||
bool System::isSDCardWritable()
|
||||
{
|
||||
QFileInfo fi(getSDCardMountPath());
|
||||
|
||||
if(fi.isDir() && fi.isWritable()) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* static function to check if a mounted usb-stick is writable.
|
||||
*
|
||||
* Note: the caller must ensure (e.g. by calling checkForUSBStick()) that a
|
||||
* usb-stick is mounted.
|
||||
*
|
||||
*/
|
||||
bool System::isUSBStickWritable()
|
||||
{
|
||||
QFileInfo fi(getUSBMountPath());
|
||||
|
||||
if(fi.isDir() && fi.isWritable()) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* wrapper function for getting free space on a sd-card on ptu
|
||||
*
|
||||
*/
|
||||
quint32 System::getFreeDiskSpaceSDCard()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
return getFreeDiskSpace("/home/siegert/server1home");
|
||||
#endif
|
||||
return getFreeDiskSpace(getSDCardMountPath());
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* wrapper function for getting free space on a usb storage device on ptu
|
||||
*
|
||||
*/
|
||||
quint32 System::getFreeDiskSpaceUSBStick()
|
||||
{
|
||||
#if defined (ARCH_DesktopLinux)
|
||||
return getFreeDiskSpace("/home/siegert/server1home");
|
||||
#endif
|
||||
return getFreeDiskSpace(getUSBMountPath());
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to read free disk space
|
||||
*
|
||||
* example output of 'df' command on ptu:
|
||||
* # df
|
||||
* Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
* ubi0:rootfs 111704 78940 32764 71% /
|
||||
* devtmpfs 62072 0 62072 0% /dev
|
||||
* tmpfs 62332 0 62332 0% /dev/shm
|
||||
* tmpfs 62332 416 61916 1% /tmp
|
||||
* tmpfs 62332 24 62308 1% /run
|
||||
* ubi0:data 222260 5892 216368 3% /opt
|
||||
* tmpfs 62332 0 62332 0% /media
|
||||
* /dev/mmcblk0p1 3878912 87360 3791552 3% /media/mmcblk0p1
|
||||
*
|
||||
* in this case, if we want to get the free space on the sd-card the methode should
|
||||
* be called:
|
||||
* getFreeDiskSpace("/dev/mmcblk0p1")
|
||||
* the result should be:
|
||||
* 3791552
|
||||
*
|
||||
*/
|
||||
quint32 System::getFreeDiskSpace(const QString& dev)
|
||||
{
|
||||
quint32 availableSpace = 0;
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
//qDebug() << "System::getFreeDiskSpace() dev = " << dev;
|
||||
|
||||
QString commandString = "df";
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::getFreeDiskSpace(): ERROR: waitForStarted()";
|
||||
return availableSpace;
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::getFreeDiskSpace(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return availableSpace;
|
||||
}
|
||||
else {
|
||||
QByteArray bytes = process.readAll();
|
||||
QStringList lines = QString(bytes).split("\n");
|
||||
foreach (QString line, lines) {
|
||||
//qDebug() << "System::getFreeDiskSpace() line: " << line;
|
||||
|
||||
|
||||
|
||||
if (line.contains(dev)) {
|
||||
//qDebug() << "System::getFreeDiskSpace() line contains dev";
|
||||
|
||||
QStringList processResultLine = line.split(' ', QString::SkipEmptyParts);
|
||||
if (processResultLine.size() >= 4) {
|
||||
bool ok;
|
||||
availableSpace = processResultLine.at(3).toLong(&ok);
|
||||
if (!ok) {
|
||||
return 0;
|
||||
}
|
||||
qDebug() << "System::getFreeDiskSpace() availableSpace = " << availableSpace;
|
||||
}
|
||||
else {
|
||||
return availableSpace;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return availableSpace;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to create a backup of logfiles
|
||||
*
|
||||
* 'targzfile' is an absolute filename for ar tar.gz file wich will be created
|
||||
* 'filelistfile' is an absolute filename of a file containing all names of files
|
||||
* which should be backed up.
|
||||
*
|
||||
* returns:
|
||||
* 1 on success
|
||||
* 0 on failure
|
||||
*
|
||||
*/
|
||||
quint8 System::createLogFileBackup(const QString & targzfile, const QString &filelistfile)
|
||||
{
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
qDebug() << "System::createLogFileBackup() targzfile = " << targzfile;
|
||||
qDebug() << "System::createLogFileBackup() filelistfile = " << filelistfile;
|
||||
|
||||
QString commandString = "tar hczvf " + targzfile + " -T " + filelistfile;
|
||||
|
||||
qDebug() << "System::createLogFileBackup() tar command:" << commandString;
|
||||
|
||||
process.start(commandString);
|
||||
if (!process.waitForStarted()) {
|
||||
errorMsg = "System::createLogFileBackup(): ERROR: waitForStarted()";
|
||||
return 1;
|
||||
}
|
||||
if (!process.waitForFinished(600000)) {
|
||||
errorMsg = "System::createLogFileBackup(): ERROR: " + process.errorString();
|
||||
qDebug() << errorMsg;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
// DEBUG
|
||||
//QByteArray bytes = process.readAll();
|
||||
//QStringList lines = QString(bytes).split("\n");
|
||||
//foreach (QString line, lines) {
|
||||
// qDebug() << "System::createLogFileBackup() line: " << line;
|
||||
//}
|
||||
}
|
||||
|
||||
QString resultMessage;
|
||||
QProcess::ExitStatus exitStatus = process.exitStatus();
|
||||
int exitCode = process.exitCode();
|
||||
|
||||
if (exitStatus == QProcess::CrashExit) {
|
||||
resultMessage = "local backup program crashed";
|
||||
qCritical() << resultMessage;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
/**
|
||||
* note for exit codes of process tar:
|
||||
* see: http://www.gnu.org/software/tar/manual/html_section/tar_19.html#Synopsis
|
||||
*
|
||||
* tar returns exitCode 2 if some files in logFileList could not be read (e.g. if they are not existing)
|
||||
* however, tar-archive is created although!
|
||||
* This means success for our needs!
|
||||
*/
|
||||
|
||||
if ( (exitCode != 0) && (exitCode != 2) && (exitStatus == QProcess::NormalExit) ) {
|
||||
resultMessage = "Local Backup file \"" + targzfile + "\" with exit code = " + QString::number(exitCode);
|
||||
qCritical() << resultMessage;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
resultMessage = "Local Backup file \"" + targzfile + "\" was created successfully.";
|
||||
qCritical() << resultMessage;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* get SD-card mount path.
|
||||
*/
|
||||
QString System::getSDCardMountPath()
|
||||
{
|
||||
#if defined (ARCH_PTU4)
|
||||
return "/media/mmcblk0p1";
|
||||
#elif defined (ARCH_PTU5)
|
||||
return "/media/mmcblk0p1";
|
||||
#elif defined (ARCH_DesktopLinux)
|
||||
// DEBUG / TEST:
|
||||
return "/home/siegert/APconfigTest";
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* get SD-card device name.
|
||||
*/
|
||||
QString System::getSDCardDeviceName()
|
||||
{
|
||||
#if defined (ARCH_PTU4)
|
||||
return "/dev/mmcblk0p1";
|
||||
#elif defined (ARCH_PTU5)
|
||||
return "/dev/mmcblk0p1";
|
||||
#elif defined (ARCH_DesktopLinux)
|
||||
return "/dev/sdf1";
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* static function to build and return a unique device id.
|
||||
* This id consists currently only of the mac-address of network device eth0.
|
||||
*/
|
||||
QString System::getUniqueDeviceId()
|
||||
{
|
||||
QString filename = "/sys/class/net/eth0/address";
|
||||
QString result;
|
||||
|
||||
QFile file(filename);
|
||||
if(!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "System::getUniqueDeviceId() could not open file: " << filename;
|
||||
result = "0";
|
||||
}
|
||||
else {
|
||||
QTextStream in(&file);
|
||||
result = in.readLine(20);
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
result.remove(':');
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString System::readStringFromFile(const QString & filename)
|
||||
{
|
||||
#if defined (ARCH_PTU4)
|
||||
QFileInfo fileinfo(filename);
|
||||
#else
|
||||
QFileInfo fileinfo(QDir::homePath() + filename);
|
||||
#endif
|
||||
if (! fileinfo.isReadable() ) {
|
||||
qDebug() << "System::readStringFromFile(): \"" << filename << "\" is not readable";
|
||||
return "";
|
||||
}
|
||||
|
||||
#if defined (ARCH_PTU4)
|
||||
QFile file(filename);
|
||||
#else
|
||||
QFile file(QDir::homePath() + filename);
|
||||
#endif
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug() << "System::readStringFromFile() cannot open file: " << filename;
|
||||
return "";
|
||||
}
|
||||
|
||||
QTextStream in(&file);
|
||||
|
||||
QString stringValue = in.readLine(100);
|
||||
qDebug() << "System::readStringFromFile() stringValue = " << stringValue;
|
||||
|
||||
file.close();
|
||||
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
|
||||
int System::readIntFromFile(const QString & filename)
|
||||
{
|
||||
bool ok;
|
||||
int result = (int)readStringFromFile(filename).toInt(&ok);
|
||||
|
||||
if (!ok) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* read ptu internal data
|
||||
*
|
||||
*/
|
||||
QString System::getPTU4SerialNumber()
|
||||
{
|
||||
return readStringFromFile("/sys/bus/i2c/devices/0-0050/SNO");
|
||||
}
|
||||
|
||||
QString System::getPTU4MACAddress()
|
||||
{
|
||||
return readStringFromFile("/sys/bus/i2c/devices/0-0050/MAC");
|
||||
}
|
||||
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#include "message_handler.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <cstring>
|
||||
#include <QString>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageLogContext>
|
||||
|
||||
|
||||
static char const *DBG_NAME[] = { "DBG ", "WARN ", "CRIT ", "FATAL", "INFO " };
|
||||
static bool installedMsgHandler = false;
|
||||
static int debugLevel = LOG_NOTICE;
|
||||
|
||||
int getDebugLevel() { return debugLevel; }
|
||||
void setDebugLevel(int newDebugLevel) {
|
||||
debugLevel = newDebugLevel;
|
||||
}
|
||||
|
||||
bool messageHandlerInstalled() {
|
||||
return installedMsgHandler;
|
||||
}
|
||||
|
||||
QtMessageHandler atbInstallMessageHandler(QtMessageHandler handler) {
|
||||
installedMsgHandler = (handler != 0);
|
||||
static QtMessageHandler prevHandler = nullptr;
|
||||
if (handler) {
|
||||
prevHandler = qInstallMessageHandler(handler);
|
||||
return prevHandler;
|
||||
} else {
|
||||
return qInstallMessageHandler(prevHandler);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// \brief Print message according to given debug level.
|
||||
///
|
||||
/// \note Install this function using qInstallMsgHandler().
|
||||
///
|
||||
/// int main(int argc, char **argv) {
|
||||
/// installMsgHandler(atbDebugOutput);
|
||||
/// QApplication app(argc, argv);
|
||||
/// ...
|
||||
/// return app.exec();
|
||||
/// }
|
||||
///
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
void atbDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||
Q_UNUSED(context);
|
||||
QString const localMsg = QString(DBG_NAME[type]) + msg.toLocal8Bit();
|
||||
|
||||
switch (debugLevel) {
|
||||
case LOG_DEBUG: { // debug-level message
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
} break;
|
||||
case LOG_INFO: { // informational message
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_NOTICE: { // normal, but significant, condition
|
||||
if (type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_WARNING: { // warning conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ERR: { // error conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_CRIT: { // critical conditions
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_ALERT: { // action must be taken immediately
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
case LOG_EMERG: { // system is unusable
|
||||
if (type != QtInfoMsg && type != QtDebugMsg && type != QtWarningMsg) {
|
||||
syslog(LOG_DEBUG, "%s", localMsg.toStdString().c_str());
|
||||
}
|
||||
} break;
|
||||
default: {
|
||||
//fprintf(stderr, "%s No ErrorLevel defined! %s\n",
|
||||
// datetime.toStdString().c_str(), msg.toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
-1427
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user