save files with comment
This commit is contained in:
@@ -79,6 +79,7 @@ int main(int argc, char **argv) {
|
||||
bool const showExtendedVersion = parser.extendedVersion();
|
||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||
Update::setPPid(parser.ppid());
|
||||
|
||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
@@ -88,29 +89,32 @@ int main(int argc, char **argv) {
|
||||
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() << "psaConfigDir ............." << psaConfigDir;
|
||||
qInfo() << "psaTariffDir ............." << psaTariffDir;
|
||||
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 (Update::ppid() == -1) {
|
||||
qInfo() << "pwd ......................" << rtPath;
|
||||
qInfo() << "repositoryUrl ............" << repositoryUrl;
|
||||
qInfo() << "plugInDir ................" << plugInDir;
|
||||
qInfo() << "plugInName ..............." << plugInName;
|
||||
qInfo() << "workingDir ..............." << workingDir;
|
||||
qInfo() << "psaConfigDir ............." << psaConfigDir;
|
||||
qInfo() << "psaTariffDir ............." << psaTariffDir;
|
||||
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;
|
||||
qInfo() << "parent pid ..............." << Update::ppid();
|
||||
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
@@ -121,7 +125,10 @@ int main(int argc, char **argv) {
|
||||
if (mountPath.has_value()) {
|
||||
filesToUpdate = System::getJsonFilesOnUsbStick(mountPath.value());
|
||||
} else {
|
||||
qCritical() << "Using customer repository" << customerRepo;
|
||||
|
||||
if (Update::ppid() == -1) {
|
||||
qCritical() << "Using customer repository" << customerRepo;
|
||||
}
|
||||
|
||||
QDir dir(QDir::cleanPath(customerRepo + QDir::separator() + "etc/psa_config"));
|
||||
if (dir.exists()) {
|
||||
@@ -146,13 +153,16 @@ int main(int argc, char **argv) {
|
||||
plugInName,
|
||||
workingDir);
|
||||
|
||||
update.doUpdate(filesToUpdate, mountPath.has_value());
|
||||
update.checkJsonVersions();
|
||||
update.doUpdate();
|
||||
// update.doUpdate(filesToUpdate, mountPath.has_value());
|
||||
// update.checkJsonVersions();
|
||||
//update.checkJsonVersions(filesToUpdate);
|
||||
|
||||
if (mountPath.has_value()) {
|
||||
System::umountUSBStick();
|
||||
}
|
||||
|
||||
qInfo() << "<JS-UPDATE-FINISH>";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -21,10 +21,13 @@
|
||||
#include <QDateTime>
|
||||
#include <QPluginLoader>
|
||||
#include <QMap>
|
||||
#include <cmath>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
|
||||
qint64 Update::c_ppid = -1;
|
||||
|
||||
static const QMap<QString, int> baudrateMap = {
|
||||
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
|
||||
{"57600" , 4}, {"115200" , 5}
|
||||
@@ -104,7 +107,7 @@ Update::Update(QString customerRepository,
|
||||
char const *serialInterface,
|
||||
char const *baudrate)
|
||||
: QObject(parent)
|
||||
, m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||
// , m_hw(loadDCPlugin(QDir(plugInDir), pluginName))
|
||||
, m_serialInterface(serialInterface)
|
||||
, m_baudrate(baudrate)
|
||||
, m_customerRepository(customerRepository)
|
||||
@@ -115,27 +118,65 @@ Update::Update(QString customerRepository,
|
||||
, 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);
|
||||
}
|
||||
m_start = QDateTime::currentDateTime();
|
||||
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
if (Update::ppid() == -1) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Update::~Update() {
|
||||
unloadDCPlugin();
|
||||
// unloadDCPlugin();
|
||||
}
|
||||
|
||||
bool Update::doUpdate() {
|
||||
|
||||
int numberOfFiles = 3;
|
||||
|
||||
QString s = nextTimePoint();
|
||||
s += " sending ";
|
||||
s += QString("%1 ...done <JS-PROGRESS>").arg("DC2C_cash.json");
|
||||
s += QString::number(ceil(((1 * 100.0) / (double)numberOfFiles)));
|
||||
|
||||
qInfo() << s.toUtf8().constData();
|
||||
|
||||
QThread::msleep(2000);
|
||||
|
||||
s = nextTimePoint();
|
||||
s += " sending ";
|
||||
s += QString("%1 ...done <JS-PROGRESS>").arg("DC2C_device.json");
|
||||
s += QString::number(ceil(((2 * 100.0) / (double)numberOfFiles)));
|
||||
|
||||
qInfo() << s.toUtf8().constData();
|
||||
|
||||
QThread::msleep(2000);
|
||||
|
||||
s = nextTimePoint();
|
||||
s += " sending ";
|
||||
s += QString("%1 ...done <JS-PROGRESS>").arg("DC2C_print01.json");
|
||||
s += QString::number(ceil(((3 * 100.0) / (double)numberOfFiles)));
|
||||
|
||||
qInfo() << s.toUtf8().constData();
|
||||
|
||||
QThread::msleep(2000);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QProcess>
|
||||
#include <QPluginLoader>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
@@ -36,6 +37,14 @@ class Update : public QObject {
|
||||
|
||||
static QPluginLoader pluginLoader;
|
||||
|
||||
QDateTime m_start;
|
||||
QString nextTimePoint() const {
|
||||
float const secs = m_start.msecsTo(QDateTime::currentDateTime()) / 1000.0;
|
||||
return QStringLiteral("+%1s").arg(secs, 7, 'f', 2, QChar('0'));
|
||||
}
|
||||
|
||||
static qint64 c_ppid;
|
||||
|
||||
public:
|
||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
||||
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
|
||||
@@ -44,6 +53,8 @@ public:
|
||||
static bool unloadDCPlugin();
|
||||
static QStringList split(QString line, QChar sep = ',');
|
||||
|
||||
static qint64 ppid() { return c_ppid; }
|
||||
static void setPPid(qint64 ppid) { c_ppid = ppid; }
|
||||
|
||||
explicit Update(QString customerRepository,
|
||||
QString customerNrStr,
|
||||
@@ -59,6 +70,7 @@ public:
|
||||
virtual ~Update() override;
|
||||
|
||||
bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false);
|
||||
bool doUpdate();
|
||||
|
||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||
bool updateConfig(QString jsFileToSendToDC);
|
||||
|
Reference in New Issue
Block a user