Compare commits
9 Commits
f67b4bfa6f
...
31aa7c0584
Author | SHA1 | Date | |
---|---|---|---|
31aa7c0584 | |||
f750f76dbb | |||
aa88a040ba | |||
3358e1a0d4 | |||
ea1d858f15 | |||
7b4bee524f | |||
b6f0615e9c | |||
fbedaab3fe | |||
8a482e328c |
@ -1,3 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
CONFIG += ordered
|
||||
SUBDIRS = DownloadDCFirmware DownloadDCJsonFiles SyncTariffs UpdatePTUDevCtrl
|
||||
SUBDIRS = Check Show DownloadDCFirmware DownloadDCJsonFiles Opkg Sync UpdatePTUDevCtrl
|
||||
|
76
Check/Check.pro
Normal file
76
Check/Check.pro
Normal file
@ -0,0 +1,76 @@
|
||||
QT += core
|
||||
|
||||
TARGET = check_update
|
||||
|
||||
VERSION="1.0.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}"
|
||||
|
||||
|
||||
INCLUDEPATH += \
|
||||
plugins \
|
||||
$${INCLUDEINTERFACES} \
|
||||
$${_PRO_FILE_PWD_}/../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 ) {
|
||||
CONFIG += link_pkgconfig
|
||||
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 ) {
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
# 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
|
||||
|
||||
# HEADERS += \
|
||||
|
||||
##########################################################################################
|
||||
# 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
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
QT += core
|
||||
|
||||
TARGET = ATBDownloadDCFirmware
|
||||
TARGET = ExecOpkgCmds
|
||||
|
||||
VERSION="1.0.0"
|
||||
win32 {
|
14
Opkg/main.cpp
Normal file
14
Opkg/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
68
Show/Show.pro
Normal file
68
Show/Show.pro
Normal file
@ -0,0 +1,68 @@
|
||||
QT += core
|
||||
|
||||
TARGET = show_update
|
||||
|
||||
VERSION="1.0.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}"
|
||||
|
||||
|
||||
INCLUDEPATH += \
|
||||
plugins \
|
||||
$${INCLUDEINTERFACES} \
|
||||
$${_PRO_FILE_PWD_}/../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 ) {
|
||||
CONFIG += link_pkgconfig
|
||||
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 ) {
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
# 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
|
||||
|
||||
# HEADERS += \
|
14
Show/main.cpp
Normal file
14
Show/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
77
Sync/Sync.pro
Normal file
77
Sync/Sync.pro
Normal file
@ -0,0 +1,77 @@
|
||||
QT += core
|
||||
|
||||
TARGET = update_sync_cust_repo
|
||||
|
||||
VERSION="1.0.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}"
|
||||
|
||||
|
||||
INCLUDEPATH += \
|
||||
plugins \
|
||||
$${INCLUDEINTERFACES} \
|
||||
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
||||
$${_PRO_FILE_PWD_}/../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 ) {
|
||||
CONFIG += link_pkgconfig
|
||||
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 ) {
|
||||
QMAKE_CXXFLAGS += -std=c++17 # for GCC >= 4.7
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
DEFINES+=PTU5
|
||||
}
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
# 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
|
||||
|
||||
# HEADERS += \
|
||||
|
||||
##########################################################################################
|
||||
# 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
|
||||
}
|
14
Sync/main.cpp
Normal file
14
Sync/main.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
#include <QByteArray>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
@ -279,9 +279,19 @@ SOURCES += \
|
||||
git/git_client.cpp \
|
||||
ismas/ismas_client.cpp \
|
||||
process/command.cpp \
|
||||
process/update_command.cpp \
|
||||
process/update_json_command.cpp \
|
||||
process/update_filesystem_command.cpp \
|
||||
process/update_dc_command.cpp \
|
||||
process/check_ismas_connectivity_command.cpp \
|
||||
process/check_update_activation_command.cpp \
|
||||
process/check_and_fetch_customer_repository_command.cpp \
|
||||
process/exec_opkg_command.cpp \
|
||||
process/show_software_status_command.cpp \
|
||||
message_handler.cpp \
|
||||
worker.cpp \
|
||||
commandline_parser.cpp
|
||||
commandline_parser.cpp \
|
||||
work_process_list.cpp
|
||||
|
||||
HEADERS += \
|
||||
update.h \
|
||||
@ -293,9 +303,20 @@ HEADERS += \
|
||||
apism/ismas_data.h \
|
||||
ismas/ismas_client.h \
|
||||
process/command.h \
|
||||
process/update_command.h \
|
||||
process/update_json_command.h \
|
||||
process/update_filesystem_command.h \
|
||||
process/update_dc_command.h \
|
||||
process/check_ismas_connectivity_command.h \
|
||||
process/check_update_activation_command.h \
|
||||
process/check_and_fetch_customer_repository_command.h \
|
||||
process/exec_opkg_command.cpp \
|
||||
process/show_software_status_command.h \
|
||||
message_handler.h \
|
||||
worker.h \
|
||||
commandline_parser.h
|
||||
commandline_parser.h \
|
||||
work_process_list.h
|
||||
|
||||
|
||||
OTHER_FILES += \
|
||||
ATBUpdateTool.ini
|
||||
|
@ -203,7 +203,8 @@ int main(int argc, char *argv[]) {
|
||||
mw.showFullScreen();
|
||||
|
||||
// test
|
||||
worker.jsUpdate();
|
||||
//worker.jsUpdate();
|
||||
worker.workList().exec();
|
||||
// worker.summary();
|
||||
|
||||
return a.exec();
|
||||
|
@ -0,0 +1,6 @@
|
||||
#include "process/check_and_fetch_customer_repository_command.h"
|
||||
|
||||
CheckAndFetchCustomerRepositoryCommand::CheckAndFetchCustomerRepositoryCommand(
|
||||
QString const &command, Worker *worker, int start_timeout, int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
||||
#define CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckAndFetchCustomerRepositoryCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckAndFetchCustomerRepositoryCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_AND_FETCH_CUSTOMER_REPOSITORY_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/check_ismas_connectivity_command.h"
|
||||
|
||||
|
||||
CheckIsmasConnectivityCommand::CheckIsmasConnectivityCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/check_ismas_connectivity_command.h
Normal file
14
UpdatePTUDevCtrl/process/check_ismas_connectivity_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
||||
#define CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckIsmasConnectivityCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckIsmasConnectivityCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_ISMAS_CONNECTIVITY_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/check_update_activation_command.h"
|
||||
|
||||
|
||||
CheckUpdateActivationCommand::CheckUpdateActivationCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/check_update_activation_command.h
Normal file
14
UpdatePTUDevCtrl/process/check_update_activation_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
||||
#define CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class CheckUpdateActivationCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit CheckUpdateActivationCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // CHECK_UPDATE_ACTIVATION_COMMAND_H_INCLUDED
|
@ -92,6 +92,7 @@ void Command::readyReadStandardError() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: nach UpdateCommands ziehen
|
||||
void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
QProcess *p = (QProcess *)sender();
|
||||
// read all remaining data sent to the process, just in case
|
||||
@ -109,6 +110,7 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: nach UpdateCommand ziehen
|
||||
bool Command::start(QString workingDirectory, QStringList args) {
|
||||
if (!QDir::setCurrent(workingDirectory)) {
|
||||
qCritical() << "SET WORKING_DIRECTORY" << workingDirectory
|
||||
|
@ -1,6 +1,5 @@
|
||||
#ifndef COMMAND_H_INCLUDED
|
||||
#define COMMAND_H_INCLUDED
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
|
||||
#include <QObject>
|
||||
#include <QCoreApplication>
|
||||
@ -13,14 +12,24 @@ class Worker;
|
||||
class Command : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
QString m_command;
|
||||
mutable QString m_commandResult;
|
||||
|
||||
private:
|
||||
int m_waitForStartTimeout;
|
||||
int m_waitForFinishTimeout;
|
||||
int m_exitCode;
|
||||
|
||||
protected:
|
||||
mutable QMutex m_mtx;
|
||||
|
||||
private:
|
||||
QProcess *m_p;
|
||||
|
||||
protected:
|
||||
Worker *m_worker;
|
||||
|
||||
public:
|
||||
explicit Command(QString const &command,
|
||||
int start_timeout = 100000,
|
||||
@ -35,8 +44,10 @@ public:
|
||||
|
||||
void setWorker(Worker *worker) {m_worker = worker; }
|
||||
|
||||
private slots:
|
||||
protected slots:
|
||||
void readyReadStandardOutput();
|
||||
void readyReadStandardError();
|
||||
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
};
|
||||
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
|
10
UpdatePTUDevCtrl/process/exec_opkg_command.cpp
Normal file
10
UpdatePTUDevCtrl/process/exec_opkg_command.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "process/exec_opkg_command.h"
|
||||
|
||||
|
||||
ExecOpkgCommand::ExecOpkgCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout)
|
||||
, m_noaction(m_noaction) {
|
||||
}
|
17
UpdatePTUDevCtrl/process/exec_opkg_command.h
Normal file
17
UpdatePTUDevCtrl/process/exec_opkg_command.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef EXEC_OPKG_COMMAND_H_INCLUDED
|
||||
#define EXEC_OPKG_COMMAND_H_INCLUDED
|
||||
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class ExecOpkgCommand : public UpdateCommand {
|
||||
bool m_noaction{false};
|
||||
public:
|
||||
explicit ExecOpkgCommand(QString const &command,
|
||||
Worker *worker,
|
||||
bool noaction,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // EXEC_OPKG_COMMAND_H_INCLUDED
|
@ -0,0 +1,9 @@
|
||||
#include "process/show_software_status_command.h"
|
||||
|
||||
|
||||
ShowSoftwareStatusCommand::ShowSoftwareStatusCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
13
UpdatePTUDevCtrl/process/show_software_status_command.h
Normal file
13
UpdatePTUDevCtrl/process/show_software_status_command.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
||||
#define SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class ShowSoftwareStatusCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit ShowSoftwareStatusCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
#endif // SHOW_SOFTWARE_STATUS_COMMAND_H_INCLUDED
|
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
45
UpdatePTUDevCtrl/process/update_command.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include "update_command.h"
|
||||
#include "worker.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
UpdateCommand::UpdateCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: Command(command, start_timeout, finish_timeout) {
|
||||
setWorker(worker);
|
||||
}
|
||||
|
||||
bool UpdateCommand::stopUpdateOnFailure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void UpdateCommand::finished(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
|
||||
qCritical() << __func__ << ":" << __LINE__ << m_command
|
||||
<< "exitCode" << exitCode
|
||||
<< "exitStatus" << exitStatus;
|
||||
|
||||
QProcess *p = (QProcess *)sender();
|
||||
if (p) {
|
||||
// read all remaining data sent to the process, just in case
|
||||
m_commandResult += p->readAllStandardOutput();
|
||||
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardOutput()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(finished(int,QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
if (!m_worker->workList().empty()) {
|
||||
if (exitCode == 0 && exitStatus == QProcess::ExitStatus::NormalExit) {
|
||||
if (m_worker->workList().nextExec()) {
|
||||
m_worker->workList().exec();
|
||||
}
|
||||
} else {
|
||||
bool execShowStatus = true;
|
||||
m_worker->workList().exec(execShowStatus);
|
||||
}
|
||||
}
|
||||
}
|
20
UpdatePTUDevCtrl/process/update_command.h
Normal file
20
UpdatePTUDevCtrl/process/update_command.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef UPDATE_COMMAND_H_INCLUDED
|
||||
#define UPDATE_COMMAND_H_INCLUDED
|
||||
|
||||
#include "process/command.h"
|
||||
|
||||
class Worker;
|
||||
class UpdateCommand : public Command {
|
||||
public:
|
||||
explicit UpdateCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
virtual bool stopUpdateOnFailure();
|
||||
|
||||
private slots:
|
||||
virtual void finished(int exitCode, QProcess::ExitStatus exitStatus) override;
|
||||
};
|
||||
|
||||
#endif // UPDATE_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_dc_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_dc_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_dc_command.h"
|
||||
|
||||
UpdateDCCommand::UpdateDCCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_dc_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_dc_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_DC_COMMAND_H_INCLUDED
|
||||
#define UPDATE_DC_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class UpdateDCCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateDCCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_DC_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_filesystem_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_filesystem_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_filesystem_command.h"
|
||||
|
||||
UpdateFileSystemCommand::UpdateFileSystemCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_filesystem_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_filesystem_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_FS_COMMAND_H_INCLUDED
|
||||
#define UPDATE_FS_COMMAND_H_INCLUDED
|
||||
|
||||
#include "update_command.h"
|
||||
|
||||
class UpdateFileSystemCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateFileSystemCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_FS_COMMAND_H_INCLUDED
|
8
UpdatePTUDevCtrl/process/update_json_command.cpp
Normal file
8
UpdatePTUDevCtrl/process/update_json_command.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "process/update_json_command.h"
|
||||
|
||||
UpdateJsonCommand::UpdateJsonCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout,
|
||||
int finish_timeout)
|
||||
: UpdateCommand(command, worker, start_timeout, finish_timeout) {
|
||||
}
|
14
UpdatePTUDevCtrl/process/update_json_command.h
Normal file
14
UpdatePTUDevCtrl/process/update_json_command.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef UPDATE_JSON_COMMAND_H_INCLUDED
|
||||
#define UPDATE_JSON_COMMAND_H_INCLUDED
|
||||
|
||||
#include "process/update_command.h"
|
||||
|
||||
class UpdateJsonCommand : public UpdateCommand {
|
||||
public:
|
||||
explicit UpdateJsonCommand(QString const &command,
|
||||
Worker *worker,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
};
|
||||
|
||||
#endif // UPDATE_JSON_HANDLER_H_INCLUDED
|
32
UpdatePTUDevCtrl/work_process_list.cpp
Normal file
32
UpdatePTUDevCtrl/work_process_list.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "work_process_list.h"
|
||||
#include "process/update_command.h"
|
||||
|
||||
#include <limits>
|
||||
#include <QDebug>
|
||||
|
||||
unsigned WorkList::nextExecIndex() const {
|
||||
if (m_workList.size() > 0 && m_workListIndex < (m_workList.size() - 1)) {
|
||||
return m_workListIndex + 1;
|
||||
}
|
||||
return std::numeric_limits<unsigned>::max();
|
||||
}
|
||||
|
||||
bool WorkList::nextExec() const {
|
||||
return m_workListIndex < m_workList.size();
|
||||
}
|
||||
|
||||
bool WorkList::exec(bool last) {
|
||||
if (last == false) {
|
||||
if (nextExec()) {
|
||||
m_workList[m_workListIndex]->start("/opt/app/tools/atbupdate");
|
||||
m_workListIndex += 1;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
m_workList.back()->start("/opt/app/tools/atbupdate");
|
||||
m_workListIndex = std::numeric_limits<unsigned>::max();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
36
UpdatePTUDevCtrl/work_process_list.h
Normal file
36
UpdatePTUDevCtrl/work_process_list.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef WORK_LIST_H_INCLUDED
|
||||
#define WORK_LIST_H_INCLUDED
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class UpdateCommand;
|
||||
class WorkList {
|
||||
public:
|
||||
std::vector<std::unique_ptr<UpdateCommand>> m_workList;
|
||||
unsigned m_workListIndex{0};
|
||||
|
||||
WorkList() = default;
|
||||
|
||||
template<typename T>
|
||||
void push_back(T&& arg) {
|
||||
m_workList.push_back(std::forward<T>(arg));
|
||||
}
|
||||
|
||||
bool empty() const { return m_workList.empty(); }
|
||||
|
||||
// move constructor: pass in classes derived from UpdateCommand
|
||||
// template<typename... Ts>
|
||||
//typename = typename std::enable_if<std::is_same<typename std::decay<Ts...>::type,
|
||||
// UpdateCommand>::value>::type>
|
||||
// WorkList(Ts&&... args)
|
||||
// : m_workList(std::forward<Ts...>(args...))
|
||||
// , m_workListIndex(0) {
|
||||
//}
|
||||
|
||||
unsigned nextExecIndex() const;
|
||||
bool nextExec() const;
|
||||
bool exec(bool last=false);
|
||||
};
|
||||
|
||||
#endif // WORK_LIST_H_INCLUDED
|
@ -20,6 +20,8 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "message_handler.h"
|
||||
#include <DeviceController/interfaces.h>
|
||||
#include "ismas/ismas_client.h"
|
||||
@ -27,6 +29,15 @@
|
||||
#include "mainwindow.h"
|
||||
#include "utils.h"
|
||||
#include "process/command.h"
|
||||
#include "process/update_command.h"
|
||||
#include "process/check_ismas_connectivity_command.h"
|
||||
#include "process/check_update_activation_command.h"
|
||||
#include "process/check_and_fetch_customer_repository_command.h"
|
||||
#include "process/update_json_command.h"
|
||||
#include "process/update_filesystem_command.h"
|
||||
#include "process/exec_opkg_command.h"
|
||||
#include "process/update_dc_command.h"
|
||||
#include "process/show_software_status_command.h"
|
||||
|
||||
QString const Worker::UPDATE_STEP_OK ( " [ ok]");
|
||||
QString const Worker::UPDATE_STEP_DONE ( " [done]");
|
||||
@ -181,8 +192,65 @@ Worker::Worker(int customerNr,
|
||||
, m_dcDownloadJsonFiles(new Command(
|
||||
QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())))
|
||||
//, m_withoutIsmasDirectPort(true) /* useful for testing */ {
|
||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
||||
, m_withoutIsmasDirectPort(false) /* useful for testing */ {
|
||||
|
||||
// check ISMAS connectivity
|
||||
m_workList.push_back(
|
||||
std::make_unique<CheckIsmasConnectivityCommand>(
|
||||
QString("echo CheckIsmasConnectivityCommand")
|
||||
, this));
|
||||
|
||||
// check if update activated in ISMAS
|
||||
m_workList.push_back(
|
||||
std::make_unique<CheckUpdateActivationCommand>(
|
||||
QString("echo CheckUpdateActivationCommand")
|
||||
, this));
|
||||
|
||||
// check and fetch git-customer repository
|
||||
m_workList.push_back(
|
||||
std::make_unique<CheckAndFetchCustomerRepositoryCommand>(
|
||||
QString("echo CheckAndFetchCustomerRepositoryCommand")
|
||||
, this));
|
||||
|
||||
// exec opkg-commands
|
||||
// first with no action -> dry-run
|
||||
m_workList.push_back(
|
||||
std::make_unique<ExecOpkgCommand>(
|
||||
QString("echo ExecOpkgCommand")
|
||||
, this, true));
|
||||
|
||||
// exec opkg-commands
|
||||
// now with action -> no dry-run
|
||||
|
||||
// send json files down to device controller
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateJsonCommand>(
|
||||
QString("echo UpdateJsonCommand")
|
||||
//QString("/opt/app/tools/atbupdate/ATBDownloadDCJsonFiles --set-ppid %1").arg(QCoreApplication::applicationPid())
|
||||
, this, false));
|
||||
|
||||
// sync json files in repo etc-directory with /etc fs-directory
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateFileSystemCommand>(
|
||||
QString("echo UpdateFileSystemCommand")
|
||||
, this));
|
||||
|
||||
|
||||
// send device-controller firmware down to device-controller-hardware
|
||||
m_workList.push_back(
|
||||
std::make_unique<UpdateDCCommand>(
|
||||
QString("echo UpdateDCCommand")
|
||||
// QString("/opt/app/tools/atbupdate/ATBDownloadDCFirmware --read-dc-version true")
|
||||
, this));
|
||||
|
||||
// show/send software-status
|
||||
m_workList.push_back(
|
||||
std::make_unique<ShowSoftwareStatusCommand>(
|
||||
QString("echo ShowSoftwareStatusCommand")
|
||||
, this));
|
||||
|
||||
// reboot machine
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
m_start = QDateTime::currentDateTime();
|
||||
m_dcDownloadFirmware->setWorker(this);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QByteArray>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include <optional>
|
||||
#include <initializer_list>
|
||||
@ -19,6 +20,7 @@
|
||||
#include "git/git_client.h"
|
||||
#include "ismas/ismas_client.h"
|
||||
#include "utils.h"
|
||||
#include "work_process_list.h"
|
||||
|
||||
#ifdef PTU5
|
||||
#define SERIAL_PORT "ttymxc2"
|
||||
@ -196,6 +198,8 @@ class Worker : public QThread{
|
||||
bool m_withoutIsmasDirectPort;
|
||||
QString m_apismVersion;
|
||||
|
||||
WorkList m_workList;
|
||||
|
||||
bool executeOpkgCommand(QString opkgCommand);
|
||||
bool cleanUpOpkgCache();
|
||||
QString getOsVersion() const;
|
||||
@ -469,6 +473,9 @@ public:
|
||||
|
||||
QByteArray standardOutput() const { return m_standardOutput; }
|
||||
|
||||
WorkList const &workList() const { return m_workList; }
|
||||
WorkList &workList() { return m_workList; }
|
||||
|
||||
signals:
|
||||
void appendText(QString, QString suffix = "");
|
||||
void insertText(QString);
|
||||
|
Loading…
x
Reference in New Issue
Block a user