#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"); pbCreditWake->setCheckable(true); // true = toggle button 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); /* 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())); */ /* pbTest1 = new QPushButton("PTU up"); pbTest1->setCheckable(false); // true = toggle button pbTest1->setFont(myTabFont); pbTest1->setStyleSheet("background-color: yellow"); myLayout->addWidget(pbTest1, 5, 0); connect(pbTest1, SIGNAL(clicked()), this, SLOT(slot_pbTest1())); pbTest2 = new QPushButton("PTU dn"); pbTest2->setCheckable(false); // true = toggle button pbTest2->setFont(myTabFont); pbTest2->setStyleSheet("background-color: yellow"); myLayout->addWidget(pbTest2, 6, 0); connect(pbTest2, SIGNAL(clicked()), this, SLOT(slot_pbTest2())); pbTest3 = new QPushButton("DC up"); pbTest3->setCheckable(false); // true = toggle button pbTest3->setFont(myTabFont); pbTest3->setStyleSheet("background-color: yellow"); myLayout->addWidget(pbTest3, 7, 0); connect(pbTest3, SIGNAL(clicked()), this, SLOT(slot_pbTest3())); pbTest4 = new QPushButton("DC dn"); pbTest4->setCheckable(false); // true = toggle button pbTest4->setFont(myTabFont); pbTest4->setStyleSheet("background-color: yellow"); myLayout->addWidget(pbTest4, 8, 0); connect(pbTest4, SIGNAL(clicked()), this, SLOT(slot_pbTest4())); */ 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); pbCreditPwr->setStyleSheet("background-color: green"); } else { HWaccess->credit_switchPower(false); pbCreditPwr->setStyleSheet("background-color: white"); } } void T_win09::slot_CreditWake(void) { 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); wakeTerminal=true; } void T_win09::slot_startTest(void) { HWaccess->sys_runCompleteTest(); } // 8.10.2024 new, control power up/down /* void slot_pbTest1(void) { HWaccess->prepareForPowerDown(); } void slot_pbTest2(void) { HWaccess->justReactivated(); } void slot_pbTest3(void) { HWaccess->dcNotActive(); } void slot_pbTest4(void) { HWaccess->dcIsActive(); } */ 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); //if (wakeTerminal) // HWaccess->credit_switchWake(false); 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 pbModemPwr->setStyleSheet("background-color: white"); //bret=HWaccess->cred_isCreditPowerOn(); // funktioniert nicht /* bret=pbCreditPwr->isChecked(); if (bret) pbCreditPwr->setStyleSheet("background-color: green"); else pbCreditPwr->setStyleSheet("background-color: white"); */ // 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; }