Add class CashUtils: utility methods for CashProcessing
This commit is contained in:
parent
e95de7f9e4
commit
247abb7520
@ -77,6 +77,7 @@ HEADERS += \
|
|||||||
src/ATBAPP/ATBMachineEvent.h \
|
src/ATBAPP/ATBMachineEvent.h \
|
||||||
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
||||||
src/ATBAPP/Utils.h \
|
src/ATBAPP/Utils.h \
|
||||||
|
src/ATBAPP/support/CashUtils.h \
|
||||||
src/ATBAPP/support/DBusControllerInterface.h \
|
src/ATBAPP/support/DBusControllerInterface.h \
|
||||||
src/ATBAPP/support/JSON.h \
|
src/ATBAPP/support/JSON.h \
|
||||||
src/ATBAPP/support/PTUSystem.h
|
src/ATBAPP/support/PTUSystem.h
|
||||||
@ -87,6 +88,7 @@ SOURCES += \
|
|||||||
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
||||||
src/ATBAPP/DeviceControllerDiag.cpp \
|
src/ATBAPP/DeviceControllerDiag.cpp \
|
||||||
src/ATBAPP/Utils.cpp \
|
src/ATBAPP/Utils.cpp \
|
||||||
|
src/ATBAPP/support/CashUtils.cpp \
|
||||||
src/ATBAPP/support/DBusControllerInterface.cpp \
|
src/ATBAPP/support/DBusControllerInterface.cpp \
|
||||||
src/ATBAPP/support/JSON.cpp \
|
src/ATBAPP/support/JSON.cpp \
|
||||||
src/ATBAPP/support/PTUSystem.cpp
|
src/ATBAPP/support/PTUSystem.cpp
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "src/ATBAPP/support/JSON.h"
|
#include "src/ATBAPP/support/JSON.h"
|
||||||
#include "src/ATBAPP/support/DBusControllerInterface.h"
|
#include "src/ATBAPP/support/DBusControllerInterface.h"
|
||||||
#include "src/ATBAPP/support/PTUSystem.h"
|
#include "src/ATBAPP/support/PTUSystem.h"
|
||||||
|
#include "src/ATBAPP/support/CashUtils.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
74
src/ATBAPP/support/CashUtils.cpp
Normal file
74
src/ATBAPP/support/CashUtils.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include "CashUtils.h"
|
||||||
|
|
||||||
|
CashUtils::CashUtils(QObject *parent) : QObject(parent){}
|
||||||
|
|
||||||
|
#define MAX_COINS 64
|
||||||
|
#define MAX_NOTES 16
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Get current inserted coins
|
||||||
|
*
|
||||||
|
* getAllInsertedCoins(uint16_t *types, uint16_t *values)
|
||||||
|
* all inserted coins of this past transaction are stored, max 64
|
||||||
|
*/
|
||||||
|
uint32_t getAmountOfInsertedCoins(hwinf* hw)
|
||||||
|
{
|
||||||
|
uint32_t result = 0;
|
||||||
|
|
||||||
|
uint16_t types[MAX_COINS];
|
||||||
|
uint16_t values[MAX_COINS];
|
||||||
|
hw->getAllInsertedCoins(types, values);
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_COINS; i++) {
|
||||||
|
result += (types[i] * values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Get current inserted notes
|
||||||
|
*
|
||||||
|
* virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const =0;
|
||||||
|
* returns number of collected bank notes since start-command (current transaction)
|
||||||
|
* latestBill: not used
|
||||||
|
* currentNotes[0] = last bill value
|
||||||
|
* currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker)
|
||||||
|
* currentNotes[2,3] = total sum of collected bills within this transaction
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
uint32_t getAmountOfInsertedNotes(hwinf* hw)
|
||||||
|
{
|
||||||
|
uint32_t result = 0;
|
||||||
|
|
||||||
|
uint16_t currentNotes[MAX_NOTES];
|
||||||
|
hw->bna_getCurrentNotes(0, currentNotes);
|
||||||
|
|
||||||
|
result = currentNotes[2] + ( currentNotes[3] >> 16);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
* Get changer result
|
||||||
|
*
|
||||||
|
* virtual uint8_t changer_getChangeResult(uint32_t *returnedAmount) const =0;
|
||||||
|
* get result of coin dispensing
|
||||||
|
* receivedData[0]: 0: not yet started
|
||||||
|
* 1:amount returned
|
||||||
|
* 2:only partial return
|
||||||
|
* 3: no return possible
|
||||||
|
* receivedData[2,3,4,5]: returned amount
|
||||||
|
*
|
||||||
|
* Note: to get changed amount this method must be called after changing!
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t getAmountDueToChange(hwinf* hw)
|
||||||
|
{
|
||||||
|
Q_UNUSED(hw)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
23
src/ATBAPP/support/CashUtils.h
Normal file
23
src/ATBAPP/support/CashUtils.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CASHUTILS_H
|
||||||
|
#define CASHUTILS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
|
class CashUtils : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
static uint32_t getAmountOfInsertedCoins(hwinf* hw);
|
||||||
|
static uint32_t getAmountOfInsertedNotes(hwinf* hw);
|
||||||
|
static uint32_t getAmountDueToChange(hwinf* hw);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit CashUtils(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CASHUTILS_H
|
Loading…
Reference in New Issue
Block a user