Compare commits

...

6 Commits

Author SHA1 Message Date
3581dd4b1d doUpdate(): start reorting thread to report download-progress to GUI. 2024-02-05 16:31:24 +01:00
8d2d7bbb15 Connect slots
void onReportDCDownloadStatus(QString const &status);
    void onReportDCDownloadSuccess(QString const &msg);
    void onReportDCDownloadFailure(QString const &errorMsg);
2024-02-05 16:30:41 +01:00
e2e7c0772d Implemented slots:
void onReportDCDownloadStatus(QString const &status);
    void onReportDCDownloadSuccess(QString const &msg);
    void onReportDCDownloadFailure(QString const &errorMsg);
2024-02-05 16:30:01 +01:00
807cea1042 Added slots:
void onReportDCDownloadStatus(QString const &status);
    void onReportDCDownloadSuccess(QString const &msg);
    void onReportDCDownloadFailure(QString const &errorMsg);
2024-02-05 16:28:34 +01:00
80712964ef Use of pointer m_update. 2024-02-05 16:26:53 +01:00
978e98b2ee removed dependency to interface.h 2024-02-05 14:53:56 +01:00
5 changed files with 190 additions and 100 deletions

View File

@ -176,7 +176,10 @@ GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}" EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
INCLUDEPATH += plugins !contains(CONFIG, INCLUDEINTERFACES) {
INCLUDEINTERFACES=/opt/ptu5/opt/DCLibraries/include
}
INCLUDEPATH += plugins $${INCLUDEINTERFACES}
CONFIG += c++17 CONFIG += c++17
# CONFIG -= app_bundle # CONFIG -= app_bundle
@ -249,9 +252,7 @@ HEADERS += \
process/command.h \ process/command.h \
message_handler.h \ message_handler.h \
worker.h \ worker.h \
interfaces.h \ commandline_parser.h
commandline_parser.h \
plugins/interfaces.h
OTHER_FILES += \ OTHER_FILES += \
ATBUpdateTool.ini ATBUpdateTool.ini

View File

@ -98,6 +98,7 @@ bool Update::unloadDCPlugin() {
return false; return false;
} }
class hwapi;
Update::Update(Worker *worker, Update::Update(Worker *worker,
QString customerRepository, QString customerRepository,
QString customerNrStr, QString customerNrStr,
@ -122,6 +123,9 @@ Update::Update(Worker *worker,
, m_dryRun(dryRun) , m_dryRun(dryRun)
, m_sys_areDCdataValid(false) { , m_sys_areDCdataValid(false) {
if (!m_hw) {
qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_hw == nullptr -> ca-slave plugin loaded ???";
} else {
int tries = 20; int tries = 20;
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) { while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
// must deliver 'true', only then are all data from hwapi valid // must deliver 'true', only then are all data from hwapi valid
@ -133,20 +137,57 @@ Update::Update(Worker *worker,
QThread::msleep(500); QThread::msleep(500);
} }
qCritical() << __PRETTY_FUNCTION__ << "m_sys_areDCDataValid ..." << m_sys_areDCdataValid; qCritical() << "(" << __func__ << ":" << __LINE__ << ") m_sys_areDCDataValid ..."
<< m_sys_areDCdataValid;
//qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface; QObject const *obj = m_hw->getAPI();
//qInfo() << "UPDATE: m_baudrate ..." << m_baudrate; Q_ASSERT(obj != nullptr);
//qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository;
//qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr; QDebug critical = qCritical();
//qInfo() << "UPDATE: m_branchName ..........." << m_branchName; critical << "connect() to onReportDCDownloadStatus() ...";
//qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName; if (!connect(obj,
//qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir; SIGNAL(hwapi_reportDCDownloadStatus(QString const&)), this,
SLOT(onReportDCDownloadStatus(QString const &)))) {
critical << "FAILED";
}
critical << "DONE";
critical = qCritical();
critical << "connect() to onReportDCDownloadSuccess() ...";
if (!connect(obj,
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
SLOT(onReportDCDownloadSuccess(QString const &)))) {
critical << "FAILED";
}
critical << "DONE";
critical = qCritical();
critical << "connect() to onReportDCDownloadFailure() ...";
if (!connect(obj,
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
SLOT(onReportDCDownloadFailure(QString const &)))) {
critical << "FAILED";
}
critical << "DONE";
}
} }
Update::~Update() { Update::~Update() {
} }
void Update::onReportDCDownloadStatus(QString const &status) {
emit m_worker->showStatusMessage("DL", status);
}
void Update::onReportDCDownloadSuccess(QString const &msg) {
qCritical() << "msg" << msg;
}
void Update::onReportDCDownloadFailure(QString const &errorMsg) {
qCritical() << "msg" << errorMsg;
}
// br is a index into a table, used for historical reasons. // br is a index into a table, used for historical reasons.
bool Update::openSerial(int br, QString baudrate, QString comPort) const { bool Update::openSerial(int br, QString baudrate, QString comPort) const {
qDebug() << "opening serial" << br << baudrate << comPort << "..."; qDebug() << "opening serial" << br << baudrate << comPort << "...";
@ -590,7 +631,6 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
return false; return false;
} }
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
if (m_sys_areDCdataValid == false) { if (m_sys_areDCdataValid == false) {
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED"; qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
@ -598,30 +638,74 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
} }
bool res = false; bool res = false;
bool dcDownloadPossible = true;
QList<QString>::const_iterator it; QList<QString>::const_iterator it;
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) { for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
m_worker->startProgressLoop(); m_worker->startProgressLoop();
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed()); QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
if (fToWorkOn.endsWith("/dc2c.bin") && dcDownloadPossible) {
qCritical() << "F-TO-WORK-ON" << fToWorkOn;
// download for dc possible only once
dcDownloadPossible = false;
if (!m_hw->dcDownloadRequest(fToWorkOn)) { // initiate download process
qCritical() << "DOWNLOAD-REQUEST-ERROR FOR" << fToWorkOn;
continue;
}
QThread::sleep(2);
if (!m_hw->dcDownloadRunning()) { // may take some time
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD NOT RUNNING";
continue;
}
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD RUNNING";
if (!m_hw->dcDownloadReportThreadStart()) { // may take some time
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD NOT STARTED";
continue;
}
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD STARTED";
QThread::sleep(2);
if (!m_hw->dcDownloadReportRunning()) { // may take some time
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT NOT RUNNING";
continue;
}
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT RUNNING";
while (m_hw->dcDownloadReportRunning()) {
QThread::msleep(500);
}
if (fToWorkOn.contains("dc2c.bin")) {
bool updateBinaryRes = true; bool updateBinaryRes = true;
// CONSOLE() // CONSOLE()
#if 0
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
QThread::sleep(1); // wait to be sure that there are no more
// commands sent to dc-hardware
// m_hw->dc_autoRequest(false);// default: turn auto-request setting off if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) {
// QThread::sleep(1); // wait to be sure that there are no more
// // commands sent to dc-hardware
// if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) {
//
// qCritical() << "downloaded binary" << fToWorkOn; // qCritical() << "downloaded binary" << fToWorkOn;
// ++displayIndex; ++displayIndex;
// emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
// + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
// Worker::UPDATE_STEP_DONE); Worker::UPDATE_STEP_DONE);
//} }
m_hw->dc_autoRequest(true); // turn auto-request setting on m_hw->dc_autoRequest(true); // turn auto-request setting on
@ -637,11 +721,10 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1]; qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
} }
} }
#endif
res = updateBinaryRes; res = updateBinaryRes;
} else { } else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
res = true; res = true;
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive); int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
@ -695,7 +778,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
res = false; res = false;
} }
} // m_worker->stopProgressLoop();
// m_worker->setProgress(100);
if (res == false) { if (res == false) {
break; break;

View File

@ -94,6 +94,8 @@ private slots:
void readyReadStandardOutput(); void readyReadStandardOutput();
void readyReadStandardError(); void readyReadStandardError();
void finished(int exitCode, QProcess::ExitStatus exitStatus); void finished(int exitCode, QProcess::ExitStatus exitStatus);
void onReportDCDownloadStatus(QString const &status);
void onReportDCDownloadSuccess(QString const &msg);
void onReportDCDownloadFailure(QString const &errorMsg);
}; };
#endif // UPDATE_H_INCLUDED #endif // UPDATE_H_INCLUDED

View File

@ -165,8 +165,8 @@ Worker::Worker(int customerNr,
// TODO: turn object into singleton // TODO: turn object into singleton
instance = this; instance = this;
m_lastFailedUpdateStep = UPDATE_STEP::NONE; m_lastFailedUpdateStep = UPDATE_STEP::NONE;
m_update = nullptr;
this->setObjectName("worker-object"); this->setObjectName("worker-object");
QDir::setCurrent(m_workingDirectory); QDir::setCurrent(m_workingDirectory);
@ -752,7 +752,7 @@ bool Worker::filesToUpdate() {
} }
m_filesToUpdate.removeDuplicates(); m_filesToUpdate.removeDuplicates();
qCritical() << __PRETTY_FUNCTION__ << "FILES-TO-UPDATE" << m_filesToUpdate; qCritical() << "(" << __func__ << ":" << __LINE__ << ") FILES-TO-UPDATE" << m_filesToUpdate;
GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE); GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE);
setProgress(_FILES_TO_UPDATE); setProgress(_FILES_TO_UPDATE);
@ -889,7 +889,7 @@ bool Worker::downloadFilesToPSAHardware() {
QStringList lst = m_filesToDownload; QStringList lst = m_filesToDownload;
ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::FILES_TO_DOWNLOAD); ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::FILES_TO_DOWNLOAD);
Update update(this, m_update = new Update(this,
QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr), QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr),
m_customerNrStr, m_customerNrStr,
m_branchName, m_branchName,
@ -897,7 +897,7 @@ bool Worker::downloadFilesToPSAHardware() {
m_pluginName, m_pluginName,
m_workingDirectory); m_workingDirectory);
if (update.doUpdate(m_displayIndex, m_filesToDownload)) { if (m_update->doUpdate(m_displayIndex, m_filesToDownload)) {
// prepared for use: at the moment, the dc-library does not work // prepared for use: at the moment, the dc-library does not work
// as expected. // as expected.

View File

@ -249,7 +249,10 @@ class Worker : public QThread{
<< UPDATE_STEP::SEND_LAST_VERSION)); << UPDATE_STEP::SEND_LAST_VERSION));
} }
m_worker->stopProgressLoop(); m_worker->stopProgressLoop();
if (m_worker->m_update != nullptr) {
delete m_worker->m_update;
m_worker->m_update = nullptr;
}
m_worker->m_updateProcessRunning = false; m_worker->m_updateProcessRunning = false;
emit m_worker->enableExit(); emit m_worker->enableExit();
emit m_worker->restartExitTimer(); emit m_worker->restartExitTimer();