Update current devl-status.
This commit is contained in:
108
update.cpp
108
update.cpp
@@ -3,7 +3,6 @@
|
||||
#include "utils.h"
|
||||
#include "update_dc_event.h"
|
||||
#include "mainwindow.h"
|
||||
#include "plugins/interfaces.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
@@ -19,6 +18,8 @@
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
#include "plugins/interfaces.h"
|
||||
|
||||
#include <QSharedMemory>
|
||||
#include <QScopedPointer>
|
||||
#include <QDir>
|
||||
@@ -118,7 +119,6 @@ Update::Update(Worker *worker,
|
||||
, m_dryRun(dryRun)
|
||||
, m_sys_areDCdataValid(false) {
|
||||
|
||||
#if 0
|
||||
int tries = 20;
|
||||
while ((m_sys_areDCdataValid = m_hw->sys_areDCdataValid()) == false) {
|
||||
// must deliver 'true', only then are all data from hwapi valid
|
||||
@@ -128,39 +128,35 @@ Update::Update(Worker *worker,
|
||||
m_hw->dc_autoRequest(true);
|
||||
QThread::msleep(500);
|
||||
}
|
||||
#endif
|
||||
|
||||
QObject const *obj = (QObject const *)(m_hw->getAPI());
|
||||
|
||||
if (connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)), this,
|
||||
SLOT(onReportDCDownloadStatus(QString const &)))) {
|
||||
qCritical() << "connect ok";
|
||||
}
|
||||
connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
|
||||
SLOT(onReportDCDownloadSuccess(QString const &)));
|
||||
connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
|
||||
SLOT(onReportDCDownloadFailure(QString const &)));
|
||||
|
||||
qCritical() << "UPDATE: m_sys_areDCDataValid ..." << m_sys_areDCdataValid;
|
||||
|
||||
//qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface;
|
||||
//qInfo() << "UPDATE: m_baudrate ..." << m_baudrate;
|
||||
//qInfo() << "UPDATE: m_customerRepository ..." << m_customerRepository;
|
||||
//qInfo() << "UPDATE: m_customerNr ..........." << m_customerNrStr;
|
||||
//qInfo() << "UPDATE: m_branchName ..........." << m_branchName;
|
||||
//qInfo() << "UPDATE: m_pluginName ..........." << m_pluginName;
|
||||
//qInfo() << "UPDATE: m_workingDirectory ....." << m_workingDir;
|
||||
QObject const *obj = m_hw->getAPI();
|
||||
// QObject const *obj = (QObject const *)(hw);
|
||||
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadStatus(QString const&)), this,
|
||||
SLOT(onReportDCDownloadStatus(QString const &)))) {
|
||||
qCritical() << "ERROR connect() to onReportDCDownloadStatus() failed";
|
||||
}
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadSuccess(QString const&)), this,
|
||||
SLOT(onReportDCDownloadSuccess(QString const &)))) {
|
||||
qCritical() << "ERROR connect() to onReportDCDownloadSuccess() failed";
|
||||
}
|
||||
if (!connect(obj,
|
||||
SIGNAL(hwapi_reportDCDownloadFailure(QString const &)), this,
|
||||
SLOT(onReportDCDownloadFailure(QString const &)))) {
|
||||
qCritical() << "ERROR connect() to onReportDCDownloadFailure() failed";
|
||||
}
|
||||
}
|
||||
|
||||
Update::~Update() {
|
||||
}
|
||||
|
||||
|
||||
void Update::onReportDCDownloadStatus(QString const &status) {
|
||||
qCritical() << "status" << status;
|
||||
//emit m_worker->showStatusMessage("", status);
|
||||
emit m_worker->showStatusMessage("DL", status);
|
||||
}
|
||||
|
||||
void Update::onReportDCDownloadSuccess(QString const &msg) {
|
||||
@@ -171,6 +167,8 @@ void Update::onReportDCDownloadFailure(QString const &errorMsg) {
|
||||
qCritical() << "msg" << errorMsg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// br is a index into a table, used for historical reasons.
|
||||
bool Update::openSerial(int br, QString baudrate, QString comPort) const {
|
||||
qDebug() << "opening serial" << br << baudrate << comPort << "...";
|
||||
@@ -524,27 +522,63 @@ QStringList Update::getDcSoftAndHardWareVersion() {
|
||||
}
|
||||
|
||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
//if (m_sys_areDCdataValid == false) {
|
||||
// qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
// return false;
|
||||
//}
|
||||
if (m_sys_areDCdataValid == false) {
|
||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool res = false;
|
||||
bool dcDownloadPossible = true;
|
||||
|
||||
QList<QString>::const_iterator it;
|
||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||
m_worker->startProgressLoop();
|
||||
QString const &fToWorkOn = QDir::cleanPath(QString("/tmp") + QDir::separator() + it->trimmed());
|
||||
//QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||
static const QRegularExpression version("^.*dc2c[.][0-9]{1,2}[.][0-9]{1,2}[.]bin.*$");
|
||||
if (fToWorkOn.contains(version)) {
|
||||
m_hw->dcDownloadRequest(fToWorkOn);
|
||||
m_hw->dcDownloadReportStart(); // start reporting thread
|
||||
qCritical() << "ABOUT TO START REPORTING THREAD (1)" << fToWorkOn;
|
||||
if (fToWorkOn.contains(version) && dcDownloadPossible) {
|
||||
// download for dc possible only once
|
||||
dcDownloadPossible = false;
|
||||
|
||||
m_hw->dcDownloadRequest(fToWorkOn); // initiate download process
|
||||
|
||||
// test
|
||||
m_hw->dcDownloadThreadStart();
|
||||
|
||||
if (!m_hw->dcDownloadRunning()) { // may take some time
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 DOWNLOAD NOT RUNNING").arg(__LINE__);
|
||||
continue; // wait for reporting thread to start
|
||||
}
|
||||
|
||||
if (!m_hw->dcDownloadReportThreadStart()) { // may take some time
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 REPORT THREAD NOT RUNNING").arg(__LINE__);
|
||||
continue; // wait for reporting thread to start
|
||||
}
|
||||
|
||||
if (!m_hw->dcDownloadReportRunning()) { // may take some time
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 DOWNLOAD REPORT NOT RUNNING").arg(__LINE__);
|
||||
continue; // reporting events from download thread
|
||||
}
|
||||
|
||||
if (!m_hw->dcDownloadReportFinished()) { // may take some time
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 DOWNLOAD REPORT THREAD DID NOT FINISH").arg(__LINE__);
|
||||
m_hw->dcDownloadReportThreadQuit();
|
||||
continue; // wait for download thread to finish
|
||||
}
|
||||
|
||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||
<< QString("line=%1 DOWNLOAD SUCCESS").arg(__LINE__);
|
||||
|
||||
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
|
||||
@@ -573,7 +607,7 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
res = updateBinaryRes;
|
||||
|
||||
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||
|
Reference in New Issue
Block a user