From 6caaae6d50e58930a73dcaebfe5180c675d73f14 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 19 Jul 2023 16:48:42 +0200 Subject: [PATCH] Add struct PSAInstalled. Changed interface of updateOfPSASendVersion into QString updateOfPSASendVersion(PSAInstalled const &psa); Re-implemented updateOfPSASendVersion(). --- ismas/ismas_client.cpp | 296 ++++++++++++++++++++++++++++++++++------- ismas/ismas_client.h | 126 +++++++++++++++--- 2 files changed, 354 insertions(+), 68 deletions(-) diff --git a/ismas/ismas_client.cpp b/ismas/ismas_client.cpp index 8f957fc..7c57811 100644 --- a/ismas/ismas_client.cpp +++ b/ismas/ismas_client.cpp @@ -53,32 +53,13 @@ QString IsmasClient::updateNewsToIsmas(char const *event, return buf; } -QString IsmasClient::updateOfPSASendVersion(QString const &tariffVersion, - QString const &tariffProject, - int tariffZone, - QString const &tariffInfo, - QString const &tariffLoadTime, - QString const &linuxVersion, - QString const &cpuSerial, - QString const &deviceControllerVersion, - QString const &deviceControllerGitBlob, - QString const &deviceControllerGitLastCommit, - QString const &raucVersion, - QString const &opkgVersion, - QString const &atbQTVersion, - QString const &atbQTGitDescribe, - QString const &deviceControllerPluginVersion, - QString const &ingenicoISelfCCPluginVersion, - QString const &mobilisisCalculatePricePluginVersion, - QString const &mobilisisCalculatePriceConfigUiVersion, - QString const &prmCalculatePricePluginVersion, - QString const &prmCalculatePriceConfigUiPluginVersion, - QString const &tcpZVTPluginVersion) { - char buf[4096]; +QString IsmasClient::updateOfPSASendVersion(PSAInstalled const &psa) { + //static int const constexpr SIZE = 4096*8; + static char buf[4096*2]; memset(buf, 0, sizeof(buf)); QString const ts = QDateTime::currentDateTime().toString(Qt::ISODateWithMs); - QString sendVersionHash; + QString sendVersionHash = "N/A"; // local data="#M=APISM#C=CMD_SENDVERSION#J= snprintf(buf, sizeof(buf)-1, @@ -92,8 +73,152 @@ QString IsmasClient::updateOfPSASendVersion(QString const &tariffVersion, "\"PROJECT\" : \"%s\"," "\"ZONE\" : %d," "\"INFO\" : \"%s\"," + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d," "\"LOADED\" : \"%s\"" "}," + "\"JSON\" : {" + "\"DC2C_CASH\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_CONF\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_DEVICE\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_01\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_02\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_03\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_04\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_05\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_06\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_07\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_08\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_09\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_10\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_11\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_12\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_13\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_14\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_15\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_16\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_17\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_18\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_19\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_20\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_21\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_22\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_23\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_24\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_25\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_26\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_27\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_28\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_29\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_30\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_31\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}," + "\"DC2C_PRINT_32\" : {" + "\"BLOB\" : \"%s\"," + "\"SIZE\" : %d" + "}" + "}," "\"HARDWARE\" : {" "\"DEVICES\" : [\"PTU5\", \"DC\", \"PRINTER\", \"BNA\"]" "}," @@ -105,7 +230,9 @@ QString IsmasClient::updateOfPSASendVersion(QString const &tariffVersion, "\"CPU_SERIAL\" : \"%s\"" "}," "\"DC\" : {" - "\"VERSION\" : \"%s\"," + "\"HW-VERSION\" : \"%s\"," + "\"SW-VERSION\" : \"%s\"," + "\"SIZE\" : %d," "\"GITBLOB\" : \"%s\"," "\"GITLASTCOMMIT\" : \"%s\"" "}," @@ -118,8 +245,7 @@ QString IsmasClient::updateOfPSASendVersion(QString const &tariffVersion, "\"RAUC\" : \"%s\"," "\"OPKG\" : \"%s\"," "\"ATBQT\" : {" - "\"VERSION\" : \"%s\"," - "\"GIT_DESCRIBE\" : \"%s\"" + "\"VERSION\" : \"%s\"" "}" "}," "\"PLUGINS\" : {" @@ -149,32 +275,108 @@ QString IsmasClient::updateOfPSASendVersion(QString const &tariffVersion, ts.toStdString().c_str(), sendVersionHash.toStdString().c_str(), - tariffVersion.toStdString().c_str(), - tariffProject.toStdString().c_str(), - tariffZone, - tariffInfo.toStdString().c_str(), - tariffLoadTime.toStdString().c_str(), + psa.tariff.version.toStdString().c_str(), + psa.tariff.project.toStdString().c_str(), + psa.tariff.zone, + psa.tariff.info.toStdString().c_str(), + psa.tariff.blob.toStdString().c_str(), + psa.tariff.size, + psa.tariff.loadTime.toStdString().c_str(), - linuxVersion.toStdString().c_str(), + psa.cash.blob.toStdString().c_str(), + psa.cash.size, + psa.conf.blob.toStdString().c_str(), + psa.conf.size, + psa.device.blob.toStdString().c_str(), + psa.device.size, - cpuSerial.toStdString().c_str(), + psa.print[0].blob.toStdString().c_str(), + psa.print[0].size, + psa.print[1].blob.toStdString().c_str(), + psa.print[1].size, + psa.print[2].blob.toStdString().c_str(), + psa.print[2].size, + psa.print[3].blob.toStdString().c_str(), + psa.print[3].size, + psa.print[4].blob.toStdString().c_str(), + psa.print[4].size, + psa.print[5].blob.toStdString().c_str(), + psa.print[5].size, + psa.print[6].blob.toStdString().c_str(), + psa.print[6].size, + psa.print[7].blob.toStdString().c_str(), + psa.print[7].size, + psa.print[8].blob.toStdString().c_str(), + psa.print[8].size, + psa.print[9].blob.toStdString().c_str(), + psa.print[9].size, + psa.print[10].blob.toStdString().c_str(), + psa.print[10].size, + psa.print[11].blob.toStdString().c_str(), + psa.print[11].size, + psa.print[12].blob.toStdString().c_str(), + psa.print[12].size, + psa.print[13].blob.toStdString().c_str(), + psa.print[13].size, + psa.print[14].blob.toStdString().c_str(), + psa.print[14].size, + psa.print[15].blob.toStdString().c_str(), + psa.print[15].size, + psa.print[16].blob.toStdString().c_str(), + psa.print[16].size, + psa.print[17].blob.toStdString().c_str(), + psa.print[17].size, + psa.print[18].blob.toStdString().c_str(), + psa.print[18].size, + psa.print[19].blob.toStdString().c_str(), + psa.print[19].size, + psa.print[20].blob.toStdString().c_str(), + psa.print[20].size, + psa.print[21].blob.toStdString().c_str(), + psa.print[21].size, + psa.print[22].blob.toStdString().c_str(), + psa.print[22].size, + psa.print[23].blob.toStdString().c_str(), + psa.print[23].size, + psa.print[24].blob.toStdString().c_str(), + psa.print[24].size, + psa.print[25].blob.toStdString().c_str(), + psa.print[25].size, + psa.print[26].blob.toStdString().c_str(), + psa.print[26].size, + psa.print[27].blob.toStdString().c_str(), + psa.print[27].size, + psa.print[28].blob.toStdString().c_str(), + psa.print[28].size, + psa.print[29].blob.toStdString().c_str(), + psa.print[29].size, + psa.print[30].blob.toStdString().c_str(), + psa.print[30].size, + psa.print[31].blob.toStdString().c_str(), + psa.print[31].size, - deviceControllerVersion.toStdString().c_str(), - deviceControllerGitBlob.toStdString().c_str(), - deviceControllerGitLastCommit.toStdString().c_str(), + psa.hw.linuxVersion.toStdString().c_str(), + psa.hw.cpuSerial.toStdString().c_str(), - raucVersion.toStdString().c_str(), - opkgVersion.toStdString().c_str(), - atbQTVersion.toStdString().c_str(), - atbQTGitDescribe.toStdString().c_str(), + psa.dc.versionHW.toStdString().c_str(), + psa.dc.versionSW.toStdString().c_str(), + psa.dc.size, + psa.dc.gitBlob.toStdString().c_str(), + psa.dc.gitLastCommit.toStdString().c_str(), - deviceControllerPluginVersion.toStdString().c_str(), - ingenicoISelfCCPluginVersion.toStdString().c_str(), - mobilisisCalculatePricePluginVersion.toStdString().c_str(), - mobilisisCalculatePriceConfigUiVersion.toStdString().c_str(), - prmCalculatePricePluginVersion.toStdString().c_str(), - prmCalculatePriceConfigUiPluginVersion.toStdString().c_str(), - tcpZVTPluginVersion.toStdString().c_str()); + psa.sw.raucVersion.toStdString().c_str(), + psa.sw.opkgVersion.toStdString().c_str(), + psa.sw.atbQTVersion.toStdString().c_str(), + + psa.pluginVersion.deviceController.toStdString().c_str(), + psa.pluginVersion.ingenicoISelfCC.toStdString().c_str(), + psa.pluginVersion.mobilisisCalculatePrice.toStdString().c_str(), + psa.pluginVersion.mobilisisCalculatePriceConfigUi.toStdString().c_str(), + psa.pluginVersion.prmCalculatePrice.toStdString().c_str(), + psa.pluginVersion.prmCalculatePriceConfigUi.toStdString().c_str(), + psa.pluginVersion.tcpZVT.toStdString().c_str()); + + printf("buf=%s\n", buf); return buf; } diff --git a/ismas/ismas_client.h b/ismas/ismas_client.h index 12946ff..7fbd5a7 100644 --- a/ismas/ismas_client.h +++ b/ismas/ismas_client.h @@ -4,6 +4,110 @@ #include #include +struct PSAInstalled { + struct Tariff { + QString name; + QString version; + QString project; + int zone; + int size; + QString blob; + QString info; + QString loadTime; + } tariff; + + struct HardWare { + QString linuxVersion; + QString cpuSerial; + } hw; + + struct DC { + QString versionHW; + QString versionSW; + QString gitBlob; + QString gitLastCommit; + int size; + } dc; + + struct SoftWare { + QString raucVersion; + QString opkgVersion; + QString atbQTVersion; + } sw; + + struct PluginVersion { + QString deviceController; + QString ingenicoISelfCC; + QString mobilisisCalculatePrice; + QString mobilisisCalculatePriceConfigUi; + QString prmCalculatePrice; + QString prmCalculatePriceConfigUi; + QString tcpZVT; + } pluginVersion; + + struct DC2C { + QString name; + QString blob; + int size; + }; + + DC2C cash; + DC2C conf; + DC2C device; + + DC2C print[32]; + + explicit PSAInstalled() { + tariff.name = "N/A"; + tariff.version = "N/A"; + tariff.project = "N/A"; + tariff.zone = -1; + tariff.size = -1; + tariff.blob = "N/A"; + tariff.info = "N/A"; + tariff.loadTime = "N/A"; + + hw.linuxVersion = "N/A"; + hw.cpuSerial = "N/A"; + + dc.versionHW = "N/A"; + dc.versionSW = "N/A"; + dc.gitBlob = "N/A"; + dc.gitLastCommit = "N/A"; + dc.size = -1; + + sw.raucVersion = "N/A"; + sw.opkgVersion = "N/A"; + sw.atbQTVersion = "N/A"; + + pluginVersion.deviceController = "N/A"; + pluginVersion.ingenicoISelfCC = "N/A"; + pluginVersion.mobilisisCalculatePrice = "N/A"; + pluginVersion.mobilisisCalculatePriceConfigUi = "N/A"; + pluginVersion.prmCalculatePrice = "N/A"; + pluginVersion.prmCalculatePriceConfigUi = "N/A"; + pluginVersion.tcpZVT = "N/A"; + + cash.name = "N/A"; + cash.blob = "N/A"; + cash.size = -1; + + conf.name = "N/A"; + conf.blob = "N/A"; + conf.size = -1; + + device.size = -1; + device.blob = "N/A"; + device.size = -1; + + for (int i=0; i < 32; ++i) { + print[i].size = -1; + print[i].blob = "N/A"; + print[i].size = -1; + } + } +}; + class IsmasClient : public QObject { Q_OBJECT @@ -17,27 +121,7 @@ public: QString updateOfPSAActivated(); QString updateOfPSASucceeded(); - QString updateOfPSASendVersion(QString const &tariffVersion, - QString const &tariffProject, - int tariffZone, - QString const &tariffInfo, - QString const &tariffLoadTime, - QString const &linuxVersion, - QString const &cpuSerial, - QString const &deviceControllerVersion, - QString const &deviceControllerGitBlob, - QString const &deviceControllerGitLastCommit, - QString const &raucVersion, - QString const &opkgVersion, - QString const &atbQTVersion, - QString const &atbQTGitDescribe, - QString const &deviceControllerPluginVersion, - QString const &ingenicoISelfCCPluginVersion, - QString const &mobilisisCalculatePricePluginVersion, - QString const &mobilisisCalculatePriceConfigUiVersion, - QString const &prmCalculatePricePluginVersion, - QString const &prmCalculatePriceConfigUiPluginVersion, - QString const &tcpZVTPluginVersion); + QString updateOfPSASendVersion(PSAInstalled const &psa); QString setUpdatesAvailable(); bool checkForAvailableUpdates();