#include "win02_home.h" #include "globVars.h" //#define BUTTONCOLOR "background-color: rgb(150,250,150)" #define zeile1PB 10 #define zeile2PB 11 #define BUTTON_HEIGHT 50 extern void exitServiceModule(void); T_win02::T_win02(hwinf *HWaccess, QWidget *parent) : QWidget(parent) { this->HWaccess = HWaccess; myLayout = new QGridLayout; QFont myTabFont; myTabFont.setPixelSize(PIXELSIZE_LABEL); QLabel *lab1 =new QLabel(tr("Service Main")); lab1->setFont(myTabFont); myLayout->addWidget(lab1,1,0); QLabel *lab2 =new QLabel(tr("MachineNr:")); lab2->setFont(myTabFont); myLayout->addWidget(lab2,2,0); QLabel *lab3 =new QLabel(tr("Borough,zone:")); lab3->setFont(myTabFont); myLayout->addWidget(lab3,3,0); QLabel *lab4 =new QLabel(tr("Location:")); lab4->setFont(myTabFont); myLayout->addWidget(lab4,4,0); QLabel *lab16 =new QLabel("DC Unique ID:"); lab16->setFont(myTabFont); myLayout->addWidget(lab16,5,0); // Anzeige: DC-connection labState =new QLabel(tr("------------")); // datenverkehr läuft labState->setFont(myTabFont); labState->setFrameStyle(1); myLayout->addWidget(labState,1,4); myTabFont.setPixelSize(PIXELSIZE_DATA); labMaNu1 =new QLabel(tr(" --- ")); labMaNu1->setFont(myTabFont); myLayout->addWidget(labMaNu1,2,1); labMaNu2 =new QLabel(tr(" --- ")); labMaNu2->setFont(myTabFont); myLayout->addWidget(labMaNu2,2,2); labBez =new QLabel(tr("-")); labBez->setFont(myTabFont); myLayout->addWidget(labBez,3,1); labZone =new QLabel(tr("-")); labZone->setFont(myTabFont); myLayout->addWidget(labZone,3,2); labLoc1 =new QLabel(tr("-")); labLoc1->setFont(myTabFont); myLayout->addWidget(labLoc1,4,1); labLoc2 =new QLabel(tr("-")); labLoc2->setFont(myTabFont); myLayout->addWidget(labLoc2,4,2); // pt_loc = new QPlainTextEdit(); // pt_loc->setFont(myTabFont); // myLayout->addWidget(pt_loc,4,1); labUID =new QLabel("-"); labUID->setFont(myTabFont); myLayout->addWidget(labUID,5,1); /* movingTest = new QLabel(); movingTest->setFont(myTabFont); myLayout->addWidget(movingTest,5,3); // */ myTabFont.setPixelSize(PIXELSIZE_BUTTONS); pb1 = new QPushButton(WIN02_LABEL_SHORT01); pb1->setCheckable(false); // true = toggle button pb1->setAutoDefault(false); // beim start aus pb1->setMinimumHeight(BUTTON_HEIGHT); pb1->setFont(myTabFont); pb1->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb1,zeile1PB,0); connect(pb1, SIGNAL(clicked()), this, SLOT(ButtonPb1Clicked())); pb2 = new QPushButton(WIN02_LABEL_SHORT02); pb2->setCheckable(false); // true = toggle button pb2->setAutoDefault(false); // beim start aus pb2->setMinimumHeight(BUTTON_HEIGHT); pb2->setFont(myTabFont); pb2->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb2,zeile1PB,1); connect(pb2, SIGNAL(clicked()), this, SLOT(ButtonPb2Clicked())); pb3 = new QPushButton(WIN02_LABEL_SHORT03); pb3->setCheckable(false); // true = toggle button pb3->setAutoDefault(false); // beim start aus pb3->setMinimumHeight(BUTTON_HEIGHT); pb3->setFont(myTabFont); pb3->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb3,zeile1PB,2); connect(pb3, SIGNAL(clicked()), this, SLOT(ButtonPb3Clicked())); pb4 = new QPushButton(WIN02_LABEL_SHORT04); pb4->setCheckable(false); // true = toggle button pb4->setAutoDefault(false); // beim start aus pb4->setMinimumHeight(BUTTON_HEIGHT); pb4->setFont(myTabFont); pb4->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb4,zeile1PB,3); connect(pb4, SIGNAL(clicked()), this, SLOT(ButtonPb4Clicked())); pb5 = new QPushButton(WIN02_LABEL_SHORT05); pb5->setCheckable(false); // true = toggle button pb5->setAutoDefault(false); // beim start aus pb5->setMinimumHeight(BUTTON_HEIGHT); pb5->setFont(myTabFont); pb5->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb5,zeile1PB,4); connect(pb5, SIGNAL(clicked()), this, SLOT(ButtonPb5Clicked())); pb6 = new QPushButton(WIN02_LABEL_SHORT06); pb6->setCheckable(false); // true = toggle button pb6->setAutoDefault(false); // beim start aus pb6->setMinimumHeight(BUTTON_HEIGHT); pb6->setFont(myTabFont); pb6->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb6,zeile2PB,0); connect(pb6, SIGNAL(clicked()), this, SLOT(ButtonPb6Clicked())); pb7 = new QPushButton(WIN02_LABEL_SHORT07); pb7->setCheckable(false); // true = toggle button pb7->setAutoDefault(false); // beim start aus pb7->setMinimumHeight(BUTTON_HEIGHT); pb7->setFont(myTabFont); pb7->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb7,zeile2PB,1); connect(pb7, SIGNAL(clicked()), this, SLOT(ButtonPb7Clicked())); pb8 = new QPushButton(WIN02_LABEL_SHORT08); pb8->setCheckable(false); // true = toggle button pb8->setAutoDefault(false); // beim start aus pb8->setMinimumHeight(BUTTON_HEIGHT); pb8->setFont(myTabFont); pb8->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb8,zeile2PB,2); connect(pb8, SIGNAL(clicked()), this, SLOT(ButtonPb8Clicked())); pb9 = new QPushButton(WIN02_LABEL_SHORT09); pb9->setCheckable(false); // true = toggle button pb9->setAutoDefault(false); // beim start aus pb9->setMinimumHeight(BUTTON_HEIGHT); pb9->setFont(myTabFont); pb9->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb9,zeile2PB,3); connect(pb9, SIGNAL(clicked()), this, SLOT(ButtonPb9Clicked())); pb10 = new QPushButton(WIN02_LABEL_SHORT10); pb10->setCheckable(false); // true = toggle button pb10->setAutoDefault(false); // beim start aus pb10->setMinimumHeight(BUTTON_HEIGHT); pb10->setFont(myTabFont); pb10->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb10,zeile2PB,4); connect(pb10, SIGNAL(clicked()), this, SLOT(ButtonPb10Clicked())); pb11 = new QPushButton("Exit Service"); pb11->setCheckable(false); // true = toggle button pb11->setAutoDefault(false); // beim start aus pb11->setMinimumHeight(BUTTON_HEIGHT); pb11->setFont(myTabFont); pb11->setStyleSheet(BUTTONCOLOR); myLayout->addWidget(pb11,5,4); connect(pb11, SIGNAL(clicked()), this, SLOT(ButtonPb11Clicked())); QLabel *lab5 =new QLabel(tr(" ")); lab5->setFont(myTabFont); myLayout->addWidget(lab5,6,0); // Autosend: AutSendButton = new QPushButton(tr("&Automatic\n reading")); // &A --> also keycode Alt-A possible myLayout->addWidget(AutSendButton,3,4); AutSendButton->setCheckable(true); // true = toggle button AutSendButton->setAutoDefault(true); // beim start aus AutSendButton->setMinimumHeight(50); connect(AutSendButton, SIGNAL(clicked()), this, SLOT(callAutoSend())); // new 4.6.2024: wake DC AutSendButton = new QPushButton(tr("&Automatic\n reading")); // &A --> also keycode Alt-A possible myLayout->addWidget(AutSendButton,3,4); AutSendButton->setCheckable(true); // true = toggle button AutSendButton->setAutoDefault(true); // beim start aus AutSendButton->setMinimumHeight(50); connect(AutSendButton, SIGNAL(clicked()), this, SLOT(callAutoSend())); systTime = new QTime(); systDate = new QDate(); setLayout(myLayout); myNextStep=0; myStep=0; myTO = new QTimer(); myTO->setSingleShot(true); myTO->start(2000); /* moveTestStr.clear(); moveTestStr.append("1234567890abcdefgh"); movingTest->setText(moveTestStr); */ // lese Datei ../APserviceConfig.csv und speichere die Parameter global ab QByteArray myBA; int cchk, br; myBA=datei_readFromFile(FILENAME_APSERVCONF); cchk=csv_getEntryAsInt(myBA,1); // 2. entry = kind of coin checker br=csv_getEntryAsInt(myBA,2); // 2. entry = kind of coin checker globVar_SetCoinChecker(cchk); globVar_SetBna(br); // Test: //int itmp=globVar_GetCoinChecker(); //if (itmp==3) // pb10->setText("Changer"); //else // pb10->setText(" EMP "); } T_win02::~T_win02() { close(); } void T_win02::Nav_back(void) { myNextStep=WCS_WIN02BAK; } void T_win02::Nav_home(void) { // already here myNextStep=WCS_WIN02MID; } void T_win02::Nav_next(void) { myNextStep=WCS_WIN02FWD; } void T_win02::ButtonPb1Clicked(void) { myNextStep=WCS_WIN02SHORT01; } void T_win02::ButtonPb2Clicked(void) { myNextStep=WCS_WIN02SHORT02; } void T_win02::ButtonPb3Clicked(void) { myNextStep=WCS_WIN02SHORT03; } void T_win02::ButtonPb4Clicked(void) { myNextStep=WCS_WIN02SHORT04; } void T_win02::ButtonPb5Clicked(void) { myNextStep=WCS_WIN02SHORT05; } void T_win02::ButtonPb6Clicked(void) { myNextStep=WCS_WIN02SHORT06; } void T_win02::ButtonPb7Clicked(void) { myNextStep=WCS_WIN02SHORT07; } void T_win02::ButtonPb8Clicked(void) { myNextStep=WCS_WIN02SHORT08; } void T_win02::ButtonPb9Clicked(void) { myNextStep=WCS_WIN02SHORT09; } void T_win02::ButtonPb10Clicked(void) { myNextStep=WCS_WIN02SHORT10; } void T_win02::ButtonPb11Clicked(void) // Leave app (quit) { emit quitMyApp(); } void T_win02::callAutoSend() { if (AutSendButton->isChecked()) { HWaccess->dc_autoRequest(1); } else { HWaccess->dc_autoRequest(0); } } // ptu_switchWake(true); bool T_win02::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_OFF | SWITCH_NEXT_ON; just for master *useNavi=SWITCH_BACK_ON | SWITCH_HOME_OFF | SWITCH_NEXT_ON; myNextStep=0; return false; } bool T_win02::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" uint8_t len, buf[64]; //, locBuf[32]; uint16_t cunu, manu, borough, zone, alias; //, uitmp; QString myStr, tmpStr, locationStr; //static int ctr; uint8_t nn, uctmp; //, yl, yh; //static int cyclCtr; QByteArray myBA; *nextScreen=0; // 0=no change *useNavi=0; if (myNextStep) { //qDebug()<<"fenster1 working: "<< myNextStep; *nextScreen=myNextStep; myNextStep=0; return false; } tmpStr.clear(); // update values: if (HWaccess->sys_areDCdataValid()) { labState->setText(" DC2 connected "); // datenverkehr läuft labState->setStyleSheet(COLORGREEN); } else { labState->setText(" no connection\n to DC "); labState->setStyleSheet(COLORYELLOW); //qDebug()<<"lost connection to DC"; } HWaccess->readback_machineIDdata(&len, buf); cunu=uchar2uint(buf[1], buf[0]); // binary, decimal manu=uchar2uint(buf[3], buf[2]); borough=uchar2uint(buf[5], buf[4]); zone=uchar2uint(buf[7], buf[6]); alias=uchar2uint(buf[9], buf[8]); myStr.clear(); for (nn=0; nn<16; nn++) { uctmp=buf[nn+10]; if (uctmp>=32) myStr+=QChar(uctmp); } labLoc1->setText(myStr); myStr.clear(); for (nn=0; nn<16; nn++) { uctmp=buf[nn+26]; if (uctmp>=32) myStr+=QChar(uctmp); } labLoc2->setText(myStr); if (cunu>0 && manu>0) { myStr.clear(); myStr.append(QString::number(cunu)); myStr.append("-"); myStr.append(QString::number(manu)); labMaNu1->setText(myStr); myStr.clear(); myStr.append(QString::number(alias)); labMaNu2->setText(myStr); } labUID->setText( HWaccess->dc_getUIDstr()); if (borough>0 || zone>0) // at least one { myStr.clear(); myStr.append(QString::number(borough)); labBez->setText(myStr); myStr.clear(); myStr.append(QString::number(zone)); labZone->setText(myStr); } if (HWaccess->dc_isAutoRequestOn()) { AutSendButton->setStyleSheet(COLORGREEN); } else AutSendButton->setStyleSheet(COLORWHITE); /* just a test: if (++cyclCtr>10) { cyclCtr=0; int LL=moveTestStr.length()-1; moveTestStr=moveTestStr.right(LL); // move left by one moveTestStr.append("-"); movingTest->clear(); movingTest->setText(moveTestStr); myBA.truncate(1); } */ return false; }