Compare commits

...

9 Commits

Author SHA1 Message Date
fd58f41c87 Implement helpers:
virtual void dcDownloadStart() {}^M
virtual bool dcDownloadRequested() const { return false; }^M
virtual void dcDownloadResetRequest() {}^M
virtual QString dcDownloadFileName() const { return ""; }^M
virtual void dcDownloadReportStart() {}^M
2023-12-02 09:47:51 +01:00
ece75887e2 Add helpers:
virtual void dcDownloadStart() {}^M
virtual bool dcDownloadRequested() const { return false; }^M
virtual void dcDownloadResetRequest() {}^M
virtual QString dcDownloadFileName() const { return ""; }^M
virtual void dcDownloadReportStart() {}^M
2023-12-02 09:47:26 +01:00
cee4caf77d Add helpers:
virtual void dcDownloadStart() {}^M
virtual bool dcDownloadRequested() const { return false; }^M
virtual void dcDownloadResetRequest() {}^M
virtual QString dcDownloadFileName() const { return ""; }^M
virtual void dcDownloadReportStart() {}^M
2023-12-02 09:46:58 +01:00
6b2830ee83 start download thread in cycleSend() when reuested 2023-12-02 09:46:18 +01:00
cd4bddd169 Minor: only hwinf as parameter needed 2023-12-02 09:44:59 +01:00
8a380c9845 Minor: only hwinf as parameter needed 2023-12-02 09:44:51 +01:00
23619543b2 Minor: only hwinf as parameter needed 2023-12-02 09:44:32 +01:00
be16fe4981 Minor: only hwinf as parameter needed 2023-12-02 09:44:18 +01:00
cf621c02bd Pass hwinf into constructor. Add pointer to download thread. 2023-12-02 09:42:50 +01:00
9 changed files with 55 additions and 21 deletions

View File

@ -133,8 +133,8 @@
#define SENDCOMBINED 0 #define SENDCOMBINED 0
class hwinf;
class DownloadThread;
class T_datif : public QObject class T_datif : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -165,13 +165,15 @@ class T_datif : public QObject
T_prot *myDCIF; T_prot *myDCIF;
QTimer *datif_trigger; QTimer *datif_trigger;
uint8_t selectedSlaveAddr; uint8_t selectedSlaveAddr;
DownloadThread *m_downloadThread;
hwinf *m_hw;
private slots: private slots:
char datif_cycleSend(); char datif_cycleSend();
void StoredRecData(); void StoredRecData();
public: public:
T_datif(QObject *parent = nullptr); T_datif(hwinf *hw, QObject *parent = nullptr);
void resetChain(void); void resetChain(void);
char isPortOpen(void); char isPortOpen(void);

View File

@ -9,7 +9,7 @@ class DownloadThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:
DownloadThread(hwinf *hw, QString const &fileToDownload); DownloadThread(hwinf *hw);
~DownloadThread(); ~DownloadThread();
protected: protected:

View File

@ -1307,8 +1307,11 @@ public:
// download device controller // download device controller
void dcDownloadInit(QString const &fileToDownload) override; void dcDownloadInit(QString const &fileToDownload) override;
void dcDownloadStart(QString const &fileToDownload) override; void dcDownloadStart() override;
void dcDownloadReportStart(QString const &fileToDownload) override; bool dcDownloadRequested() const override;
QString dcDownloadFileName() const override;
void dcDownloadResetRequest() override;
void dcDownloadReportStart() override;
bool dcDownloadStarted() const override; bool dcDownloadStarted() const override;
bool dcDownloadRunning() const override; bool dcDownloadRunning() const override;
bool dcDownloadFinished() const override; bool dcDownloadFinished() const override;

View File

@ -2277,12 +2277,11 @@ public:
virtual void dcDownloadInit(QString const &fileToDownload) { virtual void dcDownloadInit(QString const &fileToDownload) {
Q_UNUSED(fileToDownload); Q_UNUSED(fileToDownload);
} }
virtual void dcDownloadStart(QString const &fileToDownload) { virtual void dcDownloadStart() {}
Q_UNUSED(fileToDownload); virtual bool dcDownloadRequested() const { return false; }
} virtual void dcDownloadResetRequest() {}
virtual void dcDownloadReportStart(QString const &fileToDownload) { virtual QString dcDownloadFileName() const { return ""; }
Q_UNUSED(fileToDownload); virtual void dcDownloadReportStart() {}
}
virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) { virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
Q_UNUSED(totalBlockNumber); Q_UNUSED(totalBlockNumber);
} }

View File

@ -9,7 +9,7 @@ class ReportingThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:
ReportingThread(hwinf *hw, QString const &fileToDownload); ReportingThread(hwinf *hw);
~ReportingThread(); ~ReportingThread();
protected: protected:

View File

@ -2,6 +2,9 @@
#include "sendWRcmd.h" #include "sendWRcmd.h"
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
#include "download_thread.h"
#include "hwapi.h"
#include <QDebug> #include <QDebug>
#include <datei.h> #include <datei.h>
#include <QDir> #include <QDir>
@ -47,8 +50,10 @@ static uint8_t datif_pNextCmd, datif_sendSlowCmd;
//#define DATIF_CTR_GOTRESPVAL 100 //#define DATIF_CTR_GOTRESPVAL 100
T_datif::T_datif(QObject *parent) : QObject(parent) T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
{ {
m_hw = hw;
QByteArray myBA; QByteArray myBA;
QDir myDir("../dmd"); QDir myDir("../dmd");
@ -198,8 +203,21 @@ char T_datif::datif_cycleSend()
return 0; return 0;
} }
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
m_hw->dcDownloadResetRequest();
// start download-thread.
m_downloadThread = new DownloadThread(m_hw);
m_downloadThread->start();
int cnt = 10;
while (--cnt > 0 && !m_downloadThread->isRunning()) {
QThread::msleep(100);
}
if (cnt <= 0) {
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
}
}
// 17.7.2023: repeat commands if result was !=OK ------------------------------------------------------------------- // 17.7.2023: repeat commands if result was !=OK -------------------------------------------------------------------
if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht

View File

@ -2,9 +2,9 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "hwapi.h" #include "hwapi.h"
DownloadThread::DownloadThread(hwinf *hw, QString const &fileToDownload) DownloadThread::DownloadThread(hwinf *hw)
: m_hw(hw) : m_hw(hw)
, m_fileToDownload(fileToDownload) { , m_fileToDownload(m_hw->dcDownloadFileName()) {
} }
DownloadThread::~DownloadThread() { DownloadThread::~DownloadThread() {
@ -12,7 +12,7 @@ DownloadThread::~DownloadThread() {
// download thread running in ca-master sends the dc-file down to firmware // download thread running in ca-master sends the dc-file down to firmware
void DownloadThread::run() { void DownloadThread::run() {
m_hw->dcDownloadInit(m_fileToDownload); // m_hw->dcDownloadInit(m_fileToDownload);
// hier dann den eigentlichen download-process eintragen // hier dann den eigentlichen download-process eintragen

View File

@ -51,7 +51,7 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
// { // {
#ifdef THIS_IS_CA_MASTER #ifdef THIS_IS_CA_MASTER
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren! myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
#else #else
qCritical()<<"hwapi: error CAslave cannot include T_datif"; qCritical()<<"hwapi: error CAslave cannot include T_datif";
#endif #endif
@ -4383,7 +4383,7 @@ void hwapi::dcDownloadInit(QString const &dcFileToDownload) {
SharedMem::getData()->m_downLoadDC.m_totalBlocks = 0; SharedMem::getData()->m_downLoadDC.m_totalBlocks = 0;
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = 0; SharedMem::getData()->m_downLoadDC.m_currentblockNumber = 0;
SharedMem::getData()->m_downLoadDC.m_started = false; SharedMem::getData()->m_downLoadDC.m_started = true;
SharedMem::getData()->m_downLoadDC.m_running = false; SharedMem::getData()->m_downLoadDC.m_running = false;
SharedMem::getData()->m_downLoadDC.m_finished = false; SharedMem::getData()->m_downLoadDC.m_finished = false;
} }
@ -4395,6 +4395,18 @@ void hwapi::dcDownloadReportStart() {
} }
bool hwapi::dcDownloadRequested() const {
return SharedMem::getDataConst()->m_downLoadDC.m_started;
}
void hwapi::dcDownloadResetRequest() {
SharedMem::getData()->m_downLoadDC.m_started = false;
}
QString hwapi::dcDownloadFileName() const {
return SharedMem::getDataConst()->m_downLoadDC.m_filename;
}
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) { void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber; SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
} }

View File

@ -2,9 +2,9 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "hwapi.h" #include "hwapi.h"
ReportingThread::ReportingThread(hwinf *hw, QString const &fileToDownload) ReportingThread::ReportingThread(hwinf *hw)
: m_hw(hw) : m_hw(hw)
, m_fileToDownload(fileToDownload) { , m_fileToDownload(m_hw->dcDownloadFileName()) {
} }
ReportingThread::~ReportingThread() { ReportingThread::~ReportingThread() {