488 lines
17 KiB
C++
Executable File
488 lines
17 KiB
C++
Executable File
#include "win15_bna.h"
|
|
|
|
static uint8_t lastNoteCount;
|
|
|
|
|
|
T_win15::T_win15(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
|
{
|
|
this->HWaccess = HWaccess;
|
|
|
|
myLayout = new QGridLayout;
|
|
|
|
myH0layer = new QHBoxLayout;
|
|
myVlayer_left = new QVBoxLayout;
|
|
myVlayer_midd = new QVBoxLayout;
|
|
myVlayer_right = new QVBoxLayout;
|
|
myH0layer->addLayout(myVlayer_left);
|
|
myH0layer->addLayout(myVlayer_midd);
|
|
myH0layer->addLayout(myVlayer_right);
|
|
|
|
|
|
QFont myTabFont;
|
|
myTabFont.setPixelSize(22);
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_LABEL);
|
|
lab1 =new QLabel(tr("Bank note reader"));
|
|
lab1->setFont(myTabFont);
|
|
//myLayout->addWidget(lab1,1,1);
|
|
myVlayer_left->addWidget(lab1);
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_DATA);
|
|
showDynamics = new QTextEdit("dynamic values:");
|
|
showDynamics->setFont(myTabFont);
|
|
showDynamics->setStyleSheet("background-color: yellow");
|
|
showDynamics->append(" ");
|
|
//myLayout->addWidget(showDynamics,3,1);
|
|
myVlayer_left->addWidget(showDynamics);
|
|
|
|
lab4 =new QLabel(tr("Stacker / Billbox:"));
|
|
lab4->setFont(myTabFont);
|
|
//myLayout->addWidget(lab4,4,1);
|
|
myVlayer_left->addWidget(lab4);
|
|
|
|
showStacker = new QTextEdit("stacker content:");
|
|
showStacker->setFont(myTabFont);
|
|
showStacker->setStyleSheet("background-color: white");
|
|
showStacker->append(" ");
|
|
showStacker->setMinimumHeight(250);
|
|
//myLayout->addWidget(showStacker,5,1);
|
|
myVlayer_left->addWidget(showStacker);
|
|
|
|
lab5 =new QLabel(tr("Reader Data:"));
|
|
lab5->setFont(myTabFont);
|
|
//myLayout->addWidget(lab5,6,1);
|
|
myVlayer_midd->addWidget(lab5);
|
|
|
|
showStatics = new QTextEdit("static values:");
|
|
showStatics->setFont(myTabFont);
|
|
showStatics->setStyleSheet("background-color: white");
|
|
showStatics->append(" ");
|
|
//myLayout->addWidget(showStatics,7,1);
|
|
myVlayer_midd->addWidget(showStatics);
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
|
|
pb_powerOn = new QPushButton(" Power ON");
|
|
pb_powerOn->setFont(myTabFont);
|
|
pb_powerOn->setCheckable(true); // true = toggle button
|
|
pb_powerOn->setAutoDefault(true); // beim start ein
|
|
pb_powerOn->setStyleSheet(COLORWHITE);
|
|
connect(pb_powerOn, SIGNAL(clicked()), this, SLOT(slot_powerOn()));
|
|
//myLayout->addWidget(pb_powerOn,2,2);
|
|
myVlayer_right->addWidget(pb_powerOn);
|
|
|
|
pb_sendDefault = new QPushButton("All Bills on");
|
|
pb_sendDefault->setFont(myTabFont);
|
|
pb_sendDefault->setStyleSheet(COLORWHITE);
|
|
connect(pb_sendDefault, SIGNAL(clicked()), this, SLOT(slot_sendDef()));
|
|
//myLayout->addWidget(pb_sendDefault,3,2);
|
|
myVlayer_right->addWidget(pb_sendDefault);
|
|
|
|
pb_startPay = new QPushButton("Start Payment");
|
|
pb_startPay->setFont(myTabFont);
|
|
pb_startPay->setCheckable(false); // true = toggle button
|
|
pb_startPay->setAutoDefault(false); // beim start aus
|
|
pb_startPay->setStyleSheet(COLORWHITE);
|
|
connect(pb_startPay, SIGNAL(clicked()), this, SLOT(slot_start()));
|
|
//myLayout->addWidget(pb_startPay, 4,2);
|
|
myVlayer_right->addWidget(pb_startPay);
|
|
|
|
pb_only10_5 = new QPushButton(" only 10€ & 5€");
|
|
pb_only10_5->setFont(myTabFont);
|
|
pb_only10_5->setStyleSheet(COLORWHITE);
|
|
connect(pb_only10_5, SIGNAL(clicked()), this, SLOT(slot_send10_5()));
|
|
//myLayout->addWidget(pb_only10_5,5,2);
|
|
myVlayer_right->addWidget(pb_only10_5);
|
|
|
|
pb_only5 = new QPushButton(" only 5€");
|
|
pb_only5->setFont(myTabFont);
|
|
pb_only5->setStyleSheet(COLORWHITE);
|
|
connect(pb_only5, SIGNAL(clicked()), this, SLOT(slot_send5()));
|
|
//myLayout->addWidget(pb_only5,6,2);
|
|
myVlayer_right->addWidget(pb_only5);
|
|
|
|
pb_stopPay = new QPushButton("Stop Payment");
|
|
pb_stopPay->setFont(myTabFont);
|
|
pb_stopPay->setStyleSheet(COLORWHITE);
|
|
connect(pb_stopPay, SIGNAL(clicked()), this, SLOT(slot_stop()));
|
|
//myLayout->addWidget(pb_stopPay, 7,2);
|
|
myVlayer_right->addWidget(pb_stopPay);
|
|
|
|
//setLayout(myLayout);
|
|
setLayout(myH0layer);
|
|
myNextStep=0;
|
|
myStep=0;
|
|
|
|
myTO = new QTimer();
|
|
myTO->setSingleShot(true);
|
|
myTO->start(2000);
|
|
paymentStarted=false;
|
|
}
|
|
|
|
|
|
T_win15::~T_win15()
|
|
{
|
|
close();
|
|
}
|
|
|
|
void T_win15::Nav_back(void)
|
|
{
|
|
myNextStep=WCS_WIN15BAK;
|
|
}
|
|
void T_win15::Nav_home(void)
|
|
{
|
|
myNextStep=WCS_WIN15MID;
|
|
}
|
|
void T_win15::Nav_next(void)
|
|
{
|
|
myNextStep=WCS_WIN15FWD;
|
|
}
|
|
|
|
|
|
void T_win15::slot_powerOn(void)
|
|
{
|
|
|
|
if (pb_powerOn->isChecked())
|
|
{
|
|
HWaccess->mdb_switchPower(true);
|
|
} else
|
|
{
|
|
HWaccess->mdb_switchPower(false);
|
|
}
|
|
}
|
|
|
|
void T_win15::slot_sendDef(void)
|
|
{
|
|
uint16_t bilVals[16];
|
|
|
|
memset(bilVals,0,32);
|
|
// bilVals[0]=500;
|
|
// bilVals[1]=1000;
|
|
// bilVals[2]=2000;
|
|
// bilVals[3]=5000;
|
|
|
|
HWaccess->bna_sendSettings(0xFFFF, 0, bilVals, 35000);
|
|
}
|
|
|
|
void T_win15::slot_start(void)
|
|
{
|
|
HWaccess->cash_startPayment(0);
|
|
//showDynamics->clear();
|
|
showDynamics->setStyleSheet("background-color: yellow");
|
|
lastNoteCount=255; // to display value once on startup
|
|
paymentStarted=true;
|
|
}
|
|
|
|
void T_win15::slot_send10_5(void)
|
|
{
|
|
HWaccess->bna_setCurrentAcceptance(0b0000000000000011);
|
|
}
|
|
|
|
void T_win15::slot_send5(void)
|
|
{
|
|
HWaccess->bna_setCurrentAcceptance(0b0000000000000001);
|
|
}
|
|
|
|
void T_win15::slot_stop(void)
|
|
{
|
|
//HWaccess->cash_stopPayment();
|
|
HWaccess->vend_success();
|
|
paymentStarted=false;
|
|
}
|
|
|
|
bool T_win15::work_ini(uint16_t *nextScreen, uint8_t *useNavi)
|
|
{
|
|
// one state of the vending/operating FSM
|
|
// called ONE time after selecting this state (initialization)
|
|
// useNavi=0: no change
|
|
// bit0,1: enable/disable button "next"
|
|
// bit2,3: enable/disable button "home"
|
|
// bit4,5: enable/disable button "back"
|
|
|
|
*nextScreen=0; // needed 0=no change
|
|
*useNavi=SWITCH_BACK_ON | SWITCH_HOME_ON | SWITCH_NEXT_ON;
|
|
pb_startPay->setChecked(false);
|
|
lastNoteCount=255; // to display value once on startup
|
|
myNextStep=0;
|
|
return false;
|
|
}
|
|
|
|
bool T_win15::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|
{
|
|
// one state of the vending/operating FSM
|
|
// called cyclic until this state changes intentionally to another state
|
|
// display informations for human operator, react on operators inputs or wait for payment media
|
|
|
|
// useNavi=0: no change
|
|
// bit0,1: enable/disable button "next"
|
|
// bit2,3: enable/disable button "home"
|
|
// bit4,5: enable/disable button "back"
|
|
|
|
struct T_dynamicCondition myDynMachCond;
|
|
*nextScreen=0; // 0=no change
|
|
*useNavi=0;
|
|
|
|
if (HWaccess->mdb_isMdbPowerOn())
|
|
pb_powerOn->setStyleSheet(COLORGREEN);
|
|
else
|
|
pb_powerOn->setStyleSheet(COLORWHITE);
|
|
|
|
HWaccess->sys_getDynMachineConditions(&myDynMachCond);
|
|
if (myDynMachCond.paymentInProgress==2)
|
|
{
|
|
pb_startPay->setStyleSheet(COLORGREEN);
|
|
pb_startPay->setChecked(true);
|
|
} else
|
|
{
|
|
pb_startPay->setStyleSheet(COLORWHITE);
|
|
pb_startPay->setChecked(false);
|
|
}
|
|
displayDynamics();
|
|
|
|
displayStacker();
|
|
|
|
displayStatics();
|
|
|
|
if (myStep==0)
|
|
{
|
|
myStep++;
|
|
} else
|
|
|
|
if (myStep==1)
|
|
{
|
|
if (!myTO->isActive())
|
|
{
|
|
myStep++;
|
|
myTO->start(200);
|
|
//HWaccess->bna_requestParameters();
|
|
//qDebug()<<"win15 requesting bna parameters";
|
|
}
|
|
} else
|
|
|
|
if (myStep==2)
|
|
{
|
|
if (!myTO->isActive())
|
|
{
|
|
myStep++;
|
|
myTO->start(200);
|
|
//HWaccess->bna_requestCurrentNotes();
|
|
//qDebug()<<"win15 requesting bna new bills";
|
|
}
|
|
|
|
} else
|
|
|
|
if (myStep==3)
|
|
{
|
|
if (!myTO->isActive())
|
|
{
|
|
myStep=1;
|
|
myTO->start(200);
|
|
//HWaccess->bna_requestStackerLevel();
|
|
|
|
}
|
|
|
|
} else
|
|
if (myStep==4)
|
|
{
|
|
|
|
} else
|
|
if (myStep==5)
|
|
{
|
|
|
|
} else
|
|
|
|
if (myStep==6)
|
|
{
|
|
|
|
} else
|
|
|
|
if (myStep==7)
|
|
{
|
|
|
|
} else
|
|
{
|
|
|
|
}
|
|
|
|
if (myNextStep)
|
|
{
|
|
*nextScreen=myNextStep;
|
|
myNextStep=0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void T_win15::displayDynamics(void)
|
|
{
|
|
uint8_t ret;
|
|
uint16_t currentNotes[8];
|
|
uint32_t amount;
|
|
|
|
ret= HWaccess->bna_getCurrentNotes(0, currentNotes);
|
|
// 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
|
|
|
|
// if (paymentStarted==false)
|
|
// {
|
|
|
|
// } else
|
|
if (ret==99 )
|
|
{
|
|
showDynamics->clear();
|
|
showDynamics->append("BNA ERROR");
|
|
//qDebug() << "BNA ERROR "<< currentNotes[0] <<" "<< currentNotes[1] <<" "
|
|
// << currentNotes[2] <<" "<< currentNotes[3];
|
|
if (currentNotes[0]>0)
|
|
showDynamics->append(swl_int2str(currentNotes[0]));
|
|
if (currentNotes[1]>0)
|
|
showDynamics->append(swl_int2str(currentNotes[1]));
|
|
if (currentNotes[2]>0)
|
|
showDynamics->append(swl_int2str(currentNotes[2]));
|
|
if (currentNotes[3]>0)
|
|
showDynamics->append(swl_int2str(currentNotes[3]));
|
|
showDynamics->setStyleSheet("background-color: red");
|
|
|
|
} else
|
|
|
|
if (ret != lastNoteCount)
|
|
{
|
|
lastNoteCount=ret;
|
|
showDynamics->setStyleSheet("background-color: white");
|
|
showDynamics->clear();
|
|
showDynamics->append(swl_labelAndValToStr("count : ", ret));
|
|
showDynamics->append(swl_labelAndValToStr("Last bill: ", currentNotes[0]));
|
|
//showDynamics->append(swl_labelAndValToStr("stacked : ", currentNotes[1]));
|
|
if (currentNotes[1]==1)
|
|
showDynamics->append("in escrow");
|
|
else
|
|
showDynamics->append("stacked");
|
|
amount=currentNotes[3];
|
|
amount<<=16;
|
|
amount |=currentNotes[2];
|
|
showDynamics->append(swl_labelAndValToStr("total : ", amount));
|
|
|
|
}
|
|
}
|
|
|
|
void T_win15::displayStacker(void)
|
|
{
|
|
uint16_t ret;
|
|
uint32_t amountInStacker;
|
|
uint16_t countOfBills[16];
|
|
static uint16_t stacker_lastCount;
|
|
|
|
|
|
ret= HWaccess->bna_getStackerLevel(&amountInStacker, countOfBills);
|
|
// return val: nr of bills in stacker
|
|
// countOfBills[0..7] = count of bills of bill-type 0..7 (e.g. countOfBills[0]=nr of 5€-bills in stacker)
|
|
// countOfBills[8..15] = value of bill-type 0...7
|
|
|
|
if (ret>0 && ret != stacker_lastCount)
|
|
{
|
|
qDebug()<<"win15 displ stacker "<< ret << " " << stacker_lastCount;
|
|
|
|
stacker_lastCount=ret;
|
|
showStacker->clear();
|
|
showStacker->append(swl_labelAndValToStr("count of bills : ", ret));
|
|
showStacker->append(swl_labelAndValToStr("total amount : ", amountInStacker));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 0: ", countOfBills[0]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 1: ", countOfBills[1]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 2: ", countOfBills[2]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 3: ", countOfBills[3]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 4: ", countOfBills[4]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 5: ", countOfBills[5]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 6: ", countOfBills[6]));
|
|
showStacker->append(swl_labelAndValToStr("count of bill 7: ", countOfBills[7]));
|
|
|
|
showStacker->append(swl_labelAndValToStr("value of bill 0: ", countOfBills[8]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 1: ", countOfBills[9]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 2: ", countOfBills[10]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 3: ", countOfBills[11]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 4: ", countOfBills[12]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 5: ", countOfBills[13]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 6: ", countOfBills[14]));
|
|
showStacker->append(swl_labelAndValToStr("value of bill 7: ", countOfBills[15]));
|
|
showStacker->moveCursor(QTextCursor::Start);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void T_win15::displayStatics(void)
|
|
{
|
|
struct T_bna bna;
|
|
static uint16_t lastCountryCode, lastStackLev;
|
|
|
|
HWaccess->bna_getAllParameters(&bna);
|
|
/* struct T_bna
|
|
uint8_t setup; // 0: not 1: got valid parameters from device
|
|
uint8_t FeatureLevel;
|
|
uint16_t countryCode; // programmed in EMP
|
|
uint16_t scalingFactor; // z.B. 5
|
|
uint8_t decimalPlace;
|
|
uint8_t pad1;
|
|
uint16_t stackerCap;
|
|
uint16_t billSecureLevel;
|
|
uint8_t hasEscrow;
|
|
uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0
|
|
uint16_t currentStackerLevel; // requested number of notes in billbox
|
|
|
|
// settings from Master
|
|
uint16_t intendedAccept; // bit 0 =5€
|
|
uint16_t pad2;
|
|
uint16_t billDenomination[16];
|
|
}; */
|
|
|
|
//if (bna.countryCode>0)
|
|
// qDebug()<<"win15 got CountryCode" << bna.countryCode;
|
|
|
|
if (bna.countryCode>0 && (lastCountryCode!=bna.intendedAccept || lastStackLev != bna.currentStackerLevel))
|
|
{
|
|
lastCountryCode = bna.intendedAccept;
|
|
lastStackLev = bna.currentStackerLevel;
|
|
|
|
showStatics->clear();
|
|
showStatics->append(swl_labelAndValToStr("Parameter valid:", bna.setup));
|
|
showStatics->append(swl_labelAndValToStr("countryCode: ", bna.countryCode ));
|
|
showStatics->append(swl_labelAndValToStr("scalingFactor: ", bna.scalingFactor));
|
|
showStatics->append(swl_labelAndValToStr("decimals: ", bna.decimalPlace ));
|
|
showStatics->append(swl_labelAndValToStr("stackerCap: ", bna.stackerCap ));
|
|
showStatics->append(swl_labelAndValToStr("curr. st.Level: ", bna.currentStackerLevel ));
|
|
showStatics->append(swl_labelAndValToStr("intend accept : ", bna.intendedAccept ));
|
|
showStatics->append(" ");
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 1: ", bna.accBillTypes[0] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 2: ", bna.accBillTypes[1] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 3: ", bna.accBillTypes[2] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 4: ", bna.accBillTypes[3] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 5: ", bna.accBillTypes[4] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 6: ", bna.accBillTypes[5] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 7: ", bna.accBillTypes[6] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 8: ", bna.accBillTypes[7] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes 9: ", bna.accBillTypes[8] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes10: ", bna.accBillTypes[9] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes11: ", bna.accBillTypes[10] *bna.scalingFactor ));
|
|
showStatics->append(swl_labelAndValToStr("accBillTypes12: ", bna.accBillTypes[11] *bna.scalingFactor ));
|
|
|
|
//showStatics->append(swl_labelAndValToStr("curr. st.Level: ", bna.currentStackerLevel ));
|
|
//showStatics->append(swl_labelAndValToStr("intend accept : ", bna.intendedAccept ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 1: ", bna.billDenomination[0] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 2: ", bna.billDenomination[1] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 3: ", bna.billDenomination[2] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 4: ", bna.billDenomination[3] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 5: ", bna.billDenomination[4] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 16 ", bna.billDenomination[5] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 7: ", bna.billDenomination[6] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 8: ", bna.billDenomination[7] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom 9: ", bna.billDenomination[8] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom10: ", bna.billDenomination[9] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom11: ", bna.billDenomination[10] ));
|
|
showStatics->append(swl_labelAndValToStr("intend denom12: ", bna.billDenomination[11] ));
|
|
showStatics->moveCursor(QTextCursor::Start);
|
|
}
|
|
|
|
}
|
|
|
|
|