Compare commits
9 Commits
1acec4d876
...
f8472a3b87
Author | SHA1 | Date | |
---|---|---|---|
f8472a3b87 | |||
24addad11e | |||
5a8298a078 | |||
52af7894db | |||
a6592ffd3e | |||
696db7de39 | |||
b31588bfab | |||
6651920f4a | |||
ef800366e1 |
@ -24,7 +24,7 @@ INCLUDEPATH += \
|
|||||||
plugins \
|
plugins \
|
||||||
$${INCLUDEINTERFACES} \
|
$${INCLUDEINTERFACES} \
|
||||||
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
$${_PRO_FILE_PWD_}/../UpdatePTUDevCtrl \
|
||||||
$${_PRO_FILE_PWD_}/../../ATBUpdateTool/common/include
|
$${_PRO_FILE_PWD_}/../common/include
|
||||||
|
|
||||||
CONFIG += c++17
|
CONFIG += c++17
|
||||||
|
|
||||||
@ -81,13 +81,13 @@ SOURCES += \
|
|||||||
../UpdatePTUDevCtrl/message_handler.cpp \
|
../UpdatePTUDevCtrl/message_handler.cpp \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||||
update.cpp \
|
update.cpp \
|
||||||
../../ATBUpdateTool/common/src/System.cpp
|
../common/src/System.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../UpdatePTUDevCtrl/message_handler.h \
|
../UpdatePTUDevCtrl/message_handler.h \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||||
update.h \
|
update.h \
|
||||||
../../ATBUpdateTool/common/include/System.h
|
../common/include/System.h
|
||||||
|
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
ATBDownloadDCJsonFiles.ini
|
ATBDownloadDCJsonFiles.ini
|
||||||
|
@ -138,7 +138,9 @@ int main(int argc, char **argv) {
|
|||||||
plugInName,
|
plugInName,
|
||||||
workingDir);
|
workingDir);
|
||||||
|
|
||||||
|
//update.checkJsonVersions();
|
||||||
update.doUpdate(filesToUpdate);
|
update.doUpdate(filesToUpdate);
|
||||||
|
update.checkJsonVersions(filesToUpdate);
|
||||||
|
|
||||||
//return a.exec();
|
//return a.exec();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -46,7 +46,7 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
|||||||
qCritical() << "in directory" << plugInDir.absolutePath();
|
qCritical() << "in directory" << plugInDir.absolutePath();
|
||||||
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
qCritical() << "cannot load plugin" << pluginLoader.fileName();
|
||||||
qCritical() << pluginLoader.errorString();
|
qCritical() << pluginLoader.errorString();
|
||||||
exit(-1);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath();
|
||||||
@ -54,25 +54,25 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) {
|
|||||||
|
|
||||||
if (!pluginLoader.isLoaded()) {
|
if (!pluginLoader.isLoaded()) {
|
||||||
qCritical() << pluginLoader.errorString();
|
qCritical() << pluginLoader.errorString();
|
||||||
exit(-2);
|
return nullptr;
|
||||||
}
|
}
|
||||||
QObject *plugin = pluginLoader.instance();
|
QObject *plugin = pluginLoader.instance();
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
qCritical() << "cannot start instance";
|
qCritical() << "cannot start instance";
|
||||||
exit(-3);
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
if (! (hw = qobject_cast<hwinf *>(plugin))) {
|
||||||
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
qCritical() << "cannot cast plugin" << plugin << "to hwinf";
|
||||||
exit(-4);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << pluginLibName << "does not exist";
|
qCritical() << pluginLibName << "does not exist";
|
||||||
exit(-5);
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
qCritical() << "plugins directory" << plugInDir.absolutePath()
|
||||||
<< "does not exist";
|
<< "does not exist";
|
||||||
exit(-6);
|
return nullptr;
|
||||||
}
|
}
|
||||||
return hw;
|
return hw;
|
||||||
}
|
}
|
||||||
@ -131,45 +131,20 @@ Update::Update(QString customerRepository,
|
|||||||
|
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||||
<< 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() {
|
Update::~Update() {
|
||||||
// unloadDCPlugin();
|
unloadDCPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
||||||
|
|
||||||
|
if (!m_hw) {
|
||||||
|
qCritical() << "ERROR!!! m_hw == nullptr";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int tries = 20;
|
int tries = 20;
|
||||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||||
// must deliver 'true', only then are all data from hwapi valid
|
// must deliver 'true', only then are all data from hwapi valid
|
||||||
@ -205,19 +180,16 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
|
||||||
if ((res = updateCashConf(fToWorkOn))) {
|
if ((res = updateCashConf(fToWorkOn))) {
|
||||||
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
if ((res = updateConfig(fToWorkOn))) {
|
||||||
if ((res= updateConfig(fToWorkOn))) {
|
|
||||||
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
|
||||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||||
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
||||||
}
|
}
|
||||||
@ -230,13 +202,18 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||||
|
|
||||||
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
|
||||||
|
|
||||||
uint8_t jsonNr = 0;
|
uint8_t jsonNr = 0;
|
||||||
|
|
||||||
QString const &fName = jsonFileNames[i];
|
QString const &fName = jsonFileNames[i];
|
||||||
|
|
||||||
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 6=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
if (fName.endsWith("conf.json")) {
|
if (fName.endsWith("conf.json")) {
|
||||||
jsonNr = 1;
|
jsonNr = 1;
|
||||||
} else
|
} else
|
||||||
@ -254,31 +231,45 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
bool ok = false;
|
bool ok = false;
|
||||||
int n = captured.toInt(&ok);
|
int n = captured.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
jsonNr = n + 4;
|
jsonNr = n + 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonNr != 0) {
|
if (jsonNr != 0) {
|
||||||
#if 0
|
// send one request for every single version
|
||||||
|
// jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res.
|
||||||
|
// 5=printer template 1 ..... 36= template 32
|
||||||
|
|
||||||
m_hw->sys_requestJsonVersions(jsonNr);
|
m_hw->sys_requestJsonVersions(jsonNr);
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
m_hw->sys_getJsonVersions(jsonNr, buf);
|
m_hw->sys_getJsonVersions(jsonNr, buf);
|
||||||
buf[sizeof(buf)-1] = '\0';
|
buf[16] = '\0'; // the DC only handles 16 bytes
|
||||||
|
|
||||||
QString const installedVersion(buf);
|
static const QByteArray cb(16, (char)0xff);
|
||||||
|
|
||||||
|
QString const installedVersion(QString::fromStdString(buf));
|
||||||
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
QString const fileVersion = getFileVersion(jsonFileNames[i]);
|
||||||
|
|
||||||
qCritical() << "installed version:" << installedVersion;
|
QFileInfo fi(jsonFileNames[i]);
|
||||||
qCritical() << " file version:" << fileVersion;
|
|
||||||
|
qCritical() << endl;
|
||||||
|
qCritical() << " json request nr:" << jsonNr;
|
||||||
|
|
||||||
if (installedVersion == fileVersion) {
|
if (installedVersion == fileVersion) {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
} else
|
||||||
|
if (cb == QByteArray(buf) && fileVersion == "") {
|
||||||
|
qCritical() << "unknown json file (repo and DC):" << fi.fileName();
|
||||||
|
} else {
|
||||||
|
qCritical() << " json file:" << fi.fileName();
|
||||||
|
qCritical() << " installed version in DC:" << installedVersion;
|
||||||
|
qCritical() << " file version in repository:" << fileVersion;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
|
||||||
@ -288,6 +279,39 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Update::getFileVersion(QString const& jsonFileName) {
|
||||||
|
// "version":"15.10.2023 14:55 02.00.06",
|
||||||
|
static const QRegularExpression re("^.*(\\\"[Vv]ersion\\\":)([\\s\\\"]{0,})([^,\\\"]{0,}).*$");
|
||||||
|
|
||||||
|
QString fileVersion("");
|
||||||
|
QFile inputFile(QDir::cleanPath(m_customerRepository + QDir::separator() + jsonFileName));
|
||||||
|
|
||||||
|
if (inputFile.exists()) {
|
||||||
|
if (inputFile.open(QIODevice::ReadOnly)) {
|
||||||
|
QTextStream in(&inputFile);
|
||||||
|
while (!in.atEnd()) {
|
||||||
|
QString line = in.readLine();
|
||||||
|
|
||||||
|
QRegularExpressionMatch match;
|
||||||
|
int idx = line.indexOf(re, 0, &match);
|
||||||
|
if (idx != -1) {
|
||||||
|
int const lastCaptured = match.lastCapturedIndex();
|
||||||
|
// the dc only sends 16 Byte
|
||||||
|
fileVersion = match.captured(lastCaptured);
|
||||||
|
fileVersion.truncate(16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputFile.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// qCritical() << "ERROR" << inputFile.fileName() << "does not exist";
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileVersion;
|
||||||
|
}
|
||||||
|
|
||||||
bool Update::downloadJson(enum FileTypeJson type,
|
bool Update::downloadJson(enum FileTypeJson type,
|
||||||
int templateIdx,
|
int templateIdx,
|
||||||
QString jsFileToSendToDC) const {
|
QString jsFileToSendToDC) const {
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include <DeviceController/interfaces.h>
|
#include <DeviceController/interfaces.h>
|
||||||
|
|
||||||
#ifdef PTU5
|
#ifdef PTU5
|
||||||
@ -67,7 +69,46 @@ public:
|
|||||||
QString jsFileToSendToDC) const;
|
QString jsFileToSendToDC) const;
|
||||||
|
|
||||||
|
|
||||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
QString getFileVersion(QString const& jsonFileName);
|
||||||
|
bool checkJsonVersions(QStringList const& jsonFileNames =
|
||||||
|
QStringList(
|
||||||
|
QList(
|
||||||
|
std::initializer_list<QString>{
|
||||||
|
QString("etc/psa_config/DC2C_conf.json"),
|
||||||
|
QString("etc/psa_config/DC2C_cash.json"),
|
||||||
|
QString("etc/psa_config/DC2C_device.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print01.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print02.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print03.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print04.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print05.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print06.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print07.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print08.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print09.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print10.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print11.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print12.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print13.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print14.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print15.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print16.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print17.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print18.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print19.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print20.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print21.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print22.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print23.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print24.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print25.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print26.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print27.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print28.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print29.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print30.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print31.json"),
|
||||||
|
QString("etc/psa_config/DC2C_print32.json")})));
|
||||||
/*
|
/*
|
||||||
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user