Add class CashUtils: utility methods for CashProcessing

This commit is contained in:
2023-11-30 18:15:07 +01:00
parent e95de7f9e4
commit 247abb7520
4 changed files with 100 additions and 0 deletions

View 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;
}