Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
ab5a343ab2
|
|||
1199dbfd30
|
|||
06d43009ad
|
|||
bed98c2c0e
|
@@ -1,6 +1,8 @@
|
||||
#include "CArun.h"
|
||||
#include "datei.h"
|
||||
|
||||
#include "CCWakelineAbstraction.h"
|
||||
|
||||
|
||||
CArun::CArun(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -17,6 +19,8 @@ CArun::CArun(QObject *parent)
|
||||
qCritical() << "CArun: start setup...";
|
||||
|
||||
this->timerChainCtrl->start();
|
||||
|
||||
this->ccWakelineAbstraction = new CCWakelineAbstraction(this->HWaccess, this);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,7 +22,7 @@ enum class SETUP_STEP {
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CCWakelineAbstraction;
|
||||
|
||||
class CArun : public QObject
|
||||
{
|
||||
@@ -45,6 +45,8 @@ private:
|
||||
|
||||
void openSerialPort();
|
||||
|
||||
CCWakelineAbstraction* ccWakelineAbstraction;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
|
51
dCArun/CCWakelineAbstraction.cpp
Normal file
51
dCArun/CCWakelineAbstraction.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QFile>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "CCWakelineAbstraction.h"
|
||||
#include "plugin.h"
|
||||
|
||||
/**
|
||||
* this is based on a solution from:
|
||||
* https://embeddeduse.com/2018/09/18/monitoring-sys-files-qfilesystemwatcher/
|
||||
*
|
||||
*/
|
||||
|
||||
CCWakelineAbstraction::CCWakelineAbstraction(hwinf *dc, QObject *parent)
|
||||
: QObject(parent)
|
||||
, dc(dc)
|
||||
{
|
||||
auto ccWakeMonitor = new QFileSystemWatcher(this);
|
||||
|
||||
ccWakeMonitor->addPath("/sys/class/leds/wakeupctrl_cc/brightness");
|
||||
connect(ccWakeMonitor, &QFileSystemWatcher::fileChanged,
|
||||
this, &CCWakelineAbstraction::ccWakeChanged);
|
||||
|
||||
qCritical() << "... init CCWakelineAbstraction";
|
||||
}
|
||||
|
||||
|
||||
void CCWakelineAbstraction::ccWakeChanged(const QString &path)
|
||||
{
|
||||
QFile ccWakeFile(path);
|
||||
if (!ccWakeFile.open(QIODevice::ReadOnly)) {
|
||||
qWarning() << "ERROR: Could not open ccWakeFile file.";
|
||||
return;
|
||||
}
|
||||
auto ccWake = ccWakeFile.readAll();
|
||||
if (!ccWake.isEmpty()) {
|
||||
int state = ccWake.at(0);
|
||||
//qCritical() << "INFO: ccWake = " << state;
|
||||
switch (state) {
|
||||
case 0x30: // '1'
|
||||
qCritical() << "INFO: ccWake -> sleep";
|
||||
this->dc->credit_switchWake(true); // switch 'sleep'
|
||||
break;
|
||||
case 0x31: // '0'
|
||||
qCritical() << "INFO: ccWake -> wake";
|
||||
this->dc->credit_switchWake(false); // switch 'wake'
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
25
dCArun/CCWakelineAbstraction.h
Normal file
25
dCArun/CCWakelineAbstraction.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef CCWAKELINEABSTRACTION_H
|
||||
#define CCWAKELINEABSTRACTION_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class hwinf;
|
||||
class QFileSystemWatcher;
|
||||
|
||||
|
||||
class CCWakelineAbstraction : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CCWakelineAbstraction(hwinf *dc, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
hwinf *dc;
|
||||
QFileSystemWatcher *ccWakeMonitor;
|
||||
|
||||
void ccWakeChanged(const QString &path);
|
||||
};
|
||||
|
||||
#endif // CCWAKELINEABSTRACTION_H
|
@@ -40,12 +40,14 @@ DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
|
||||
|
||||
SOURCES += \
|
||||
CArun.cpp \
|
||||
CCWakelineAbstraction.cpp \
|
||||
main.cpp \
|
||||
tslib.cpp \
|
||||
datei.cpp
|
||||
|
||||
HEADERS += \
|
||||
CArun.h \
|
||||
CCWakelineAbstraction.h \
|
||||
guidefs.h \
|
||||
tslib.h \
|
||||
versionHistory.txt \
|
||||
|
@@ -990,8 +990,8 @@ char T_datif::loadRecDataFromFrame()
|
||||
case 112: // get inserted amount in cent in sum
|
||||
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
|
||||
newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
|
||||
uitmp=uchar2uint(receivedData[5],receivedData[4]);
|
||||
uit2=uchar2uint(receivedData[7],receivedData[6]);
|
||||
uitmp=uchar2uint(receivedData[5],receivedData[4]); // last coin type
|
||||
uit2=uchar2uint(receivedData[7],receivedData[6]); // last coin value
|
||||
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern:
|
||||
// beim Wechsler hat die kleinste Muenze immer coin type 0!
|
||||
if (uitmp>10000 || uit2>10000)
|
||||
@@ -999,7 +999,7 @@ char T_datif::loadRecDataFromFrame()
|
||||
uitmp=0;
|
||||
uit2=0;
|
||||
}
|
||||
if (newInsertedAmount != lastInsertedAmount)
|
||||
if ((newInsertedAmount != lastInsertedAmount) || uit2>0) // 22.5.2024
|
||||
{
|
||||
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
|
||||
emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
|
||||
|
Reference in New Issue
Block a user