APservice/win07_coin.cpp

512 lines
15 KiB
C++
Executable File

#include "win07_coin.h"
T_win07::T_win07(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
{
this->HWaccess = HWaccess;
myLayout = new QGridLayout;
QFont myTabFont;
// Überschrift
myTabFont.setPixelSize(PIXELSIZE_LABEL);
QLabel *LAB_HEAD = new QLabel("Cash Devices");
LAB_HEAD->setFont(myTabFont);
myLayout->addWidget(LAB_HEAD, 0,0);
QLabel *Led_empty = new QLabel(" ");
myLayout->addWidget(Led_empty, 0,2);
myLayout->addWidget(Led_empty, 0,5);
myLayout->addWidget(Led_empty, 6,0);
myLayout->addWidget(Led_empty, 8,0);
QLabel *ShutLab3 = new QLabel(tr(" MDB Bus"));
ShutLab3->setFont(myTabFont);
myLayout->addWidget(ShutLab3, 1,0);
QLabel *ShutLab4 = new QLabel(tr("Coin Blocker"));
ShutLab4->setFont(myTabFont);
myLayout->addWidget(ShutLab4, 1,3);
QLabel *ShutLab5 = new QLabel(tr("Coin Escrow"));
ShutLab5->setFont(myTabFont);
myLayout->addWidget(ShutLab5, 1,6);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
shut_PB1 = new QPushButton(" MDB\nPower");
shut_PB1->setCheckable(true); // true = toggle button
shut_PB1->setAutoDefault(true); // beim start ein (weil mdb Spannung default EIN ist)
shut_PB1->setFont(myTabFont);
myLayout->addWidget(shut_PB1, 2,0);
connect(shut_PB1, SIGNAL(clicked()), this, SLOT(pbMdbPow()));
myTabFont.setPixelSize(PIXELSIZE_LABEL);
labMdbPowDev = new QLabel("dev");
labMdbPowDev->setFrameStyle(QFrame::Box | QFrame::Sunken);
labMdbPowDev->setLineWidth(3); // 1,2,3
labMdbPowDev->setMaximumWidth(60);
labMdbPowDev->setStyleSheet("background-color: white"); // white red green
labMdbPowDev->setFont(myTabFont);
myLayout->addWidget(labMdbPowDev, 2,1);
QLabel *ShutLab30 = new QLabel(tr(" MDB 5V\nalways on"));
ShutLab30->setFont(myTabFont);
myLayout->addWidget(ShutLab30, 3,0);
labMdbPowBus = new QLabel("bus");
labMdbPowBus->setFrameStyle(QFrame::Box | QFrame::Sunken);
labMdbPowBus->setLineWidth(3); // 1,2,3
labMdbPowBus->setMaximumWidth(60);
labMdbPowBus->setStyleSheet("background-color: white"); // white red green
labMdbPowBus->setFont(myTabFont);
myLayout->addWidget(labMdbPowBus, 3,1);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
shut_PB2 = new QPushButton(" MDB wake\n out");
shut_PB2->setCheckable(true); // true = toggle button
shut_PB2->setAutoDefault(true); // beim start ein
shut_PB2->setFont(myTabFont);
myLayout->addWidget(shut_PB2, 4,0);
connect(shut_PB2, SIGNAL(clicked()), this, SLOT(pbMdbWak()));
myTabFont.setPixelSize(PIXELSIZE_LABEL);
labMdbWakIn = new QLabel("wake\n In");
labMdbWakIn->setFrameStyle(QFrame::Box | QFrame::Sunken);
labMdbWakIn->setLineWidth(3); // 1,2,3
labMdbWakIn->setMaximumWidth(60);
//labMdbWakIn->setMaximumHeight(60);
labMdbWakIn->setStyleSheet("background-color: white"); // white red green
labMdbWakIn->setFont(myTabFont);
myLayout->addWidget(labMdbWakIn, 4,1);
/* motor dauerlauf nicht nötig
rejMot_PB5 = new QPushButton(" reject motor:");
rejMot_PB5->setCheckable(true); // true = toggle button
rejMot_PB5->setAutoDefault(false); // beim start aus
rejMot_PB5->setStyleSheet("background-color: white");
rejMot_PB5->setFont(myTabFont);
myLayout->addWidget(rejMot_PB5, 5,1);
connect(rejMot_PB5, SIGNAL(clicked()), this, SLOT(PB5clicked()));
*/
QLabel *empty2 = new QLabel(" ");
empty2->setFont(myTabFont);
myLayout->addWidget(empty2, 5,0);
QLabel *rej_label = new QLabel("reject motor");
rej_label->setFont(myTabFont);
myLayout->addWidget(rej_label, 6,0);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
QPushButton *rejMot_PB6 = new QPushButton(" Turn");
rejMot_PB6->setCheckable(false); // true = toggle button
rejMot_PB6->setAutoDefault(false); // beim start aus
rejMot_PB6->setFont(myTabFont);
myLayout->addWidget(rejMot_PB6, 7,0);
connect(rejMot_PB6, SIGNAL(clicked()), this, SLOT(pbRejectTurn()));
myTabFont.setPixelSize(PIXELSIZE_LABEL);
labRejSw = new QLabel(" ");
labRejSw->setFrameStyle(QFrame::Box | QFrame::Sunken);
labRejSw->setLineWidth(3); // 1,2,3
labRejSw->setMaximumWidth(60);
labRejSw->setMaximumHeight(40);
labRejSw->setStyleSheet("background-color: white"); // white red green
labRejSw->setFont(myTabFont);
myLayout->addWidget(labRejSw, 7,1);
// 2. Spalte
// read Coin-Attached-Input
labBlockFree = new QLabel(" - ");
labBlockFree->setFrameStyle(QFrame::Box | QFrame::Sunken);
labBlockFree->setLineWidth(3); // 1,2,3
labBlockFree->setMaximumWidth(80);
labBlockFree->setMaximumHeight(40);
labBlockFree->setStyleSheet("background-color: white");
labBlockFree->setFont(myTabFont);
myLayout->addWidget(labBlockFree, 2,3);
// readback Slot is Open (right from uC-output)
labSlotPower = new QLabel("");
labSlotPower->setFrameStyle(QFrame::Box | QFrame::Sunken);
labSlotPower->setLineWidth(3); // 1,2,3
labSlotPower->setMaximumWidth(25);
labSlotPower->setMaximumHeight(25);
labSlotPower->setStyleSheet("background-color: white");
labSlotPower->setFont(myTabFont);
myLayout->addWidget(labSlotPower, 3,4);
// coin blocker
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
Led_PB17 = new QPushButton("Open Slot\n");
Led_PB17->setCheckable(true); // true = toggle button
Led_PB17->setAutoDefault(false); // beim start aus
Led_PB17->setFont(myTabFont);
myLayout->addWidget(Led_PB17, 3,3);
connect(Led_PB17, SIGNAL(clicked()), this, SLOT(pbShutOpen()));
// Coin Blocker: open for 3s
QPushButton *Led_PB27 = new QPushButton("Open for 3s\n");
Led_PB27->setCheckable(false); // true = toggle button
Led_PB27->setAutoDefault(false); // beim start aus
Led_PB27->setFont(myTabFont);
myLayout->addWidget(Led_PB27, 4,3);
connect(Led_PB27, SIGNAL(clicked()), this, SLOT(pbShut3s()));
/* nicht nötig
QPushButton *Led_PB28 = new QPushButton("\nOpen 4 Coin\n");
Led_PB28->setCheckable(true); // true = toggle button
Led_PB28->setAutoDefault(false); // beim start aus
Led_PB28->setFont(myTabFont);
myLayout->addWidget(Led_PB28, 4,3);
connect(Led_PB28, SIGNAL(clicked()), this, SLOT(PB28clicked()));
*/
pb_ledas = new QPushButton("LED issue");
pb_ledas->setCheckable(true); // true = toggle button
pb_ledas->setAutoDefault(false); // beim start aus
pb_ledas->setFont(myTabFont);
myLayout->addWidget(pb_ledas, 7,3);
connect(pb_ledas, SIGNAL(clicked()), this, SLOT(pbLEDclicked()));
// coin Escrow, 3. Spalte
myTabFont.setPixelSize(PIXELSIZE_LABEL);
labEscrowSw = new QLabel(" switch");
labEscrowSw->setFrameStyle(QFrame::Box | QFrame::Sunken);
labEscrowSw->setLineWidth(3); // 1,2,3
labEscrowSw->setStyleSheet("background-color: white");
labEscrowSw->setFont(myTabFont);
myLayout->addWidget(labEscrowSw, 2,6);
/* nicht nötig
Led_PB18 = new QPushButton("\nOpen Take");
Led_PB18->setCheckable(true); // true = toggle button
Led_PB18->setAutoDefault(false); // beim start aus
Led_PB18->setFont(myTabFont);
myLayout->addWidget(Led_PB18, 3,6);
connect(Led_PB18, SIGNAL(clicked()), this, SLOT(PB18clicked()));
Led_PB19 = new QPushButton("\nOpen Give");
Led_PB19->setCheckable(true); // true = toggle button
Led_PB19->setAutoDefault(false); // beim start aus
Led_PB19->setFont(myTabFont);
myLayout->addWidget(Led_PB19, 4,6);
connect(Led_PB19, SIGNAL(clicked()), this, SLOT(PB19clicked()));
*/
// Coin Escrow Level2: open flap for 1s
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
QPushButton *Led_PB30 = new QPushButton("\n Take Coins");
Led_PB30->setCheckable(false); // true = toggle button
Led_PB30->setAutoDefault(false); // beim start aus
Led_PB30->setMinimumHeight(50);
Led_PB30->setFont(myTabFont);
myLayout->addWidget(Led_PB30, 3,6);
connect(Led_PB30, SIGNAL(clicked()), this, SLOT(pbEscrowTake()));
// Coin Escrow Level2: open flap for 1s
QPushButton *Led_PB31 = new QPushButton("\nReturn Coins");
Led_PB31->setCheckable(false); // true = toggle button
Led_PB31->setAutoDefault(false); // beim start aus
Led_PB31->setMinimumHeight(50);
Led_PB31->setFont(myTabFont);
myLayout->addWidget(Led_PB31, 4,6);
connect(Led_PB31, SIGNAL(clicked()), this, SLOT(pbEscrowRet()));
// Barrier
myTabFont.setPixelSize(PIXELSIZE_LABEL);
QLabel *lab_barr = new QLabel("Barrier");
lab_barr->setFont(myTabFont);
myLayout->addWidget(lab_barr, 6,6);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
pb_relay = new QPushButton("Relais\nBarrier");
pb_relay->setCheckable(true); // true = toggle button
pb_relay->setAutoDefault(false); // beim start aus
pb_relay->setFont(myTabFont);
myLayout->addWidget(pb_relay, 7,6);
connect(pb_relay, SIGNAL(clicked()), this, SLOT(pbRELclicked()));
// Barrier INPUTs:
myTabFont.setPixelSize(PIXELSIZE_LABEL);
labBarOk = new QLabel(" OK ");
labBarOk->setFrameStyle(QFrame::Box | QFrame::Sunken);
labBarOk->setLineWidth(3); // 1,2,3
labBarOk->setMaximumWidth(80);
labBarOk->setMaximumHeight(40);
labBarOk->setStyleSheet("background-color: white");
labBarOk->setFont(myTabFont);
myLayout->addWidget(labBarOk, 6,8);
labBarOpen = new QLabel(" open");
labBarOpen->setFrameStyle(QFrame::Box | QFrame::Sunken);
labBarOpen->setLineWidth(3); // 1,2,3
labBarOpen->setMaximumWidth(80);
labBarOpen->setMaximumHeight(40);
labBarOpen->setStyleSheet("background-color: white");
labBarOpen->setFont(myTabFont);
myLayout->addWidget(labBarOpen, 7,8);
setLayout(myLayout);
myNextStep=0;
myStep=0;
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(2000);
HWaccess->mdb_switchPower(1);
}
T_win07::~T_win07()
{
close();
}
void T_win07::Nav_back(void)
{
myNextStep=WCS_WIN07BAK;
}
void T_win07::Nav_home(void)
{
myNextStep=WCS_WIN07MID;
}
void T_win07::Nav_next(void)
{
myNextStep=WCS_WIN07FWD;
}
bool T_win07::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;
myNextStep=0;
return false;
}
bool T_win07::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"
*nextScreen=0; // 0=no change
*useNavi=0;
/*
*/
// U_device:
if (HWaccess->mdb_deviceVoltageOK()) // MDB12V
labMdbPowDev->setStyleSheet("background-color: green"); // white red green
else
labMdbPowDev->setStyleSheet("background-color: white"); // white red green
if (HWaccess->mdb_busVoltageOk()) // =MDB-Bus-Pwr (5V), wird im DC auf 1 gehalten
labMdbPowBus->setStyleSheet("background-color: yellow"); // white red green
else
labMdbPowBus->setStyleSheet("background-color: white"); // white red green
if (HWaccess->mdb_WakeINisActive())
labMdbWakIn->setStyleSheet("background-color: yellow"); // white red green
else
labMdbWakIn->setStyleSheet("background-color: white"); // white red green
if (HWaccess->cash_getRejectMotorHomePos())
labRejSw->setStyleSheet("background-color: green");
else
labRejSw->setStyleSheet("background-color: white");
// readback Coin Slot is Open (right from uC-output)
if (HWaccess->coin_shutterIsOpen())
labSlotPower->setStyleSheet("background-color: green");
else
labSlotPower->setStyleSheet("background-color: white");
// read Coin-Attached-Input
if (HWaccess->coid_isAttached())
{
labBlockFree->setText("COIN");
labBlockFree->setStyleSheet("background-color: green");
} else
{
labBlockFree->setText("FREE");
labBlockFree->setStyleSheet("background-color: white");
}
// Coin Escrow Flap is Open
if (HWaccess->coin_escrowIsOpen())
// retval: 1:return flap is open 2:take flap is open 0:closed
labEscrowSw->setStyleSheet("background-color: green");
else
labEscrowSw->setStyleSheet("background-color: white");
// read OptoCouplers:
if (HWaccess->bar_optoIn1isOn())
labBarOk->setStyleSheet("background-color: yellow");
else
labBarOk->setStyleSheet("background-color: white");
if (HWaccess->bar_optoIn2isOn())
labBarOpen->setStyleSheet("background-color: yellow");
else
labBarOpen->setStyleSheet("background-color: white");
/*
if (myStep==0)
{
myTO->start(); // restart
} else
if (myStep==1)
{
if (!myTO->isActive())
{
// time out
}
} else
if (myStep==2)
{
} else
if (myStep==3)
{
} 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_win07::pbMdbPow(void)
{
if (shut_PB1->isChecked())
HWaccess->mdb_switchPower(1);
else
HWaccess->mdb_switchPower(0);
}
void T_win07::pbMdbWak(void)
{
if (shut_PB2->isChecked())
HWaccess->mdb_switchWake(1);
else
HWaccess->mdb_switchWake(0);
}
void T_win07::pbRejectTurn(void)
{
HWaccess->coin_rejectCoins();
}
void T_win07::pbShutOpen(void)
{
if (Led_PB17->isChecked())
{
//qDebug()<<"main app 1";
HWaccess->shut_move(1);
} else
{
//qDebug()<<"main app 0";
HWaccess->shut_move(0);
}
}
void T_win07::pbShut3s(void)
{
// coin shutter, open for shutter-time
HWaccess->shut_sendOpeningTime(3000);
HWaccess->shut_openOnce();
}
void T_win07::pbLEDclicked(void)
{
if (pb_ledas->isChecked())
HWaccess->led_switchLedPaper(1,0,0);
else
HWaccess->led_switchLedPaper(0,0,0);
}
void T_win07::pbEscrowTake(void)
{
HWaccess->esc_takeMoney();
}
void T_win07::pbEscrowRet(void)
{
HWaccess->esc_returnMoney();
}
void T_win07::pbRELclicked(void)
{
// Relay (Barrier)
if (pb_relay->isChecked())
HWaccess->bar_OpenBarrier(1);
else
HWaccess->bar_OpenBarrier(0);
}