Compare commits
6 Commits
11524b8389
...
1.5.8
Author | SHA1 | Date | |
---|---|---|---|
42624409ba | |||
c49ff5045b | |||
358fd80c47 | |||
8a2d710cf8 | |||
1ea1cdc3e6 | |||
348fb15508
|
@@ -80,7 +80,6 @@ SOURCES += \
|
|||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
../common/src/message_handler.cpp \
|
../common/src/message_handler.cpp \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
../UpdatePTUDevCtrl/commandline_parser.cpp \
|
||||||
../UpdatePTUDevCtrl/process/command.cpp \
|
|
||||||
update.cpp \
|
update.cpp \
|
||||||
dc_download.cpp \
|
dc_download.cpp \
|
||||||
../common/src/System.cpp
|
../common/src/System.cpp
|
||||||
@@ -90,7 +89,6 @@ HEADERS += \
|
|||||||
mainwindow.h \
|
mainwindow.h \
|
||||||
../common/include/message_handler.h \
|
../common/include/message_handler.h \
|
||||||
../UpdatePTUDevCtrl/commandline_parser.h \
|
../UpdatePTUDevCtrl/commandline_parser.h \
|
||||||
../UpdatePTUDevCtrl/process/command.h \
|
|
||||||
update.h \
|
update.h \
|
||||||
dc_download.h \
|
dc_download.h \
|
||||||
../common/include/System.h
|
../common/include/System.h
|
||||||
|
@@ -73,7 +73,6 @@ int main(int argc, char **argv) {
|
|||||||
QString workingDir = parser.workingDir();
|
QString workingDir = parser.workingDir();
|
||||||
QString psaConfigDir = parser.psaConfigDir();
|
QString psaConfigDir = parser.psaConfigDir();
|
||||||
QString psaTariffDir = parser.psaTariffDir();
|
QString psaTariffDir = parser.psaTariffDir();
|
||||||
QString dcDir = parser.dcDir();
|
|
||||||
QString iniFileName = parser.iniFileName();
|
QString iniFileName = parser.iniFileName();
|
||||||
bool const dryRun = parser.dryRun();
|
bool const dryRun = parser.dryRun();
|
||||||
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
|
||||||
@@ -82,7 +81,6 @@ int main(int argc, char **argv) {
|
|||||||
bool const showExtendedVersion = parser.extendedVersion();
|
bool const showExtendedVersion = parser.extendedVersion();
|
||||||
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
bool const alwaysDownloadConfig = parser.alwaysDownloadConfig();
|
||||||
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
bool const alwaysDownloadDC = parser.alwaysDownloadDC();
|
||||||
bool const readDCVersion = parser.readDCVersion();
|
|
||||||
|
|
||||||
QString const rtPath = QCoreApplication::applicationDirPath();
|
QString const rtPath = QCoreApplication::applicationDirPath();
|
||||||
|
|
||||||
@@ -111,31 +109,21 @@ int main(int argc, char **argv) {
|
|||||||
qInfo() << "machineNr ................" << machineNr;
|
qInfo() << "machineNr ................" << machineNr;
|
||||||
qInfo() << "customerNr ..............." << customerNr;
|
qInfo() << "customerNr ..............." << customerNr;
|
||||||
qInfo() << "zoneNr ..................." << zoneNr;
|
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) {
|
if (showExtendedVersion) {
|
||||||
printf(APP_EXTENDED_VERSION"\n");
|
printf(APP_EXTENDED_VERSION"\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
||||||
// QString const &customerRepo = QDir::cleanPath(workingDir + QDir::separator() + QString("customer_%1").arg(customerNr));
|
QStringList filesToUpdate;
|
||||||
// QStringList filesToUpdate;
|
|
||||||
|
|
||||||
QThread::currentThread()->setObjectName("main thread");
|
QThread::currentThread()->setObjectName("main thread");
|
||||||
qInfo() << "Main thread" << QThread::currentThreadId();
|
qInfo() << "Main thread" << QThread::currentThreadId();
|
||||||
|
|
||||||
// MainWindow mw;
|
MainWindow mw;
|
||||||
|
|
||||||
// mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
mw.setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
|
||||||
// mw.showFullScreen();
|
// mw.showFullScreen();
|
||||||
|
|
||||||
// qCritical() << "SHOW";
|
// qCritical() << "SHOW";
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "process/command.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@@ -22,8 +21,6 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QStringList>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#define UPDATE_OPKG (1)
|
#define UPDATE_OPKG (1)
|
||||||
#define UPDATE_DC (0)
|
#define UPDATE_DC (0)
|
||||||
@@ -95,20 +92,6 @@ bool Update::unloadDCPlugin() {
|
|||||||
return false;
|
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;
|
class hwapi;
|
||||||
Update::Update(QString customerRepository,
|
Update::Update(QString customerRepository,
|
||||||
QString customerNrStr,
|
QString customerNrStr,
|
||||||
@@ -135,8 +118,19 @@ Update::Update(QString customerRepository,
|
|||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
|
||||||
} else {
|
} 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();
|
unloadDCPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Update::DownloadResult Update::sendStatus(int ret) const {
|
bool Update::doUpdate(QStringList const &filesToWorkOn, bool usbStickDetected) {
|
||||||
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());
|
|
||||||
|
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
@@ -378,58 +146,66 @@ bool Update::doUpdate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
int tries = 20;
|
||||||
if (ba.size() > 0) {
|
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||||
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
// must deliver 'true', only then are all data from hwapi valid
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
if (--tries < 0) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
// fill last block of data to be sent with 0xFF
|
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED";
|
||||||
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());
|
|
||||||
}
|
|
||||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
|
<< "ERROR!!! DC DATA NOT VALID -> CA-SLAVE-PLUGIN NOT CONNECTED (" << tries << ")";
|
||||||
|
m_hw->dc_autoRequest(true);
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
bool Update::checkJsonVersions(QStringList const& jsonFileNames) {
|
||||||
if (!m_hw) {
|
if (!m_hw) {
|
||||||
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
qCritical() << "(" << __func__ << ":" << __LINE__ << "):"
|
||||||
@@ -660,4 +436,3 @@ bool Update::updateCashConf(QString jsFile) {
|
|||||||
bool Update::updateDeviceConf(QString jsFile) {
|
bool Update::updateDeviceConf(QString jsFile) {
|
||||||
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
|
return downloadJson(FileTypeJson::DEVICE, 0, jsFile);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@@ -58,22 +58,72 @@ public:
|
|||||||
|
|
||||||
virtual ~Update() override;
|
virtual ~Update() override;
|
||||||
|
|
||||||
bool doUpdate();
|
bool doUpdate(QStringList const &jsonFilesToDownload, bool usbStickDetected = false);
|
||||||
static QString dcVersion(QString const &dcBinFile);
|
|
||||||
|
|
||||||
private:
|
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
||||||
DownloadResult sendStatus(int ret) const;
|
bool updateConfig(QString jsFileToSendToDC);
|
||||||
DownloadResult sendNextAddress(int bNum) const;
|
bool updateCashConf(QString jsFileToSendToDC);
|
||||||
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
bool updateDeviceConf(QString jsFileToSendToDC);
|
||||||
bool startBootloader() const;
|
|
||||||
bool stopBootloader() const;
|
|
||||||
QByteArray loadBinaryDCFile(QString const &dcFilename) const;
|
|
||||||
bool resetDeviceController() const;
|
|
||||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
|
||||||
|
|
||||||
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:
|
private:
|
||||||
static QString jsonType(enum FileTypeJson type);
|
static QString jsonType(enum FileTypeJson type);
|
||||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
bool openSerial(int br, QString baudrate, QString comPort) const;
|
||||||
|
@@ -147,7 +147,9 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
# 1.5.5 : Call into binary ptuPackageVersion to get installed package
|
# 1.5.5 : Call into binary ptuPackageVersion to get installed package
|
||||||
# versions.
|
# versions.
|
||||||
# 1.5.6 : Show additional update progress info in status bar.
|
# 1.5.6 : Show additional update progress info in status bar.
|
||||||
VERSION="1.5.6"
|
# 1.5.7 : Add support for dynamic portrait / landscape.
|
||||||
|
# 1.5.8 : Use EVENT_ID=<pid of update-tool> for CMD_EVENT.
|
||||||
|
VERSION="1.5.8"
|
||||||
# PLANNED TODOS:
|
# PLANNED TODOS:
|
||||||
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
# 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT.
|
||||||
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
# 2: Wenn der WAIT-Button aktiv ist, dann wird ein Repository repariert (neu
|
||||||
|
@@ -85,17 +85,7 @@ CommandLineParser::CommandLineParser()
|
|||||||
, m_yoctoInstallStatusOption(
|
, m_yoctoInstallStatusOption(
|
||||||
QCommandLineOption(
|
QCommandLineOption(
|
||||||
QStringList() << "Y" << "yocto-install",
|
QStringList() << "Y" << "yocto-install",
|
||||||
QCoreApplication::translate("main", "Show yocto install status of ATBUpdateTool.")))
|
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."))) {
|
|
||||||
configure();
|
configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,12 +138,6 @@ void CommandLineParser::configure() {
|
|||||||
|
|
||||||
m_yoctoInstallStatusOption.setDefaultValue("false");
|
m_yoctoInstallStatusOption.setDefaultValue("false");
|
||||||
m_parser.addOption(m_yoctoInstallStatusOption);
|
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() {
|
void CommandLineParser::readSettings() {
|
||||||
@@ -161,8 +145,8 @@ void CommandLineParser::readSettings() {
|
|||||||
QString const iniFileName = m_parser.value(m_iniFileNameOption);
|
QString const iniFileName = m_parser.value(m_iniFileNameOption);
|
||||||
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
|
m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName);
|
||||||
|
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir;
|
||||||
//qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName;
|
||||||
|
|
||||||
if (!m_iniFileName.isEmpty()) {
|
if (!m_iniFileName.isEmpty()) {
|
||||||
if (QFile(m_iniFileName).exists()) {
|
if (QFile(m_iniFileName).exists()) {
|
||||||
@@ -171,8 +155,8 @@ void CommandLineParser::readSettings() {
|
|||||||
for (QString const &key: keys) {
|
for (QString const &key: keys) {
|
||||||
QVariant v = settings.value(key);
|
QVariant v = settings.value(key);
|
||||||
|
|
||||||
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
qCritical() << __PRETTY_FUNCTION__
|
||||||
// << key << " -> " << v.toString();
|
<< key << " -> " << v.toString();
|
||||||
|
|
||||||
if (key.contains("repository-url")) {
|
if (key.contains("repository-url")) {
|
||||||
m_repositoryUrl = v.toString();
|
m_repositoryUrl = v.toString();
|
||||||
@@ -212,12 +196,6 @@ void CommandLineParser::readSettings() {
|
|||||||
} else
|
} else
|
||||||
if (key.contains("plugin-name")) {
|
if (key.contains("plugin-name")) {
|
||||||
m_plugInName = v.toString();
|
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 {
|
} else {
|
||||||
qCritical() << __PRETTY_FUNCTION__
|
qCritical() << __PRETTY_FUNCTION__
|
||||||
<< key << " -> (UNKNOWN) " << v.toString();
|
<< key << " -> (UNKNOWN) " << v.toString();
|
||||||
@@ -265,20 +243,6 @@ QString CommandLineParser::psaTariffDir() {
|
|||||||
return m_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() {
|
QString CommandLineParser::workingDir() {
|
||||||
if (m_parser.isSet(m_workingDirectoryOption)) {
|
if (m_parser.isSet(m_workingDirectoryOption)) {
|
||||||
m_workingDir = m_parser.value(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
|
#define COMMAND_LINE_PARSER_H_INCLUDED
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -11,8 +11,8 @@ class CommandLineParser : public QCommandLineParser {
|
|||||||
QString m_plugInDir;
|
QString m_plugInDir;
|
||||||
QString m_plugInName;
|
QString m_plugInName;
|
||||||
QString m_workingDir;
|
QString m_workingDir;
|
||||||
QString m_psaConfigDir{"etc/psa_config"};
|
QString m_psaConfigDir;
|
||||||
QString m_psaTariffDir{"etc/psa_tariff"};
|
QString m_psaTariffDir;
|
||||||
QString m_dryRun;
|
QString m_dryRun;
|
||||||
QString m_noUpdatePsaHardware;
|
QString m_noUpdatePsaHardware;
|
||||||
QString m_showYoctoVersion;
|
QString m_showYoctoVersion;
|
||||||
@@ -21,8 +21,6 @@ class CommandLineParser : public QCommandLineParser {
|
|||||||
QString m_iniFileName;
|
QString m_iniFileName;
|
||||||
QString m_alwaysDownloadConfig;
|
QString m_alwaysDownloadConfig;
|
||||||
QString m_alwaysDownloadDC;
|
QString m_alwaysDownloadDC;
|
||||||
QString m_readDCVersion{"false"};
|
|
||||||
QString m_dcDir{"etc/dc/"};
|
|
||||||
|
|
||||||
QCommandLineOption m_repositoryUrlOption;
|
QCommandLineOption m_repositoryUrlOption;
|
||||||
QCommandLineOption m_iniFileDirectoryOption;
|
QCommandLineOption m_iniFileDirectoryOption;
|
||||||
@@ -39,8 +37,6 @@ class CommandLineParser : public QCommandLineParser {
|
|||||||
QCommandLineOption m_extendedVersionOption;
|
QCommandLineOption m_extendedVersionOption;
|
||||||
QCommandLineOption m_yoctoVersionOption;
|
QCommandLineOption m_yoctoVersionOption;
|
||||||
QCommandLineOption m_yoctoInstallStatusOption;
|
QCommandLineOption m_yoctoInstallStatusOption;
|
||||||
QCommandLineOption m_dcDirectoryOption;
|
|
||||||
QCommandLineOption m_readDCVersionOption;
|
|
||||||
|
|
||||||
QCommandLineParser m_parser;
|
QCommandLineParser m_parser;
|
||||||
|
|
||||||
@@ -69,7 +65,5 @@ public:
|
|||||||
bool extendedVersion();
|
bool extendedVersion();
|
||||||
bool alwaysDownloadConfig();
|
bool alwaysDownloadConfig();
|
||||||
bool alwaysDownloadDC();
|
bool alwaysDownloadDC();
|
||||||
bool readDCVersion();
|
|
||||||
QString dcDir();
|
|
||||||
};
|
};
|
||||||
#endif // COMMAND_LINE_PARSER_H_INCLUDED
|
#endif // COMMAND_LINE_PARSER_H_INCLUDED
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
########################
|
########################
|
||||||
@@ -380,7 +381,7 @@ QString IsmasClient::updateNewsToIsmas(char const *event,
|
|||||||
"{"
|
"{"
|
||||||
"\"REASON\":\"SW_UP\","
|
"\"REASON\":\"SW_UP\","
|
||||||
"\"TIMESTAMP\":\"%s\","
|
"\"TIMESTAMP\":\"%s\","
|
||||||
"\"EVENT_ID\":\"0\","
|
"\"EVENT_ID\":\"%d\","
|
||||||
"\"EVENT\":\"%s\","
|
"\"EVENT\":\"%s\","
|
||||||
"\"EVENTSTATE\":1,"
|
"\"EVENTSTATE\":1,"
|
||||||
"\"PARAMETER\": {"
|
"\"PARAMETER\": {"
|
||||||
@@ -390,7 +391,7 @@ QString IsmasClient::updateNewsToIsmas(char const *event,
|
|||||||
"\"STEP_RESULT\" : \"%s\","
|
"\"STEP_RESULT\" : \"%s\","
|
||||||
"\"VERSION\" : \"%s\""
|
"\"VERSION\" : \"%s\""
|
||||||
"}"
|
"}"
|
||||||
"}", ts.toStdString().c_str(), event, percent, resultCode,
|
"}", ts.toStdString().c_str(), static_cast<int>(QCoreApplication::applicationPid()), event, percent, resultCode,
|
||||||
step, step_result, version);
|
step, step_result, version);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,9 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@@ -30,6 +33,7 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
|||||||
this->statusBar()->setFont(f);
|
this->statusBar()->setFont(f);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
checkOrientation();
|
||||||
|
|
||||||
ui->updateProgress->setRange(0, 100);
|
ui->updateProgress->setRange(0, 100);
|
||||||
ui->updateProgress->reset();
|
ui->updateProgress->reset();
|
||||||
@@ -98,6 +102,56 @@ MainWindow::~MainWindow() {
|
|||||||
delete ui;
|
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) {
|
void MainWindow::customEvent(QEvent *event) {
|
||||||
if (event->type() == ProgressEvent::type()) {
|
if (event->type() == ProgressEvent::type()) {
|
||||||
ProgressEvent *pevent = (ProgressEvent *)event;
|
ProgressEvent *pevent = (ProgressEvent *)event;
|
||||||
|
@@ -66,6 +66,12 @@ private:
|
|||||||
void onShowMessage(QString, QString);
|
void onShowMessage(QString, QString);
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
void checkOrientation();
|
||||||
|
void setPortraitLayout();
|
||||||
|
void setLandscapeLayout();
|
||||||
|
Qt::ScreenOrientation currentOrientation;
|
||||||
|
|
||||||
|
|
||||||
Worker *m_worker;
|
Worker *m_worker;
|
||||||
int const m_width;
|
int const m_width;
|
||||||
QTimer *m_startTimer;
|
QTimer *m_startTimer;
|
||||||
|
@@ -10,6 +10,12 @@
|
|||||||
<height>480</height>
|
<height>480</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>480</width>
|
||||||
|
<height>480</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<family>Source Code Pro</family>
|
<family>Source Code Pro</family>
|
||||||
@@ -19,15 +25,8 @@
|
|||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>781</width>
|
|
||||||
<height>441</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QPushButton" name="exit">
|
<widget class="QPushButton" name="exit">
|
||||||
@@ -52,6 +51,7 @@
|
|||||||
<font>
|
<font>
|
||||||
<family>Misc Fixed</family>
|
<family>Misc Fixed</family>
|
||||||
<pointsize>11</pointsize>
|
<pointsize>11</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
<bold>true</bold>
|
<bold>true</bold>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
@@ -61,13 +61,11 @@
|
|||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Reference in New Issue
Block a user