CashUtils: is not a class, it is a namespace

This commit is contained in:
Siegfried Siegert 2023-12-08 12:33:46 +01:00
parent 7affcb0313
commit 05113057b0
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 15 additions and 47 deletions

View File

@ -1,6 +1,6 @@
#include "CashUtils.h"
CashUtils::CashUtils(QObject *parent) : QObject(parent){}
#include <QDebug>
#define MAX_COINS 64
#define MAX_NOTES 16
@ -11,7 +11,7 @@ CashUtils::CashUtils(QObject *parent) : QObject(parent){}
* 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 CashUtils::getAmountOfInsertedCoins(hwinf* hw)
{
uint32_t result = 0;
@ -20,7 +20,7 @@ uint32_t getAmountOfInsertedCoins(hwinf* hw)
hw->getAllInsertedCoins(types, values);
for (int i = 0; i < MAX_COINS; i++) {
result += (types[i] * values[i]);
result += values[i];
}
return result;
@ -32,43 +32,20 @@ uint32_t getAmountOfInsertedCoins(hwinf* hw)
*
* 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
* latestBill: last accepted bank note, value in cent
* currentNotes an array with up to 16 (further) notes collected
*
*/
uint32_t getAmountOfInsertedNotes(hwinf* hw)
uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw)
{
uint32_t result = 0;
uint16_t currentNotes[MAX_NOTES];
hw->bna_getCurrentNotes(0, currentNotes);
uint16_t values[MAX_NOTES];
hw->bna_getCurrentNotes(0, values);
result = currentNotes[2] + ( currentNotes[3] >> 16);
for (int i = 0; i < MAX_COINS; i++) {
result += values[i];
}
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;
}

View File

@ -4,20 +4,11 @@
#include <QObject>
#include "interfaces.h"
class CashUtils : public QObject
{
Q_OBJECT
namespace CashUtils {
public:
static uint32_t getAmountOfInsertedCoins(hwinf* hw);
static uint32_t getAmountOfInsertedNotes(hwinf* hw);
static uint32_t getAmountDueToChange(hwinf* hw);
uint32_t getAmountOfInsertedCoins(hwinf* hw);
uint32_t getAmountOfInsertedNotes(hwinf* hw);
private:
explicit CashUtils(QObject *parent = nullptr);
signals:
};
}
#endif // CASHUTILS_H