Compare commits
1 Commits
11524b8389
...
pu/portrai
Author | SHA1 | Date | |
---|---|---|---|
348fb15508
|
@@ -80,7 +80,6 @@ SOURCES += \
|
||||
mainwindow.cpp \
|
||||
../common/src/message_handler.cpp \
|
||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||
../UpdatePTUDevCtrl/process/command.cpp \
|
||||
update.cpp \
|
||||
dc_download.cpp \
|
||||
../common/src/System.cpp
|
||||
@@ -90,7 +89,6 @@ HEADERS += \
|
||||
mainwindow.h \
|
||||
../common/include/message_handler.h \
|
||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||
../UpdatePTUDevCtrl/process/command.h \
|
||||
update.h \
|
||||
dc_download.h \
|
||||
../common/include/System.h
|
||||
|
@@ -73,7 +73,6 @@ int main(int argc, char **argv) {
|
||||
QString workingDir = parser.workingDir();
|
||||
QString psaConfigDir = parser.psaConfigDir();
|
||||
QString psaTariffDir = parser.psaTariffDir();
|
||||
QString dcDir = parser.dcDir();
|
||||
QString iniFileName = parser.iniFileName();
|
||||
bool const dryRun = parser.dryRun();
|
||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||
@@ -82,7 +81,6 @@ int main(int argc, char **argv) {
|
||||
bool const showExtendedVersion = parser.extendedVersion();
|
||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||
bool const readDCVersion = parser.readDCVersion();
|
||||
|
||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||
|
||||
@@ -111,31 +109,21 @@ int main(int argc, char **argv) {
|
||||
qInfo() << "machineNr ................" << machineNr;
|
||||
qInfo() << "customerNr ..............." << customerNr;
|
||||
qInfo() << "zoneNr ..................." << zoneNr;
|
||||
qInfo() << "readDCVersion ............" << readDCVersion;
|
||||
qInfo() << "dcDir ...................." << dcDir;
|
||||
|
||||
if (readDCVersion) {
|
||||
qInfo() << "dc-version ..............." << Update::dcVersion(
|
||||
QDir::cleanPath(rtPath + QDir::separator()
|
||||
+ QString("customer_%1").arg(customerNr) + QDir::separator()
|
||||
+ dcDir + QDir::separator() + "dc2c.bin"));
|
||||
}
|
||||
|
||||
if (showExtendedVersion) {
|
||||
printf(APP_EXTENDED_VERSION"\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
// QStringList filesToUpdate;
|
||||
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||
QStringList filesToUpdate;
|
||||
|
||||
QThread::currentThread()->setObjectName("main thread");
|
||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||
|
||||
// MainWindow mw;
|
||||
MainWindow mw;
|
||||
|
||||
// mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||
// mw.showFullScreen();
|
||||
|
||||
// qCritical() << "SHOW";
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include "update.h"
|
||||
#include "process/command.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
@@ -22,8 +21,6 @@
|
||||
#include <QDateTime>
|
||||
#include <QPluginLoader>
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
#define UPDATE_OPKG (1)
|
||||
#define UPDATE_DC (0)
|
||||
@@ -95,20 +92,6 @@ bool Update::unloadDCPlugin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString Update::dcVersion(QString const &dcBinFile) {
|
||||
Command c("bash");
|
||||
QStringList param;
|
||||
|
||||
param << "-c" << QString(R"(strings %1 | grep DC2c.\[0-9\] | uniq)").arg(dcBinFile);
|
||||
|
||||
if (c.execute("/tmp", param)) {
|
||||
return c.getCommandResult().trimmed().split(QRegularExpression("\\s")).first();
|
||||
// qInfo() << "(" << __func__ << ":" << __LINE__ << ")" << v;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
class hwapi;
|
||||
Update::Update(QString customerRepository,
|
||||
QString customerNrStr,
|
||||
@@ -135,8 +118,19 @@ Update::Update(QString customerRepository,
|
||||
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);
|
||||
}
|
||||
|
||||
// carun stoppen
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
|
||||
<< m_sys_areDCdataValid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,233 +138,7 @@ Update::~Update() {
|
||||
unloadDCPlugin();
|
||||
}
|
||||
|
||||
Update::DownloadResult Update::sendStatus(int ret) const {
|
||||
switch (ret) { // return values of dc are:
|
||||
case 0: // 0: no answer by now
|
||||
return DownloadResult::NOP; // 1: error
|
||||
case 10: // 10: success
|
||||
return DownloadResult::OK;
|
||||
default:;
|
||||
}
|
||||
return DownloadResult::ERROR;
|
||||
}
|
||||
|
||||
Update::DownloadResult
|
||||
Update::sendNextAddress(int bNum) const {
|
||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||
// qDebug() << "addr-block" << bNum << "...";
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendAddress(bNum);
|
||||
QThread::msleep(100);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else { // res == DownloadResult::OK
|
||||
qCritical() << "addr-block" << bNum << "...OK";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
|
||||
return DownloadResult::NOP;
|
||||
}
|
||||
|
||||
Update::DownloadResult
|
||||
Update::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
||||
uint8_t local[66];
|
||||
int const bAddr = bNum * 64;
|
||||
int noAnswerCount = 0;
|
||||
int errorCount = 0;
|
||||
|
||||
memcpy(local, binary.constData() + bAddr, 64);
|
||||
local[64] = local[65] = 0x00;
|
||||
|
||||
// QByteArray b((const char *)(&local[0]), 64);
|
||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
||||
|
||||
while (noAnswerCount <= 250) {
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
QThread::msleep(10);
|
||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
if (res != DownloadResult::NOP) {
|
||||
if (res == DownloadResult::ERROR) {
|
||||
if (++errorCount >= 10) {
|
||||
qCritical() << "data for block" << bNum << "...FAILED";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
qCritical() << "data for block" << bNum << "OK";
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
noAnswerCount += 1; // no answer by now
|
||||
}
|
||||
}
|
||||
// wait max. about 3 seconds
|
||||
return DownloadResult::TIMEOUT;
|
||||
}
|
||||
|
||||
bool Update::startBootloader() const {
|
||||
qDebug() << "starting bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_startBL();
|
||||
QThread::msleep(5000);
|
||||
m_hw->bl_checkBL();
|
||||
if (m_hw->bl_isUp()) {
|
||||
qInfo() << "starting bootloader...OK";
|
||||
QThread::msleep(5000);
|
||||
return true;
|
||||
} else {
|
||||
qCritical() << "bootloader not up (" << nTry << ")";
|
||||
}
|
||||
}
|
||||
qCritical() << "starting bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::stopBootloader() const {
|
||||
qDebug() << "stopping bootloader...";
|
||||
int nTry = 5;
|
||||
while (--nTry >= 0) {
|
||||
m_hw->bl_stopBL();
|
||||
QThread::msleep(500);
|
||||
if (!m_hw->bl_isUp()) {
|
||||
qInfo() << "stopping bootloader...OK";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
qCritical() << "stopping bootloader...FAILED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Update::resetDeviceController() const {
|
||||
qDebug() << "resetting device controller...";
|
||||
m_hw->bl_rebootDC();
|
||||
// wait maximally 3 seconds, before starting bootloader
|
||||
QThread::sleep(1);
|
||||
qInfo() << "resetting device controller...OK";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QByteArray Update::loadBinaryDCFile(QString const &filename) const {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "loading dc binary" << filename << "...";
|
||||
|
||||
QFile file(filename); // closed in destructor call
|
||||
if (!file.exists()) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< file.fileName() << "does not exist";
|
||||
return QByteArray();
|
||||
}
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "cannot open file" << file.fileName();
|
||||
return QByteArray();
|
||||
}
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
<< "loading dc binary" << filename << "...OK";
|
||||
|
||||
return file.readAll();
|
||||
}
|
||||
/*
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// USING THE DC BOOTLOADER
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1 : bl_reboot() // send to application, want DC2 to reset (in order to
|
||||
// start the bootloader)
|
||||
//
|
||||
// NOTE: this function is NOT reliable !!! Sometimes it
|
||||
// simply does not work, in which case bl_startBL,
|
||||
// bl_checkBL and bl_isUp do not work as well.
|
||||
// Alas, there is no feedback if bl_reboot worked!
|
||||
//
|
||||
// NOTE: this function can be called only once per
|
||||
// minute, because once called again, the controller
|
||||
// performs some self-checks consuming some time.
|
||||
//
|
||||
// NOTE: after a successful bl_reboot(), the device is
|
||||
// waiting about 4 seconds in the bootloader. To stay in
|
||||
// the bootloader, we have to send the command
|
||||
// bl_startBL(), which is kind of a misnomer, as it
|
||||
// should be bl_doNotLeaveBL().
|
||||
//
|
||||
2 : bl_startBL(): // send within 4s after DC power-on, otherwise
|
||||
// bootloader is left.
|
||||
//
|
||||
// NOTE: a running bootloader is a MUST for the download
|
||||
// process of a device controller firmware as it does
|
||||
// the actual writing of the memory (the bl_reboot()
|
||||
// from above erases the available memory).
|
||||
//
|
||||
3 : bl_check(): // send command to verify if bl is up
|
||||
//
|
||||
// NOTE: this command is kind of a request that we want
|
||||
// to check if the bootloader is up. The device
|
||||
// (actually the bootloader) responds with its version.
|
||||
//
|
||||
4 : bl_isUp(): // returns true if bl is up and running
|
||||
//
|
||||
// NOTE: we know what the bootloader version actually is
|
||||
// as the bootloader does not change. By comparing the
|
||||
// string received in the previous step with this known
|
||||
// version string we know if the bootloader is up.
|
||||
//
|
||||
// NOTE FOR ALL PREVIOUS STEPS: execute them in their
|
||||
// own slots each to be sure to receive any possible
|
||||
// responds from the device.
|
||||
//
|
||||
5 : bl_sendAddress(blockNumber)
|
||||
// send start address, nr of 64-byte block, start with 0
|
||||
// will be sent only for following block-numbers:
|
||||
// 0, 1024, 2048, 3072 and 4096, so basically every
|
||||
// 64kByte.
|
||||
// for other addresses nothing happens
|
||||
|
||||
6 : bl_wasSendingAddOK()
|
||||
// return val: 0: no response by now
|
||||
// 1: error
|
||||
// 10: OK
|
||||
|
||||
7 : bl_sendDataBlock()
|
||||
// send 64 byte from bin file
|
||||
|
||||
8 : bl_sendLastBlock()
|
||||
// send this command after all data are transferred
|
||||
|
||||
9 : bl_wasSendingDataOK()
|
||||
// return val: 0: no response by now
|
||||
// 1: error
|
||||
// 10: OK
|
||||
|
||||
10 : bl_stopBL() // leave bl and start (the new) application
|
||||
//
|
||||
// NOTE: this function MUST work under all conditions.
|
||||
// Alas, there is no direct result for this command, so
|
||||
// the only way of knowing it was successful is to ask
|
||||
// the device if the bootloader is still running.
|
||||
// There is no problem to repeat this command until the
|
||||
// bootloader is really not running anymore.
|
||||
*/
|
||||
bool Update::doUpdate() {
|
||||
//QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed())
|
||||
//: QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
@@ -378,58 +146,66 @@ bool Update::doUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||
if (ba.size() > 0) {
|
||||
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||
|
||||
// fill last block of data to be sent with 0xFF
|
||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||
|
||||
resetDeviceController();
|
||||
if (startBootloader()) {
|
||||
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||
|
||||
int currentBlock = 0;
|
||||
DownloadResult res = DownloadResult::OK;
|
||||
qCritical() << "64-byte block " << currentBlock;
|
||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
currentBlock += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
||||
|
||||
int const rest = ba.size() % 64;
|
||||
int const offset = ba.size() - rest;
|
||||
char const *startAddress = ba.constData() + offset;
|
||||
|
||||
if (rest > 0) {
|
||||
// SHOULD NEVER HAPPEN !!!
|
||||
uint8_t local[66];
|
||||
memset(local, 0xFF, sizeof(local));
|
||||
memcpy(local, startAddress, rest);
|
||||
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
||||
m_hw->bl_sendDataBlock(64, local);
|
||||
} else {
|
||||
m_hw->bl_sendLastBlock();
|
||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||
}
|
||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
||||
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() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
||||
return false;
|
||||
}
|
||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
|
||||
return false;
|
||||
bool res = false;
|
||||
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
QString const &fToWorkOn = usbStickDetected ? QDir::cleanPath(it->trimmed())
|
||||
: QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
res = true;
|
||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||
res = false;
|
||||
} else {
|
||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||
qCritical() <<
|
||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||
.arg(fToWorkOn)
|
||||
.arg(templateIdx);
|
||||
}
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateCashConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateConfig(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||
qCritical() << QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn);
|
||||
}
|
||||
} else {
|
||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||
res = false;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||
if (!m_hw) {
|
||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||
@@ -660,4 +436,3 @@ bool Update::updateCashConf(QString jsFile) {
|
||||
bool Update::updateDeviceConf(QString jsFile) {
|
||||
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
|
||||
}
|
||||
#endif
|
||||
|
@@ -58,22 +58,72 @@ public:
|
||||
|
||||
virtual ~Update() override;
|
||||
|
||||
bool doUpdate();
|
||||
static QString dcVersion(QString const &dcBinFile);
|
||||
bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false);
|
||||
|
||||
private:
|
||||
DownloadResult sendStatus(int ret) const;
|
||||
DownloadResult sendNextAddress(int bNum) const;
|
||||
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
||||
bool startBootloader() const;
|
||||
bool stopBootloader() const;
|
||||
QByteArray loadBinaryDCFile(QString const &dcFilename) const;
|
||||
bool resetDeviceController() const;
|
||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
||||
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||
bool updateConfig(QString jsFileToSendToDC);
|
||||
bool updateCashConf(QString jsFileToSendToDC);
|
||||
bool updateDeviceConf(QString jsFileToSendToDC);
|
||||
|
||||
QString m_fileToDownload;
|
||||
bool downloadJson(enum FileTypeJson type, int templateIdx,
|
||||
QString jsFileToSendToDC) const;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
hwinf *hw() { return m_hw; }
|
||||
hwinf const *hw() const { return m_hw; }
|
||||
|
||||
//QString customerId() { return m_customerId; }
|
||||
//QString const customerId() const { return m_customerId; }
|
||||
|
||||
QString branchName() { return m_branchName; }
|
||||
QString const branchName() const { return m_branchName; }
|
||||
|
||||
//QString repositoryPath() { return m_repositoryPath; }
|
||||
//QString const repositoryPath() const { return m_repositoryPath; }
|
||||
|
||||
private:
|
||||
static QString jsonType(enum FileTypeJson type);
|
||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||
|
@@ -85,17 +85,7 @@ CommandLineParser::CommandLineParser()
|
||||
, m_yoctoInstallStatusOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "Y" << "yocto-install",
|
||||
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool.")))
|
||||
, m_dcDirectoryOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "dc-directory" << "dc-directory",
|
||||
QCoreApplication::translate("main", "device controller directory."),
|
||||
QCoreApplication::translate("main", "directory")))
|
||||
, m_readDCVersionOption(
|
||||
QCommandLineOption(
|
||||
QStringList() << "D" << "read-dc-version",
|
||||
QCoreApplication::translate("main", "Show version of device controller."),
|
||||
QCoreApplication::translate("main", "Show version of device controller."))) {
|
||||
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool."))) {
|
||||
configure();
|
||||
}
|
||||
|
||||
@@ -148,12 +138,6 @@ void CommandLineParser::configure() {
|
||||
|
||||
m_yoctoInstallStatusOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_yoctoInstallStatusOption);
|
||||
|
||||
m_dcDirectoryOption.setDefaultValue("etc/dc/");
|
||||
m_parser.addOption(m_dcDirectoryOption);
|
||||
|
||||
m_readDCVersionOption.setDefaultValue("false");
|
||||
m_parser.addOption(m_readDCVersionOption);
|
||||
}
|
||||
|
||||
void CommandLineParser::readSettings() {
|
||||
@@ -161,8 +145,8 @@ void CommandLineParser::readSettings() {
|
||||
QString const iniFileName = m_parser.value(m_iniFileNameOption);
|
||||
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
|
||||
|
||||
//qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||
//qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||
qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||
qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||
|
||||
if (!m_iniFileName.isEmpty()) {
|
||||
if (QFile(m_iniFileName).exists()) {
|
||||
@@ -171,8 +155,8 @@ void CommandLineParser::readSettings() {
|
||||
for (QString const &key: keys) {
|
||||
QVariant v = settings.value(key);
|
||||
|
||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||
// << key << " -> " << v.toString();
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> " << v.toString();
|
||||
|
||||
if (key.contains("repository-url")) {
|
||||
m_repositoryUrl = v.toString();
|
||||
@@ -212,12 +196,6 @@ void CommandLineParser::readSettings() {
|
||||
} else
|
||||
if (key.contains("plugin-name")) {
|
||||
m_plugInName = v.toString();
|
||||
} else
|
||||
if (key.contains("dc-directory")) {
|
||||
m_dcDir = v.toString();
|
||||
} else
|
||||
if (key.contains("read-dc-version")) {
|
||||
m_readDCVersion = (v.toBool() ? "true" : "false");
|
||||
} else {
|
||||
qCritical() << __PRETTY_FUNCTION__
|
||||
<< key << " -> (UNKNOWN) " << v.toString();
|
||||
@@ -265,20 +243,6 @@ QString CommandLineParser::psaTariffDir() {
|
||||
return m_psaTariffDir;
|
||||
}
|
||||
|
||||
QString CommandLineParser::dcDir() {
|
||||
if (m_parser.isSet(m_dcDirectoryOption)) {
|
||||
m_dcDir = m_parser.value(m_dcDirectoryOption);
|
||||
}
|
||||
return m_dcDir;
|
||||
}
|
||||
|
||||
bool CommandLineParser::readDCVersion() {
|
||||
if (m_parser.isSet(m_readDCVersionOption)) {
|
||||
m_readDCVersion = m_parser.value(m_readDCVersionOption);
|
||||
}
|
||||
return m_readDCVersion == "false" ? false : true;
|
||||
}
|
||||
|
||||
QString CommandLineParser::workingDir() {
|
||||
if (m_parser.isSet(m_workingDirectoryOption)) {
|
||||
m_workingDir = m_parser.value(m_workingDirectoryOption);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#ifndef COMMAND_LINE_PARSER_H_INCLUDED
|
||||
#ifndef COMMAND_LINE_PARSER_H_INCLUDED
|
||||
#define COMMAND_LINE_PARSER_H_INCLUDED
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -11,8 +11,8 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_plugInDir;
|
||||
QString m_plugInName;
|
||||
QString m_workingDir;
|
||||
QString m_psaConfigDir{"etc/psa_config"};
|
||||
QString m_psaTariffDir{"etc/psa_tariff"};
|
||||
QString m_psaConfigDir;
|
||||
QString m_psaTariffDir;
|
||||
QString m_dryRun;
|
||||
QString m_noUpdatePsaHardware;
|
||||
QString m_showYoctoVersion;
|
||||
@@ -21,8 +21,6 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QString m_iniFileName;
|
||||
QString m_alwaysDownloadConfig;
|
||||
QString m_alwaysDownloadDC;
|
||||
QString m_readDCVersion{"false"};
|
||||
QString m_dcDir{"etc/dc/"};
|
||||
|
||||
QCommandLineOption m_repositoryUrlOption;
|
||||
QCommandLineOption m_iniFileDirectoryOption;
|
||||
@@ -39,8 +37,6 @@ class CommandLineParser : public QCommandLineParser {
|
||||
QCommandLineOption m_extendedVersionOption;
|
||||
QCommandLineOption m_yoctoVersionOption;
|
||||
QCommandLineOption m_yoctoInstallStatusOption;
|
||||
QCommandLineOption m_dcDirectoryOption;
|
||||
QCommandLineOption m_readDCVersionOption;
|
||||
|
||||
QCommandLineParser m_parser;
|
||||
|
||||
@@ -69,7 +65,5 @@ public:
|
||||
bool extendedVersion();
|
||||
bool alwaysDownloadConfig();
|
||||
bool alwaysDownloadDC();
|
||||
bool readDCVersion();
|
||||
QString dcDir();
|
||||
};
|
||||
#endif // COMMAND_LINE_PARSER_H_INCLUDED
|
||||
|
@@ -12,6 +12,9 @@
|
||||
#include <QScrollBar>
|
||||
#include <QEvent>
|
||||
|
||||
#include <QScreen>
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
@@ -30,6 +33,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
this->statusBar()->setFont(f);
|
||||
|
||||
ui->setupUi(this);
|
||||
checkOrientation();
|
||||
|
||||
ui->updateProgress->setRange(0, 100);
|
||||
ui->updateProgress->reset();
|
||||
@@ -98,6 +102,56 @@ MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------- Ui::LAYOUT setting -------------------------------------
|
||||
|
||||
void MainWindow::checkOrientation()
|
||||
{
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
Qt::ScreenOrientation orientation = screen->orientation();
|
||||
|
||||
switch (orientation) {
|
||||
case Qt::PrimaryOrientation:
|
||||
this->setLandscapeLayout();
|
||||
break;
|
||||
case Qt::LandscapeOrientation:
|
||||
this->setLandscapeLayout();
|
||||
break;
|
||||
case Qt::PortraitOrientation:
|
||||
this->setPortraitLayout();
|
||||
break;
|
||||
case Qt::InvertedLandscapeOrientation:
|
||||
this->setLandscapeLayout();
|
||||
break;
|
||||
case Qt::InvertedPortraitOrientation:
|
||||
this->setPortraitLayout();
|
||||
break;
|
||||
}
|
||||
|
||||
this->currentOrientation = orientation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::setPortraitLayout()
|
||||
{
|
||||
// Adjust layout for portrait mode (480x800)
|
||||
this->setFixedSize(480, 800);
|
||||
ui->centralwidget->setFixedSize(480, 800);
|
||||
}
|
||||
|
||||
void MainWindow::setLandscapeLayout()
|
||||
{
|
||||
// Adjust layout for landscape mode (800x480)
|
||||
this->setFixedSize(800, 480);
|
||||
ui->centralwidget->setFixedSize(800, 480);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void MainWindow::customEvent(QEvent *event) {
|
||||
if (event->type() == ProgressEvent::type()) {
|
||||
ProgressEvent *pevent = (ProgressEvent *)event;
|
||||
|
@@ -66,6 +66,12 @@ private:
|
||||
void onShowMessage(QString, QString);
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
void checkOrientation();
|
||||
void setPortraitLayout();
|
||||
void setLandscapeLayout();
|
||||
Qt::ScreenOrientation currentOrientation;
|
||||
|
||||
|
||||
Worker *m_worker;
|
||||
int const m_width;
|
||||
QTimer *m_startTimer;
|
||||
|
@@ -10,6 +10,12 @@
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>480</width>
|
||||
<height>480</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Source Code Pro</family>
|
||||
@@ -19,55 +25,47 @@
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>781</width>
|
||||
<height>441</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="exit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QProgressBar" name="updateProgress">
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="3" colspan="3">
|
||||
<widget class="QTextEdit" name="updateStatus">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Misc Fixed</family>
|
||||
<pointsize>11</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="exit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QProgressBar" name="updateProgress">
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="3" colspan="3">
|
||||
<widget class="QTextEdit" name="updateStatus">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Misc Fixed</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
Reference in New Issue
Block a user