APservice/win04_stat.cpp

447 lines
15 KiB
C++
Executable File

#include "win04_stat.h"
static bool win04_dataAreValid;
T_win04::T_win04(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
{
this->HWaccess = HWaccess;
myLayout = new QGridLayout;
QFont myTabFont;
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab1 =new QLabel(tr("Machine status"));
lab1->setFont(myTabFont);
myLayout->addWidget(lab1,1,0);
myTabFont.setPixelSize(PIXELSIZE_BUTTONS);
pb_refresh = new QPushButton("Refresh");
pb_refresh->setFont(myTabFont);
myLayout->addWidget(pb_refresh,1,1);
connect(pb_refresh, SIGNAL(clicked()), this, SLOT(ButtonRefreshClicked()));
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab2 =new QLabel(tr("Error or Warning:"));
lab2->setFont(myTabFont);
myLayout->addWidget(lab2,2,0);
myTabFont.setPixelSize(PIXELSIZE_DATA);
win4_showErrors = new QListWidget;
win4_showErrors->setFont(myTabFont);
myLayout->addWidget(win4_showErrors,3,0);
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab3 =new QLabel(tr("Used devices"));
lab3->setFont(myTabFont);
myLayout->addWidget(lab3,4,0);
myTabFont.setPixelSize(PIXELSIZE_DATA);
win4_devParameters = new QListWidget;
win4_devParameters->setFont(myTabFont);
myLayout->addWidget(win4_devParameters,5,0);
// rechte Spalte:
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab4 =new QLabel(tr("state of each device:"));
lab4->setFont(myTabFont);
myLayout->addWidget(lab4,2,1);
myTabFont.setPixelSize(PIXELSIZE_DATA);
win4_showDeviceState = new QListWidget;
win4_showDeviceState->setFont(myTabFont);
myLayout->addWidget(win4_showDeviceState,3,1);
myTabFont.setPixelSize(PIXELSIZE_LABEL);
lab5 =new QLabel(tr("dynamic condition:"));
lab5->setFont(myTabFont);
myLayout->addWidget(lab5,4,1);
myTabFont.setPixelSize(PIXELSIZE_DATA);
win4_showMachineState = new QListWidget;
win4_showMachineState->setFont(myTabFont);
myLayout->addWidget(win4_showMachineState,5,1);
setLayout(myLayout);
myNextStep=0;
myStep=0;
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(2000);
}
T_win04::~T_win04()
{
close();
}
void T_win04::Nav_back(void)
{
myNextStep=WCS_WIN04BAK;
}
void T_win04::Nav_home(void)
{
myNextStep=WCS_WIN04MID;
}
void T_win04::Nav_next(void)
{
myNextStep=WCS_WIN04FWD;
}
void T_win04::ButtonRefreshClicked(void)
{
win04_dataAreValid=0;
}
bool T_win04::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;
win04_dataAreValid=0;
return false;
}
void T_win04::entryDevState(QString label, uint8_t val)
{
QString myStr;
myStr.clear();
myStr.append(label);
myStr.append(QString::number(val));
win4_showDeviceState->addItem(myStr);
}
void T_win04::entryMachineCond(QString label, uint32_t val)
{
QString myStr;
myStr.clear();
myStr.append(label);
myStr.append(QString::number(val));
win4_showMachineState->addItem(myStr);
}
void T_win04::entryArray(QString label, uint8_t *buff)
{
QString myStr;
char myChar;
int nn;
myStr.clear();
myStr.append(label);
for (nn=0; nn<8; nn++)
{
myChar=char(buff[nn]);
myStr.append(myChar);
}
win4_showMachineState->addItem(myStr);
}
bool T_win04::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"
QString myStr;
*nextScreen=0; // 0=no change
*useNavi=0;
struct T_moduleCondition myDevCond;
struct T_dynamicCondition myDynMachCond;
//struct T_devices devPara; // used devices
if (!win04_dataAreValid)
{
win04_dataAreValid=1;
win4_showDeviceState->clear();
HWaccess->sys_getDeviceConditions(&myDevCond);
entryDevState("Internal Ram : ", myDevCond.ram );
entryDevState("Internal Eeprom: ", myDevCond.intEe );
entryDevState("External Eeprom: ", myDevCond.extEe );
entryDevState("Real Time Clock: ", myDevCond.rtc );
entryDevState("Board Hardware : ", myDevCond.boardHw );
entryDevState("Printer : ", myDevCond.printer );
entryDevState("Modem : ", myDevCond.modem );
entryDevState("GSM Signal : ", myDevCond.signal );
entryDevState("GSMregistration: ", myDevCond.regist );
entryDevState("MDB Bus : ", myDevCond.mdbBus );
entryDevState("Coin Checker : ", myDevCond.coinChecker );
entryDevState("Coin Escrow : ", myDevCond.coinEscrow );
entryDevState("Mifare Reader : ", myDevCond.mifareReader );
entryDevState("Credit Terminal: ", myDevCond.creditTerm );
entryDevState("Reject Motor : ", myDevCond.coinReject );
entryDevState("Coin Safe : ", myDevCond.coinSafe );
entryDevState("Bill Safe : ", myDevCond.billSafe );
entryDevState("Battery Voltage: ", myDevCond.voltage );
entryDevState("Temperature : ", myDevCond.temper );
entryDevState("Power-On-Test : ", myDevCond.poweronTest );
entryDevState("Doors State : ", myDevCond.doorState );
entryDevState("Door-Was-Opened: ", myDevCond.doorWasOpened );
entryDevState("Coin Changer : ", myDevCond.changer );
entryDevState("Coin Blocker : ", myDevCond.coinBlocker );
entryDevState("Banknote Reader: ", myDevCond.billReader );
entryDevState("Reset Reason : ", myDevCond.ResetReason );
entryDevState("Check Complete : ", myDevCond.allModulesChecked );
entryDevState("Alarm State : ", myDevCond.alarmState );
//entryDevState(": ", myDevCond. );
//entryDevState(": ", myDevCond. );
win4_showMachineState->clear();
HWaccess->sys_getDynMachineConditions(&myDynMachCond);
entryMachineCond("All Doors deb.: ", myDynMachCond.allDoorsDebounced);
entryMachineCond("open Authorize: ", myDynMachCond.openedAuthorized );
entryMachineCond("CBin debounced: ", myDynMachCond.CBinDebounced );
entryMachineCond("Upper Door : ", myDynMachCond.upperDoor );
entryMachineCond("Middle Door: : ", myDynMachCond.middleDoor );
entryMachineCond("Lower Door : ", myDynMachCond.lowerDoor );
//entryMachineCond("Coin Safe in : ", myDynMachCond.coinBox );
entryMachineCond("Bill Box in : ", myDynMachCond.billBox );
entryMachineCond("Mode Account : ", myDynMachCond.modeAbrech );
entryMachineCond("On Alarm now : ", myDynMachCond.onAlarm );
entryMachineCond("CardTest now : ", myDynMachCond.nowCardTest );
//entryMachineCond("Payment now : ", myDynMachCond.nowPayment );
entryMachineCond("last CardType : ", myDynMachCond.lastMifCardType );
entryMachineCond("last Sdoor st.: ", myDynMachCond.lastSDoorState );
entryMachineCond("last Vdoor st.: ", myDynMachCond.lastVDoorState );
entryMachineCond("last Vault st.: ", myDynMachCond.lastCBstate );
entryMachineCond("PayInProgress : ", myDynMachCond.paymentInProgress );
//entryMachineCond(": ", myDynMachCond.res1 );
entryMachineCond("Voltage now : ", myDynMachCond.U_Batt );
entryMachineCond("Temperature : ", myDynMachCond.Temperatur );
entryMachineCond("Nr Coins now : ", myDynMachCond.nrCoinsInBox );
entryMachineCond("Amount now : ", myDynMachCond.amountInBox );
entryMachineCond("Tot.Trans.Vol.: ", myDynMachCond.totalTransVolume );
entryMachineCond("Tot.Nr.Vends : ", myDynMachCond.totalNrOfVends );
entryMachineCond("jsonConf valid: ", myDynMachCond.jsonValid_config );
entryMachineCond("jsonDev valid : ", myDynMachCond.jsonValid_device );
entryMachineCond("jsonCash valid: ", myDynMachCond.jsonValid_cash );
entryMachineCond("jsonPri valid : ", myDynMachCond.jsonValid_print );
entryMachineCond("jsonSer valid : ", myDynMachCond.jsonValid_serial );
entryMachineCond("jsonTime valid: ", myDynMachCond.jsonValid_time );
entryMachineCond("last File Type: ", myDynMachCond.lastFileType );
entryArray( "Card Holder : ", myDynMachCond.MifCardHolder );
entryMachineCond("Print result : ", myDynMachCond.resultOfLastTemplPrint );
entryMachineCond("last Pri. Stat: ", myDynMachCond.lastPrinterStatus );
entryMachineCond("startup run : ", myDynMachCond.startupTestIsRunning);
//entryMachineCond(": ", myDynMachCond. );
win4_showErrors->clear();
win4_devParameters->clear();
//HWaccess->sys_restoreDeviceParameter(&devPara); // all 0
if (myDevCond.rtc>=200)
win4_showErrors->addItem("Error RTC HW");
else if (myDevCond.rtc>=100)
win4_showErrors->addItem("Warning RTC time may be wrong");
if (myDevCond.printer==200) win4_showErrors->addItem("Error Printer no response");
if (myDevCond.printer==201) win4_showErrors->addItem("Error Printer HW");
if (myDevCond.printer==202) win4_showErrors->addItem("Error Printer no Paper");
if (myDevCond.coinBlocker>=200) win4_showErrors->addItem("Error Coin Blocker");
if (myDevCond.mdbBus>=200) win4_showErrors->addItem("Error Mdb Bus");
if (myDevCond.intEe>=200) win4_showErrors->addItem("Error int eeprom");
if (myDevCond.coinChecker>=200) win4_showErrors->addItem("Error Coin checker");
if (myDevCond.coinEscrow>=200) win4_showErrors->addItem("Error Coin escrow");
if (myDevCond.coinChecker==3)
{
if (myDevCond.changer>=200) win4_showErrors->addItem("Error Coin changer");
}
if (myDevCond.coinChecker>0) // irgendeiner
{
if (myDevCond.coinSafe==200)
win4_showErrors->addItem("Error no cash box ");
if (myDevCond.coinSafe==201)
win4_showErrors->addItem("Error cash box full");
}
if ( myDevCond.billReader>=200 )
{
win4_showErrors->addItem("Error Bill reader");
}
if (myDevCond.voltage==200)
win4_showErrors->addItem("Error voltage off limits");
if (myDevCond.voltage==201)
win4_showErrors->addItem("Error voltage too low");
if (myDevCond.temper==200 )
win4_showErrors->addItem("Error temperature off limits");
if (myDevCond.temper==201 )
win4_showErrors->addItem("Error extrem temperature");
if (myDevCond.printer==100) win4_showErrors->addItem("Warning Printer NearPaperEnd");
if (myDevCond.coinChecker>0)
{
if (myDevCond.coinSafe>=100 && myDevCond.coinSafe<200)
win4_showErrors->addItem("Warning cash box almost full");
}
if (myDevCond.voltage>=100 && myDevCond.voltage<200)
win4_showErrors->addItem("Warning voltage low");
if (myDevCond.temper>=100 && myDevCond.temper<200 )
win4_showErrors->addItem("Warning temperature");
}
if (myNextStep)
{
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep;
myNextStep=0;
}
return false;
}
/*
uint8_t T_win04::sub_componentAssessment(void)
{
// this function decides if vending mode is possible, independant from door
// return >0 in case of error
// is inncluded in sys_superviseSystem
struct T_moduleCondition *modCond=0;
HWaccess->sys_getDeviceConditions(modCond);
struct T_dynamicCondition *dynMaCond=0;
HWaccess->sys_getDynMachineConditions(dynMaCond);
struct T_devices *devPara=0;
//hwaccess->sys_restoreDeviceParameter(devPara);
if (modCond->rtc>=200)
return 1;
if (modCond->printer==200 || modCond->printer==201) // 200: not connected 201: printer-HW-error 202: no paper
return 2;
if (modCond->printer==202)
return 3;
if (modCond->coinBlocker>=200)
return 4;
if (modCond->mdbBus>=200)
return 5;
if (modCond->intEe>=200)
return 6;
if (devPara->kindOfCoinChecker==1 || devPara->kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW)
{
if (modCond->coinChecker>=200 || modCond->coinEscrow>=200)
{
// Fehler Münzver.
return 7;
}
if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{
return 8;
}
} else
if (devPara->kindOfCoinChecker==3)
{
if (modCond->changer>=200)
{
// Fehler Münzver.
return 7;
}
if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{
return 8;
}
}
if ( modCond->billReader>=200 && devPara->BillAcceptor>0)
{
// Fehler BNA
return 9;
}
if (dynMaCond->onAlarm>0)
return 10;
if (dynMaCond->modeAbrech>0)
return 11;
if (dynMaCond->nowCardTest>0)
return 12;
//if (dynMaCond->startupTestIsRunning>0)
// return 13;
if (modCond->voltage>=200)
return 14;
if (modCond->temper>=200)
return 15;
return 0;
}
*/
//uint8_t T_win04::sys_getSystemErrors(void)
//{
// 0: everything fine 1..15: errors
/* 1: real time clock error
2: printer error
3: no paper
4: coin blocker
5: mdb error
6: mem error int.ee.
7: error coin validator
8: coin safe missed or full
9: bill acceptor error
10: alarm / intrusion
11: cash box change is ongoing
12: card test running
13: startup-test is running
14: voltage error
15: temperature error
*/
// return this->sub_componentAssessment();
//}