Additinal UPDATE_STATE constants.
Added struct UpdateStatus for printing debug messages. Added member variables used for sending SENDCMD to ISMAS.A Added helper functions getATBQTVersion(), getCPUSerial(), getRaucVersion(), getOpkgVersion(), getPluginVersion(), getDCVersion(), getFileSize(). Removed automatic restart of Apism. Added emergency timer to end application after 10 mintes. onHandleChangedFilenames(): handling of opkg_commands handling of json/dc -> deactivated for the moment. Re-implemented onSendCmdSendVersionToIsmas(): use only one parameter of type PSAInstalled. Implemented operators<<() to print debug messages.
This commit is contained in:
parent
088d7c8aa0
commit
0e0363f131
442
worker.cpp
442
worker.cpp
@ -43,7 +43,8 @@ Worker::Worker(hwinf *hw,
|
||||
QObject *parent,
|
||||
char const *serialInterface,
|
||||
char const *baudrate)
|
||||
: m_workerThread("workerThread")
|
||||
: m_hw(hw)
|
||||
, m_workerThread("workerThread")
|
||||
, m_apismClient(0, 0, 0, this) // TODO
|
||||
, m_customerNr(customerNr)
|
||||
, m_customerNrStr(QString("customer_") + QString::number(m_customerNr).rightJustified(3, '0'))
|
||||
@ -51,10 +52,22 @@ Worker::Worker(hwinf *hw,
|
||||
, m_zoneNr(zoneNr)
|
||||
, m_workingDirectory(workingDirectory)
|
||||
, m_branchName(branchName)
|
||||
, m_customerRepositoryPath(QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(m_customerNrStr))
|
||||
, m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr))
|
||||
, m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this)
|
||||
, m_maintenanceMode(maintenanceMode)
|
||||
, m_osVersion(getOsVersion())
|
||||
, m_atbqtVersion(getATBQTVersion())
|
||||
, m_cpuSerial(getCPUSerial())
|
||||
, m_raucVersion(getRaucVersion())
|
||||
, m_opkgVersion(getOpkgVersion())
|
||||
, m_pluginVersionATBDeciceController(getPluginVersion("/opt/app/ATBAPP/plugins/libATBDeviceControllerPlugin.so"))
|
||||
, m_pluginVersionIngenicoISelf(getPluginVersion("/opt/app/ATBAPP/plugins/libIngenicoISelf_CCPlugin.so"))
|
||||
, m_pluginVersionMobilisisCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin.so"))
|
||||
, m_pluginVersionMobilisisCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libMOBILISIS_CalculatePricePlugin_ConfigUi.so"))
|
||||
, m_pluginVersionPrmCalc(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin.so"))
|
||||
, m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so"))
|
||||
, m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so"))
|
||||
, m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS)
|
||||
, m_waitForNewUpdates(this) {
|
||||
|
||||
@ -62,21 +75,23 @@ Worker::Worker(hwinf *hw,
|
||||
|
||||
qInfo() << "CURRENT TIME ..............." << QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||
qInfo() << "OS VERSION ................." << m_osVersion;
|
||||
qInfo() << "ATBQT VERSION .............." << m_atbqtVersion;
|
||||
qInfo() << "CPU SERIAL ................." << m_cpuSerial;
|
||||
qInfo() << "CUSTOMER_NR ................" << m_customerNr;
|
||||
qInfo() << "CUSTOMER_NR_STR ............" << m_customerNrStr;
|
||||
qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << QString("https://git.mimbach49.de/GerhardHoffmann/%1.git").arg(m_customerNrStr);
|
||||
qInfo() << "CUSTOMER_REPOSITORY_PATH ..." << m_customerRepositoryPath;
|
||||
qInfo() << "CUSTOMER_REPOSITORY ........" << m_customerRepository;
|
||||
qInfo() << "MACHINE_NR ................." << m_machineNr;
|
||||
qInfo() << "ZONE_NR ...................." << m_zoneNr;
|
||||
qInfo() << "BRANCH_NAME ................" << m_branchName;
|
||||
qInfo() << "WORKING_DIRECTORY .........." << m_workingDirectory;
|
||||
|
||||
QProcess p;
|
||||
p.start("/bin/systemctl", {"restart", "apism"});
|
||||
if (!p.waitForStarted(5000) || !p.waitForFinished(5000)) {
|
||||
qCritical() << "APISM-RESTART-FAILURE";
|
||||
return;
|
||||
}
|
||||
//QProcess p;
|
||||
//p.start("/bin/systemctl", {"restart", "apism"});
|
||||
//if (!p.waitForStarted(5000) || !p.waitForFinished(5000)) {
|
||||
// qCritical() << "APISM-RESTART-FAILURE";
|
||||
// return;
|
||||
//}
|
||||
|
||||
this->moveToThread(&m_workerThread);
|
||||
m_workerThread.start();
|
||||
@ -105,15 +120,22 @@ Worker::Worker(hwinf *hw,
|
||||
connect(this, SIGNAL(terminateUpdateProcess()), this,
|
||||
SLOT(onTerminateUpdateProcess()), Qt::QueuedConnection);
|
||||
|
||||
connect(&m_emergencyTimer, SIGNAL(timeout()), this, SLOT(onTerminateUpdateProcess()), Qt::QueuedConnection);
|
||||
m_emergencyTimer.setSingleShot(true);
|
||||
m_emergencyTimer.start(1000 * 60 * 10);
|
||||
|
||||
QDir customerRepository(m_customerRepository);
|
||||
if (!customerRepository.exists()) {
|
||||
if (m_gc.gitCloneAndCheckoutBranch()) {
|
||||
// do nothing else, not even executing opkg-commands
|
||||
onFinishUpdateProcess(false);
|
||||
emit this->finishUpdateProcess(false);
|
||||
}
|
||||
} else {
|
||||
m_update = new Update(hw, m_customerRepository, m_customerNrStr,
|
||||
m_branchName, m_workingDirectory,
|
||||
m_update = new Update(m_hw,
|
||||
m_customerRepository,
|
||||
m_customerNrStr,
|
||||
m_branchName,
|
||||
m_workingDirectory,
|
||||
dryRun, parent, serialInterface, baudrate);
|
||||
|
||||
connect(&m_startUpdateProcess, SIGNAL(timeout()), this, SLOT(askIsmasForNewData()), Qt::QueuedConnection);
|
||||
@ -150,36 +172,111 @@ QString Worker::getOsVersion() const {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getATBQTVersion() const {
|
||||
QString const cmd = QString("echo -n $(/opt/app/ATBAPP/ATBQT -v | head -n 2 | cut -d':' -f2)");
|
||||
Command c("bash");
|
||||
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult();
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getCPUSerial() const {
|
||||
QString const cmd = QString("echo -n $(cat /proc/cpuinfo | grep -i Serial | cut -d':' -f2)");
|
||||
Command c("bash");
|
||||
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult();
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getRaucVersion() const {
|
||||
QString const cmd = QString("echo -n $(rauc --version)");
|
||||
Command c("bash");
|
||||
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult();
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getOpkgVersion() const {
|
||||
QString const cmd = QString("echo -n $(opkg --version)");
|
||||
Command c("bash");
|
||||
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult();
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QString Worker::getPluginVersion(QString const &pluginFileName) const {
|
||||
QString const cmd = QString("echo -n $(strings %1 | grep \\\"Version\\\" | cut -d':' -f2 | tr -d '\"' | tr -d ',')").arg(pluginFileName);
|
||||
Command c("bash");
|
||||
if (c.execute(m_workingDirectory, QStringList() << "-c" << cmd)) {
|
||||
return c.getCommandResult();
|
||||
}
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
QStringList Worker::getDCVersion() const {
|
||||
QStringList lst = (QStringList() << "N/A" << "N/A");
|
||||
if (m_hw) {
|
||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||
|
||||
QByteArray const cmp(8, char(0));
|
||||
QByteArray hw(""), sw("");
|
||||
for (int i=0; i<5; ++i) {
|
||||
hw = m_hw->dc_getHWversion().toUtf8();
|
||||
sw = m_hw->dc_getSWversion().toUtf8();
|
||||
if (!hw.startsWith(cmp)) {
|
||||
lst.clear();
|
||||
qInfo() << hw << sw;
|
||||
lst << hw << sw;
|
||||
break;
|
||||
}
|
||||
QThread::sleep(1);
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
qint64 Worker::getFileSize(QString const &fileName) const {
|
||||
// fileName has to be an absolute path
|
||||
QFileInfo fInfo(fileName);
|
||||
return fInfo.exists() ? fInfo.size() : -1;
|
||||
}
|
||||
|
||||
void Worker::onHandleChangedFiles(QStringList changedFiles) {
|
||||
qCritical() << QDir::currentPath() << "ON HANDLE CHANGED FILES" << changedFiles;
|
||||
|
||||
QString opkg_commands;
|
||||
static const QRegularExpression re("^.*opkg_commands\\s*$");
|
||||
static const QRegularExpression comment("^\\s*#.*$");
|
||||
int idx = changedFiles.indexOf(re);
|
||||
if (idx != -1) {
|
||||
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMANDS_REQUEST;
|
||||
m_statusDescription = "EXECUTE OPKG COMMANDS";
|
||||
|
||||
opkg_commands = changedFiles.takeAt(idx);
|
||||
|
||||
QFile f(opkg_commands);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream in(&f);
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
if (line.indexOf(comment, 0) == -1) {
|
||||
// found opkg command
|
||||
QString opkgCommand = line.trimmed();
|
||||
executeOpkgCommand(opkgCommand);
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMANDS,
|
||||
QString("EXEC OPKG-COMMANDS FOR ") + opkg_commands);
|
||||
|
||||
if (QDir::setCurrent(m_customerRepository)) {
|
||||
QFile f(opkg_commands);
|
||||
if (f.exists()) {
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QTextStream in(&f);
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
if (line.indexOf(comment, 0) == -1) {
|
||||
// found opkg command
|
||||
QString opkgCommand = line.trimmed();
|
||||
executeOpkgCommand(opkgCommand);
|
||||
}
|
||||
}
|
||||
f.close();
|
||||
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS,
|
||||
QString("EXECUTING OPKG-COMMANDS OK"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS;
|
||||
// m_statusDescription = QString("EXECUTE OPKG COMMANDS %1 OK").arg(opkgCommands.join('\n'));
|
||||
|
||||
f.close();
|
||||
}
|
||||
|
||||
if (m_update->doUpdate(changedFiles)) { // first update the hardware
|
||||
@ -213,7 +310,7 @@ void Worker::onHandleChangedFiles(QStringList changedFiles) {
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
onFinishUpdateProcess(true);
|
||||
emit this->finishUpdateProcess(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -277,11 +374,14 @@ void Worker::executeOpkgCommand(QString opkgCommand) {
|
||||
Command c(opkgCommand);
|
||||
if (c.execute(m_workingDirectory)) {
|
||||
QString const r = c.getCommandResult();
|
||||
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS;
|
||||
m_statusDescription = QString("EXECUTE OPKG COMMAND %1 OK").arg(opkgCommand);
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS,
|
||||
QString("EXECUTE OPKG COMMAND %1 OK: %2")
|
||||
.arg(opkgCommand)
|
||||
.arg(c.getCommandResult()));
|
||||
} else {
|
||||
m_updateStatus = UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE;
|
||||
m_statusDescription = QString("EXECUTE OPKG COMMAND %1 FAILED").arg(opkgCommand);
|
||||
qCritical() << UpdateStatus(UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE,
|
||||
QString("EXECUTE OPKG COMMAND %1 FAILED")
|
||||
.arg(opkgCommand));
|
||||
onTerminateUpdateProcess();
|
||||
return;
|
||||
}
|
||||
@ -289,8 +389,14 @@ void Worker::executeOpkgCommand(QString opkgCommand) {
|
||||
|
||||
// sollte ParameterResponse heissen
|
||||
void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
|
||||
|
||||
qInfo() << "IN ON_ISMAS_RESPONSE_RECEIVED" << QThread::currentThread()->objectName();
|
||||
|
||||
if (!ismasResponse.isEmpty()) {
|
||||
QStringList const keys = ismasResponse.keys();
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED,
|
||||
QString("RECEIVED JSON WITH KEYS: ") + keys.join(","));
|
||||
|
||||
static QRegularExpression re("^REQ_ISMASPARAMETER.*");
|
||||
if(keys.indexOf(re) >= 0) {
|
||||
m_waitForNewUpdates.stop(); // stop asking ISMAS for updates
|
||||
@ -328,10 +434,19 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
|
||||
if (!v.isNull() && !v.isUndefined()) {
|
||||
QString const s = v.toString("");
|
||||
if (s == "WAIT") {
|
||||
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS;
|
||||
m_ismasUpdateRequests = ISMAS_UPDATE_REQUESTS;
|
||||
m_statusDescription = "ISMAS UPDATES AVAILABLE";
|
||||
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS,
|
||||
"DETECTED AVAILABLE ISMAS-DOWNLOAD");
|
||||
|
||||
QString const &data = m_ismasClient.updateOfPSAActivated();
|
||||
m_apismClient.onSendCmdEventToIsmas(data);
|
||||
|
||||
emit m_gc.ismasUpdatesAvailable();
|
||||
} else {
|
||||
// TODO: enorm wichtig
|
||||
qCritical() << "DID NOT RECEIVE 'WAIT' BUT" << s;
|
||||
onTerminateUpdateProcess();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -339,6 +454,7 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
|
||||
m_statusDescription = "NO FILEUPLOAD KEY AVAILABLE";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_FAILURE;
|
||||
@ -347,64 +463,108 @@ void Worker::onIsmasResponseReceived(QJsonObject ismasResponse) {
|
||||
}
|
||||
|
||||
void Worker::onFinishUpdateProcess(bool changes) {
|
||||
qCritical() << "ON FINISH UPDATE PROCESS. CHANGES=" << changes;
|
||||
Q_UNUSED(changes);
|
||||
|
||||
qInfo() << "ON FINISH UPDATE PROCESS" << QThread::currentThread()->objectName();
|
||||
// m_emergencyTimer.stop();
|
||||
|
||||
onSendCmdSendVersionToIsmas(); // final message to ISMAS
|
||||
|
||||
m_workerThread.quit();
|
||||
QApplication::quit();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
void Worker::onTerminateUpdateProcess() {
|
||||
qCritical() << "ON TERMINATE UPDATE PROCESS";
|
||||
|
||||
onSendCmdSendVersionToIsmas(); // final message to ISMAS
|
||||
|
||||
m_workerThread.quit();
|
||||
QApplication::quit();
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void Worker::onSendCmdSendVersionToIsmas() {
|
||||
|
||||
QString const tariffVersion = "0.0.1";
|
||||
QString const tariffProject = "test_project";
|
||||
int tariffZone = 1;
|
||||
QString const tariffInfo = "test_tariff_info";
|
||||
QString const tariffLoadTime = QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
// QString const linuxVersion = "test_linux_version";
|
||||
QString const cpuSerial = "test_cpu_serial";
|
||||
QString const deviceControllerVersion = "test_dc_version";
|
||||
QString const deviceControllerGitBlob = "test_dc_blob_2a3b4f50";
|
||||
QString const deviceControllerGitLastCommit = "test_dc_commit_12345abc";
|
||||
QString const raucVersion = "test_rauc_version";
|
||||
QString const opkgVersion = "test_opkg_version";
|
||||
QString const atbQTVersion = "test_qtbqt_version";
|
||||
QString const atbQTGitDescribe = "test_atbqt_git_describe";
|
||||
QString const deviceControllerPluginVersion = "test_CAmaster_version";
|
||||
QString const ingenicoISelfCCPluginVersion = "test_ingenico_plugin_version";
|
||||
QString const mobilisisCalculatePricePluginVersion = "test_mobilisis_plugin_version";
|
||||
QString const mobilisisCalculatePriceConfigUiVersion = "test_mobilisis_config_ui_plugin";
|
||||
QString const prmCalculatePricePluginVersion = "test_prm_calculate_price_plugin";
|
||||
QString const prmCalculatePriceConfigUiPluginVersion = "test_prm_calculate_price_config_ui_plugin";
|
||||
QString const tcpZVTPluginVersion = "test_tcp_zvt_plugin";
|
||||
QStringList const dcVersion = getDCVersion();
|
||||
QString const deviceControllerVersionHW = dcVersion.first();
|
||||
QString const deviceControllerVersionSW = dcVersion.last();
|
||||
|
||||
QString data = m_ismasClient.updateOfPSASendVersion(tariffVersion,
|
||||
tariffProject,
|
||||
tariffZone,
|
||||
tariffInfo,
|
||||
tariffLoadTime,
|
||||
m_osVersion,
|
||||
cpuSerial,
|
||||
deviceControllerVersion,
|
||||
deviceControllerGitBlob,
|
||||
deviceControllerGitLastCommit,
|
||||
raucVersion,
|
||||
opkgVersion,
|
||||
atbQTVersion,
|
||||
atbQTGitDescribe,
|
||||
deviceControllerPluginVersion,
|
||||
ingenicoISelfCCPluginVersion,
|
||||
mobilisisCalculatePricePluginVersion,
|
||||
mobilisisCalculatePriceConfigUiVersion,
|
||||
prmCalculatePricePluginVersion,
|
||||
prmCalculatePriceConfigUiPluginVersion,
|
||||
tcpZVTPluginVersion);
|
||||
m_apismClient.sendCmdSendVersionToIsmas(data);
|
||||
qInfo() << "CURRENT DC-HW-VERSION: " << deviceControllerVersionHW;
|
||||
qInfo() << "CURRENT DC-SW-VERSION: " << deviceControllerVersionSW;
|
||||
|
||||
QString const deviceControllerGitBlob = "N/A";
|
||||
QString const deviceControllerGitLastCommit = "N/A";
|
||||
|
||||
PSAInstalled psaInstalled;
|
||||
QString printSysDir("/etc/psa_config");
|
||||
QString tariffSysDir("/etc/psa_tariff");
|
||||
QString absPathName;
|
||||
|
||||
if (m_zoneNr != 0) {
|
||||
QString const &n = QString("%1").arg(m_zoneNr).rightJustified(2, '0');
|
||||
psaInstalled.tariff.name = QString("tariff%1.json").arg(n);
|
||||
absPathName = QDir::cleanPath(tariffSysDir + QDir::separator() + psaInstalled.tariff.name);
|
||||
psaInstalled.tariff.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.tariff.size = getFileSize(absPathName);
|
||||
psaInstalled.tariff.zone = m_zoneNr;
|
||||
}
|
||||
psaInstalled.tariff.project = "Szeged";
|
||||
psaInstalled.tariff.info = "N/A";
|
||||
psaInstalled.tariff.loadTime = "N/A"; // QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
|
||||
psaInstalled.tariff.version = "N/A";
|
||||
|
||||
psaInstalled.hw.linuxVersion = m_osVersion;
|
||||
psaInstalled.hw.cpuSerial = m_cpuSerial;
|
||||
|
||||
psaInstalled.dc.versionHW = deviceControllerVersionHW;
|
||||
psaInstalled.dc.versionSW = deviceControllerVersionSW;
|
||||
psaInstalled.dc.gitBlob = "N/A";
|
||||
psaInstalled.dc.gitLastCommit = "N/A";
|
||||
psaInstalled.dc.size = -1;
|
||||
|
||||
psaInstalled.sw.raucVersion = m_raucVersion;
|
||||
psaInstalled.sw.opkgVersion = m_opkgVersion;
|
||||
psaInstalled.sw.atbQTVersion = m_atbqtVersion;
|
||||
|
||||
psaInstalled.pluginVersion.deviceController = m_pluginVersionATBDeciceController;
|
||||
psaInstalled.pluginVersion.ingenicoISelfCC = m_pluginVersionIngenicoISelf;
|
||||
psaInstalled.pluginVersion.mobilisisCalculatePrice = m_pluginVersionMobilisisCalc;
|
||||
psaInstalled.pluginVersion.mobilisisCalculatePriceConfigUi = m_pluginVersionMobilisisCalcConfig;
|
||||
psaInstalled.pluginVersion.prmCalculatePrice = m_pluginVersionPrmCalc;
|
||||
psaInstalled.pluginVersion.prmCalculatePriceConfigUi = m_pluginVersionPrmCalcConfig;
|
||||
psaInstalled.pluginVersion.tcpZVT = m_pluginVersionTcpZvt;
|
||||
|
||||
psaInstalled.cash.name = "DC2C_cash.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.cash.name);
|
||||
psaInstalled.cash.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.cash.size = getFileSize(absPathName);
|
||||
|
||||
psaInstalled.conf.name = "DC2C_conf.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.conf.name);
|
||||
psaInstalled.conf.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.conf.size = getFileSize(absPathName);
|
||||
|
||||
psaInstalled.device.name = "DC2C_device.json";
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.device.name);
|
||||
psaInstalled.device.blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.device.size = getFileSize(absPathName);
|
||||
|
||||
for (int i=0; i < 32; ++i) {
|
||||
QString const &n = QString("%1").arg(i+1).rightJustified(2, '0');
|
||||
psaInstalled.print[i].name = QString("DC2C_print%1.json").arg(n);
|
||||
absPathName = QDir::cleanPath(printSysDir + QDir::separator() + psaInstalled.print[i].name);
|
||||
psaInstalled.print[i].blob = m_gc.gitBlob(absPathName);
|
||||
psaInstalled.print[i].size = getFileSize(absPathName);
|
||||
}
|
||||
|
||||
QString data = m_ismasClient.updateOfPSASendVersion(psaInstalled);
|
||||
|
||||
// printf("data=%s\n", data.toStdString().c_str());
|
||||
|
||||
m_apismClient.onSendCmdSendVersionToIsmas(data);
|
||||
}
|
||||
|
||||
void Worker::askIsmasForNewData() {
|
||||
@ -413,7 +573,14 @@ void Worker::askIsmasForNewData() {
|
||||
QString data = m_ismasClient.setUpdatesAvailable();
|
||||
m_apismClient.emulateUpdatesAvailable(data);
|
||||
}
|
||||
m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING;
|
||||
|
||||
//m_updateStatus = UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING;
|
||||
//m_statusDescription = "Ask ISMAS IF NEW DATA AVAILABLE";
|
||||
|
||||
qInfo() << UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING,
|
||||
QString("ASK ISMAS IF NEW DATA AVAILABLE") +
|
||||
QString(" (%1)").arg(m_ismasUpdateRequests));
|
||||
|
||||
m_apismClient.requestAvailableIsmasUpdates();
|
||||
|
||||
if (--m_ismasUpdateRequests > 0) {
|
||||
@ -425,3 +592,116 @@ void Worker::askIsmasForNewData() {
|
||||
onTerminateUpdateProcess();
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* operators
|
||||
*/
|
||||
QDebug operator<< (QDebug debug, UpdateStatus status) {
|
||||
switch(status.m_updateStatus) {
|
||||
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING:
|
||||
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS:
|
||||
debug << QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST:
|
||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
|
||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
|
||||
debug << QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
||||
debug << QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
|
||||
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_REQUEST: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
|
||||
debug << QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
|
||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
|
||||
debug << QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ")
|
||||
<< status.m_statusDescription;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return debug;
|
||||
}
|
||||
|
||||
QString& operator<< (QString& str, UpdateStatus status) {
|
||||
switch(status.m_updateStatus) {
|
||||
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING:
|
||||
str = QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_PENDING: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS:
|
||||
str = QString("UPDATE_STATUS::ISMAS_UPDATE_REQUEST_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST:
|
||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE:
|
||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_FAILURE: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS:
|
||||
str = QString("UPDATE_STATUS::GIT_FETCH_UPDATES_REQUEST_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS:
|
||||
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE:
|
||||
str = QString("UPDATE_STATUS::GIT_PULL_UPDATES_FAILURE: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED:
|
||||
str = QString("UPDATE_STATUS::ISMAS_RESPONSE_RECEIVED: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS:
|
||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS:
|
||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMANDS_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS:
|
||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_SUCCESS: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
case UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE:
|
||||
str = QString("UPDATE_STATUS::EXEC_OPKG_COMMAND_FAILURE: ");
|
||||
str += status.m_statusDescription;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user