2023-11-14 09:32:56 +01:00
|
|
|
#include "win09_gsm.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct T_moduleCondition
|
|
|
|
{
|
|
|
|
uint8_t modem;
|
|
|
|
uint8_t signal; // 1...99
|
|
|
|
uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime
|
|
|
|
|
|
|
|
uint8_t creditTerm;
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool wakeTerminal, wakeModem, resetModem;
|
|
|
|
|
|
|
|
T_win09::T_win09(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
this->HWaccess = HWaccess;
|
|
|
|
|
|
|
|
myLayout = new QGridLayout;
|
|
|
|
|
|
|
|
QFont myTabFont;
|
|
|
|
myTabFont.setPixelSize(22);
|
|
|
|
|
|
|
|
lab1 =new QLabel(tr("Modem"));
|
|
|
|
lab1->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab1,1,0);
|
|
|
|
|
|
|
|
lab3 =new QLabel(tr(" "));
|
|
|
|
lab3->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab3,1,1);
|
|
|
|
|
|
|
|
lab4 =new QLabel(tr(" "));
|
|
|
|
lab4->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab4,1,2);
|
|
|
|
|
|
|
|
pbModemPwr = new QPushButton("Modem (credit) Power");
|
|
|
|
pbModemPwr->setCheckable(true); // true = toggle button
|
|
|
|
pbModemPwr->setAutoDefault(false); // beim start aus
|
|
|
|
pbModemPwr->setFont(myTabFont);
|
|
|
|
pbModemPwr->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbModemPwr, 3, 1);
|
|
|
|
connect(pbModemPwr, SIGNAL(clicked()), this, SLOT(slot_ModemPower()));
|
|
|
|
|
|
|
|
lab8 =new QLabel(tr(" "));
|
|
|
|
lab8->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab8,4,1);
|
|
|
|
|
|
|
|
pbModemWake = new QPushButton("Modem wake");
|
|
|
|
pbModemWake->setCheckable(false); // true = toggle button
|
|
|
|
pbModemWake->setFont(myTabFont);
|
|
|
|
pbModemWake->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbModemWake, 5, 1);
|
|
|
|
connect(pbModemWake, SIGNAL(clicked()), this, SLOT(slot_ModemWake()));
|
|
|
|
|
|
|
|
lab9 =new QLabel(tr(" "));
|
|
|
|
lab9->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab9,6,1);
|
|
|
|
|
|
|
|
pbModemRes = new QPushButton("Modem reset");
|
|
|
|
pbModemRes->setCheckable(false); // true = toggle button
|
|
|
|
pbModemRes->setFont(myTabFont);
|
|
|
|
pbModemRes->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbModemRes, 7, 1);
|
|
|
|
connect(pbModemRes, SIGNAL(clicked()), this, SLOT(slot_ModemRes()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lab5 =new QLabel(tr(" modem condition:"));
|
|
|
|
lab5->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab5,4,2);
|
|
|
|
|
|
|
|
showModemCondition = new QLabel();
|
|
|
|
showModemCondition->setFont(myTabFont);
|
|
|
|
showModemCondition->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(showModemCondition,5,2);
|
|
|
|
|
|
|
|
lab10 =new QLabel(tr(" "));
|
|
|
|
lab10->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab10,8,1);
|
|
|
|
|
|
|
|
pbCreditPwr = new QPushButton("Creditcard (PTU) power");
|
|
|
|
pbCreditPwr->setCheckable(true); // true = toggle button
|
|
|
|
pbCreditPwr->setAutoDefault(false); // beim start aus
|
|
|
|
pbCreditPwr->setFont(myTabFont);
|
|
|
|
pbCreditPwr->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbCreditPwr, 9, 1);
|
|
|
|
connect(pbCreditPwr, SIGNAL(clicked()), this, SLOT(slot_CreditPower()));
|
|
|
|
|
|
|
|
lab11 =new QLabel(tr(" "));
|
|
|
|
lab11->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab11,10,1);
|
|
|
|
|
|
|
|
pbCreditWake = new QPushButton("Creditcard wake");
|
2024-07-08 10:34:47 +02:00
|
|
|
pbCreditWake->setCheckable(true); // true = toggle button
|
2023-11-14 09:32:56 +01:00
|
|
|
pbCreditWake->setFont(myTabFont);
|
|
|
|
pbCreditWake->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbCreditWake, 11, 1);
|
|
|
|
connect(pbCreditWake, SIGNAL(clicked()), this, SLOT(slot_CreditWake()));
|
|
|
|
|
|
|
|
lab7 =new QLabel(tr(" "));
|
|
|
|
lab7->setFont(myTabFont);
|
|
|
|
myLayout->addWidget(lab7,12,1);
|
2024-07-08 10:34:47 +02:00
|
|
|
/*
|
2023-11-14 09:32:56 +01:00
|
|
|
pbCreditWake = new QPushButton("restart System test (20s!)");
|
|
|
|
pbCreditWake->setCheckable(false); // true = toggle button
|
|
|
|
pbCreditWake->setFont(myTabFont);
|
|
|
|
pbCreditWake->setStyleSheet("background-color: white");
|
|
|
|
myLayout->addWidget(pbCreditWake, 13, 1);
|
|
|
|
connect(pbCreditWake, SIGNAL(clicked()), this, SLOT(slot_startTest()));
|
2024-07-08 10:34:47 +02:00
|
|
|
*/
|
2023-11-14 09:32:56 +01:00
|
|
|
|
|
|
|
setLayout(myLayout);
|
|
|
|
myNextStep=0;
|
|
|
|
myStep=0;
|
|
|
|
|
|
|
|
myTO = new QTimer();
|
|
|
|
myTO->setSingleShot(true);
|
|
|
|
myTO->start(100);
|
|
|
|
wakeTerminal=false;
|
|
|
|
wakeModem=false;
|
|
|
|
resetModem=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
T_win09::~T_win09()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::Nav_back(void)
|
|
|
|
{
|
|
|
|
myNextStep=WCS_WIN09BAK;
|
|
|
|
}
|
|
|
|
void T_win09::Nav_home(void)
|
|
|
|
{
|
|
|
|
myNextStep=WCS_WIN09MID;
|
|
|
|
}
|
|
|
|
void T_win09::Nav_next(void)
|
|
|
|
{
|
|
|
|
myNextStep=WCS_WIN09FWD;
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_ModemPower(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pbModemPwr->isChecked())
|
|
|
|
{
|
|
|
|
HWaccess->mod_switchPower(true);
|
|
|
|
} else
|
|
|
|
HWaccess->mod_switchPower(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_ModemWake(void)
|
|
|
|
{
|
|
|
|
HWaccess->mod_switchWake(true);
|
|
|
|
myTO->start(200);
|
|
|
|
wakeModem=true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_ModemRes(void)
|
|
|
|
{
|
|
|
|
// Modem Reset: aux6=used
|
|
|
|
//aux_setUsage(0x20);
|
|
|
|
//aux_setOutputs(0x20); aux_setOutputs(0);
|
|
|
|
|
|
|
|
HWaccess->aux_setUsage(0x20);
|
|
|
|
HWaccess->aux_setOutputs(0x20);
|
|
|
|
myTO->start(200);
|
|
|
|
resetModem=true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_CreditPower(void)
|
|
|
|
{
|
|
|
|
if (pbCreditPwr->isChecked())
|
|
|
|
{
|
|
|
|
HWaccess->credit_switchPower(true);
|
2024-07-08 10:34:47 +02:00
|
|
|
pbCreditPwr->setStyleSheet("background-color: green");
|
2023-11-14 09:32:56 +01:00
|
|
|
} else
|
2024-07-08 10:34:47 +02:00
|
|
|
{
|
2023-11-14 09:32:56 +01:00
|
|
|
HWaccess->credit_switchPower(false);
|
2024-07-08 10:34:47 +02:00
|
|
|
pbCreditPwr->setStyleSheet("background-color: white");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-14 09:32:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_CreditWake(void)
|
|
|
|
{
|
2024-07-08 10:34:47 +02:00
|
|
|
if (pbCreditWake->isChecked())
|
|
|
|
{
|
|
|
|
pbCreditWake->setStyleSheet("background-color: green");
|
|
|
|
HWaccess->credit_switchWake(false); // LOW-ACTIVE
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
pbCreditWake->setStyleSheet("background-color: white");
|
|
|
|
HWaccess->credit_switchWake(true);
|
|
|
|
}
|
|
|
|
myTO->start(200);
|
2023-11-14 09:32:56 +01:00
|
|
|
wakeTerminal=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void T_win09::slot_startTest(void)
|
|
|
|
{
|
|
|
|
HWaccess->sys_runCompleteTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool T_win09::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_win09::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;
|
|
|
|
QString myStr;
|
|
|
|
bool bret;
|
|
|
|
|
|
|
|
if (!myTO->isActive())
|
|
|
|
{
|
|
|
|
// time out
|
|
|
|
if (wakeModem)
|
|
|
|
HWaccess->mod_switchWake(false);
|
2024-07-08 10:34:47 +02:00
|
|
|
//if (wakeTerminal)
|
|
|
|
// HWaccess->credit_switchWake(false);
|
2023-11-14 09:32:56 +01:00
|
|
|
if (resetModem)
|
|
|
|
HWaccess->aux_setOutputs(0);
|
|
|
|
|
|
|
|
myTO->stop();
|
|
|
|
wakeTerminal=false;
|
|
|
|
wakeModem=false;
|
|
|
|
resetModem=false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bret=HWaccess->mod_isGsmPowerOn();
|
|
|
|
if (bret)
|
|
|
|
pbModemPwr->setStyleSheet("background-color: green");
|
|
|
|
else
|
2024-07-08 10:34:47 +02:00
|
|
|
pbModemPwr->setStyleSheet("background-color: white");
|
2023-11-14 09:32:56 +01:00
|
|
|
|
2024-07-08 10:34:47 +02:00
|
|
|
//bret=HWaccess->cred_isCreditPowerOn(); // funktioniert nicht
|
|
|
|
/*
|
|
|
|
bret=pbCreditPwr->isChecked();
|
2023-11-14 09:32:56 +01:00
|
|
|
if (bret)
|
|
|
|
pbCreditPwr->setStyleSheet("background-color: green");
|
|
|
|
else
|
|
|
|
pbCreditPwr->setStyleSheet("background-color: white");
|
2024-07-08 10:34:47 +02:00
|
|
|
*/
|
2023-11-14 09:32:56 +01:00
|
|
|
|
|
|
|
// restart complete system test with cmd 149
|
|
|
|
|
|
|
|
/*
|
|
|
|
struct T_moduleCondition
|
|
|
|
{
|
|
|
|
uint8_t modem; // 0:unknown 1:OK 100: sim card problem 200: no resp 201: wrong modem type
|
|
|
|
uint8_t signal; // 1...99
|
|
|
|
uint8_t regist; // 100:not 1:reg (not impl.: 2:ping OK 3:gotTime )
|
|
|
|
uint8_t creditTerm; // always 1
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct T_moduleCondition modulCond;
|
|
|
|
HWaccess->sys_getDeviceConditions(&modulCond);
|
|
|
|
if (modulCond.modem==100)
|
|
|
|
showModemCondition->setText("Simcard problem");
|
|
|
|
else
|
|
|
|
if (modulCond.modem==200)
|
|
|
|
showModemCondition->setText("not connected");
|
|
|
|
else
|
|
|
|
if (modulCond.modem==201)
|
|
|
|
showModemCondition->setText("wrong type");
|
|
|
|
else
|
|
|
|
if (modulCond.modem==1)
|
|
|
|
{
|
|
|
|
// Modem OK
|
|
|
|
myStr.append("modem OK, ");
|
|
|
|
myStr.clear();
|
|
|
|
if (modulCond.regist==1)
|
|
|
|
myStr.append("registered, ");
|
|
|
|
if (modulCond.regist==100)
|
|
|
|
myStr.append(" not registered, ");
|
|
|
|
|
|
|
|
myStr.append("last signal: ");
|
|
|
|
myStr.append(QString::number(modulCond.signal,10));
|
|
|
|
showModemCondition->setText(myStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (myNextStep)
|
|
|
|
{
|
|
|
|
*nextScreen=myNextStep;
|
|
|
|
myNextStep=0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|