430 lines
11 KiB
C++
Executable File
430 lines
11 KiB
C++
Executable File
#include "win16.h"
|
|
|
|
static char generalState=0;
|
|
|
|
|
|
T_win16::T_win16(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);
|
|
// myVlayer_left->addWidget(lab1);
|
|
|
|
|
|
QFont myTabFont;
|
|
myTabFont.setPixelSize(PIXELSIZE_BIGFONT);
|
|
|
|
lab1 =new QLabel(tr("PSA1256DC Doors"));
|
|
lab1->setFont(myTabFont);
|
|
myVlayer_left->addWidget(lab1);
|
|
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_DATA);
|
|
win16_showDoors = new QListWidget;
|
|
win16_showDoors->setFont(myTabFont);
|
|
myVlayer_left->addWidget(win16_showDoors);
|
|
win16_showDoors->clear();
|
|
win16_showDoors->addItem(" - ");
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_BIGFONT);
|
|
lab2 =new QLabel(tr(" "));
|
|
lab2->setFont(myTabFont);
|
|
myVlayer_left->addWidget(lab2);
|
|
|
|
lab3 =new QLabel(tr("PSA1256DC Status"));
|
|
lab3->setFont(myTabFont);
|
|
myVlayer_left->addWidget(lab3);
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_DATA);
|
|
win16_showErrors = new QListWidget;
|
|
win16_showErrors->setFont(myTabFont);
|
|
myVlayer_left->addWidget(win16_showErrors);
|
|
win16_showErrors->clear();
|
|
win16_showErrors->addItem("no errors, no warnings");
|
|
|
|
lab4 =new QLabel(tr(" "));
|
|
lab4->setFont(myTabFont);
|
|
myVlayer_midd->addWidget(lab4);
|
|
|
|
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
|
|
pb1 = new QPushButton("S E R V I C E");
|
|
pb1->setFont(myTabFont);
|
|
myVlayer_right->addWidget(pb1);
|
|
connect(pb1, SIGNAL(clicked()), this, SLOT(Button1Clicked()));
|
|
|
|
pb2 = new QPushButton(" D E M O ");
|
|
pb2->setFont(myTabFont);
|
|
myVlayer_right->addWidget(pb2);
|
|
connect(pb2, SIGNAL(clicked()), this, SLOT(Button2Clicked()));
|
|
|
|
pb3 = new QPushButton(" E X I T ");
|
|
pb3->setFont(myTabFont);
|
|
myVlayer_right->addWidget(pb3);
|
|
connect(pb3, SIGNAL(clicked()), this, SLOT(Button3Clicked()));
|
|
|
|
|
|
|
|
//setLayout(myLayout);
|
|
setLayout(myH0layer);
|
|
|
|
myNextStep=0;
|
|
myStep=0;
|
|
|
|
myTO = new QTimer();
|
|
myTO->setSingleShot(true);
|
|
myTO->start(2000);
|
|
|
|
}
|
|
|
|
T_win16::~T_win16()
|
|
{
|
|
close();
|
|
}
|
|
|
|
void T_win16::Nav_back(void)
|
|
{
|
|
myNextStep=WCS_WIN16BAK;
|
|
}
|
|
void T_win16::Nav_home(void)
|
|
{
|
|
myNextStep=WCS_WIN16MID;
|
|
}
|
|
void T_win16::Nav_next(void)
|
|
{
|
|
myNextStep=WCS_WIN16FWD;
|
|
}
|
|
|
|
void T_win16::Button1Clicked(void)
|
|
{
|
|
myNextStep=PAGE_SERVICEMAIN;
|
|
}
|
|
|
|
void T_win16::Button2Clicked(void)
|
|
{
|
|
|
|
myNextStep=PAGE_SERVICEMAIN;
|
|
|
|
}
|
|
|
|
void T_win16::Button3Clicked(void)
|
|
{
|
|
//emit quitMyApp();
|
|
}
|
|
|
|
bool T_win16::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_win16::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;
|
|
|
|
if (generalState==0)
|
|
{
|
|
win16_showErrors->setStyleSheet("background-color: green");
|
|
win16_showErrors->clear();
|
|
win16_showErrors->addItem(" *** machine OK ***");
|
|
} else
|
|
if (generalState==1)
|
|
{
|
|
win16_showErrors->setStyleSheet("background-color: yellow");
|
|
} else
|
|
if (generalState==2)
|
|
{
|
|
win16_showErrors->setStyleSheet("background-color: red");
|
|
}
|
|
|
|
if (HWaccess->sys_areDCdataValid())
|
|
{
|
|
showDoorState();
|
|
showErrAndWarn();
|
|
win16_showDoors->setStyleSheet(COLORGREY);
|
|
} else
|
|
{
|
|
win16_showDoors->setStyleSheet(COLOR_LIGHTRED);
|
|
win16_showErrors->setStyleSheet(COLOR_LIGHTRED);
|
|
win16_showDoors->clear();
|
|
win16_showDoors->addItem(" DC not connected");
|
|
win16_showErrors->clear();
|
|
win16_showErrors->addItem(" DC not connected");
|
|
}
|
|
if (myNextStep)
|
|
{
|
|
*nextScreen=myNextStep;
|
|
myNextStep=0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void T_win16::showErrAndWarn(void)
|
|
{
|
|
static struct T_moduleCondition myDevCond;
|
|
static struct T_devices devPara; // used devices
|
|
uint8_t uctmp;
|
|
|
|
myDevCond.rtc=0;
|
|
myDevCond.changer=0;
|
|
devPara.autoAlarm=0;
|
|
|
|
HWaccess->sys_getDeviceConditions(&myDevCond);
|
|
HWaccess->sys_restoreDeviceParameter(&devPara);
|
|
qDebug()<<"win16 changer: "<<myDevCond.changer;
|
|
|
|
win16_showErrors->clear();
|
|
generalState=0;
|
|
|
|
if ( myDevCond.rtc>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error RTC HW");
|
|
} else
|
|
if (myDevCond.rtc>=100)
|
|
{
|
|
if (generalState==0) generalState=1;
|
|
win16_showErrors->addItem("Warning RTC time may be wrong");
|
|
}
|
|
|
|
if (myDevCond.printer==200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Printer no response");
|
|
} else
|
|
{
|
|
if (myDevCond.printer==201)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Printer HW");
|
|
} else
|
|
{
|
|
if (myDevCond.printer==202)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Printer no Paper");
|
|
} else
|
|
if (myDevCond.printer>=100)
|
|
{
|
|
if (generalState==0) generalState=1;
|
|
win16_showErrors->addItem("Warning Printer NearPaperEnd");
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (myDevCond.coinBlocker>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Coin Blocker");
|
|
}
|
|
|
|
if (myDevCond.mdbBus>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Mdb Bus");
|
|
}
|
|
|
|
if (myDevCond.intEe>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error int eeprom");
|
|
}
|
|
|
|
if (myDevCond.coinChecker>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Coin checker");
|
|
}
|
|
|
|
if (myDevCond.coinEscrow>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Coin escrow");
|
|
}
|
|
|
|
if (devPara.kindOfCoinChecker==3)
|
|
{
|
|
uctmp = myDevCond.changer;
|
|
if (uctmp>=200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Coin changer");
|
|
}
|
|
}
|
|
|
|
if (devPara.kindOfCoinChecker>0)
|
|
{
|
|
if (myDevCond.coinSafe==200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error no cash box ");
|
|
}
|
|
if (myDevCond.coinSafe==201)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error cash box full");
|
|
}
|
|
}
|
|
if ( myDevCond.billReader>=200 )
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error Bill reader");
|
|
}
|
|
|
|
if (myDevCond.voltage==200)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error voltage off limits");
|
|
}
|
|
if (myDevCond.voltage==201)
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error voltage too low");
|
|
}
|
|
if (myDevCond.temper==200 )
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error temperature off limits");
|
|
}
|
|
if (myDevCond.temper==201 )
|
|
{
|
|
generalState=2;
|
|
win16_showErrors->addItem("Error extrem temperature");
|
|
}
|
|
|
|
if (devPara.kindOfCoinChecker>0)
|
|
{
|
|
if (myDevCond.coinSafe>=100 && myDevCond.coinSafe<200)
|
|
{
|
|
if (generalState==0) generalState=1;
|
|
win16_showErrors->addItem("Warning cash box almost full");
|
|
}
|
|
}
|
|
|
|
if (myDevCond.voltage>=100 && myDevCond.voltage<200)
|
|
{
|
|
if (generalState==0) generalState=1;
|
|
win16_showErrors->addItem("Warning voltage low");
|
|
}
|
|
|
|
if (myDevCond.temper>=100 && myDevCond.temper<200 )
|
|
{
|
|
if (generalState==0) generalState=1;
|
|
win16_showErrors->addItem("Warning temperature");
|
|
}
|
|
|
|
}
|
|
|
|
void T_win16::showDoorState(void)
|
|
{
|
|
static struct T_dynamicCondition dynCond;
|
|
static char acc_stat;
|
|
|
|
win16_showDoors->clear();
|
|
HWaccess->sys_getDynMachineConditions(&dynCond);
|
|
if (dynCond.upperDoor==0) // 99: undefined 0:closed 1:open
|
|
win16_showDoors->addItem("service door closed");
|
|
else
|
|
if (dynCond.upperDoor==1)
|
|
win16_showDoors->addItem("service door open");
|
|
|
|
if (dynCond.middleDoor==0) // 99: undefined 0:closed 1:open
|
|
{
|
|
win16_showDoors->addItem("vault door closed");
|
|
lab2->setText(" ");
|
|
acc_stat=0;
|
|
} else
|
|
if (dynCond.middleDoor==1)
|
|
{
|
|
win16_showDoors->addItem("vault door open");
|
|
if (dynCond.onAlarm==0)
|
|
{
|
|
if (dynCond.CBinDebounced==1) // drin
|
|
{
|
|
if (acc_stat==2)
|
|
{
|
|
lab2->setText("close vault door please");
|
|
|
|
} else
|
|
{
|
|
lab2->setText("cash box can be removed now...");
|
|
acc_stat=1;
|
|
}
|
|
} else
|
|
{
|
|
if (acc_stat==1 )
|
|
{
|
|
lab2->setText("insert cash box please");
|
|
acc_stat=2;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (dynCond.lowerDoor==0) // 99: undefined 0:closed 1:open
|
|
win16_showDoors->addItem("battery door closed");
|
|
else
|
|
if (dynCond.lowerDoor==1)
|
|
win16_showDoors->addItem("battery door open");
|
|
|
|
if (dynCond.CBinDebounced==0)
|
|
win16_showDoors->addItem("no cash box");
|
|
else
|
|
if (dynCond.CBinDebounced==1)
|
|
win16_showDoors->addItem("cash box inserted");
|
|
|
|
|
|
if (dynCond.modeAbrech)
|
|
win16_showDoors->addItem("cash box change ongoing...");
|
|
|
|
if (dynCond.onAlarm)
|
|
win16_showDoors->addItem("on alarm");
|
|
|
|
if (dynCond.lastMifCardType==1)
|
|
{
|
|
win16_showDoors->addItem("valid card Service door");
|
|
lab2->setText(" service door may be opened now...");
|
|
}
|
|
|
|
if (dynCond.lastMifCardType==2)
|
|
{
|
|
win16_showDoors->addItem("valid card Vault door");
|
|
lab2->setText(" vault door may be opened now...");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|