Compare commits
6 Commits
master
...
palanga-sw
Author | SHA1 | Date | |
---|---|---|---|
91a0f88cd9 | |||
c31b38917a | |||
fe1351fcca | |||
c337b6e50e | |||
821a6e63bf | |||
73b2dec85e |
@ -63,7 +63,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "runProc.h"
|
||||
#include "interfaces.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QFileSystemWatcher>
|
||||
|
||||
/*
|
||||
* select Plugin Type here
|
||||
@ -98,7 +99,7 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
||||
//#define THIS_IS_CA_MASTER
|
||||
|
||||
|
||||
|
||||
class QFileSystemWatcher;
|
||||
class QSharedMemory;
|
||||
class DownloadThread;
|
||||
class ReportingThread;
|
||||
@ -115,7 +116,11 @@ private:
|
||||
QSharedMemory *m_sharedMem;
|
||||
ReportingThread *m_reportingThread;
|
||||
DownloadThread *m_downloadThread;
|
||||
//QTimer *hwapi_triggerBL;
|
||||
QScopedPointer<QFileSystemWatcher> m_fileSystemWatcher;
|
||||
QString m_watchedFile;
|
||||
|
||||
private slots:
|
||||
void onCCWakeGpioChanged(QString const &file);
|
||||
|
||||
public:
|
||||
explicit hwapi(QObject *parent = nullptr);
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <cstring>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
static uint32_t hwapi_lastStartAmount;
|
||||
@ -35,6 +37,7 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
||||
qCritical() << " hwapi::hwapi() APP_EXTENDED_VERSION:" << APP_EXTENDED_VERSION;
|
||||
qCritical() << "hwapi::hwapi() APP_EXTENDED_VERSION_LIB:" << APP_EXTENDED_VERSION_LIB;
|
||||
|
||||
m_fileSystemWatcher.reset();
|
||||
|
||||
// create or attach shared memory segment
|
||||
m_sharedMem = SharedMem::getShm(sizeof(SharedMem));
|
||||
@ -56,8 +59,21 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
||||
#error "SLAVE LIB COMPILED INTO MASTER"
|
||||
#endif
|
||||
|
||||
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||
QSettings settings("/opt/app/ATBAPP/ATBQT.ini", QSettings::IniFormat);
|
||||
m_watchedFile = settings.value("AsyncPOS_CCPlugin/terminal_watch_file",
|
||||
"/opt/app/ATBAPP/watch.txt").toString();
|
||||
|
||||
m_fileSystemWatcher.reset(new QFileSystemWatcher());
|
||||
if (!m_fileSystemWatcher->addPath(m_watchedFile)) {
|
||||
qCritical() << "cannot add path for" << m_watchedFile;
|
||||
} else {
|
||||
if (connect(m_fileSystemWatcher.get(), SIGNAL(fileChanged(QString const&)),
|
||||
this, SLOT(onCCWakeGpioChanged(QString const&)))) {
|
||||
qCritical() << "connected file watcher with" << m_watchedFile;
|
||||
}
|
||||
}
|
||||
|
||||
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||
#endif
|
||||
|
||||
#ifdef THIS_IS_CA_SLAVE
|
||||
@ -120,6 +136,44 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
||||
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
|
||||
}
|
||||
|
||||
void hwapi::onCCWakeGpioChanged(QString const &fileName) {
|
||||
if (fileName == m_watchedFile) {
|
||||
QFile f(m_watchedFile);
|
||||
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QTextStream stream(&f);
|
||||
QString const &content = stream.readAll();
|
||||
if (content.startsWith("0")) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "switching terminal off...";
|
||||
mod_switchWake(false);
|
||||
mod_switchPower(false);
|
||||
f.close();
|
||||
f.setFileName(m_watchedFile);
|
||||
// to turn off cc-terminal, the content must be "0"
|
||||
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||
QTextStream s(&f);
|
||||
s << "switching terminal off";
|
||||
}
|
||||
} else
|
||||
if (content.startsWith("1")) {
|
||||
qCritical() << __func__ << ":" << __LINE__ << "switching terminal on...";
|
||||
mod_switchPower(true);
|
||||
mod_switchWake(true);
|
||||
f.close();
|
||||
f.setFileName(m_watchedFile);
|
||||
// to turn on cc-terminal, the content must be "1"
|
||||
if (f.open(QFile::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
|
||||
QTextStream s(&f);
|
||||
s << "switching terminal on";
|
||||
}
|
||||
} else {
|
||||
qCritical() << "watched file contained" << content;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCritical() << "ERROR watching the wrong file" << fileName;
|
||||
}
|
||||
}
|
||||
|
||||
void hwapi::hwapi_slotPayProc(void)
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user