Compare commits
2 Commits
fix-dynami
...
1.99.4
Author | SHA1 | Date | |
---|---|---|---|
ab5a343ab2
|
|||
1199dbfd30
|
@@ -87,7 +87,6 @@ HEADERS += \
|
||||
$${PWD}/include/dcBL.h \
|
||||
$${PWD}/include/hwapi.h \
|
||||
$${PWD}/include/interfaces.h \
|
||||
$${PWD}/include/dynamic-machine-conditions.h \
|
||||
$${PWD}/include/sendWRcmd.h \
|
||||
$${PWD}/include/storeINdata.h \
|
||||
$${PWD}/include/tslib.h \
|
||||
|
@@ -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 \
|
||||
|
@@ -1,84 +0,0 @@
|
||||
#ifndef DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED
|
||||
#define DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED
|
||||
|
||||
struct T_dynamicCondition
|
||||
{
|
||||
char allDoorsDebounced;
|
||||
char openedAuthorized;
|
||||
uint8_t CBinDebounced; // 0:fehlt 1:drin
|
||||
char upperDoor; // 99: undefined 0:closed 1:open
|
||||
char middleDoor; // 99: undefined 0:closed 1:open
|
||||
char lowerDoor; // 99: undefined 0:closed 1:open
|
||||
char coinAttached;
|
||||
char billBox;
|
||||
char modeAbrech;
|
||||
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
|
||||
char nowCardTest;
|
||||
char nowPayment; // not used, always 0
|
||||
char lastMifCardType;
|
||||
uint8_t lastSDoorState;
|
||||
uint8_t lastVDoorState;
|
||||
uint8_t lastCBstate;
|
||||
char paymentInProgress;
|
||||
// Version Szeged: aug2023
|
||||
// 0: stopped by timeout
|
||||
// 1: running 2: wait4lastCoin
|
||||
// 3: payment stopped manually, coins in Escrow
|
||||
// 4: payment stopped autom, amount collected, coins in Escrow
|
||||
// 5: payment stopped, escrow full, coins in Escrow
|
||||
// 6: coins encashed 7:coins returned
|
||||
// 8: CoinChecker or MDB on Error
|
||||
|
||||
// since Schoenau with bill and changer, nov2023
|
||||
//0 = no payment
|
||||
//will be set to 1 by cash_startCollection()
|
||||
//neu 1: wait for devices getting ready for payment
|
||||
//2 = payment,
|
||||
//3 = wait for last coin/bill
|
||||
//4 = Bezahlvorgang manuell beendet
|
||||
//5 = payment stopped autom, amount collected, coins in Escrow
|
||||
//6 = Bezahlvorgang beendet weil ZK voll
|
||||
//4,5,6: payment done, keep on polling, wait for cash or return command
|
||||
//7 = encash collected money from coin escrow into cash box
|
||||
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
|
||||
//9 = wait for changer result
|
||||
//10= print refund receipt with "amountToReturn"
|
||||
|
||||
char res1;
|
||||
uint16_t U_Batt;
|
||||
uint16_t Temperatur;
|
||||
uint16_t nrCoinsInBox;
|
||||
uint32_t amountInBox;
|
||||
uint32_t totalTransVolume;
|
||||
uint32_t totalNrOfVends;
|
||||
char jsonValid_config;
|
||||
char jsonValid_device;
|
||||
char jsonValid_cash;
|
||||
char jsonValid_print;
|
||||
// 40
|
||||
char jsonValid_serial;
|
||||
char jsonValid_time;
|
||||
char lastFileType;
|
||||
uint8_t MifCardHolder[8];
|
||||
uint8_t resultOfLastTemplPrint;
|
||||
// 0: unknown or printing in progress
|
||||
// 1: OK, doc was printed 2: error, doc was not printed
|
||||
uint8_t lastPrinterStatus;
|
||||
// 0: printer OK
|
||||
// bit0: near paper end bit1: no paper
|
||||
// bit2: temperature error bit3: error head open
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
uint8_t startupTestIsRunning;
|
||||
|
||||
uint8_t padd01;
|
||||
uint8_t padd02;
|
||||
uint8_t padd03;
|
||||
uint32_t padd04;
|
||||
uint32_t padd05;
|
||||
uint32_t padd06;
|
||||
uint16_t padd07;
|
||||
};
|
||||
|
||||
#endif // DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED
|
@@ -1033,7 +1033,8 @@ public:
|
||||
|
||||
void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
||||
|
||||
void sys_getDynMachineConditions(void *data) const override;
|
||||
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
||||
|
||||
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
||||
|
||||
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
|
||||
|
||||
struct T_emp
|
||||
{
|
||||
|
||||
@@ -1856,7 +1858,8 @@ public:
|
||||
Q_UNUSED(devCond);
|
||||
}
|
||||
|
||||
virtual void sys_getDynMachineConditions(void *data) const {
|
||||
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const {
|
||||
Q_UNUSED(leng);
|
||||
Q_UNUSED(data);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <QSharedMemory>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "interfaces.h"
|
||||
|
||||
bool shdMem_firstUse(void);
|
||||
|
||||
@@ -191,10 +190,8 @@ struct SharedMem
|
||||
uint8_t store_deviceCondLen;
|
||||
uint8_t store_deviceCond[66];
|
||||
|
||||
// uint8_t store_machCondLen;
|
||||
// uint8_t store_machCond[66];
|
||||
|
||||
struct T_dynamicCondition dynMachCond;
|
||||
uint8_t store_machCondLen;
|
||||
uint8_t store_machCond[66];
|
||||
|
||||
uint8_t store_DcBackupNrOfAccNr;
|
||||
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||
|
@@ -488,8 +488,10 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
|
||||
|
||||
void epi_clearDynMachineConditions(void); // new, 24.6.23
|
||||
|
||||
void gpi_storeDynMachineConditions(void const *data);
|
||||
void epi_restoreDynMachineConditions(void *data);
|
||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data);
|
||||
|
||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
||||
|
||||
|
||||
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data);
|
||||
|
||||
|
@@ -14,7 +14,6 @@ History:
|
||||
#include <QDir>
|
||||
|
||||
|
||||
#include <algorithm> // min/max
|
||||
|
||||
|
||||
|
||||
@@ -1043,19 +1042,9 @@ char T_datif::loadRecDataFromFrame()
|
||||
epi_setDcDataValid(); // DC-Data are valid as DC responded.
|
||||
// Could be set to every response but this (31)
|
||||
// is a very common and very important request
|
||||
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
||||
|
||||
if (RdDleng > sizeof(struct T_dynamicCondition)) {
|
||||
qCritical() << "!!!WARNING!!! RdDlen too high" << RdDleng;
|
||||
// only use as many bytes as maximally possible
|
||||
char buf[sizeof(struct T_dynamicCondition)];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
memcpy(buf, receivedData, std::min(sizeof(receivedData), sizeof(struct T_dynamicCondition)));
|
||||
gpi_storeDynMachineConditions(buf);
|
||||
} else {
|
||||
gpi_storeDynMachineConditions(receivedData);
|
||||
}
|
||||
|
||||
gpi_storeDI_CoinAttach(((struct T_dynamicCondition *)receivedData)->coinAttached); // new, 14.2.24 needed for direct coin insertion
|
||||
gpi_storeDI_CoinAttach(receivedData[6]); // new, 14.2.24 needed for direct coin insertion
|
||||
|
||||
}
|
||||
/* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt
|
||||
|
@@ -3229,14 +3229,29 @@ void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
|
||||
|
||||
|
||||
|
||||
void hwapi::sys_getDynMachineConditions(void *data) const
|
||||
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const
|
||||
{
|
||||
epi_restoreDynMachineConditions(data);
|
||||
epi_restoreDynMachineConditions(leng, data);
|
||||
}
|
||||
|
||||
void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
|
||||
{
|
||||
epi_restoreDynMachineConditions(dynMachCond);
|
||||
|
||||
uint16_t LL, nn;
|
||||
char *start;
|
||||
uint8_t buf[70], leng;
|
||||
|
||||
epi_restoreDynMachineConditions(&leng, buf);
|
||||
// Puffer in struct eintragen:
|
||||
LL=sizeof(struct T_dynamicCondition);
|
||||
start = &dynMachCond->allDoorsDebounced;
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3273,15 +3288,19 @@ uint8_t hwapi::prn_getCurrentPrinterState() const
|
||||
// bit4: paper jam in cutter
|
||||
// bit6: no response bit7: serial rec. error
|
||||
// bit5: printer not ready
|
||||
struct T_dynamicCondition dynCond;
|
||||
memset(&dynCond, 0, sizeof(dynCond));
|
||||
|
||||
|
||||
uint8_t lastPrinterStatus;
|
||||
uint8_t buf[70], leng;
|
||||
|
||||
if (!epi_areDcDataValid()) // was set to 0 with print command
|
||||
return 0x40; // no response
|
||||
|
||||
// 2nd way to get dyn.conditions:
|
||||
epi_restoreDynMachineConditions(&dynCond);
|
||||
return dynCond.lastPrinterStatus;
|
||||
epi_restoreDynMachineConditions(&leng, buf);
|
||||
lastPrinterStatus=buf[52];
|
||||
|
||||
return lastPrinterStatus;
|
||||
|
||||
// oder mit:
|
||||
//struct T_dynamicCondition myDynMachCond;
|
||||
|
@@ -400,7 +400,22 @@ void T_runProc::changer_getAllParameters(struct T_changer *mw)
|
||||
|
||||
void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCond)
|
||||
{
|
||||
epi_restoreDynMachineConditions(dynMachCond);
|
||||
|
||||
uint16_t LL, nn;
|
||||
char *start;
|
||||
uint8_t buf[70], leng;
|
||||
|
||||
epi_restoreDynMachineConditions(&leng, buf);
|
||||
// Puffer in struct eintragen:
|
||||
LL=sizeof(struct T_dynamicCondition);
|
||||
start = &dynMachCond->allDoorsDebounced;
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -6,8 +6,6 @@
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "datei.h"
|
||||
|
||||
#include "interfaces.h" // #include "dynamic-machine-conditions.h"
|
||||
|
||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||
|
||||
@@ -1934,17 +1932,32 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data)
|
||||
|
||||
void epi_clearDynMachineConditions(void)
|
||||
{
|
||||
memset(&SharedMem::write()->dynMachCond, 0, sizeof(struct T_dynamicCondition));
|
||||
uint8_t nn;
|
||||
SharedMem::write()->store_machCondLen=0;
|
||||
for (nn=0; nn<64; nn++)
|
||||
SharedMem::write()->store_machCond[nn] = 0;
|
||||
}
|
||||
|
||||
void gpi_storeDynMachineConditions(void const *data)
|
||||
{
|
||||
SharedMem::write()->dynMachCond = *(struct T_dynamicCondition const *)(data);
|
||||
}
|
||||
|
||||
void epi_restoreDynMachineConditions(void *data)
|
||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data)
|
||||
{
|
||||
*(struct T_dynamicCondition *)(data) = SharedMem::read()->dynMachCond;
|
||||
uint8_t nn;
|
||||
if (leng>64) leng=64;
|
||||
SharedMem::write()->store_machCondLen=leng;
|
||||
// tslib_strcpy(data, SharedMem::write()->store_machCond, leng);
|
||||
for (nn=0; nn<leng; nn++)
|
||||
SharedMem::write()->store_machCond[nn] = data[nn];
|
||||
|
||||
}
|
||||
|
||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
|
||||
{
|
||||
uint8_t nn, LL;
|
||||
LL=SharedMem::read()->store_machCondLen;
|
||||
*leng=LL;
|
||||
//tslib_strcpy(SharedMem::read()->store_machCond, data, SharedMem::read()->store_machCondLen);
|
||||
for (nn=0; nn<LL; nn++)
|
||||
data[nn] = SharedMem::read()->store_machCond[nn];
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user