commit 3648b3d129693ade16a56227620305a57fe37bba Author: Gerhard Hoffmann Date: Tue Nov 14 09:32:56 2023 +0100 Add files from 13.November 2023. diff --git a/APservice.pro b/APservice.pro new file mode 100755 index 0000000..9e04c9d --- /dev/null +++ b/APservice.pro @@ -0,0 +1,85 @@ +QT += core gui +QT +=widgets serialport +QT +=network + # for TCP-IP + +TARGET = APservice +#LIBS = -L../plugins + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 +QMAKE_CXXFLAGS += -Wno-deprecated-copy + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + globVars.cpp \ + keypad.cpp \ + lib_template.cpp \ + main.cpp \ + mainwindow.cpp \ + tslib.cpp \ + win01_com.cpp \ + win02_home.cpp \ + win03_time.cpp \ + win04_stat.cpp \ + win05_doors.cpp \ + win06_prn.cpp \ + win07_coin.cpp \ + win08_mif.cpp \ + win09_gsm.cpp \ + win10_pay.cpp \ + win11_abr.cpp \ + win12_BL.cpp \ + win13_json.cpp \ + win14_mw.cpp \ + win15_bna.cpp \ + win16.cpp \ + win17.cpp \ + win18.cpp \ + win19.cpp \ + win20.cpp \ + win_template.cpp \ + datei.cpp + +HEADERS += \ + globVars.h \ + guidefs.h \ + keypad.h \ + lib_template.h \ + mainwindow.h \ + stepList.h \ + tslib.h \ + versionHistory.txt \ + win01_com.h \ + win02_home.h \ + win03_time.h \ + win04_stat.h \ + win05_doors.h \ + win06_prn.h \ + win07_coin.h \ + win08_mif.h \ + win09_gsm.h \ + win10_pay.h \ + win11_abr.h \ + win12_BL.h \ + win13_json.h \ + win14_mw.h \ + win15_bna.h \ + win16.h \ + win17.h \ + win18.h \ + win19.h \ + win20.h \ + win_template.h \ + datei.h \ + plugin.h \ + interfaces.h + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/datei.cpp b/datei.cpp new file mode 100755 index 0000000..69a3812 --- /dev/null +++ b/datei.cpp @@ -0,0 +1,944 @@ +// written by Thomas Sax, Jan.2022 +#include "datei.h" + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ create csv file ------------------------------- +// ------------------------------------------------------------------------------------------------- + +QByteArray datei_writeArray, datei_tempArray; + +void csv_startCreatingFile(void) +{ + datei_writeArray.clear(); + datei_tempArray.clear(); +} + +void csv_addTextToFile(QString myText) +{ + datei_writeArray.append(myText.toLatin1()); + datei_writeArray.append(FILESEPERATOR); +} + +void csv_addIntToFile(int myValue) +{ + //qulonglong ullt=12345678901234567890; // max 1,844 x10^19 + datei_tempArray.setNum(myValue,10); // accepted types: short, ushort, int, uint, + // qlonglong, qulonglong, float, double + // numerbase can be 2...36(!),10=dec + + datei_writeArray.append(datei_tempArray); + datei_writeArray.append(FILESEPERATOR); +} + +void csv_addUintToFile(uint myValue) +{ + datei_tempArray.setNum(myValue,10); + datei_writeArray.append(datei_tempArray); + datei_writeArray.append(FILESEPERATOR); +} + + +void csv_addLongvalToFile(qlonglong myValue) +{ + datei_tempArray.setNum(myValue,10); + datei_writeArray.append(datei_tempArray); + datei_writeArray.append(FILESEPERATOR); +} + +void csv_addUlongvalToFile(qulonglong myValue) +{ + datei_tempArray.setNum(myValue,10); + datei_writeArray.append(datei_tempArray); + datei_writeArray.append(FILESEPERATOR); +} + +/* +void csv_addCurrentTimeToFile(void) +{ + uint8_t hour, minute, sec, ui8buf[20]; + char buf[20]; + + config_getSysTime(&hour, &minute, &sec); + GetTimeString(hour, minute, sec, 0, 1, ui8buf); + for (uint8_t nn=0; nn<20; nn++) + buf[nn]=char(ui8buf[nn]); + datei_writeArray.append(buf,8); // time string + datei_writeArray.append(FILESEPERATOR); + +} + +void csv_addCurrentDateToFile(void) +{ + uint16_t year; + uint8_t month, day, ui8buf[20]; + char buf[20]; + + config_getSystemDate(&year, &month, &day); + //qDebug()<<"date year: "<1) + filSize=uint32_t(filLen); + else + return 0; + + // 1) find position of seperators + for (uint32_t ii=0; iiMAXNUMBEROFSEQUENCES) + return ""; + + // 1) find position of seperators + for (ii=0; ii0) + { + start=sepPos[sequNr-1]+1; + ende=sepPos[sequNr]; + } + + //qDebug()<<"datei getOneFileSequence start/ende: "<=ende) + return ""; + //return "-err3-"; + sequence.clear(); + //batmp.clear(); + pp=0; + for (ii=start; ii=int(filSize)) + mm=0; + oneByt=sourceFile.at(mm); + sequence.append(oneByt); + } + return sequence; +} + +int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA, myVA; + int entry=0; + bool ok; + + myVA.clear(); + myBA = csv_getOneFileSequence(sourceFile, sequNr); + //qDebug()<<"datei getEntryAsInt, sequence: " << myBA; + + entry=myBA.toInt(&ok,16); + if (ok) + { + //qDebug()<<"datei getEntryAsInt, number: " << entry; + return entry; + } + //qDebug()<<"datei getEntryAsInt, error " << myBA; + return 0; +} + +int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + long entry=0; + bool ok; + + entry=myBA.toLong(&ok,10); + if (ok) + return entry; + return 0; +} + +uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + uint8_t entry=0; + bool ok; + + entry=uint8_t(myBA.toUShort(&ok,10)); + if (ok) + return entry; + return 0; +} + +uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + uint16_t entry=0; + bool ok; + + entry=uint16_t(myBA.toUInt(&ok,10)); + if (ok) + return entry; + return 0; +} + +uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + uint32_t entry=0; + bool ok; + + entry=myBA.toULong(&ok,10); + if (ok) + return entry; + return 0; +} + +uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + uint64_t entry=0; + bool ok; + + entry=myBA.toULongLong(&ok,10); + if (ok) + return entry; + return 0; +} + + + +QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr) +{ + QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr); + QString entry; + + //qDebug()<<"datei getEntryAsString, sequence: " << myBA; + entry=myBA.toStdString().c_str(); + return entry; +} + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ create Json file ------------------------------- +// ------------------------------------------------------------------------------------------------- + +/* + example +QString str = "{" + " \"Herausgeber\": \"Xema\"," + " \"Nummer\": \"1234-5678-9012-3456\"," + " \"Deckung\": 2e+6," + " \"Währung\": \"EURO\"," + " \"Inhaber\": {" + " \"Name\": \"Mustermann\"," + " \"Vorname\": \"Max\"," + " \"männlich\": true," + " \"Hobbys\": [ \"Reiten\", \"Golfen\", \"Lesen\" ]," + " \"Alter\": 42," + " \"Kinder\": []," + " \"Partner\": null" + " }" + "}"; + +*/ + +QString myJsonCon; +QString tmpStr; + +void json_startRecord(void) +{ + myJsonCon.clear(); + tmpStr.clear(); + myJsonCon.append('{'); +} + +void json_enterIntToRecord(QString attribute, ulong i_value) +{ + tmpStr.clear(); + myJsonCon.append('"'); + myJsonCon.append(attribute); + myJsonCon.append('"'); + myJsonCon.append(':'); + tmpStr.setNum(i_value); + myJsonCon.append(tmpStr); + myJsonCon.append(','); + myJsonCon.append(NEWLINEINFILE); +} + +void json_enterTextToRecord(QString attribute, QString txt_value) +{ + myJsonCon.append('"'); + myJsonCon.append(attribute); + myJsonCon.append('"'); + myJsonCon.append(':'); + myJsonCon.append('"'); + myJsonCon.append(txt_value); + myJsonCon.append('"'); + myJsonCon.append(','); + myJsonCon.append(NEWLINEINFILE); +} +/* +void json_addCurrentTimeToRecord(QString attribute) +{ + uint8_t hour, minute, sec, ui8buf[20]; + //char buf[20]; + + myJsonCon.append('"'); + myJsonCon.append(attribute); + myJsonCon.append('"'); + myJsonCon.append(':'); + myJsonCon.append('"'); + + datei_getSysTime(&hour, &minute, &sec); + GetTimeString(hour, minute, sec, 0, 1, ui8buf); + for (uint8_t nn=0; nn<8; nn++) + myJsonCon.append(ui8buf[nn]); + + myJsonCon.append('"'); + myJsonCon.append(','); + myJsonCon.append(NEWLINEINFILE); + +} + +void json_addCurrentDateToRecord(QString attribute) +{ + uint16_t year; + uint8_t month, day, ui8buf[20]; + //char buf[20]; + + myJsonCon.append('"'); + myJsonCon.append(attribute); + myJsonCon.append('"'); + myJsonCon.append(':'); + myJsonCon.append('"'); + + datei_getSystemDate(&year, &month, &day); + GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf); + for (uint8_t nn=0; nn<10; nn++) + myJsonCon.append(ui8buf[nn]); + + myJsonCon.append('"'); + myJsonCon.append(','); + myJsonCon.append(NEWLINEINFILE); + +} +*/ + +void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals) +{ + // add array of numbers with "nrofVals" elements + + myJsonCon.append('"'); + myJsonCon.append(attribute); + myJsonCon.append('"'); + myJsonCon.append(':'); + myJsonCon.append('['); // eckig!!! + for (ulong ul=0; ulMAXNROFARRAYVALUES) + nrOfPairs=MAXNROFARRAYVALUES; + + for (ii=0; iiMaxBufferSize) + { + ok=false; // got not all + nrOfPairs=MaxBufferSize; + } + for (int ii=0; ii +#include +#include +#include +#include "tslib.h" +#include +#include +#include +#include +#include + + // create csv file with: +#define FILESEPERATOR ',' + + // pasre csv with: +#define FILESEP1 ',' +#define FILESEP2 ';' + +#define NEWLINEINFILE '\n' +#define MAXNUMBEROFSEQUENCES 200 + // only for csv files + + +// all seting-files located in sudirectory "static machine data - smd" +// all generated files located in sudirectory "dynamic machine data - dmd" + +#define FILENAME_COMPORT "../comport.csv" +#define FILENAME_CONFIG "/own/work2023/PSA1256ptu5/smd/DC2C_conf.json" +#define FILENAME_DEVICE "/own/work2023/PSA1256ptu5/smd/DC2C_device.json" +#define FILENAME_CASH "/own/work2023/PSA1256ptu5/smd/DC2C_cash.json" +#define FILENAME_PRINT "/own/work2023/PSA1256ptu5/smd/DC2C_print32.json" +#define FILENAME_APSERVCONF "../APserviceConfig.csv" + + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ create csv file ------------------------------- +// ------------------------------------------------------------------------------------------------- + + +// create array with strings and values (to be written to file) +void csv_startCreatingFile(void); +void csv_addTextToFile(QString myText); +void csv_addIntToFile(int myValue); +void csv_addUintToFile(uint myValue); +void csv_addLongvalToFile(qlonglong myValue); +void csv_addUlongvalToFile(qulonglong myValue); +//void csv_addCurrentTimeToFile(void); +//void csv_addCurrentDateToFile(void); +void csv_addNewlineToFile(void); +QByteArray csv_readbackArray(void); + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ parse csv file ------------------------------- +// ------------------------------------------------------------------------------------------------- + + +// return number of entries in the just read file (entries are seperated by +// comma or line-feed) +uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile); + +// before: QByteArray sourceFile=datei_readFromFile(filename); + +QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr); +// not needed, just for test // sequNr: 0....(size-1) + +// get single entries of of the just read fie: +int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + +QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr); + // sequNr: 0....(size-1) + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ create Json Record ------------------------------- +// ------------------------------------------------------------------------------------------------- + +void json_startRecord(void); + // clear buffer and write opening curly bracket { + +void json_enterIntToRecord(QString attribute, ulong i_value); + // example: "parameter":1234567890 + +void json_enterTextToRecord(QString attribute, QString txt_value); + // example: "parameter":"slow" + +//void json_addCurrentTimeToRecord(QString attribute); + // example: if attribute=myTime: "myTime":"hh_mm_ss" + +//void json_addCurrentDateToRecord(QString attribute); + // example: if attribute=myDate: "myDate":"dd.mm.yyyy" + // also / possible as seperator + // further possible forms: + // format= 0: dd.mm.yyyy (deutsch) + // 1: mm.dd.yyyy (amerika) + // 2: yyyy.mm.dd (Iran, Dubai) + // 3: dd.yyyy.mm + // 4: mm.yyyy.dd + // 5: yyyy.dd.mm + +void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals); + // add array of numbers with "nrofVals" elements + +void json_enterStructToRecord(QString attribute); + // every call must be concluded with an extra "json_finishFile()" + // example: "sname":{ + +void json_finishStruct(void); + +void json_finishRecord(void); + // close curly bracket + + +QString json_readbackRecordStr(void); + +QByteArray json_readbackRecordBa(void); + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ parse Json file ------------------------------- +// ------------------------------------------------------------------------------------------------- + +// first: QByteArray datei_readFromFile(QString filename); + +//void datei_json_readTestFile(QString filename); + +int json_nrOfPairsInFile(QByteArray filename); + +bool json_exists(QByteArray filename, QString searchForKey); + // look for "searchForKey" =name of the pair (left of : ) + // retval true if exists + +bool json_remove(QByteArray filename, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and remove the record from file + // retval true if removed + +QString json_searchForStringInFile(QByteArray filename, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String + +int json_searchForIntInFile(QByteArray filename, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String + +//....................... + +QJsonObject json_searchForObjectInFile(QByteArray filename, QString searchFor); + // return an object from the json file + +int json_nrOfPairsInObject(QJsonObject objname); + +QString json_searchForStringInObject(QJsonObject objname, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String + +int json_searchForIntInObject(QJsonObject objname, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String + +//....................... + +QJsonArray json_searchForArrayInFile(QByteArray filename, QString searchFor); + // look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String + +int json_nrOfValuesInArray(QJsonArray arrayname); + +bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize); + // assuming that the array consists of integers + + + +// ------------------------------------------------------------------------------------------------- +// ------------------------------------------------------ read, write, copy files ------------------- +// ------------------------------------------------------------------------------------------------- + +void datei_closeFile(QString filename); + +// read content of an exiting file: +QByteArray datei_readFromFile(QString filename); + +bool datei_ifFileExists(QString filename); + +char datei_writeToFile(QString filename, QByteArray content); + // retval=0 if successful 1: no write access allowed + // 2:cannot open to append 3:cannot create new file + +bool datei_copyFile(QString currentFileName, QString newFileName); + // retval=true if successful + +bool datei_clearFile(QString filename); + // retval=true if successful + +#endif // DATEI_H diff --git a/globVars.cpp b/globVars.cpp new file mode 100755 index 0000000..d7b6ff5 --- /dev/null +++ b/globVars.cpp @@ -0,0 +1,25 @@ +#include "globVars.h" + +static int CoinCheckerType; + +void globVar_SetCoinChecker(int checkerTyp) +{ + CoinCheckerType=checkerTyp; +} + +int globVar_GetCoinChecker(void) +{ + return CoinCheckerType; +} + +static int billReaderType; + +void globVar_SetBna(int bnaTyp) +{ + billReaderType=bnaTyp; +} + +int globVar_GetBna(void) +{ + return billReaderType; +} diff --git a/globVars.h b/globVars.h new file mode 100755 index 0000000..c2a88de --- /dev/null +++ b/globVars.h @@ -0,0 +1,11 @@ +#ifndef GLOBVARS_H +#define GLOBVARS_H + + +void globVar_SetCoinChecker(int checkerTyp); +int globVar_GetCoinChecker(void); + +void globVar_SetBna(int bnaTyp); +int globVar_GetBna(void); + +#endif diff --git a/guidefs.h b/guidefs.h new file mode 100755 index 0000000..fb65802 --- /dev/null +++ b/guidefs.h @@ -0,0 +1,24 @@ +#ifndef GUIDEFS_H +#define GUIDEFS_H + +#define PIXELSIZE_BUTTONS 18 +#define PIXELSIZE_LABEL 18 +#define PIXELSIZE_DATA 16 + +#define PIXELSIZE_BIGFONT 22 +#define PIXELSIZE_SMALLFONT 14 + +#define BUTTONCOLOR "background-color: rgb(150,250,150)" + +#define COLORGREEN "background-color: rgb(160,250,190)" +#define COLOR_RED "background-color: rgb(150,0,0)" +#define COLOR_LIGHTRED "background-color: rgb(250,150,150)" +//#define COLORGREY "background-color: rgb(160,250,190)" +#define COLORGREY "background-color: grey" +#define COLORYELLOW "background-color: yellow" +#define COLORWHITE "background-color: white" + +// "background-color: lightgrey" + + +#endif diff --git a/interfaces.h b/interfaces.h new file mode 100755 index 0000000..4a23c09 --- /dev/null +++ b/interfaces.h @@ -0,0 +1,1700 @@ +#ifndef INTERFACE_H +#define INTERFACE_H + +#include + + + +struct T_emp +{ + + // Fixdata from EMP: + uint8_t shaft; // = changer level + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinValues[16]; + uint16_t routing; + + // Master specs: + uint8_t gotSetup; // 1: got specifications from master 0: no specs + uint16_t coinAccept; // bit 0 = coin1 bit H=accept + uint8_t tokenChannel; + uint16_t denomination[16]; + + // dynamic: + uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): + // 0=start command + // 1=powered, do emp ini, send reset + // 2=delay + // 3=wait for response, requesting status after response + // 4,5 through, startup + // 6: wait for status + // 7: through, startup + // 8: IDLE state. EMP is up and ready, polling is running + // 9: polling on, payment not yet on + // 10: payment, check coins + // 11: through + // 12: wait 1s for last coin + // 90: stop all, 1s delay + // 99: off, all stopped + + + uint8_t pollingRunning; + uint8_t paymentRunning; + +}; + +struct Trtc_DateTime +{ + uint8_t rtc_hour; + uint8_t rtc_min; + uint8_t rtc_sec; + uint8_t rtc_dayOfMonth; + uint8_t rtc_month; + uint8_t rtc_year; + uint8_t rtc_dayOfWeek; +}; + +struct Tprn_hw_state +{ + // hardware (IO's) + bool powerRdBk; // prn pwr is on + bool rsSwOk; // serial switch (printer or modem) is set to printer + bool rsDrvOk; // RS232 converter for PTU, Printer and Modem in on + + bool ReadyLine; // HW signal from printer showing ready + bool inIdle; // powered and free from errors + bool paperNearEnd; // paper roll runs out + bool noPaper; + bool ErrorTemp; + bool HeadOpen; + bool cutterJam; + bool noResponse; // printer is not connected, cable broken, wrong baudrate + bool badResponse; +}; + + struct Tprn_currentSettings +{ + uint8_t currFont; + uint8_t currSize; + uint8_t currHeigth; + uint8_t currWidth; + bool nowBold; + bool nowInvers; + bool nowUnderlined; + uint8_t currDensity; + uint8_t currSpeed; + bool nowAligned; +}; + +// obsolete + struct T_dynDat +{ + uint8_t licensePlate[8]; + uint8_t vendingPrice[8]; + uint8_t parkingEnd[8]; + uint8_t currentTime[8]; + uint8_t currentDate[8]; + uint8_t dynDat5[8]; + uint8_t dynDat6[8]; + uint8_t dynDat7[8]; +}; + + +struct T_vaultRecord +{ + + // Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz) + char startbuffer[4]; // Psa> // never move or change this 1st entry + uint16_t AccountingNumber; + uint16_t CUNU; + uint16_t MANU; + uint16_t resint1; + //uint16_t resint2; + + char label1buffer[4]; // tim> + uint8_t year; + uint8_t month; + uint8_t dom; + uint8_t hour; + uint8_t min; + uint8_t sec; + uint8_t DoW; + uint8_t reschar3; + + char label2buffer[4]; // abs> + uint32_t AbsIncome1; + uint32_t AbsReserve; + uint32_t AbsNrOfCuts; + + char label3buffer[4]; // mw > + + // Verkauf, Tuer zu: + uint32_t VKcoinsInserted[16]; // nur fuer Wechsler, soviel wurde eingeworfen + uint32_t VKcoinsReturned[6]; // nur fuer Wechsler, Anzahl Muenzen pro Typ, soviel wurde zurueckgegeben + + // Service, Tuer offen: + uint16_t ServCoinsInserted[16]; // nur fuer Wechsler, soviel wurde eingeworfen + uint16_t ServCoinsReturned[6]; // nur fuer Wechsler, Anzahl Muenzen pro Typ, soviel wurde zurueckgegeben + uint16_t resint3; + uint16_t resint4; + uint16_t currentTubeContent[6]; // nur fuer Wechsler, aktueller Fuellstand + uint16_t resint5; + uint16_t resint6; + + char label4buffer[4]; // box> + uint16_t coinsInVault[16]; + uint16_t billsInStacker[8]; + + char label5buffer[4]; // val> + // actually constant unless exchange rate is changed + uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft) + uint16_t billDenom[8]; + uint16_t tubeDenom[6]; + uint16_t exchangeRate; + uint16_t resint9; + + // new from 1.8.23 + uint32_t cutsSinceCBchange; + uint32_t CBcontent_cent; + uint32_t CBnrofCoins; + + char endofblock[4]; // end +// 332 bytes + + uint16_t CRC16; // Xmodem16 from startbuffer[0] to endofblock[3] + uint16_t resint11; + char endofRecord[4]; // ---- + +}; + +struct T_moduleCondition +{ + // store conditon of all system components, hold in RAM + // 0 means unknown, not yet tested/used + // 1 means OK + // 50..99 = HINT / Notification + // 100..150 = WARNING + // 200..250 = ERROR + + uint8_t ram; + uint8_t intEe; + uint8_t extEe; + + uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error + uint8_t boardHw; + uint8_t printer; + uint8_t modem; + + uint8_t signal; // 1...99 + uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime + uint8_t mdbBus; + uint8_t coinChecker; // EMP, OMP or mei-cashflow + + uint8_t coinEscrow; + uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error + uint8_t creditTerm; + uint8_t coinReject; + + uint8_t coinSafe; + uint8_t billSafe; + uint8_t voltage; // 1:11..14V + uint8_t temper; + + uint8_t poweronTest; + uint8_t doorState; // 1: alles zu 200: tuer offen + bit1(S) +bit2(CB) + bit3(CB) + uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened + uint8_t changer; // can only be tested by usage + + uint8_t coinBlocker; // can only be tested by usage + uint8_t billReader; // can only be tested by usage + uint8_t ResetReason; + uint8_t allModulesChecked; + + uint8_t alarmState; + uint8_t res11; + uint8_t res12; + uint8_t res13; +// 31 +}; + +struct T_dynamicCondition +{ + char allDoorsDebounced; + char openedAuthorized; + uint8_t CBinDebounced; // 0:fehlt 1:drin + char upperDoor; // 99: undefined 0:closed 1:open + char middleDoor; // 99: undefined 0:closed 1:open + char lowerDoor; // 99: undefined 0:closed 1:open + char reserve; + char billBox; + char modeAbrech; + char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest + char nowCardTest; + char nowPayment; // not used, always 0 + char lastMifCardType; + uint8_t lastSDoorState; + uint8_t lastVDoorState; + uint8_t lastCBstate; + char paymentInProgress; + // 0: stopped by timeout + // 1: running 2: wait4lastCoin + // 3: payment stopped manually, coins in Escrow + // 4: payment stopped autom, amount collected, coins in Escrow + // 5: payment stopped, escrow full, coins in Escrow + // 6: coins encashed 7:coins returned + // 8: CoinChecker or MDB on Error + + + char res1; + uint16_t U_Batt; + uint16_t Temperatur; + uint16_t nrCoinsInBox; + uint32_t amountInBox; + uint32_t totalTransVolume; + uint32_t totalNrOfVends; + char jsonValid_config; + char jsonValid_device; + char jsonValid_cash; + char jsonValid_print; + char jsonValid_serial; + char jsonValid_time; + char lastFileType; +// 44 + uint8_t MifCardHolder[8]; + uint8_t resultOfLastTemplPrint; + // 0: unknown or printing in progress + // 1: OK, doc was printed 2: error, doc was not printed + uint8_t lastPrinterStatus; + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + uint8_t startupTestIsRunning; + + //54 +}; + +struct T_extTime +{ + uint8_t Hours; + uint8_t Min; + uint8_t Sec; + uint8_t Year; + uint8_t Month; + uint8_t Day; + uint8_t DOW; + uint8_t res1; + uint16_t MinOfDay; + uint16_t res2; + uint32_t SecOfDay; + uint8_t isLeapYear; + uint8_t nxtLeapYear; + uint8_t lastLeapYear; + uint8_t hoursOfThisWeek; + uint16_t minutesOfThisWeek; + uint16_t hoursOfThisMonth; + uint16_t daysOfThisYear; + uint16_t GetHoursOfYear; + uint16_t res3; + uint32_t GetMinutesOfYear; + uint8_t getWakeIntvSec; + uint8_t res4; + uint16_t res5; + uint32_t MinutesOfMillenium; + +}; + + +typedef uint8_t UCHAR; +typedef uint16_t UINT; + +struct T_devices +{ + // set by master, used(1) or notused (0) or type 2....20 + + UCHAR kindOfPrinter; // 0:off 1:Gebe + UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza Csquare (MW) + UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 + UCHAR solarPower; // 1:sleep allowed 0: no sleep + //UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep + + UCHAR kindOfModem; // 0:off 1:Sunlink + UCHAR kindOfCreditcard; // 0:off 1:Feig NFC + UCHAR CoinEscrow; + UCHAR CoinRejectUnit; + + UCHAR CoinShutter; + UCHAR BillAcceptor; + UCHAR usevaultLock; + UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized + + UCHAR autoOpen; // 1: open door covers after valid ATBcard + UCHAR printAccReceipt; // 0/1 + UCHAR printDoorReceipt; + UCHAR printTokenTicket; + + UINT VaultFullWarnLevel; + UINT VaultFullErrorLevel; + UINT BattEmptyWarnLevel; + UINT BattEmptyErrorLevel; + +}; + +struct T_chg_Tub +{ + + uint8_t tubeLevel[8]; // [0]=nr coins of lowest value + uint8_t tubeFull[8]; // 1=full 0 else + uint16_t tubeValues[8]; // in cent [0]=lowest value 5c or 10cent + uint16_t tubeFilled[8]; // nr of every coin inserted + uint16_t tubeDispens[8]; // nr of every coin dispensed + // 64 byte +}; + +struct T_changer +{ + // Fixdata from Coin Changer + uint8_t setup; // always 1 + uint8_t state; // step of state machine + // 0..12 like EMP, 13...30 for coin dispense + + uint8_t level; // mdb-level, always 3 + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinSetup[16]; // [0]=lowest coin, multiply with scale + uint16_t intendedAcceptance; //bitwise 0,1 1=accept coin, came from master + uint8_t tokenChannel; + uint8_t pollingRunning; // 1: emp is polled 0:not + uint8_t paymentRunning; // 1: coins are accepted + uint16_t denomination[16]; + uint16_t availableTubes; //bitwise 0,1 1=av. bit0 = lowest coin value +}; + +struct T_bna +{ + // reported with STATUS: + uint8_t setup; // 0: not 1: got valid parameters from device + uint8_t FeatureLevel; + uint16_t countryCode; // programmed in EMP + uint16_t scalingFactor; // z.B. 5 + uint8_t decimalPlace; + uint8_t pad1; + uint16_t stackerCap; + uint16_t billSecureLevel; + uint8_t hasEscrow; + uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0 + uint16_t currentStackerLevel; // requested number of notes in billbox + + // settings from Master + uint16_t intendedAccept; // bit 0 =5€ + uint16_t pad2; + uint16_t billDenomination[16]; +}; + +class hwinf +{ + +public: + virtual ~hwinf() {} + + + + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + // Use serial interface and protocol stack in Cashagent-Library + // Sending Output data to DeviceController DC2b + // Sending input requests to DC2 (single or auto-batch) + // Getting input data as receiver payload + // Furthermore the Cashagent-Library answers with status strings about sending and reading result + // $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + + virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const =0; + // Command: open serial interface + // BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200 + // BaudStr: for exapmle "19200" + // ComName: for example "COM48" + // connect: 0, 1 + + virtual void dc_closeSerial(void) const =0; + // Command: close serial interface in order to save power while power down + // or if another port must be used + + + virtual bool dc_isPortOpen(void) const =0; + // returns true if port open (don't send unless open. Sending to closed port will crash program) + + virtual void dc_autoRequest(bool on) const =0; + // on = true: select that all READ-Requests are sent automatically + // on = false: select that all READ-Requests are sent manually one by one + // Every input information from DC2 must be requested + // ( digital and analog sensors, get time/date, get status information ) + + virtual void dc_requTestResponse() const =0; + // tell DC2 to send a test-string, useful to see if cable and baudrate is OK + + virtual bool dc_readAnswTestResponse() const =0; + // retval: true: test was successful, got right response + + virtual uint8_t dc_isRequestDone(void) const =0; + // retval: 0: request is still in progress + // 1: answer from DC2 was OK + // 2: wrong answer from DC2 + + virtual uint16_t dc_getCompletePayLoad(uint16_t plBufSiz, uint8_t *payLoad) const =0; + // get data back in "payLoad", max 64 byte, can be used for diagnosis + // retval = nr of bytes received. If host buffer too small then + // only plBufSiz bytes are copied to "payLoad" + // plBufSiz = size of host buffer + + virtual void dc_setWakeFrequency(uint8_t period) const =0; + // RTC wakes DC2 (and PTU) by hardware signal every 32seconds + // change wake signal period to 1...64s + + virtual void dc_OrderToReset(void) const =0; + // want DC2 to reset (in order to start Bootloader) + + + virtual QString dc_getSerialState(void) const =0; + // get result of opening-command like "ttyS0 opened with 115200 8N1! + // or error messages like "comport not available..." + // was saved by last opening event, can be passed for 100ms + + virtual void dc_clrSerialStateText(void) const =0; + // clear above text to avoid multiple repetive displaying + + + virtual void bl_sendDataDirectly(uint8_t length, uint8_t *buf) const =0; + // send without protocol frame, needed for the DC bootloader + + virtual uint8_t getRawRecLength(void) const =0; + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual uint8_t getRawReceivedData(uint8_t *receivedData) const =0; + // only needed if protocol stack in Cashagent-Library is bypassed + + virtual QString dc_getSerialParams(void) const =0; + // get DC2 serial settings (not very meaningful as they will not come if different from master settings) + + virtual QString dc_getHWversion(void) const =0; + // get DC2 hardware version + + virtual QString dc_getSWversion(void) const =0; + // get DC2 software version + + virtual QString dc_getState(void) const =0; + // get DC2 status (every OK or any error/warning? ) + + +// ---------------------------------------------------------------------------------------------------------- +// Date and Time +// ---------------------------------------------------------------------------------------------------------- + + virtual uint8_t rtc_getDateTime(struct Trtc_DateTime *rtc_DateTime) const =0; + + virtual uint8_t rtc_setDateTime(void) const =0; + // synch DC2 with PC or PTU system time and date + + virtual void rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const =0; + // get time directly + + virtual void rtc_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd) const =0; + // get date directly + + virtual uint8_t rtc_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday) const =0; + // dow=day of week, 1=monday...7 + // minOfToday: 0=midnight...1439= 23:59 + // secOfToday: 0=midnight...86399= 23:59:59 + + virtual bool rtc_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear) const =0; + // retval true: this year is leap year + + virtual bool rtc_isLeapYear() const =0; + + virtual void rtc_getWeek(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek) const =0; + // DayOfWeek: 1=monday...7 + // HoursOfWeek: 0=Monday 0:00 o'clock...167=Sunday 23:00 + // MinutesOfWeek: 0=Monday 0:00 o'clock...10079=Sunday 23:59 + + virtual void rtc_getMonth(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth) const =0; + // DayOfMonth: 1...31 + // HoursOfMonth: 0 = 0:00o'clock of 1.day in month up to 743 + // MinutesOfMonth:0 = 0:00o'clock of 1.day in month up to 44639 + + virtual void rtc_getYear(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear) const =0; + // DayOfYear: 1...366 1= 1.Jan of this current year + // HoursOfYear: 0=1.Jan 0:00o'clock ...8783=31.12 23 o'clock + // MinutesOfYear: 0=1.Jan 0:00o'clock ...527039=31.12 23:59 o'clock + + virtual QString rtc_getTimStr(void) const =0; + virtual QString rtc_getDatStr(void) const =0; + virtual QString rtc_getTimDatStr(void) const =0; + + + // UID - unique number, different in every DC + virtual void dc_getUID8byte(uint8_t *buf8byteUid) const =0; + // get 8 single bytes in buffer + + virtual QString dc_getUIDstr() const =0; + // get as string + + virtual uint64_t dc_getUIDnumber(void) const =0; + // get UID as one long number + +// ---------------------------------------------------------------------------------------------------------- +// analogs +// ---------------------------------------------------------------------------------------------------------- + + // Analog values: + virtual uint32_t dc_getTemperature(void) const =0; + // in Sax-Format 0...400 (0=-50,0degC 100=0,0degC 141=20,5degC 400=150,0degC) + + virtual QString dc_getTemperaturStr(void) const =0; + // as string like "-12,5degC" + + virtual uint32_t dc_getVoltage(void) const =0; + // as value in mV, 0...65,535V + + virtual QString dc_getVoltagStr(void) const =0; + // as string in mV + + virtual bool dc_mainFuseIsOk(void) const=0; + // true if 12V fuse is OK + // false: fuse blown, DC will continue working but no 12V device can be used! + +// ------------------------------------------------------------------------------ +// digital outputs +// ------------------------------------------------------------------------------ + + virtual uint8_t lock_switchUpperLock(uint8_t dir) const =0; + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual uint8_t lock_switchLowerLock(uint8_t dir) const =0; + // dir 0=off 1=up 2=down + // move lock until stop cmd (0) + + virtual void lock_switchVaultDoor(void) const =0; + + virtual void coin_switchRejectMotor(uint8_t dir) const =0; + + virtual void coin_rejectCoins(void) const =0; + + // LEDs + virtual void led_switchLedService(uint8_t on) const =0; + virtual void led_switchLedPaper(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual void led_switchLedPinPad(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual void led_switchLedStart(uint8_t on, uint8_t ton, uint8_t tof) const =0; + virtual void led_switchLedCoinbassin(uint8_t on, uint8_t ton, uint8_t tof) const =0; + + virtual void fan_switchFan(bool on) const =0; + virtual void alarm_switchSiren(bool on) const =0; + virtual void bar_OpenBarrier(bool open) const =0; + virtual void ptu_switchWake(bool WAKEACTIVE) const =0; + + virtual void aux_power(bool on) const =0; + virtual void aux_setUsage(uint8_t PinDirection) const =0; + virtual void aux_setOutputs(uint8_t PinIsHigh) const =0; + + virtual void lock_switchContactPower(bool on) const =0; + + virtual void prn_switchPower(bool on) const =0; + + virtual void mif_readerOn(bool on) const =0; + + virtual void mif_creatAtbCard(uint8_t cardType) const =0; + + virtual void mod_switchPower(bool on) const=0; + + virtual void mod_switchWake(bool WAKEACTIVE) const=0; + + virtual void mdb_switchPower(bool on) const =0; + + virtual void mdb_switchWake(bool WAKEACTIVE) const =0; + + virtual void credit_switchPower(bool on) const =0; + // the same as modem power + + virtual void credit_switchWake(bool WAKEACTIVE) const =0; + + virtual void shut_move(bool open) const =0; + + virtual void esc_moveFlaps(uint8_t flap ) const =0; + // 0: close both 1: open take-flap 2: open return + + +// ------------------------------------------------------------------------------ +// door, cashbox and lock switches +// ------------------------------------------------------------------------------ + + virtual uint8_t door_getSwitches(void) const =0; + // retval: bit0: upper door 1: low door 2:vault door + + virtual bool door_isUpperDoorOpen(void) const =0; + + virtual bool door_isLowerDoorOpen(void) const =0; + + virtual bool vault_isVaultDoorOpen(void) const =0; + + virtual uint8_t vault_getSwitches(void) const =0; + // retval bit0: cash box, bit 1: bill box + + virtual bool vault_isCoinVaultIn(void) const =0; + + virtual bool vault_isBillVaultIn(void) const =0; + + virtual uint8_t door_getLocks(void) const =0; + // retval bit0: upper lever is up (=open) + // bit1: upper lever is down (=locked) + // bit2: lower lever is up + // bit3: lower lever is down (=locked) + + virtual bool door_upperDoorIsLocked(void) const =0; + + virtual bool door_upperDoorIsUnlocked(void) const =0; + + virtual bool door_lowerDoorIsLocked(void) const =0; + + virtual bool door_lowerDoorIsUnlocked(void) const =0; + + virtual bool bar_optoIn1isOn(void) const =0; + + virtual bool bar_optoIn2isOn(void) const =0; + + virtual uint8_t aux_getAuxInputs(void) const =0; + + virtual bool ptu_WakeINisActive(void) const =0; + + virtual bool mdb_WakeINisActive(void) const =0; + + virtual bool prn_readyINisActive(void) const =0; + + virtual bool coid_isAttached(void) const =0; + + virtual bool coin_escrowIsOpen(void) const =0; + + virtual bool mif_cardIsAttached(void) const =0; + +//bool hwapi::mod_WakeINisActive(void); + + virtual bool door_isContactPowerOn(void) const =0; + + virtual bool mif_isMifarePowerOn(void) const =0; + + virtual bool mdb_testIsmdbTxDon(void) const =0; + + virtual bool aux_isAuxPowerOn(void) const =0; + + virtual bool mod_isGsmPowerOn(void) const =0; + + virtual bool cred_isCreditPowerOn(void) const =0; + + virtual bool prn_isPrinterPowerOn(void) const =0; + + virtual uint8_t prn_PrnFuseIsOk(void) const=0; + //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off + + virtual bool mdb_isMdbPowerOn(void) const =0; + + virtual bool cash_getRejectMotorHomePos(void) const=0; + + virtual uint8_t cash_getLowPaperSensor(void) const=0; + // 0: Sensor sees paper 1: no paper 99: off + + + // ------------------------------------------------------------------------------ + // request commands + // ------------------------------------------------------------------------------ + + // all read-requests can be sent manually by the following functions + // or automatically in background by: void hwapi::dc_autoRequest(bool on) + + + virtual void request_DC2serialConfig() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + + virtual void request_DC2_HWversion() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_SWversion() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_condition() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_UID() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_TimeAndDate() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_analogues() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalInputs() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + virtual void request_DC2_digitalOutputs() const =0; + // read-request can be sent manually by this function, not needed if auto-request is on + + // ------------------------------------------------------------------------------ + + // the following device state requests are deployed only if device is powered up: + virtual void request_PrinterHwState() const =0; + virtual void request_PrinterCurrentFonts() const =0; + virtual void request_PrinterStateComplete() const =0; + + virtual void request_MifareReaderState() const =0; + virtual void request_MifareCardType() const =0; + virtual void request_MifareAtbType() const =0; + virtual void request_MifareID() const =0; + virtual void request_MifareData(uint8_t dataBlockNumber) const =0; + //virtual void request_MifareData() const =0; + + virtual void request_MDB_Status() const =0; + virtual void request_MDB_lastResponse() const =0; + virtual void request_EMP_allParameters() const =0; + virtual void request_EMP_lastCoin() const =0; + + + // ------------------------------------------------------------------------------ + // readback digital outputs of connected devices + // these functions are not needed for normal operation + // but can be used to test and verify conditions + // ------------------------------------------------------------------------------ + + + virtual bool test_getDO_mdbRXtst(void) const =0; + // readback digital outputs of connected devices + // these functions are not needed for normal operation + // but can be used to test and verify conditions + + virtual uint8_t lock_getDO_motors(void) const =0; + // bit0: upper lock forward bit 1 backward + // bit2: lower lock forward bit 3 backward + + virtual uint8_t test_serialState(void) const =0; + // test on-board signals for the serials + // serial drv on/off, Serial mux1, Serial mux2 + + virtual bool test_serialIsOn(void) const =0; + + virtual bool test_serialMux1isSetToPrinter(void) const =0; + virtual bool test_serialMux1isSetToModem(void) const =0; + virtual bool test_serialMux2isSetToCredit(void) const =0; + virtual bool test_serialMux2isSetToMifare(void) const =0; + + virtual bool led_coinIsOn(void) const =0; + virtual bool led_frontIsOn(void) const =0; + virtual bool led_ticketIsOn(void) const =0; + virtual bool led_pinIsOn(void) const =0; + virtual bool led_StartIsOn(void) const =0; + virtual bool led_insideIsOn(void) const =0; + + virtual bool fan_isOn(void) const =0; + virtual bool siren_isOn(void) const =0; + virtual bool bar_relayIsOn(void) const =0; + virtual bool ptu_WakeOutIsOn(void) const =0; + + virtual bool aux_powerIsOn(void) const =0; + + virtual bool coin_shutterIsOpen(void) const =0; + virtual bool coin_shutterTestOutput(void) const =0; + + virtual uint8_t coin_escrowFlapOpened(void) const =0; + // retval: 1:return flap is open 2:take flap is open 0:closed + + + +// ------------------------------------------------------------------------------ +// devices are operated by DC +// processes with more then one devices +// timer controlled or long term processes +// ------------------------------------------------------------------------------ + + + virtual void sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, + uint8_t kindOfMifareReader, uint8_t suppressSleep, + uint8_t kindOfModem, uint8_t kindOfCredit ) const =0; + // enable hardware in device controller: + // kindOfPrinter: 0:off 1: GPT4672 (only this one implemented) + // kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: Csquare_changer + // kindOfMifareReader: 0:off 1: SL025 (only this one implemented) + // suppressSleep: 0:sleep allowed 1: sleep surpressed for special reason + // kindOfModem: 0:off 1: ATB_Sunlink_LTE (not yet implemented) + // kindOfCredit: 0:off 1: cVendTopp 2:cVendPin (not yet implemented) + + virtual void request_ReadbackDeviceSettings() const =0; + + virtual void readback_DeviceSettings(uint8_t *length, uint8_t *data) const =0; + // refer to DC2 manual for exact content + // state 5.5.21: byte[0]=kindOfPrinter byte[1]=kindOfCoinChecker + // byte[2]=kindOfMifarereadr byte[3]=suppress sleep mode + // byte[4]=kindOfModem byte[5]=kind of cc terminal + + virtual void sendMachineID(uint16_t customerNr, uint16_t machineNr, + uint16_t borough, uint16_t zone, + uint16_t alias, char *location) const =0; + + virtual void request_ReadbackMachineID() const =0; + + virtual void readback_machineIDdata(uint8_t *length, uint8_t *data) const =0; + // state 5.5.21: byte[0,1]=customer number byte[2,3]=machine number + // byte[4,5]=borough byte[6,7]=zone byte[8,9]=alias name + // byte[10...41]=location + + // Locks stops automatically at end switch or by timeout + virtual uint8_t lock_openUpperDoor(void) const =0; + virtual uint8_t lock_closeUpperDoor(void) const =0; + + virtual uint8_t lock_openLowerDoor(void) const =0; + virtual uint8_t lock_closeLowerDoor(void) const =0; + + virtual void shut_openOnce(void) const =0; + // and close automatic after shutter time + + virtual void shut_openForCoin(bool start) const =0; + // open flap if coin is attached + // once process is started it runs until stop command + + virtual void shut_sendOpeningTime(uint16_t timeIn_ms ) const =0; + // after this time without retrigger the flap is closed + + virtual void esc_takeMoney(void) const =0; + // and close automatically after escrow time (1s) + + virtual void esc_returnMoney(void) const =0; + // and close automatically after escrow time (1s) + + +// ---------------------------------------------------------------------------------------------------------- +// --------------------------------------------- MIFARE ----------------------------------------------------- +// ---------------------------------------------------------------------------------------------------------- + +// obsolete + virtual uint8_t mif_returnReaderStateAndCardType(uint8_t *buf, uint8_t maxBufferSize) const =0; + // retval 0=OK 1=error host buffer too small + /* data description, new fast version: + byte 0= still the same: current read state: + 0=power off 1=reader-fault 2=ready + 3=just reading 4=read complete + 5=read partial, removed too early + 6=state unknown + + byte 1: reader state 1=ok 0=nok + byte 2: card preent (0,1) + byte 3: card selected (0) + byte 4: card type: 0...5 + byte 5: card allowed (0=no 1=MifareClassic 1k or 4k) + byte 6: CardSize: 1 or 4 (kB) + byte 7: length of UID 4 or 7 (byte) + */ + + virtual bool mif_readerIsOK(void) const =0; + + virtual bool mif_cardAttached(void) const =0; + // not working! use mif_cardIsAttached() instead + + virtual uint8_t mif_readResult(void) const =0; + // result: 0: unknown or still in progress + // 1: card read successful + // 2: reading error + // not working! + + virtual QString mif_cardUID(void) const =0; + // not working + + virtual uint8_t mif_getCardDataDec(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize) const =0; + + virtual QString mif_getCardDataStr(uint8_t blockNumber) const =0; + // with blockNumber=0...11 + + + + // ---------------------------------------------------------------------------------------------------------- + // --------------------------------------------- PRINTER ---------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + // read printer condition and settings + + virtual uint8_t prn_getHwState(struct Tprn_hw_state *prn_hw_state) const =0; + // retval: status byte + // byte 0 = 0: prnter OK, >0: error + // bit0: paper low 1: no paper 2: temperature error + // 3: head open 4: paper jam in cutter + // 6: no response 7: bad response from printer + // and return struct "Tprn_hw_state" + + virtual bool prn_isUpAndReady(void) const =0; + // true: printer is powered, serial is ok, no error, printer is connected and resonding + + virtual void prn_getCurrentFontSetting(struct Tprn_currentSettings *prn_fonts) const =0; + + + // send Commands to printer: + + virtual void prn_sendText(QByteArray *buf) const =0; + // up to 1280 bytes + + virtual void prn_sendPrnSysCmd(uint8_t para1, uint8_t para2, uint32_t para3) const =0; + // send three byte through to printer, see printers manual + + virtual void prn_sendPrnEscCmd(uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4) const =0; + // send four byte through to printer, see printers manual + + + virtual void prn_sendPrnSetup(uint16_t paperSpeed, uint8_t density, uint8_t alignment, uint8_t orientation) const =0; + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0deg, 90deg, 180deg rotation (by now not supported!) + // not batched! don't use twice within 100ms + + virtual void prn_movePaper(uint8_t wayInMm, uint8_t direction) const =0; + //direction: 1=forward 2=backward + // + virtual void prn_setFonts(uint8_t font, uint8_t size, uint8_t width, uint8_t height) const =0; + // font = kind of font 5...11 (0..22) + // size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge + // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) + // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense + + virtual void prn_setLetters(uint8_t bold, uint8_t invers, uint8_t underlined) const =0; + // bold: 0/1 + // invers: 0/1 + // underlined: 0/1 + + virtual void prn_cut(uint8_t kindof) const =0; + // kindof: 1=full cut 2=partial cut 3=eject (5xLF + full cut) + + virtual void prn_newLine(uint8_t nrOfLines) const =0; + + virtual void prn_printCompleteFontTable(void) const =0; + + + virtual void prn_printBarcode(uint8_t kindOf, uint8_t withText, uint8_t offset, uint8_t rotation, uint8_t dataLeng, uint8_t *data) const =0; + // kind of barcode: 0=Code39 1=Code128 2=EAN13 3= 2/5interleaved 4=UPC-A 5=EAN8 + // withText: print readable text below + // offset: move by pixel from left border + // rotation + // dataLeng in byte + + virtual void prn_sendQRdata(QByteArray *buf) const =0; + // maximal 150 alphanummeric bytes + + virtual void prn_printQRcode(void) const =0; + // QRcode may have 1...150 alphanummeric data, must be transfered in advance + + + virtual void prn_printLogo(uint8_t nrOfLogo, uint8_t offset ) const =0; + // nrOfLogo: 1..4 in flash 5...8 in Ram + // offset: in mm form left border + + + // ......................................................... + // Parking Ticket (print-out document) designer TD - obsolete + // ......................................................... + + + + // ---------------------------------------------------------------------------------------------------------- + // --------------------------------------------- MDB Bus ---------------------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + virtual void mdb_sendBusReset(void) const =0; + + virtual void mdb_sendCommand(uint8_t toMdbDevice, uint8_t mdbCommand) const =0; + // send one bus command directly over mdb bus, refer to mdb manual for commands + // this command is not needed in normal operation, just for new or special things + + virtual void mdb_sendMessage(uint8_t toMdbDevice, uint8_t mdbCommand, uint8_t nrOfData, uint8_t *dataBuffer) const =0; + // nrOfData = sizeOf(dataBuffer) maximal 34 byte according mdb specs + // same as mdb_sendCommand, just with data + + virtual bool mdb_busIsReadyToWork() const =0; + + virtual bool mdb_deviceVoltageOK() const =0; + + virtual bool mdb_busVoltageOk() const =0; + + virtual uint8_t mdb_getLastDeviceResponse(uint8_t *fromDevice, uint8_t *lastRequest, + uint8_t *responseLength, uint8_t *responseBuffer) const =0; + // fromDevice: device nr from which data was requested 0,1,2,3 + // lastRequest: sent mdb command + // responseLength: nr of payload data (after mdb-ack) 0...34 + // responseBuffer holds payload data (answer from mdb device) + // return val: mdb result of this request: 1=got ACK 2=got 3xNAK 3=no or bad response 4:got Data (after ACK) + + + // ---------------------------------------------------------------------------------------------------------- + // ---------------------------------- Electronic Coin Validator EMP ----------------------------------------- + // ---------------------------------------------------------------------------------------------------------- + + + virtual void emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0; + // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) + // tokenChannel 0...31: if this signal comes from emp then a token was inserted + // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) + + virtual void emp_pollingOnOff(uint8_t on) const =0; + + virtual void emp_startCoinAcceptance(void) const =0; + + virtual void emp_stopCoinAcceptance(void) const =0; + + virtual void emp_getAllParameters(struct T_emp *emp) const =0; + // see struct in hwapi.h + // usage example: + // hwapi *HWaccess const override; + // HWaccess = new hwapi() const override; + // struct T_emp myEmp const override; + // HWaccess->emp_getAllParameters(&myEmp) const override; + // readval=myEmp.pollingRunning const override; + + virtual uint8_t emp_chkIfCoinInserted(void) const =0; + // retval: 0...16 coins left in FIFO + + virtual void emp_getNewCoinRecord(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value) const =0; + // with every call ONE coin is taken out of FIFO and pointer decremented + // valid: should be 1 + // signal: comes right from coin checker, 0...15 (0=first programmed coin type) 0xFF=no signal + // error: was reported from EMP as dynamic signal right after coin insertion (instead of + // coin signal), example: 3=unknown coin 4=coin is blocked by host. 0xFF=no error + // value: of the coin. Depends on parameter "coinDenomination" in function "emp_sendSettings" + // if coinDenomination[coin 0..15] = 0 then the value programmed in coin checker is taken + // if coinDenomination > 0 then this value is taken. + // Useful in case of two currencies (adapt to local currency) or for token. + + // function gives more details as "emp getLastCoin()" but "emp getLastCoin()" is easier to use + + // alternativ to emp_getNewCoinRecord( ): + virtual uint8_t emp_giveLastCoin(uint16_t *value, uint8_t *signal) const =0; + // retval: 0: NO coin stored 1: valid coin 2: got wrong coin or coin denied + // value: if retval1: value of the coin if reval=2: error number + // 0xFF means NO error or NO signal (as 0 is a valid error/signal) + // signal: channel nr reported from checker 0...15 + + + virtual uint8_t emp_returnLastCoin(uint16_t *value, uint8_t *signal) const =0; + // use for changer + + + + virtual QString dc_getTxt4RsDiagWin(void) const =0; + virtual void dc_clrTxt4RsDiagWin(void) const =0; + virtual QString dc_get2ndTxt4RsDiagWin(void) const =0; + virtual void dc_clr2ndTxt4RsDiagWin(void) const =0; + virtual QString dc_getTxt4HsStateLine(void) const =0; + virtual void dc_clrTxt4HsStateLine(void) const =0; + virtual QString dc_getTxt4masterStateLine(void) const =0; + virtual void dc_clrTxt4masterStateLine(void) const =0; + virtual QString dc_getTxt4resultStateLine(void) const =0; + virtual void dc_clrTxt4resultStateLine(void) const =0; + virtual QString dc_getdataStateLine(void) const =0; + virtual void dc_clrTxt4dataStateLine(void) const =0; + virtual QString dc_getdatifLine(void) const =0; + virtual void dc_clrTxt4datifLine(void) const =0; + + + +// ---------------------------------------------------------------------------------------------------------- +// -------- DC Bootloader 1.Version +// ---------------------------------------------------------------------------------------------------------- + + // using DC2 Bootloader + virtual void bl_iniChain(void) const =0; + virtual bool bl_importBinFile(QByteArray readBinFile, uint32_t fileSize, char withDispl) const =0; + virtual uint8_t bl_activatBootloader(uint8_t *sendData) const =0; + virtual uint8_t bl_startChain(void) const =0; + virtual uint8_t bl_readBLversion(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + virtual uint8_t bl_readFWversion(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + + virtual uint8_t bl_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) const =0; + // make BL protocol, retval = outbuf length (5...133) + // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum + // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 + // Data length = 0...64 + // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 + // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 + + virtual uint8_t bl_exitBL(uint8_t *sendData) const =0; + // minimum size of sendData-buffer: 5byte retval: length + + virtual void led_switchLedIllumination(uint8_t on) const =0; + + + + +// ------------------------------------------------------------------------------------ +// 27.3.2023: Use Device-Controller's Bootloader to send hex-file +// ------------------------------------------------------------------------------------ + + virtual void bl_rebootDC(void) const =0; + + virtual void bl_startBL(void) const =0; + virtual void bl_checkBL(void) const =0; + virtual bool bl_isUp(void) const =0; + // return true is bl is up and running + // also initializes "sendFile" + + virtual void bl_sendAddress(uint16_t blockNumber) const =0; + // send start address, nr of 64byte-block, start with 0 + // will be sent only for folling block-numbers: + // 0, 1024, 2048, 3072 and 4096, so basically every 64kByte + + virtual uint8_t bl_wasSendingAddOK(void) const =0; + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_openBinary(void) const =0; + + virtual void bl_sendDataBlock(uint8_t length, uint8_t *buffer) const =0; + // send 64 byte from bin file + + virtual void bl_sendLastBlock(void) const =0; + + virtual uint8_t bl_wasSendingDataOK(void) const =0; + // return val: 0: no response by now 1:error 10: OK + + virtual void bl_stopBL(void) const =0; + + +// ------------------------------------------------------------------------------------ +// 6.4.2023: new functions for coin collection and printing +// some new system functions +// ------------------------------------------------------------------------------------ + + + virtual bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const =0; + // return true if successful. could fail if more the 8 commands are waiting + + virtual bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const =0; + + virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const =0; + + virtual bool sys_runCompleteTest(void) const =0; + // warning: lasts 20s in one pace + + virtual bool sys_ready4sending(void) const =0; + // return true if a Json-file can be sent + + virtual bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const =0; + // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer + // nrOfTemplate=1...32 if kindOfFile==6 + // content = content of the Json file, max 800byte ascii signs + // file is 0-terminated! + // return false if sending is not possible, wait a second + + virtual bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const =0; + // dynPrnVal = array of 8 Variables with 8 byte each, come as ascii string + // like: char prn_dynPrnVal[8][8]; + // return true if sending, false if cmd-stack is full + + virtual bool prn_printTemplate(uint8_t nrOftemplate) const =0; + // print one of the templates loaded by Json prior + // nr = 1..32 + // return true if sending, false if cmd-stack is full + + virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const =0; + // returns all acc nrs of the backuped vault records + // use: uint16_t backupedAccNumbers[8] + + virtual bool log_selectVaultRecord(uint16_t accountNr ) const =0; + // return true if sending, false if cmd-stack is full + // and trigger transfer + + virtual bool log_chkIfVaultRecordAvailable(void) const =0; + // return true if completly received + + virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const =0; + // which was selected by: log_selectVaultRecord() + // to be forwarded to Ismas + + virtual bool prn_printAccountReceipt(void) const =0; + // print all 8 backuped accounting receipts + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool prn_printTestTicket(void) const =0; + // return true if sending to DC OK, false if cmd-stack is full + + + virtual bool cash_startPayment(uint32_t amount) const =0; + // 17.4.23TS: extended to 32bit + + virtual uint8_t cash_paymentProcessing(void) const =0; + // run this function periodically while coin payment process to generate necessary signals + // return value: + // 0: stopped 1: starting up 2: coin collection + // 3: finished by User (Push button) 4: finished, Max-Value collected + // 5: finished by escrow + // 10,11: error cannot start + // 12: timeout while payment, coins returned + // 13: stopped by unexpected error + + virtual uint32_t getInsertedAmount(void) const =0; + + virtual uint16_t getLastInsertedCoin(void) const =0; + + virtual bool getAllInsertedCoins(uint16_t *types, uint16_t *values) const =0; + // alle bei diesem Verkauf eingeworfenen Muenzen sind gespeichert, max 64 + + + virtual bool cash_cancelPayment(void) const =0; + // and return coins + + virtual bool cash_stopPayment(void) const =0; + // and keep coins in escrow + + + // after ticket/goods issue: + virtual bool vend_success(void) const =0; + // conclude payment process, encash all inserted coins to vault. Printing was successful + // if possible return change + + virtual bool vend_failed(void) const =0; + // conclude payment process and return all inserted coins + + + + + + virtual uint8_t mif_getCardType(QString *cardholder) const =0; + // return 1,2,3,4 = upper, lower access card, printer test, coin test + // cardholder: 7byte Name-String + + virtual uint64_t sys_getWakeSource(void) const =0; + // retval: 6 bytes, bit coded, 1=event keeps DC awake + + virtual uint8_t sys_getWakeReason(void) const =0; + // Master was woken by following reason: + // 1: MDB Event + // 2: Coin Event + // ( 3: Master Event) - will not set the wake line + // ( 4: 32s pulse) - will not set the wake line + // 5: Door Event + // ( 6: Diag Event) - will not set the wake line + // 7: 30min-Pulse for HB + + virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const =0; + + virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const =0; + + virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const =0; + + virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const =0; + + + virtual uint32_t cash_getAmountInVault(void) const =0; + + virtual uint16_t cash_getNrCoinsInVault(void) const =0; + + virtual uint8_t prn_getPrintResult() const =0; + + + + virtual uint8_t prn_getCurrentPrinterState() const =0; + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + + + virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const =0; + + virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const =0; + // attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before + // cannot be used to see settings programmed by JsonFile + + virtual bool sys_areDCdataValid(void) const =0; + + virtual bool sys_sendingTest(void) const =0; + + virtual void prn_requestCurrentDynData(void) const =0; + + virtual bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const =0; + // which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const =0; + + virtual bool prn_dynDataAreEqual(uint8_t *buf) const =0; + + virtual bool prn_printKombiticket(uint8_t nrOfKombi) const =0; + // print four of the templates loaded by Json prior + // nr = 1..8 + + virtual void lock_triggerUpperSolenoid(void) const =0; + + virtual void lock_triggerLowerSolenoid(void) const =0; + + virtual bool doors_supervise(void) const =0; + + virtual bool dc_isAutoRequestOn(void) const =0; + + virtual uint16_t log_getLatestAccountNumber(void) const=0; + // new function 27.6.2023 + // latest = highest of the backup's + + virtual uint8_t log_getAvailableVaultBlocks(void) const=0; + // return 0x0011 1111 if all 6 blocks are loaded (one bit per block) + + virtual uint8_t log_getAnswerToLastSlaveRequest(void) const =0; + // use only for ONE request/command + // return: 0xFF: result unknown by now as sending is ongoing + // 0=OK + // 1= wrong length 2=wrong start sign 5= wrong crc + // 6= slave: master cmd was wrong 7: slave: could not write/read data + // 8=timeout, got no response from slave + // 0,8 work, 1..6 not yet tested. 8 comes immed. and stays 8 until reconnect + + // use for important and extended commands (print several templates, print ticket...) + virtual void log_startSupervision(void) const =0; + + virtual uint8_t log_getAnswerToLastCmdBatch(void) const =0; + // 0xFF: no command sent by now + // 0: started, in progress + // 1: done and OK + // 2: done and error + // not working properly, always 0 + + virtual bool log_getVaultData(uint8_t *data) const =0; + // get vault record in linear 8bit buffer with 384 byte + + + + // new from 1.8.23 + virtual bool prn_printOneAccountReceipt(uint16_t accountNr) const =0; + // print one out of eight stored last accounting receipts + // function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts + + virtual bool prn_printAllAvailAccountReceipts(void) const =0; + // same as: prn_printAccountReceipt() from line 1153 + // return true if sending to DC OK, false if cmd-stack is full + + virtual bool log_verifyVaultRecordByCrc(void) const =0; + // return true if CRC16 is correct, data are 100% OK. Security level 1:65536 + // verification is strongly recommended before further processing + // in case of "false"-result please reload from DC + + + virtual uint16_t log_DC_getNextAccountNumber(void) const=0; + // the current cash box content will be backuped with this number on next cashbox-change + + virtual void log_DC_setNextAccountNumber(uint16_t newAccountingNumber) const=0; + // the current cash box content will be backuped with this number on next cashbox-change + // use only in case of hardware replacements or errors which derailed the number + + virtual void log_DC_deleteAllVaultrecordsInDc(void) const=0; + // use only in case of hardware replacements or errors which derailed the number + + virtual void log_DC_deleteAllTotalCounters(void) const=0; + // use only in case of hardware replacements or errors which derailed the number + + virtual void dc_setNewCustomerNumber(uint16_t newCustNr) const =0; + + virtual void dc_setNewMachineNumber(uint16_t newMachNr) const =0; + + virtual void dc_setNewBorough(uint16_t newBorough) const =0; + + virtual void dc_setNewZone(uint16_t newZone) const =0; + + + + // new functions from 8.9.23 + virtual QString mif_getReaderType(void) const =0; + // return "SL025" if correct reader is connected + + virtual void mif_getCardSize(uint8_t *cardSize, uint8_t *idLeng) const =0; + // cardSize=1k or 4kByte + // idLeng =4Byte or 7 byte + + virtual char mif_getAtbCardData(uint8_t *buf, uint8_t maxBuffSiz) const =0; + // return complete buffer binary, just for test purpose + + virtual bool mif_isValidAtbCard(void) const =0; + + virtual uint32_t mif_getAtbCardCuNu(void) const =0; + + virtual uint8_t mif_getAtbCardTyp(void) const =0; + // return 1=upper door card 1=lower door 3=printer-test 4=coin-test + // 0: not a valid atb2020 card + + virtual QString mif_getAtbCardPerso(void) const =0; + // e.g. "PNsax001" used for personal number, name shortcode, card number + // free to use, can be set in AtbMcw23.exe tool + + virtual void mif_getAtbCardExpire(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute) const =0; + + + // ------------------------------------------------------------------------------------ + // Device-Controller-Bootloader convenient version 21.09.2023 + // ------------------------------------------------------------------------------------ + + // use this to jump to BL: + //void hwapi::bl_rebootDC(void) const + + // use this to start BL: + // void hwapi::bl_startBL(void) const + + // call this in order to get response from BL: + //void hwapi::bl_checkBL(void) const + + // evaluate BL response: + //bool hwapi::bl_isUp(void) const + + // 29.9.23: new: "completeStart" function, replaces bl_rebootDC(), bl_startBL() and bl_checkBL() + // result can be verified with bl_isUp() as before + virtual bool bl_completeStart(void) const =0; + // must be used in DC's normal operation + + // select binfile-name in GUI + + // send binfile-name to BL-processor: + virtual bool bl_storeFirmware(QString fileName) const =0; + // load binary file 3x and compare + // return true if loaded correctly + // return false: error, could not load correctly + + // request the number of blocks for this file + virtual uint16_t bl_getNrOfFirmwareBlocks(void) const =0; + // size of the loaded bin file in 64byte blocks + // call after bl_storeFirmware() + + // call the next two function's repetitive with "blockNumber"=0,1,2,3....."bl_getNrOfFirmwareBlocks()" + + virtual bool bl_blockAutoLoad(uint16_t blockNumber) const =0; + // call in loop from block number 0 up to <= "dcBL_getNrOfBlocks()" + //the last block "bl_getNrOfFirmwareBlocks()" is sent as conclusion command (important!) + // but after every call WAIT (!) for response "bl_blockAutoResponse()" !!!! + // data will be sent to DC, if neccesary addr will be sent additionally + // if neccesary sending will automatically repeat up to 3times + // retval: false if blockNumber>4095, true else + + // check out this response after every block-sending, wait until >0!!! + virtual int8_t bl_blockAutoResponse(void) const =0; + // after every "bl_blockAutoLoad()" call this until response + // retval 0: wait 1: OK, blk was sent 2: OK, transfer complete + // 3: error despite repeating, cancel. probably bin file corrupted + // Max duration: 3x no response from BL = 900ms + + + // finally call: + // void hwapi::bl_stopBL(void) const + // -------------- end of bootloader --------------------------------------------------- + + + + // new from 28.9.23 and earliest from DC version 4.45 + // get all versions of the DC-Jsons + virtual void sys_requestJsonVersions(uint8_t jsonNr) const =0; + // send one request for every single version + // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res. + // 5=printer template 1 ..... 36= template 32 + + virtual void sys_getJsonVersions(uint8_t jsonNr, char *versionString) const =0; + // jsonNr=1...36, 1=config file (cust.Nr) 2=devices 3=cash 4=res. + // 5=printer template 1 ..... 36= template 32 + // length of buffer is always 16 byte + + // ------------------------------------------------------------------------------------ + // Coin Changer + // ------------------------------------------------------------------------------------ + + // find above (same as for coin checker (EMP)): + + // mdb_switchPower(true); // power on/off + // cash_startPayment(amount_cent); // start polling, enable coins, changer turns to green + + // getInsertedAmount() + // getLastInsertedCoin() + // getAllInsertedCoins(uint16_t *types, uint16_t *values) + // all inserted coins of this past transaction are stored, max 64 + + // cash_stopPayment(); // and wait for further command (changer blinks yellow) + // cash_cancelPayment(); // and return complete paid amount + + // after ticket/goods issue: + // vend_success() + // conclude payment process, keep all coins. Printing was successful + // return change (payment above start-amount), so it works only if + // Payment was started with real vending price (pre selection). + // if payment was started with maximum price (for direct coin insertion) + // then use "changer_returnCoins()", not vend_success() + + // vend_failed() + // conclude payment process and return complete paid amount + + // also valid for changer: + // emp_sendSettings(uint16_t coinAcceptance, uint8_t tokenChannel, uint16_t *coinDenomination ) const =0; + // coinAcceptance: bit0=coin1 (lowest donomination) bit15=coin16 bitH=accept bit L = deny coin (no validation) + // tokenChannel 0...31: if this signal comes from emp then a token was inserted + // coinDenomination = array of 16 coin values (e.g. 5, 10, 20...) + + virtual void changer_returnCoins(uint32_t amountInCent) const =0; + + virtual void changer_requestChangeResult(void) const =0; + + virtual uint8_t changer_getChangeResult(uint32_t *returnedAmount) const =0; + // get result of coin dispensing + // receivedData[0]: 0: not yet started 1:amount returned + // 2:only partial return 3: no return possible + // receivedData[2,3,4,5]: returned amount + + virtual void changer_getAllParameters(struct T_changer *mw) const =0; + // requested automatically with 23, same like EMP + + virtual void changer_requestTubelevel(void) const =0; + + virtual void changer_getTubelevel(struct T_chg_Tub *tubLevel) const =0; + // don't use tubeDispens[], it's not yet correct! + + + + // ------------------------------------------------------------------------------------ + // bank note acceptor + // ------------------------------------------------------------------------------------ + + // already defiened functions applying for BNA as well: + // mdb_switchPower(true); // power on/off + + // bank notes are integrated in the normal transaction process, so use the usual functions to run a vending cycle: + // cash_startPayment(amount_cent); // start polling, enable bills, reader shows green + // getInsertedAmount() + // cash_stopPayment(); + // cash_cancelPayment(); + // vend_success() + // vend_failed() + + virtual void bna_sendSettings(uint16_t notesToAccept, uint16_t parameters, + uint16_t *billDenomination, + uint32_t acceptanceLimit) const =0; + // notesToAccept: bit0=bill1 (lowest donomination) bitH=accept bit L = deny + // parameters: e.g. use escrow function for some notes + // billDenomination = array of 16 bill values (e.g. 5, 10, 20...) + // these can be set alternatively by Json-File DC2C_cash.json + // acceptanceLimit: device will stop acceptance once this amount is reached and + // optionally keep last bill in escrow until vend_success() + // is called (put bill to stacker) or vend_failed() is called (return bill) + + virtual void bna_setCurrentAcceptance(uint16_t notesToAccept) const =0; + // can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid) + // only valid till next start-payment. Cannot add notes which are not activated in Json + + virtual void bna_requestParameters(void) const =0; + // send command to DC in order to get static invariable device parameters like currency + // device must be powered and polled to get these + + virtual bool bna_getAllParameters(struct T_bna *bna) const =0; + // get all constant data from reader (e.g. currency) + // and actual Host-Settings (sent with bna_sendSettings() or json) + // retval = true if data are valid + + virtual void bna_requestCurrentNotes(void) const =0; + // send command to DC in order to get transaction data + + virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const =0; + // returns number of collected bank notes since start-command (current transaction) + // latestBill: last accepted bank note, value in cent + // currentNotes an array with up to 16 (further) notes collected + + virtual void bna_requestStackerLevel(void) const =0; + + virtual uint16_t bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const =0; + // return val: nr of bills in stacker + // countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker + // countOfBills[1] for 10€ and so on + + + + +signals: + virtual void hwapi_templatePrintFinished_OK(void) const=0; + virtual void hwapi_templatePrintFinished_Err(void) const=0; + + virtual void hwapi_coinCollectionJustStarted(void) const=0; + virtual void hwapi_coinCollectionAborted(void) const=0; + + virtual void hwapi_gotNewCoin(void) const=0; + virtual void hwapi_payStopByMax(void) const=0; + virtual void hwapi_payStopByPushbutton(void) const=0; + + virtual void hwapi_payStopByEscrow(void) const=0; + virtual void hwapi_payStopByError(void) const=0; + virtual void hwapi_payStopByTimeout(void) const=0; + virtual void hwapi_payCancelled(void) const=0; + virtual void hwapi_coinProcessJustStopped(void) const=0; + + virtual void hwapi_doorServiceDoorOpened(void) const=0; + virtual void hwapi_doorVaultDoorOpened(void) const=0; + virtual void hwapi_doorCoinBoxRemoved(void) const=0; + virtual void hwapi_doorCoinBoxInserted(void) const=0; + virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0; + virtual void hwapi_doorAllDoorsClosed(void) const=0; + + + +}; + + +// History +// 11.10.2021: V1.0 222 functions +// 23.12.2021: V1.1 added block-parameter to function "read mifare data" +// 30.12.2021: V1.2 added function: mif_clearDataBuffer(), mif_isBlockAvailable(uint8_t blkNr) and mif_getAvailableDataBlocks() +// 1.1.2022: V1.3 Mifare extended. ( background: read 16 x 48byte from card to DC, read 12 x 64byte from DC to CA) +// new: read full card with 768bytes from HWapi without block borders +// added: mif_getNrOfAvailableDataBytes mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize) +// mif_getCardDataStr(bool useHexFormat, char seperator) + +// 29.03.2023: V3.1 some extensions for PSA1256_ptu5, +// V3.2 Bootloader improvement +// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging +// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and +// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord +// +// 19.04.2023: V3.5 new function: sys_getWakeReason(); +// 17.05.2023: V3.6 new function: cash_isCollectionActive(), cash_isPayProcessActive() +// new signals: hwapi_coinCollectionJustStopped, hwapi_coinCollectionJustStarted +// getAllInsertedCoins() fixed, also in datif and storeINdata + +// 15.06.2023 V4.2 bring into same order as hwapi in order to set the THIS_IS_CA_MASTER correct +// 19.06.2023 V4.3 added some qCriticals to see emits + +// 01.08.2023 V4.4 some new values at the end of struct T_vaultRecord +// two more values in struct T_devices +// 7 new functions at the end of the file + + +//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.0" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.1" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.2" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.3" +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.4" + // 8.9.2023 two new functions (end of file) for mifare test +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.5" + // 18.9.2023 major improvements for DC data exchange + // verification of door and cash box signals + // intensive verification of Json-Programming Master-Slave (PTU to DC), 100% ok +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.6" + // 20.9.2023: speeding up door and cash box signals +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.7" + // 26.09.2023: added improved DC-bootloader files +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/4.8" +// 28.09.2023: added version request of DC-Json-Files +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.0" + // 10.10.2023: added coin changer +//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1" + // 20.10.2023: added bill validator +#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2" + // 7.11.2023: bna functions activated + +Q_DECLARE_INTERFACE(hwinf, HWINF_iid) + + +#endif + + + diff --git a/keypad.cpp b/keypad.cpp new file mode 100755 index 0000000..8d546c5 --- /dev/null +++ b/keypad.cpp @@ -0,0 +1,345 @@ +#include "keypad.h" + + +#define numPadKeyWidth 40 +static bool keypad_NumberIsVisible; +static bool keypad_visiKeyAllowed; + +T_keypad::T_keypad(QWidget *parent) : QWidget(parent) +{ + QFont myTabFont; + myTabFont.setPixelSize(20); + + myMainLay = new QVBoxLayout; + mySubLayout = new QGridLayout; + + valueDisplay = new QLabel(); + valueDisplay->setStyleSheet("background-color: white"); + valueDisplay->setLineWidth(5); + valueDisplay->setFont(myTabFont); + myMainLay->addWidget(valueDisplay); + myMainLay->addLayout(mySubLayout); + + + // number Pad Popup for Value entry: + numPad = new QGroupBox(" "); + numPad->setStyleSheet("background-color: grey"); + numPad->setLayout(myMainLay); + + QPushButton *key1 = new QPushButton("1"); + mySubLayout->addWidget(key1,0,0); + key1->setMaximumWidth(numPadKeyWidth); + key1->setFont(myTabFont); + connect(key1, SIGNAL(clicked()), this, SLOT(key1Clicked())); + + QPushButton *key2 = new QPushButton("2"); + mySubLayout->addWidget(key2,0,1); + key2->setMaximumWidth(numPadKeyWidth); + key2->setFont(myTabFont); + connect(key2, SIGNAL(clicked()), this, SLOT(key2Clicked())); + + QPushButton *key3 = new QPushButton("3"); + mySubLayout->addWidget(key3,0,2); + key3->setMaximumWidth(numPadKeyWidth); + key3->setFont(myTabFont); + connect(key3, SIGNAL(clicked()), this, SLOT(key3Clicked())); + + QPushButton *key4 = new QPushButton("4"); + mySubLayout->addWidget(key4,1,0); + key4->setMaximumWidth(numPadKeyWidth); + key4->setFont(myTabFont); + connect(key4, SIGNAL(clicked()), this, SLOT(key4Clicked())); + + QPushButton *key5 = new QPushButton("5"); + mySubLayout->addWidget(key5,1,1); + key5->setMaximumWidth(numPadKeyWidth); + key5->setFont(myTabFont); + connect(key5, SIGNAL(clicked()), this, SLOT(key5Clicked())); + + QPushButton *key6 = new QPushButton("6"); + mySubLayout->addWidget(key6,1,2); + key6->setMaximumWidth(numPadKeyWidth); + key6->setFont(myTabFont); + connect(key6, SIGNAL(clicked()), this, SLOT(key6Clicked())); + + QPushButton *key7 = new QPushButton("7"); + mySubLayout->addWidget(key7,2,0); + key7->setMaximumWidth(numPadKeyWidth); + key7->setFont(myTabFont); + connect(key7, SIGNAL(clicked()), this, SLOT(key7Clicked())); + + QPushButton *key8 = new QPushButton("8"); + mySubLayout->addWidget(key8,2,1); + key8->setMaximumWidth(numPadKeyWidth); + key8->setFont(myTabFont); + connect(key8, SIGNAL(clicked()), this, SLOT(key8Clicked())); + + QPushButton *key9 = new QPushButton("9"); + mySubLayout->addWidget(key9,2,2); + key9->setMaximumWidth(numPadKeyWidth); + key9->setFont(myTabFont); + connect(key9, SIGNAL(clicked()), this, SLOT(key9Clicked())); + + QPushButton *keyAc = new QPushButton("AC"); + mySubLayout->addWidget(keyAc,3,0); + keyAc->setMaximumWidth(numPadKeyWidth); + keyAc->setFont(myTabFont); + connect(keyAc, SIGNAL(clicked()), this, SLOT(keyAcClicked())); + + QPushButton *key0 = new QPushButton("0"); + mySubLayout->addWidget(key0,3,1); + key0->setMaximumWidth(numPadKeyWidth); + key0->setFont(myTabFont); + connect(key0, SIGNAL(clicked()), this, SLOT(key0Clicked())); + + QPushButton *keyBs = new QPushButton("<<"); + mySubLayout->addWidget(keyBs,3,2); + keyBs->setMaximumWidth(numPadKeyWidth); + keyBs->setFont(myTabFont); + connect(keyBs, SIGNAL(clicked()), this, SLOT(keyBsClicked())); + + QPushButton *keyC = new QPushButton("Esc"); + mySubLayout->addWidget(keyC,4,0); + keyC->setMaximumWidth(numPadKeyWidth); + keyC->setFont(myTabFont); + connect(keyC, SIGNAL(clicked()), this, SLOT(keyCancelClicked())); + + QPushButton *keySee = new QPushButton("see"); + mySubLayout->addWidget(keySee,4,1); + keySee->setMaximumWidth(numPadKeyWidth); + keySee->setFont(myTabFont); + connect(keySee, SIGNAL(clicked()), this, SLOT(keySeeEntryClicked())); + + QPushButton *keyOK = new QPushButton("OK"); + mySubLayout->addWidget(keyOK,4,2); + keyOK->setMaximumWidth(numPadKeyWidth); + keyOK->setFont(myTabFont); + connect(keyOK, SIGNAL(clicked()), this, SLOT(keyOkClicked())); + + numPad->hide(); + myValueString.clear(); + valueDisplay->clear(); + myReturnString.clear(); + keypad_visiKeyAllowed=true; + keypad_NumberIsVisible=true; +} + +T_keypad::~T_keypad() +{ + +} + +void T_keypad::show(void) +{ + numPad->show(); + numPad->setFocus(); + numPad->setEnabled(true); + numPad->raise(); + myValueString.clear(); + valueDisplay->clear(); + myReturnString.clear(); +} + +void T_keypad::hide(void) +{ + numPad->hide(); +} + +void T_keypad::keysVisible(uint8_t visib) +{ + // visib=0: show * 1:show numbers 2: show * but allow visi-key + if (visib==0) + { + keypad_NumberIsVisible=false; + keypad_visiKeyAllowed=false; + } else + if (visib==1) + { + keypad_NumberIsVisible=true; + keypad_visiKeyAllowed=false; + } else + if (visib==2) + { + keypad_NumberIsVisible=false; + keypad_visiKeyAllowed=true; + } + +} + + +QString T_keypad::getValueString(void) +{ + return myReturnString; +} + +int32_t T_keypad::getValueDecimal(void) +{ + return myReturnString.toULong(); + +} + + +void T_keypad::key0Clicked(void) +{ + myReturnString.append("0"); + if (keypad_NumberIsVisible) + { + myValueString.append("0"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key1Clicked(void) +{ + myReturnString.append("1"); + if (keypad_NumberIsVisible) + { + myValueString.append("1"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key2Clicked(void) +{ + myReturnString.append("2"); + if (keypad_NumberIsVisible) + { + myValueString.append("2"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key3Clicked(void) +{ + myReturnString.append("3"); + if (keypad_NumberIsVisible) + { + + myValueString.append("3"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key4Clicked(void) +{ + myReturnString.append("4"); + if (keypad_NumberIsVisible) + { + myValueString.append("4"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key5Clicked(void) +{ + myReturnString.append("5"); + if (keypad_NumberIsVisible) + { + myValueString.append("5"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key6Clicked(void) +{ + myReturnString.append("6"); + if (keypad_NumberIsVisible) + { + myValueString.append("6"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key7Clicked(void) +{ + myReturnString.append("7"); + if (keypad_NumberIsVisible) + { + myValueString.append("7"); + } else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key8Clicked(void) +{ + myReturnString.append("8"); + if (keypad_NumberIsVisible) + myValueString.append("8"); + else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::key9Clicked(void) +{ + myReturnString.append("9"); + if (keypad_NumberIsVisible) + myValueString.append("9"); + else + myValueString.append("*"); + valueDisplay->setText(myValueString); +} + +void T_keypad::keyOkClicked(void) +{ + numPad->hide(); + emit keyEntryFinished(); +} + +void T_keypad::keyCancelClicked(void) +{ + myValueString.clear(); + myReturnString.clear(); + valueDisplay->clear(); + numPad->hide(); + emit keyEntryFinished(); +} + +void T_keypad::keySeeEntryClicked(void) +{ + + if (keypad_visiKeyAllowed) + { + if (keypad_NumberIsVisible) + { + // dont want to see the entry, so overwrite number(s) with asteriks + int len=myValueString.length(); + myValueString.clear(); + for (int nn=0; nnsetText(myValueString); +} + +void T_keypad::keyAcClicked(void) +{ + myValueString.clear(); + myReturnString.clear(); + valueDisplay->clear(); +} + +void T_keypad::keyBsClicked(void) +{ + myValueString.chop(1); + myReturnString.chop(1); + valueDisplay->setText(myValueString); +} + + diff --git a/keypad.h b/keypad.h new file mode 100755 index 0000000..89fc78c --- /dev/null +++ b/keypad.h @@ -0,0 +1,71 @@ +#ifndef KEYPAD_USED +#define KEYPAD_USED + +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include +#include +#include +#include +#include +#include +#include + +class T_keypad : public QWidget +{ + Q_OBJECT + + QGroupBox *numPad; + QLabel *valueDisplay; + QString myValueString; // used to display the entry in upper line + QString myReturnString; // used to return the value + + QVBoxLayout *myMainLay; + QGridLayout *mySubLayout; + +public: + explicit T_keypad(QWidget *parent = nullptr); + ~T_keypad(); + + void show(void); + void hide(); + void keysVisible(uint8_t visib); + // visib=0: show * 1:show numbers 2: show * but allow visi-key + + + QString getValueString(void); + int32_t getValueDecimal(void); + + +private slots: + void key0Clicked(void); + void key1Clicked(void); + void key2Clicked(void); + void key3Clicked(void); + void key4Clicked(void); + void key5Clicked(void); + void key6Clicked(void); + void key7Clicked(void); + void key8Clicked(void); + void key9Clicked(void); + + void keyAcClicked(void); + void keyBsClicked(void); + + void keyOkClicked(void); + void keyCancelClicked(void); + void keySeeEntryClicked(void); + +signals: + void keyEntryFinished(void); + + + +}; + +#endif diff --git a/lib_template.cpp b/lib_template.cpp new file mode 100755 index 0000000..646e377 --- /dev/null +++ b/lib_template.cpp @@ -0,0 +1,25 @@ +#include "lib_template.h" + + + +T_lib_template::T_lib_template(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + +} + +T_lib_template::~T_lib_template() +{ + +} + +bool T_lib_template::working(void) +{ + // is called cyclic + + + return false; +} + + diff --git a/lib_template.h b/lib_template.h new file mode 100755 index 0000000..6c9c60c --- /dev/null +++ b/lib_template.h @@ -0,0 +1,28 @@ +#ifndef LIB_TEMPLATE_H +#define LIB_TEMPLATE_H + +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" + + + +class T_lib_template : public QWidget +{ + Q_OBJECT + hwinf *HWaccess; + + +public: + explicit T_lib_template(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + + bool working (void); + ~T_lib_template(); + +}; + +#endif diff --git a/main.cpp b/main.cpp new file mode 100755 index 0000000..37a277b --- /dev/null +++ b/main.cpp @@ -0,0 +1,41 @@ +#include "mainwindow.h" +//#include "message_handler.h" +#include + +int thisisglobal; + +int main(int argc, char *argv[]) +{ + int ret; + QApplication myapp(argc, argv); +/* + if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling + atbInstallMessageHandler(atbDebugOutput); + setDebugLevel(QtMsgType::QtDebugMsg); + //setDebugLevel(QtMsgType::QtDebugMsg); + } +*/ + MainWindow myMainWin; + QSize myMainSize={800, 480}; // breite, höhe, PTU: 800x440 + myMainWin.setMinimumSize(myMainSize); + myMainWin.setMaximumSize(myMainSize); + myMainWin.setWindowTitle("PSA Service Tool V4.1"); + myMainWin.show(); + //myMainWin.showFullScreen(); + + ret=myapp.exec(); + + return ret; +} + + + +//QApplication a(argc, argv); +//MainWindow CatMW; +//QSize myMainSize={800, 480}; // breite, höhe +//CatMW.setMinimumSize(myMainSize); +//CatMW.setMaximumSize(myMainSize); +//CatMW.setWindowTitle("ATB CashAgent V2.0"); +// QPalette mainPal; +// mainPal.setColor(QPalette::Window, Qt::red ); +// CatMW.setPalette(mainPal); sieht man nicht mehr diff --git a/mainwindow.cpp b/mainwindow.cpp new file mode 100755 index 0000000..3452e42 --- /dev/null +++ b/mainwindow.cpp @@ -0,0 +1,1259 @@ +#include "mainwindow.h" +/* + * Mainwindow is establishing special TS Layout which can be used alternatively to QtabWidget + * Mainwindow is setting up all necessary screen-layouts and make the complete navigation + * The real needed customers screens can be find in class "subwindows" or other external classes + * All screens have the same size and the same place + * A naviation bar at bottom side calls all screens successively + * Window 0 (=home) offers short links to the most important windows (main menu) + * introduced in CatGui in 2021, dec. 6. +*/ + + + +char MainWindow::loadPlugIn(char lade1_entlade2) +{ + //const auto staticInstances=QPluginLoader::staticInstances(); + //Pfad lässt sich verändern und die enthaltenen Dateien anzeigen + //wird aber von QPluginLoader dann nicht verwendet, also müßig + + plugInDir.cd("plugins"); + QPluginLoader *pluginLoader = new QPluginLoader(); + +// select system: + //pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse + //pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5 + //pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows + + pluginLoader->setFileName("../../SlavePlug/CAslave.dll"); // for windows +// pluginLoader->setFileName("/usr/lib/libCAslave.so"); // for PTU5 + + if (lade1_entlade2==2) + { + pluginLoader->unload(); + return 0; + } + + if (!pluginLoader->load()) + { + qDebug()<<"cannot load plugin"; + } else + qDebug() <<"loaded plugin: " << pluginLoader->fileName(); + + if (!pluginLoader->isLoaded()) + { + qDebug()<errorString(); + return 0; + } + + QObject *plugin = pluginLoader->instance(); + if ( plugin == nullptr) + { + // make instance of the root component (which can hold more then one clases) + // also loads the lib if not yet done + qDebug()<<"cannot start instance"; + return 0; + } + + //int rr=hwapi->giveVal(2); funktioniert :)) + //qDebug()<<"got value from plugin"<(plugin); + // make instance to class "hwinf" in dll_HWapi.h over "interfaces.h" + + qDebug()<<"loadPlugIn, HWAccess: " << HWaccess; + return 0; + +} + + + + + +// find HWsettings in subwindows.cpp line 630 + +#define WINCTRMIN 0 + // 0 is always the home screen + +#define WINCTRMAX 30 + // number of needed application screens, up to 255 + // All screens must be defined below in mainwindow-class first before increasing the nr + // numbers must be consecutively from 0 always, 0 is the home screen always + +#define FORMWIDTH 725 +//#define FORMWIDTH 690 + // this width is the same for ALL windows + +#define FORMHEIGHT 440 +// this height is the same for ALL windows + +#define NAVIBUTTONHEIGHT 70 +#define NAVIBUTTONWIDHT 50 + +#define HOMEPAGE_BACKGROUND_COLOR "background-color: lightgrey" + +#define BUTTON_COLOR "background-color: rgb(160,250,190)" + +#define ACTIVE_NAVI_COLOR "background-color: rgb(160,250,190)" +#define DISABL_NAVI_COLOR "background-color: grey" + +#define APPPAGE_BACKGROUND_COLOR "background-color: lightgrey" + +#define UPDATE_PERIOD_MS 100 + // period to call chain steps + +#define VENDINGTIMEOUT_MS 30000 + // after this time without any operation the program returns to idle state + // time in ms, that means 30.000 gives 30seconds + +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) +{ + loadPlugIn(1); + + // define all working moduls (besides gui) here, call ini and working in chainControl() (~Line 1000) + //mifCard = new T_Mifare(HWaccess); // ganz wichtig: HWaccess an sub-Konstruktor übergeben + // sonst crash bei HW-Zugriff!!!! + //diary = new T_lib_diary(); absturz!!!!!! + //conf = new T_lib_config(HWaccess); + + timerChainCtrl = new QTimer(this); + connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl())); + timerChainCtrl->setSingleShot(0); + timerChainCtrl->start(UPDATE_PERIOD_MS); // 1000: call every 1000ms + + timerVendingTimeout = new QTimer(this); + connect(timerVendingTimeout, SIGNAL(timeout()), this, SLOT(vendingTimeout())); + timerVendingTimeout->setSingleShot(true); + timerVendingTimeout->start(VENDINGTIMEOUT_MS); // in ms + + // ########################################################################################## + // für jedes anzuzeigende Fenster eine eigene Groupbox mit eigenem Grid anlegen: + + frame01 = new QGroupBox; + frame01->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame01->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay01 = new QVBoxLayout; + frame01->setLayout(smallLay01); + // Fensterinhalt aus externer Klasse einfügen: + //myFenster01 = new T_winComPort(HWaccess); // HWaccess damit auf das HW-Plugin zugegriffen werden kann, sonst crash + //smallLay01->addWidget(myFenster01); + + frame02 = new QGroupBox; + frame02->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame02->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay02 = new QVBoxLayout; + frame02->setLayout(smallLay02); + // insert an instance of an external app class: + myFenster02 = new T_win02(HWaccess); + smallLay02->addWidget(myFenster02); + + frame03 = new QGroupBox; + frame03->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame03->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay03 = new QVBoxLayout; + frame03->setLayout(smallLay03); + myFenster03 = new T_win03(HWaccess); + smallLay03->addWidget(myFenster03); + + frame04 = new QGroupBox; + frame04->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame04->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay04 = new QVBoxLayout; + frame04->setLayout(smallLay04); + myFenster04 = new T_win04(HWaccess); + smallLay04->addWidget(myFenster04); + + frame05 = new QGroupBox; + frame05->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame05->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay05 = new QVBoxLayout; + frame05->setLayout(smallLay05); + myFenster05 = new T_win05(HWaccess); + smallLay05->addWidget(myFenster05); + + frame06 = new QGroupBox; + frame06->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame06->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay06 = new QVBoxLayout; + frame06->setLayout(smallLay06); + myFenster06 = new T_win06(HWaccess); + smallLay06->addWidget(myFenster06); + + frame07 = new QGroupBox; + frame07->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame07->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay07 = new QVBoxLayout; + frame07->setLayout(smallLay07); + myFenster07 = new T_win07(HWaccess); + smallLay07->addWidget(myFenster07); + + frame08 = new QGroupBox; + frame08->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame08->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay08 = new QVBoxLayout; + frame08->setLayout(smallLay08); + myFenster08 = new T_win08(HWaccess); + smallLay08->addWidget(myFenster08); + + frame09 = new QGroupBox; + frame09->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame09->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay09 = new QVBoxLayout; + frame09->setLayout(smallLay09); + myFenster09 = new T_win09(HWaccess); + smallLay09->addWidget(myFenster09); + + frame10 = new QGroupBox; + frame10->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame10->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay10 = new QVBoxLayout; + frame10->setLayout(smallLay10); + myFenster10 = new T_win10(HWaccess); + smallLay10->addWidget(myFenster10); + + frame11 = new QGroupBox; + frame11->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame11->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay11 = new QVBoxLayout; + frame11->setLayout(smallLay11); + myFenster11 = new T_win11(HWaccess); + smallLay11->addWidget(myFenster11); + + frame12 = new QGroupBox; + frame12->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame12->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay12 = new QVBoxLayout; + frame12->setLayout(smallLay12); + myFenster12 = new T_win12(HWaccess); + smallLay12->addWidget(myFenster12); + + frame13 = new QGroupBox; + frame13->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame13->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay13 = new QVBoxLayout; + frame13->setLayout(smallLay13); + myFenster13 = new T_win13(HWaccess); + smallLay13->addWidget(myFenster13); + + frame14 = new QGroupBox; + frame14->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame14->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay14 = new QVBoxLayout; + frame14->setLayout(smallLay14); + myFenster14 = new T_win14(HWaccess); + smallLay14->addWidget(myFenster14); + + frame15 = new QGroupBox; + frame15->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame15->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay15 = new QVBoxLayout; + frame15->setLayout(smallLay15); + myFenster15 = new T_win15(HWaccess); + smallLay15->addWidget(myFenster15); + + frame16 = new QGroupBox; + frame16->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame16->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay16 = new QVBoxLayout; + frame16->setLayout(smallLay16); + myFenster16 = new T_win16(HWaccess); + smallLay16->addWidget(myFenster16); + + frame17 = new QGroupBox; + frame17->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame17->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay17 = new QVBoxLayout; + frame17->setLayout(smallLay17); + myFenster17 = new T_win17(HWaccess); + smallLay17->addWidget(myFenster17); + + frame18 = new QGroupBox; + frame18->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame18->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay18 = new QVBoxLayout; + frame18->setLayout(smallLay18); + myFenster18 = new T_win18(HWaccess); + smallLay18->addWidget(myFenster18); + + frame19 = new QGroupBox; + frame19->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame19->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay19 = new QVBoxLayout; + frame19->setLayout(smallLay19); + myFenster19 = new T_win19(HWaccess); + smallLay19->addWidget(myFenster19); + + frame20 = new QGroupBox; + frame20->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame20->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay20 = new QVBoxLayout; + frame20->setLayout(smallLay20); + myFenster20 = new T_win20(HWaccess); + smallLay20->addWidget(myFenster20); +/* + frame21 = new QGroupBox; + frame21->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame21->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay21 = new QVBoxLayout; + frame21->setLayout(smallLay21); + myFenster21 = new T_win21(HWaccess); + smallLay21->addWidget(myFenster21); + + frame22 = new QGroupBox; + frame22->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame22->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay22 = new QVBoxLayout; + frame22->setLayout(smallLay22); + myFenster22 = new T_win22(HWaccess); + smallLay22->addWidget(myFenster22); + + frame23 = new QGroupBox; + frame23->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame23->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay23 = new QVBoxLayout; + frame23->setLayout(smallLay23); + myFenster23 = new T_win23(HWaccess); + smallLay23->addWidget(myFenster23); + + frame24 = new QGroupBox; + frame24->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame24->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay24 = new QVBoxLayout; + frame24->setLayout(smallLay24); + myFenster24 = new T_win_pwrDo(HWaccess); + smallLay24->addWidget(myFenster24); + + frame25 = new QGroupBox; + frame25->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame25->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay25 = new QVBoxLayout; + frame25->setLayout(smallLay25); + myFenster25 = new T_win_barrAux(HWaccess); + smallLay25->addWidget(myFenster25); + + frame26 = new QGroupBox; + frame26->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame26->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay26 = new QVBoxLayout; + frame26->setLayout(smallLay26); + myFenster26 = new T_fenster26(HWaccess); + smallLay26->addWidget(myFenster26); + + frame27 = new QGroupBox; + frame27->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame27->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay27 = new QVBoxLayout; + frame27->setLayout(smallLay27); + myFenster27 = new T_fenster27(HWaccess); + smallLay27->addWidget(myFenster27); + + frame28 = new QGroupBox; + frame28->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame28->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay28 = new QVBoxLayout; + frame28->setLayout(smallLay28); + myFenster28 = new T_fenster28(HWaccess); + smallLay28->addWidget(myFenster28); + + frame29 = new QGroupBox; + frame29->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame29->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay29 = new QVBoxLayout; + frame29->setLayout(smallLay29); + myFenster29 = new T_fenster29(HWaccess); + smallLay29->addWidget(myFenster29); + + frame30 = new QGroupBox; + frame30->setStyleSheet(APPPAGE_BACKGROUND_COLOR); + frame30->setMinimumSize(FORMWIDTH,FORMHEIGHT); + QVBoxLayout *smallLay30 = new QVBoxLayout; + frame30->setLayout(smallLay30); + myFenster30 = new T_fenster30(HWaccess); + smallLay30->addWidget(myFenster30); +*/ + + + // ########################################################################################## + // draw Mainwindow: + bigGroupbox = new QGroupBox; + bigGroupbox->setStyleSheet("background-color: grey"); + bigGroupbox->setMinimumSize(800,480); +// bigLayout = new QVBoxLayout; // navi buttons on bottom side + bigLayout = new QHBoxLayout; // navi buttons right hand + + // ########################################################################################## + // add all windows (but display only one) + // display only one: then all windows are shown at the same place + // display more then one: the windows are listed in vertical order + + bigLayout->addWidget(frame01); + bigLayout->addWidget(frame02); + bigLayout->addWidget(frame03); + bigLayout->addWidget(frame04); + bigLayout->addWidget(frame05); + bigLayout->addWidget(frame06); + bigLayout->addWidget(frame07); + bigLayout->addWidget(frame08); + bigLayout->addWidget(frame09); + bigLayout->addWidget(frame10); + bigLayout->addWidget(frame11); + bigLayout->addWidget(frame12); + bigLayout->addWidget(frame13); + bigLayout->addWidget(frame14); + bigLayout->addWidget(frame15); + bigLayout->addWidget(frame16); + bigLayout->addWidget(frame17); + bigLayout->addWidget(frame18); + bigLayout->addWidget(frame19); + bigLayout->addWidget(frame20); + /* + bigLayout->addWidget(frame21); + bigLayout->addWidget(frame22); + bigLayout->addWidget(frame23); + bigLayout->addWidget(frame24); + bigLayout->addWidget(frame25); + bigLayout->addWidget(frame26); + bigLayout->addWidget(frame27); + bigLayout->addWidget(frame28); + bigLayout->addWidget(frame29); + bigLayout->addWidget(frame30); +*/ + + + bigGroupbox->setLayout(bigLayout); + switchScreen(1); + //HideAllWindows(); + + // ########################################################################################## + // Steuer Leiste + + //QHBoxLayout *ButtonLayout = new QHBoxLayout(); + QVBoxLayout *ButtonLayout = new QVBoxLayout(); + QFont myTabFont; + myTabFont.setPixelSize(26); + + pBback = new QPushButton("<"); //b\na\nc\nk"); + pBback->setFont(myTabFont); + pBback->setStyleSheet(ACTIVE_NAVI_COLOR); + pBback->setMinimumHeight(NAVIBUTTONHEIGHT); + pBback->setMaximumWidth(NAVIBUTTONWIDHT); +// connect(pBback, SIGNAL( clicked() ), this, SLOT( goBack() )); + //connect(pBback, SIGNAL( clicked() ), myFenster01, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster02, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster03, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster04, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster05, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster06, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster07, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster08, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster09, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster10, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster11, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster12, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster13, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster14, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster15, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster16, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster17, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster18, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster19, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster20, SLOT( Nav_back())); + /* + connect(pBback, SIGNAL( clicked() ), myFenster21, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster22, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster23, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster24, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster25, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster26, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster27, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster28, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster29, SLOT( Nav_back())); + connect(pBback, SIGNAL( clicked() ), myFenster30, SLOT( Nav_back())); +*/ + + myTabFont.setPixelSize(22); + pBhome = new QPushButton("<<"); //h\no\nm\ne"); + pBhome->setFont(myTabFont); + pBhome->setStyleSheet(ACTIVE_NAVI_COLOR); + pBhome->setMinimumHeight(NAVIBUTTONHEIGHT); + pBhome->setMaximumWidth(NAVIBUTTONWIDHT); + //connect(pBhome, SIGNAL( clicked() ), myFenster01, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster02, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster03, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster04, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster05, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster06, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster07, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster08, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster09, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster10, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster11, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster12, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster13, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster14, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster15, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster16, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster17, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster18, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster19, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster20, SLOT( Nav_home())); + /* + connect(pBhome, SIGNAL( clicked() ), myFenster21, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster22, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster23, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster24, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster25, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster26, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster27, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster28, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster29, SLOT( Nav_home())); + connect(pBhome, SIGNAL( clicked() ), myFenster30, SLOT( Nav_home())); +*/ + + myTabFont.setPixelSize(26); + pBforward = new QPushButton(">"); //n\ne\nx\nt"); + pBforward->setFont(myTabFont); + pBforward->setStyleSheet(ACTIVE_NAVI_COLOR); + pBforward->setMinimumHeight(NAVIBUTTONHEIGHT); + pBforward->setMaximumWidth(NAVIBUTTONWIDHT); + //connect(pBforward, SIGNAL( clicked() ), myFenster01, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster02, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster03, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster04, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster05, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster06, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster07, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster08, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster09, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster10, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster11, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster12, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster13, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster14, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster15, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster16, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster17, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster18, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster19, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster20, SLOT( Nav_next())); +/* + connect(pBforward, SIGNAL( clicked() ), myFenster21, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster21, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster22, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster23, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster24, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster25, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster26, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster27, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster28, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster29, SLOT( Nav_next())); + connect(pBforward, SIGNAL( clicked() ), myFenster30, SLOT( Nav_next())); +*/ + + + QLabel *buttonSpace = new QLabel(" "); + ButtonLayout->addWidget(pBback); + ButtonLayout->addWidget(buttonSpace); + //ButtonLayout->addWidget(buttonSpace); + ButtonLayout->addWidget(pBhome); + ButtonLayout->addWidget(buttonSpace); + //ButtonLayout->addWidget(buttonSpace); + ButtonLayout->addWidget(pBforward); + QLabel *bottomSpace = new QLabel(" "); + ButtonLayout->addWidget(bottomSpace); + + bigLayout->addLayout(ButtonLayout); + + //QLabel *bottomSpace = new QLabel(" "); + //bigLayout->addLayout(bottomSpace); // Zeile unter den Tasten + + setCentralWidget(bigGroupbox); + + // AUTOSTART serial transmission + //HWaccess->dc_openSerial(5,"115200","ttyS0",1); // my suse computer + //HWaccess->dc_openSerial(1,"9600","COM5",1); // my suse computer + //HWaccess->dc_openSerial(5,"115200","ttymxc2",1); // ptu5 + //HWaccess->dc_autoRequest(true); + //myFenster01->setButtons4autoStart(); + //HWaccess->alarm_switchSiren(0); // test + + enableNaviButtons(BACKBUTTON,true); + enableNaviButtons(HOMEBUTTON,true); + enableNaviButtons(FORWBUTTON,true); + this->chainIni(); + + connect(myFenster02, SIGNAL(quitMyApp()), this, SLOT(close())); + +} + +MainWindow::~MainWindow() +{ + loadPlugIn(2); +} + + +void MainWindow::HideAllWindows() +{ + // vorsicht: Fenster muss oben definiert sein sonst Programmabsturz ohne Kommentar + + frame01->setEnabled(false); + frame02->setEnabled(false); + frame03->setEnabled(false); + frame04->setEnabled(false); + frame05->setEnabled(false); + frame06->setEnabled(false); + frame07->setEnabled(false); + frame08->setEnabled(false); + frame09->setEnabled(false); + frame10->setEnabled(false); + frame11->setEnabled(false); + frame12->setEnabled(false); + frame13->setEnabled(false); + frame14->setEnabled(false); + frame15->setEnabled(false); + frame16->setEnabled(false); + frame17->setEnabled(false); + frame18->setEnabled(false); + frame19->setEnabled(false); + frame20->setEnabled(false); +/* + frame21->setEnabled(false); + frame22->setEnabled(false); + frame23->setEnabled(false); + frame24->setEnabled(false); + frame25->setEnabled(false); + frame26->setEnabled(false); + frame27->setEnabled(false); + frame28->setEnabled(false); + frame29->setEnabled(false); + frame30->setEnabled(false); +*/ + + frame01->setVisible(false); + frame02->setVisible(false); + frame03->setVisible(false); + frame04->setVisible(false); + frame05->setVisible(false); + frame06->setVisible(false); + frame07->setVisible(false); + frame08->setVisible(false); + frame09->setVisible(false); + frame10->setVisible(false); + frame11->setVisible(false); + frame12->setVisible(false); + frame13->setVisible(false); + frame14->setVisible(false); + frame15->setVisible(false); + frame16->setVisible(false); + frame17->setVisible(false); + frame18->setVisible(false); + frame19->setVisible(false); + frame20->setVisible(false); +/* + frame21->setVisible(false); + frame22->setVisible(false); + frame23->setVisible(false); + frame24->setVisible(false); + frame25->setVisible(false); + frame26->setVisible(false); + frame27->setVisible(false); + frame28->setVisible(false); + frame29->setVisible(false); + frame30->setVisible(false); +*/ +} + + +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// Call Windows +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +void MainWindow::switchScreen(uint16_t winNr) // 0...30 +{ + + HideAllWindows(); + //qDebug()<<"switch screen to " << winNr; + + switch (winNr) + { + case 1: + frame01->setEnabled(true); + frame01->setVisible(true); + break; + + case 2: + frame02->setEnabled(true); + frame02->setVisible(true); + break; + + case 3: + frame03->setEnabled(true); + frame03->setVisible(true); + break; + + case 4: + frame04->setEnabled(true); + frame04->setVisible(true); + break; + + case 5: + frame05->setEnabled(true); + frame05->setVisible(true); + break; + + case 6: + frame06->setEnabled(true); + frame06->setVisible(true); + break; + + case 7: + frame07->setEnabled(true); + frame07->setVisible(true); + break; + + case 8: + frame08->setEnabled(true); + frame08->setVisible(true); + break; + + case 9: + frame09->setEnabled(true); + frame09->setVisible(true); + break; + + case 10: + frame10->setEnabled(true); + frame10->setVisible(true); + break; + case 11: + frame11->setEnabled(true); + frame11->setVisible(true); + break; + case 12: + frame12->setEnabled(true); + frame12->setVisible(true); + break; + case 13: + frame13->setEnabled(true); + frame13->setVisible(true); + break; + case 14: + frame14->setEnabled(true); + frame14->setVisible(true); + break; + case 15: + frame15->setEnabled(true); + frame15->setVisible(true); + break; + case 16: + frame16->setEnabled(true); + frame16->setVisible(true); + break; + case 17: + frame17->setEnabled(true); + frame17->setVisible(true); + break; + case 18: + frame18->setEnabled(true); + frame18->setVisible(true); + break; + case 19: + frame19->setEnabled(true); + frame19->setVisible(true); + break; + case 20: + frame20->setEnabled(true); + frame20->setVisible(true); + break; +/* + case 21: + frame21->setEnabled(true); + frame21->setVisible(true); + break; + case 22: + frame22->setEnabled(true); + frame22->setVisible(true); + break; + case 23: + frame23->setEnabled(true); + frame23->setVisible(true); + break; + case 24: + frame24->setEnabled(true); + frame24->setVisible(true); + break; + case 25: + frame25->setEnabled(true); + frame25->setVisible(true); + break; + case 26: + frame26->setEnabled(true); + frame26->setVisible(true); + break; + case 27: + frame27->setEnabled(true); + frame27->setVisible(true); + break; + case 28: + frame28->setEnabled(true); + frame28->setVisible(true); + break; + case 29: + frame29->setEnabled(true); + frame29->setVisible(true); + break; + case 30: + frame30->setEnabled(true); + frame30->setVisible(true); + break; +*/ + default: + //fenster00->setEnabled(true); + //fenster00->setVisible(true); + break; + + } + +} + +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// Navigation buttons +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +void MainWindow::enableNaviButtons(uint8_t switchBitwise) +{ + // switchBitwise=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + + if (switchBitwise &1) + { + pBforward->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBforward->setText("next"); + pBforward->setEnabled(true); + } else + if (switchBitwise &2) + { + pBforward->setStyleSheet(DISABL_NAVI_COLOR); + //pBforward->setText(" "); + pBforward->setEnabled(false); + } + + if (switchBitwise &4) + { + pBhome->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBhome->setText("home"); + pBhome->setEnabled(true); + } else + if (switchBitwise &8) + { + pBhome->setStyleSheet(DISABL_NAVI_COLOR); + //pBhome->setText(" "); + pBhome->setEnabled(false); + } + + if (switchBitwise &16) + { + pBback->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBback->setText("back"); + pBback->setEnabled(true); + } else + if (switchBitwise &32) + { + pBback->setStyleSheet(DISABL_NAVI_COLOR); + //pBback->setText(" "); + pBback->setEnabled(false); + } + + + +} + +void MainWindow::enableNaviButtons(uint8_t buttonNr, bool enabled) +{ + if (buttonNr==1) + { + if (enabled) + { + pBback->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBback->setText("back"); + pBback->setEnabled(true); + } else + { + pBback->setStyleSheet(DISABL_NAVI_COLOR); + //pBback->setText(" "); + pBback->setEnabled(false); + } + } else + if (buttonNr==2) + { + if (enabled) + { + pBhome->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBhome->setText("home"); + pBhome->setEnabled(true); + } else + { + pBhome->setStyleSheet(DISABL_NAVI_COLOR); + //pBhome->setText(" "); + pBhome->setEnabled(false); + } + } else + if (buttonNr==3) + { + if (enabled) + { + pBforward->setStyleSheet(ACTIVE_NAVI_COLOR); + //pBforward->setText("next"); + pBforward->setEnabled(true); + } else + { + pBforward->setStyleSheet(DISABL_NAVI_COLOR); + //pBforward->setText(" "); + pBforward->setEnabled(false); + } + } + +} + + + +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// control work flow by Finite state machine +// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +/* +basics: the complete work flow is organized in a step chain (Finite State Machine) +The MainWindowClass (here) always starts with screen number 1 which decides about the next starting steps +Every workingStep (step of the chain) has it's one Frame (with the same number) in MainWindow +Every workingStep has it's own subClass where it processes all work and designes it's own screen +Every workingStep comes back with the request of the next step (& it's screen) once needed which is switched here. +The MainFrame (here) offers three navigation buttons which are forwarded into all subclasses +After a subclass desires a step change the appropriate work-ini function is called one time. +24.12.2021TS +*/ + +static uint16_t chainCurrentStep, chainNextStep; +static bool chain_stepIni; + +void MainWindow::chainIni(void) +{ + // called once after power-up by constructor + chainCurrentStep=WCS_STARTSCREEN; // start screen + chainNextStep=chainCurrentStep; + switchScreen(chainCurrentStep); + chain_stepIni=true; +//qDebug()<<"chain ini, call step "<working(); + //diary->working(); + //conf->working(); + +//qDebug()<<"mainwin chaincontrol calling mif"; + + // working step chain: + if (chainCurrentStep != chainNextStep) + { + if (chainNextStep!=WCS_STARTSCREEN) + { + timerVendingTimeout->stop(); + timerVendingTimeout->start(VENDINGTIMEOUT_MS); + } + //qDebug()<<"found new sreen"; + chainCurrentStep=chainNextStep; + switchScreen(chainCurrentStep); + chain_stepIni=true; + + } + + //qDebug()<<"chain control step: "<< chainCurrentStep<<" "<work_ini(&nextScreen, &useNavi); + //else + // busy=myFenster01->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==2) + { + if (chain_stepIni) + busy=myFenster02->work_ini(&nextScreen, &useNavi); + else + busy=myFenster02->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==3) + { + if (chain_stepIni) + busy=myFenster03->work_ini(&nextScreen, &useNavi); + else + busy=myFenster03->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==4) + { + if (chain_stepIni) + busy=myFenster04->work_ini(&nextScreen, &useNavi); + else + busy=myFenster04->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==5) + { + if (chain_stepIni) + busy=myFenster05->work_ini(&nextScreen, &useNavi); + else + busy=myFenster05->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==6) + { + if (chain_stepIni) + busy=myFenster06->work_ini(&nextScreen, &useNavi); + else + busy=myFenster06->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==7) + { + if (chain_stepIni) + busy=myFenster07->work_ini(&nextScreen, &useNavi); + else + busy=myFenster07->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==8) + { + if (chain_stepIni) + busy=myFenster08->work_ini(&nextScreen, &useNavi); + else + busy=myFenster08->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==9) + { + if (chain_stepIni) + busy=myFenster09->work_ini(&nextScreen, &useNavi); + else + busy=myFenster09->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==10) + { + if (chain_stepIni) + busy=myFenster10->work_ini(&nextScreen, &useNavi); + else + busy=myFenster10->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==11) + { + if (chain_stepIni) + busy=myFenster11->work_ini(&nextScreen, &useNavi); + else + busy=myFenster11->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==12) + { + if (chain_stepIni) + busy=myFenster12->work_ini(&nextScreen, &useNavi); + else + busy=myFenster12->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==13) + { + if (chain_stepIni) + busy=myFenster13->work_ini(&nextScreen, &useNavi); + else + busy=myFenster13->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==14) + { + if (chain_stepIni) + busy=myFenster14->work_ini(&nextScreen, &useNavi); + else + busy=myFenster14->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==15) + { + if (chain_stepIni) + busy=myFenster15->work_ini(&nextScreen, &useNavi); + else + busy=myFenster15->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==16) + { + if (chain_stepIni) + busy=myFenster16->work_ini(&nextScreen, &useNavi); + else + busy=myFenster16->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==17) + { + if (chain_stepIni) + busy=myFenster17->work_ini(&nextScreen, &useNavi); + else + busy=myFenster17->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==18) + { + if (chain_stepIni) + busy=myFenster18->work_ini(&nextScreen, &useNavi); + else + busy=myFenster18->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==19) + { + if (chain_stepIni) + busy=myFenster19->work_ini(&nextScreen, &useNavi); + else + busy=myFenster19->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==20) + { + if (chain_stepIni) + busy=myFenster20->work_ini(&nextScreen, &useNavi); + else + busy=myFenster20->working(&nextScreen, &useNavi); + } else +/* + if (chainCurrentStep==21) + { + if (chain_stepIni) + busy=myFenster21->work_ini(&nextScreen, &useNavi); + else + busy=myFenster21->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==22) + { + if (chain_stepIni) + busy=myFenster22->work_ini(&nextScreen, &useNavi); + else + busy=myFenster22->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==23) + { + if (chain_stepIni) + busy=myFenster23->work_ini(&nextScreen, &useNavi); + else + busy=myFenster23->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==24) + { + if (chain_stepIni) + busy=myFenster24->work_ini(&nextScreen, &useNavi); + else + busy=myFenster24->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==25) + { + if (chain_stepIni) + busy=myFenster25->work_ini(&nextScreen, &useNavi); + else + busy=myFenster25->working(&nextScreen, &useNavi); + } else + + if (chainCurrentStep==26) + { + if (chain_stepIni) + busy=myFenster26->work_ini(&nextScreen, &useNavi); + else + busy=myFenster26->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==27) + { + if (chain_stepIni) + busy=myFenster27->work_ini(&nextScreen, &useNavi); + else + busy=myFenster27->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==28) + { + if (chain_stepIni) + busy=myFenster28->work_ini(&nextScreen, &useNavi); + else + busy=myFenster28->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==29) + { + if (chain_stepIni) + busy=myFenster29->work_ini(&nextScreen, &useNavi); + else + busy=myFenster29->working(&nextScreen, &useNavi); + } else + if (chainCurrentStep==30) + { + if (chain_stepIni) + busy=myFenster30->work_ini(&nextScreen, &useNavi); + else + busy=myFenster30->working(&nextScreen, &useNavi); + } else +*/ + { + // error undefined step + qDebug()<<"error main chain control, wrong step ("<0) + { + // call next chain step + //qDebug()<<"chain control: new step selected: "<< nextScreen; + + chainNextStep=nextScreen; + } + if (useNavi>0) + { + //qDebug()<<"chain control: navi buttons "<< useNavi; + enableNaviButtons(useNavi); + } + + if (busy>0) + { + // reset time-out + timerVendingTimeout->start(); + + + } + + +} + + + +void MainWindow::vendingTimeout(void) +{ + // there was no user operation for 30s so return to start screen +// uint16_t nextScreen=WCS_STARTSCREEN; +// chainNextStep=nextScreen; erstmal stilllegen, stört bei IBN + //qDebug()<<"chain control: vending TO"; + timerVendingTimeout->stop(); +} + + + diff --git a/mainwindow.h b/mainwindow.h new file mode 100755 index 0000000..c016b7d --- /dev/null +++ b/mainwindow.h @@ -0,0 +1,160 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "plugin.h" + + +//#include "stepList.h" // define all working chain steps here +#include "win01_com.h" +#include "win02_home.h" +#include "win03_time.h" +#include "win04_stat.h" +#include "win05_doors.h" +#include "win06_prn.h" +#include "win07_coin.h" +#include "win08_mif.h" +#include "win09_gsm.h" +#include "win10_pay.h" +#include "win11_abr.h" +#include "win12_BL.h" +#include "win13_json.h" +#include "win14_mw.h" +#include "win15_bna.h" +#include "win16.h" +#include "win17.h" +#include "win18.h" +#include "win19.h" +#include "win20.h" +//#include "win21.h" +//#include "win22.h" +//#include "win23.h" + +//#include "lib_mifare.h" +//#include "lib_diary.h" +//#include "lib_config.h" + + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + QPushButton *pBback; + QPushButton *pBhome; + QPushButton *pBforward; + QGroupBox *bigGroupbox; +// QVBoxLayout *bigLayout; + QHBoxLayout *bigLayout; + QTimer *timerChainCtrl; + QTimer *timerVendingTimeout; + + QGroupBox *frame01; + QGroupBox *frame02; + QGroupBox *frame03; + QGroupBox *frame04; + QGroupBox *frame05; + QGroupBox *frame06; + QGroupBox *frame07; + QGroupBox *frame08; + QGroupBox *frame09; + QGroupBox *frame10; + QGroupBox *frame11; + QGroupBox *frame12; + QGroupBox *frame13; + QGroupBox *frame14; + QGroupBox *frame15; + QGroupBox *frame16; + QGroupBox *frame17; + QGroupBox *frame18; + QGroupBox *frame19; + QGroupBox *frame20; + QGroupBox *frame21; + QGroupBox *frame22; + QGroupBox *frame23; + QGroupBox *frame24; + QGroupBox *frame25; + QGroupBox *frame26; + QGroupBox *frame27; + QGroupBox *frame28; + QGroupBox *frame29; + QGroupBox *frame30; + + //T_winComPort *myFenster01; + T_win02 *myFenster02; + T_win03 *myFenster03; + T_win04 *myFenster04; + T_win05 *myFenster05; + T_win06 *myFenster06; + T_win07 *myFenster07; + T_win08 *myFenster08; + T_win09 *myFenster09; + T_win10 *myFenster10; + T_win11 *myFenster11; + T_win12 *myFenster12; + T_win13 *myFenster13; + T_win14 *myFenster14; + T_win15 *myFenster15; + T_win16 *myFenster16; + T_win17 *myFenster17; + T_win18 *myFenster18; + T_win19 *myFenster19; + T_win20 *myFenster20; + /* + T_win21 *myFenster21; + T_win22 *myFenster22; + T_win23 *myFenster23; +*/ + + + + void HideAllWindows(); + void switchScreen(uint16_t winNr); + char loadPlugIn(char lade1_entlade2); + QDir plugInDir; + void chainIni(void); + //T_Mifare *mifCard; + //T_lib_diary *diary; + //T_lib_config *conf; + + +public: + hwinf *HWaccess=nullptr; // global pointer to plugin-class + + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +#define BACKBUTTON 1 +#define HOMEBUTTON 2 +#define FORWBUTTON 3 + void enableNaviButtons(uint8_t buttonNr, bool enabled); + void enableNaviButtons(uint8_t switchBitwise); + +private slots: + void chainControl(); + void vendingTimeout(); + +}; + + + + +#endif // MAINWINDOW_H diff --git a/plugin.h b/plugin.h new file mode 100755 index 0000000..aec497c --- /dev/null +++ b/plugin.h @@ -0,0 +1,5 @@ +#ifndef PLUGIN_H +#define PLUGIN_H +#include "interfaces.h" + +#endif diff --git a/stepList.h b/stepList.h new file mode 100755 index 0000000..1e7a5fa --- /dev/null +++ b/stepList.h @@ -0,0 +1,211 @@ +#ifndef STEPLIST_H +#define STEPLIST_H + + +// define all working chain steps +// every FSM-Step get's a frame in MainWindow with the same number and a self-designed GUI +// labels are used for switchScreen( label=nr ); +// numbers are important: e.g. number 3 calls frame3 and frame3 includes subClass "T_fenster03" +// so best solution: label = same name like class (in example: Fenster03). Label is fixed bound to number, never change! + +// numbers are fixed assosiated with the function (e.g. ComPort), can't be changed. +// but screen order can be called in step chain randomly + + +// Windownumbers for certain function, never change +#define PAGE_COMPORT 1 +#define PAGE_SERVICEMAIN 2 +#define PAGE_TIMEDATEVERSION 3 +#define PAGE_MACHINESTATUS 4 +#define PAGE_CHECKDOORS 5 +#define PAGE_PRINTER 6 +#define PAGE_COINMECHANIC 7 +#define PAGE_MIFARE 8 +#define PAGE_MODEM 9 +#define PAGE_COINPAYMENT 10 +#define PAGE_VAULTRECORD 11 +#define PAGE_BOOTLOADER 12 +#define PAGE_PROG_JSON 13 +#define PAGE_COINCHANGER 14 +#define PAGE_BILLREADER 15 +#define PAGE_NEXT16 16 +#define PAGE_NEXT17 17 +#define PAGE_NEXT18 18 +#define PAGE_NEXT19 19 +#define PAGE_NEXT20 20 + +// fix: customize: +//#define WCS_STARTSCREEN PAGE_COMPORT // if APservice uses masterLib +#define WCS_STARTSCREEN PAGE_SERVICEMAIN // if APservice uses slaveLib + +// PAGE_COMPORT: +#define WCS_WIN01BAK PAGE_COMPORT +#define WCS_WIN01MID PAGE_SERVICEMAIN +#define WCS_WIN01FWD PAGE_SERVICEMAIN + +// PAGE_SERVICEMAIN: +#define WCS_WIN02BAK PAGE_COMPORT +#define WCS_WIN02MID PAGE_SERVICEMAIN +#define WCS_WIN02FWD PAGE_TIMEDATEVERSION + +// PAGE_TIMEDATEVERSION: +#define WCS_WIN03BAK PAGE_SERVICEMAIN +#define WCS_WIN03MID PAGE_SERVICEMAIN +#define WCS_WIN03FWD PAGE_MACHINESTATUS + +// PAGE_MACHINESTATUS: +#define WCS_WIN04BAK PAGE_TIMEDATEVERSION +#define WCS_WIN04MID PAGE_SERVICEMAIN +#define WCS_WIN04FWD PAGE_CHECKDOORS + + +// PAGE_CHECKDOORS: +#define WCS_WIN05BAK PAGE_MACHINESTATUS +#define WCS_WIN05MID PAGE_SERVICEMAIN +#define WCS_WIN05FWD PAGE_COINMECHANIC + +// PAGE_COINMECHANIC: +#define WCS_WIN07BAK PAGE_CHECKDOORS +#define WCS_WIN07MID PAGE_SERVICEMAIN +#define WCS_WIN07FWD PAGE_COINPAYMENT + +// PAGE_COINPAYMENT: +#define WCS_WIN10BAK PAGE_COINMECHANIC +#define WCS_WIN10MID PAGE_SERVICEMAIN +#define WCS_WIN10FWD PAGE_COINCHANGER + +// PAGE_COINCHANGER: +#define WCS_WIN14BAK PAGE_COINPAYMENT +#define WCS_WIN14MID PAGE_SERVICEMAIN +#define WCS_WIN14FWD PAGE_BILLREADER + + +// PAGE_BILLREADER: +#define WCS_WIN15BAK PAGE_COINCHANGER +#define WCS_WIN15MID PAGE_SERVICEMAIN +#define WCS_WIN15FWD PAGE_PRINTER + +// PAGE_PRINTER: +#define WCS_WIN06BAK PAGE_BILLREADER +#define WCS_WIN06MID PAGE_SERVICEMAIN +#define WCS_WIN06FWD PAGE_MIFARE + +// PAGE_MIFARE: +#define WCS_WIN08BAK PAGE_PRINTER +#define WCS_WIN08MID PAGE_SERVICEMAIN +#define WCS_WIN08FWD PAGE_MODEM + +// PAGE_MODEM: +#define WCS_WIN09BAK PAGE_MIFARE +#define WCS_WIN09MID PAGE_SERVICEMAIN +#define WCS_WIN09FWD PAGE_VAULTRECORD + + +// PAGE_VAULTRECORD: +#define WCS_WIN11BAK PAGE_MODEM +#define WCS_WIN11MID PAGE_SERVICEMAIN +#define WCS_WIN11FWD PAGE_PROG_JSON + +// PAGE_PROG_JSON: +#define WCS_WIN13BAK PAGE_VAULTRECORD +#define WCS_WIN13MID PAGE_SERVICEMAIN +#define WCS_WIN13FWD PAGE_BOOTLOADER + +// PAGE_BOOTLOADER: +#define WCS_WIN12BAK PAGE_PROG_JSON +#define WCS_WIN12MID PAGE_SERVICEMAIN +#define WCS_WIN12FWD PAGE_NEXT16 + + +// PAGE_NEXT16 +#define WCS_WIN16BAK PAGE_BOOTLOADER +#define WCS_WIN16MID PAGE_SERVICEMAIN +#define WCS_WIN16FWD PAGE_NEXT17 + +// PAGE_NEXT17 +#define WCS_WIN17BAK PAGE_NEXT16 +#define WCS_WIN17MID PAGE_SERVICEMAIN +#define WCS_WIN17FWD PAGE_NEXT18 + +// PAGE_NEXT18 +#define WCS_WIN18BAK PAGE_NEXT17 +#define WCS_WIN18MID PAGE_SERVICEMAIN +#define WCS_WIN18FWD PAGE_NEXT19 + +// PAGE_NEXT19 +#define WCS_WIN19BAK PAGE_NEXT18 +#define WCS_WIN19MID PAGE_SERVICEMAIN +#define WCS_WIN19FWD PAGE_NEXT20 + +// PAGE_NEXT20 +#define WCS_WIN20BAK PAGE_NEXT19 +#define WCS_WIN20MID PAGE_SERVICEMAIN +#define WCS_WIN20FWD PAGE_SERVICEMAIN + +// just for Template +#define WCS_WIN99BAK PAGE_SERVICEMAIN +#define WCS_WIN99MID PAGE_SERVICEMAIN +#define WCS_WIN99FWD PAGE_SERVICEMAIN + + + +#define WIN02_LABEL_SHORT01 " Status" +#define WCS_WIN02SHORT01 PAGE_MACHINESTATUS +#define WIN02_LABEL_SHORT02 " Doors " +#define WCS_WIN02SHORT02 PAGE_CHECKDOORS +#define WIN02_LABEL_SHORT03 "Coin mech" +#define WCS_WIN02SHORT03 PAGE_COINMECHANIC +#define WIN02_LABEL_SHORT04 "Payment" +#define WCS_WIN02SHORT04 PAGE_COINPAYMENT + +#define WIN02_LABEL_SHORT05 "Changer" +#define WCS_WIN02SHORT05 PAGE_COINCHANGER +#define WIN02_LABEL_SHORT06 " Bill " +#define WCS_WIN02SHORT06 PAGE_BILLREADER +#define WIN02_LABEL_SHORT07 "Printer" +#define WCS_WIN02SHORT07 PAGE_PRINTER + +#define WIN02_LABEL_SHORT08 "Accounting" +#define WCS_WIN02SHORT08 PAGE_VAULTRECORD +#define WIN02_LABEL_SHORT09 "Program" +#define WCS_WIN02SHORT09 PAGE_PROG_JSON +#define WIN02_LABEL_SHORT10 " " +#define WCS_WIN02SHORT10 PAGE_SERVICEMAIN + + + + + + + +// set needed navigation buttons, use | to combine more then one: +#define SWITCH_NEXT_ON 1 +#define SWITCH_NEXT_OFF 2 +#define SWITCH_HOME_ON 4 +#define SWITCH_HOME_OFF 8 +#define SWITCH_BACK_ON 16 +#define SWITCH_BACK_OFF 32 +// example: *useNavi=SWITCH_BACK_ON; // change only this one, or set all: +// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON; + + + +// some defines for Widget design: + +#define TS_VALUEBOX_FRAMESTYLE 0x0032 +#define TS_VALUEBOX_LINEWIDTH 3 + +//genDatPort->setFrameStyle(QFrame::Panel | QFrame::Sunken ); funktioniert aber gibt unverständliche Warnung +// QFrame::Panel = 0x0002 QFrame::Sunken=0x0030 +//genDatPort->setFrameStyle(0x0032); // funktioniert und gibt keine Warnung +//genDatPort->setFrameStyle(TS_VALUEBOX_FRAMESTYLE); // funktioniert und gibt keine Warnung + +#define TS_LED_FRAMESTYLE 0x0031 +// QFrame::Box | QFrame::Sunken + + + + + + +#endif // STEPLIST_H diff --git a/subwindows.cpp b/subwindows.cpp new file mode 100755 index 0000000..a78317d --- /dev/null +++ b/subwindows.cpp @@ -0,0 +1,267 @@ +#include "subwindows.h" + + + + + + + + + +/* + +// %%%%%%%%%%%%%%%%%%%% TabChanger + +T_fenster12::T_fenster12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Coin Changer"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster12::updateGui(void) +{ + +} + + +// %%%%%%%%%%%%%%%%%%%% TabBill +T_fenster13::T_fenster13(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Bank note acceptor"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster13::updateGui(void) +{ + +} + +T_fenster14::T_fenster14(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 14"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster14::updateGui(void) +{ + +} + +T_fenster15::T_fenster15(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 15"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster15::updateGui(void) +{ + +} + +T_fenster16::T_fenster16(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 16"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster16::updateGui(void) +{ + +} + +T_fenster17::T_fenster17(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 17"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster17::updateGui(void) +{ + +} + +T_fenster18::T_fenster18(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 18"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster18::updateGui(void) +{ + +} + +T_fenster19::T_fenster19(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 19"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster19::updateGui(void) +{ + +} + +T_fenster20::T_fenster20(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 20"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster20::updateGui(void) +{ + +} + + + +T_fenster21::T_fenster21(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 21"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster21::updateGui(void) +{ + +} + +T_fenster22::T_fenster22(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 22"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster22::updateGui(void) +{ + +} + +T_fenster23::T_fenster23(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 23"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster23::updateGui(void) +{ + +} + +T_fenster24::T_fenster24(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 24"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster24::updateGui(void) +{ + +} + +T_fenster25::T_fenster25(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 25"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster25::updateGui(void) +{ + +} + +T_fenster26::T_fenster26(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 26"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster26::updateGui(void) +{ + +} + +T_fenster27::T_fenster27(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 27"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster27::updateGui(void) +{ + +} + +T_fenster28::T_fenster28(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 28"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster28::updateGui(void) +{ + +} + +T_fenster29::T_fenster29(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 29"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster29::updateGui(void) +{ + +} + +T_fenster30::T_fenster30(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + QGridLayout *myLayout = new QGridLayout(); + QLabel *Lab1 = new QLabel("Dialog 30"); + myLayout->addWidget(Lab1,1,1); + setLayout(myLayout); +} + +void T_fenster30::updateGui(void) +{ + +} + +*/ + diff --git a/subwindows.h b/subwindows.h new file mode 100755 index 0000000..061ca8c --- /dev/null +++ b/subwindows.h @@ -0,0 +1,161 @@ +#ifndef SUBWINDOWS_H +#define SUBWINDOWS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" // define all working chain steps here +#include "../plugins/interfaces.h" + + + +class T_fenster12 : public QWidget // TabChanger +{ + public: + explicit T_fenster12(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster13 : public QWidget // TabBill +{ + public: + explicit T_fenster13(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster14 : public QWidget +{ + public: + explicit T_fenster14(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster15 : public QWidget +{ + public: + explicit T_fenster15(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster16 : public QWidget +{ + public: + explicit T_fenster16(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster17 : public QWidget +{ + public: + explicit T_fenster17(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster18 : public QWidget +{ + public: + explicit T_fenster18(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster19 : public QWidget +{ + public: + explicit T_fenster19(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster20 : public QWidget +{ + public: + explicit T_fenster20(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; + +class T_fenster21 : public QWidget +{ + public: + explicit T_fenster21(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster22 : public QWidget +{ + public: + explicit T_fenster22(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster23 : public QWidget +{ + public: + explicit T_fenster23(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster24 : public QWidget +{ + public: + explicit T_fenster24(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster25 : public QWidget +{ + public: + explicit T_fenster25(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster26 : public QWidget +{ + public: + explicit T_fenster26(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster27 : public QWidget +{ + public: + explicit T_fenster27(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster28 : public QWidget +{ + public: + explicit T_fenster28(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster29 : public QWidget +{ + public: + explicit T_fenster29(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; +class T_fenster30 : public QWidget +{ + public: + explicit T_fenster30(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + void updateGui(void); + +}; + +#endif diff --git a/tslib.cpp b/tslib.cpp new file mode 100755 index 0000000..d70c1fc --- /dev/null +++ b/tslib.cpp @@ -0,0 +1,1016 @@ +#include "tslib.h" +#include + + +//tslib::tslib() +//{ + + +//} + + +/* +uint16_t tslib::uchar2uint(uint8_t Highbyte, uint8_t Lowbyte) +{ + uint16_t uitmp; + uitmp=0; + uitmp |= uint8_t(Highbyte); + uitmp<<=8; + uitmp |= uint8_t(Lowbyte); + return uitmp; +} + +uint8_t tslib::uint2uchar(uint16_t uival, bool getHighB) +{ + // getHighB: low=GetLowByte + uint16_t uitmp=uival; + if (getHighB==0) + return uint8_t(uitmp); + uitmp>>=8; + return uint8_t(uitmp); + +}*/ + +uint16_t uchar2uint(char Highbyte, char Lowbyte) +{ + uint16_t uitmp; + uitmp=0; + uitmp |= uint8_t(Highbyte); + uitmp<<=8; + uitmp |= uint8_t(Lowbyte); + return uitmp; +} + +uint16_t uchar2uint(uint8_t Highbyte, uint8_t Lowbyte) +{ + uint16_t uitmp; + uitmp=0; + uitmp |= uint8_t(Highbyte); + uitmp<<=8; + uitmp |= uint8_t(Lowbyte); + return uitmp; +} + +uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t Lowbyte) +{ + uint32_t ultmp=0; + + ultmp |= uint8_t(Highbyte); + ultmp<<=8; + ultmp |= uint8_t(MHbyte); + ultmp<<=8; + ultmp |= uint8_t(MLbyte); + ultmp<<=8; + ultmp |= uint8_t(Lowbyte); + return ultmp; +} + +uint8_t uint2uchar(uint16_t uival, bool getHighB) +{ + // getHighB: low=GetLowByte + uint16_t uitmp=uival; + if (getHighB==0) + return uint8_t(uitmp); + uitmp>>=8; + return uint8_t(uitmp); + +} + + +void delay(uint16_t MilliSec) +{ + QThread::msleep(uint32_t(MilliSec)); +} + + +void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf) +{ + // Zahlenwerte in String wandeln, 12/24h-Format // 12byte für buf! + uint8_t usa; + uint16_t jj; + uint8_t hh, mm, ss, with_sec; + + // buf[0]= ganz linkes Zeichen + hh=hours; + mm=minutes; + ss=seconds; + + // 15.10.12, Plausibilitätsprüfung -------------------------------------------------- + if (hh>23) hh=0; + if (mm>59) mm=0; + if (ss>59) ss=0; + + with_sec=ShowSec; + for (jj=0; jj<12; jj++) buf[jj]=0; + usa = System12h; // 1:12h 0:24h + + // Stunden: + if (usa) + { + // 12h System + if (hh==0 || hh==12) + { + // 12AM (Mitternacht) oder 12PM (Mittag) + buf[0]=0x31; + buf[1]=0x32; + } else + if (hh<12) + { + // 1..11AM + buf[0]=hh/10+0x30; + buf[1]=hh%10+0x30; + } else + { + //13:00 bis 23Uhr + buf[0]=(hh-12)/10+0x30; + buf[1]=(hh-12)%10+0x30; + } + } else + { + // 24h System + buf[0]=hh/10+0x30; + buf[1]=hh%10+0x30; + } + + // Minuten: + buf[2]=':'; + //buf[2]='_'; // : not allowed in JsonFormat + buf[3]=mm/10+0x30; + buf[4]=mm%10+0x30; + + jj=5; + if (with_sec) + { + buf[jj++]=':'; + //buf[jj++]='_'; // : not allowed in JsonFormat + buf[jj++]=ss/10+0x30; + buf[jj++]=ss%10+0x30; + } + if (usa) + { + buf[jj++]=' '; + if (hh<12) + buf[jj++]='A'; + else + buf[jj++]='P'; + buf[jj++]='M'; + } + +} + +// ------------------- ******************************************************************************** + +void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf) +{ + // generate date as ascii string from integers day/month/year + // yearhigh: 10..29, in europe always 20 (not in arabia!) comes as hex number, e.g. 0x20 + // format= 0: dd.mm.yyyy (deutsch) + // 1: mm.dd.yyyy (amerika) + // 2: yyyy.mm.dd (Iran, Dubai) + // 3: dd.yyyy.mm + // 4: mm.yyyy.dd + // 5: yyyy.dd.mm + // sep: 0: use . as seperator 1: use / as seperator + // return String in *buf // 11byte für buf! + + + uint8_t tag, mon, jahr, d10, d1, m10, m1, y1000, y100, y10, y1; + uint8_t slash; + + + y100= (yearhigh & 0x0F)+0x30; + y1000=((yearhigh & 0xF0)>>4)+0x30; +// if (yearhigh>=20) +// { +// y1000='2'; +// y100=28+yearhigh; // '0' + (yearhigh-20) +// } else +// if (yearhigh<20) +// { +// y1000='1'; +// y100=38-yearhigh; // '9' - (19-yearhigh) +// } + + tag=day; + mon=month; + jahr=yearlow; + + if (mon>12 || mon==0) mon=1; // 23.10.12 + if (tag>31 || tag==0) tag=1; + if (jahr>50 || jahr<11) jahr=1; + + if (sep==0) + slash='.'; // slash==0 + else if (sep==1) + slash='/'; + else + if (sep>=0x20) + slash=sep; + else + slash='.'; + + d10 =tag/10; + d1 =tag%10; + m10 =mon/10; + m1 =mon%10; + y10 =jahr/10; + y1 =jahr%10; + + d10 +=0x30; // in Asccii wandeln + d1 +=0x30; + m10 +=0x30; + m1 +=0x30; + y10 +=0x30; + y1 +=0x30; + + switch (format) + { + // 0: dd.mm.yyyy + case 0: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=m10; buf[4]=m1; buf[5]=slash; + buf[6]=y1000; buf[7]=y100; buf[8]=y10; buf[9]=y1; break; + + // 1: mm.dd.yyyy + case 1: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=d10; buf[4]=d1; buf[5]=slash; + buf[6]=y1000; buf[7]=y100; buf[8]=y10; buf[9]=y1; break; + + // 2: yyyy.mm.dd + case 2: buf[0]=y1000; buf[1]=y100; buf[2]=y10; buf[3]=y1; buf[4]=slash; buf[5]=m10; + buf[6]=m1; buf[7]=slash; buf[8]=d10; buf[9]=d1; break; + + // 3: dd.yyyy.mm + case 3: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=y1000; buf[4]=y100; + buf[5]=y10; buf[6]=y1; buf[7]=slash; buf[8]=m10; buf[9]=m1; break; + + // 4: mm.yyyy.dd + case 4: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=y1000; buf[4]=y100; + buf[5]=y10; buf[6]=y1; buf[7]=slash; buf[8]=d10; buf[9]=d1; break; + + // 5: yyyy.dd.mm + case 5: buf[0]=y1000; buf[1]=y100; buf[2]=y10; buf[3]=y1; buf[4]=slash; buf[5]=d10; + buf[6]=d1; buf[7]=slash; buf[8]=m10; buf[9]=m1; break; + + } + buf[10]=0; + + +} + +// ------------------- ******************************************************************************** + +void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf) +{ + // generate date as ascii string from integers day/month/year + // format= 0: dd.mm.yy (deutsch) + // 1: mm.dd.yy (amerika) + // 2: yy.mm.dd (Iran, Dubai) + // 3: dd.yy.mm + // 4: mm.yy.dd + // 5: yy.dd.mm + // sep: 0: use . as seperator 1: use / as seperator + // return String in *buf // 11byte für buf! + + + uint8_t tag, mon, jahr, d10, d1, m10, m1, y10, y1; + uint8_t slash; + + + tag=day; + mon=month; + jahr=yearlow; + + if (mon>12 || mon==0) mon=1; // 23.10.12 + if (tag>31 || tag==0) tag=1; + if (jahr>50 || jahr<11) jahr=1; + + if (sep==0) + slash='.'; // slash==0 + else if (sep==1) + slash='/'; + else if (sep>=0x20) + slash=sep; + else + slash='.'; + + d10 =tag/10; + d1 =tag%10; + m10 =mon/10; + m1 =mon%10; + y10 =jahr/10; + y1 =jahr%10; + + d10 +=0x30; // in Asccii wandeln + d1 +=0x30; + m10 +=0x30; + m1 +=0x30; + y10 +=0x30; + y1 +=0x30; + + switch (format) + { + // 0: dd.mm.yyyy + case 0: buf[0]=d10; buf[1]=d1; buf[2]=slash; buf[3]=m10; buf[4]=m1; buf[5]=slash; + buf[6]=y10; buf[7]=y1; break; + + // 1: mm.dd.yyyy + case 1: buf[0]=m10; buf[1]=m1; buf[2]=slash; buf[3]=d10; buf[4]=d1; buf[5]=slash; + buf[6]=y10; buf[7]=y1; break; + + // 2: yyyy.mm.dd + case 2: buf[0]=y10; buf[1]=y1; buf[2]=slash; buf[3]=m10; + buf[4]=m1; buf[5]=slash; buf[6]=d10; buf[7]=d1; break; + + // 3: dd.yyyy.mm + case 3: buf[0]=d10; buf[1]=d1; buf[2]=slash; + buf[3]=y10; buf[4]=y1; buf[5]=slash; buf[6]=m10; buf[7]=m1; break; + + // 4: mm.yyyy.dd + case 4: buf[0]=m10; buf[1]=m1; buf[2]=slash; + buf[3]=y10; buf[4]=y1; buf[5]=slash; buf[6]=d10; buf[7]=d1; break; + + // 5: yyyy.dd.mm + case 5: buf[0]=y10; buf[1]=y1; buf[2]=slash; buf[3]=d10; + buf[4]=d1; buf[5]=slash; buf[6]=m10; buf[7]=m1; break; + + } + buf[8]=0; + + +} + +uint16_t tslib_strlen(char *buf) +{ + uint16_t nn; + + for (nn=0; nn<0xFFF0; nn++) + if (buf[nn]==0) + return nn; + return 0; +} + +void tslib_strclr(char *buf, char clrsign, uint16_t len) +{ + uint16_t nn; + + for (nn=0; nn=0x30 && sign<=0x39) + return true; + return false; +} + +bool tslib_isHexAsciiNumber(char sign) +{ + if (sign>=0x30 && sign<=0x39) + return true; + if (sign>=0x61 && sign<=0x66) // a...f + return true; + if (sign>=0x41 && sign<=0x46) // A...F + return true; + return false; +} + +int tslib_getMinimum(int val1, int val2) +{ + if (val1maxArayLen) LL=maxArayLen; + for (ii=0; ii> (7 - nn)) & 0x01); + if (B15H) + { + crc ^= 0x1021; + } + } + } + + for (nn = 0; nn < 16; nn++) + { + B15H = 0; + if(crc & 0x8000) + B15H = 1; + crc = (crc << 1) | 0x00; + if (B15H) + { + crc ^= 0x1021; + } + } + return crc; + +} + +static uint8_t LastBLcmd; // stored the last sent cmd in order to analys response + // cmd echo'ed: error cmd or'ed with 0x80: OK + +uint8_t tslib_prepareDC_BLcmd(uint8_t Cmd, uint8_t SendDataLength, uint8_t *sendData, uint8_t *outBuf) +{ + // make BL protocol, retval = outbuf length (5...133) + // bring data in correct form: start always with 0x02 finish with 0x03 and append checksum + // 0x02 Cmd < ...sendData ..> CRC CRC 0x03 + // Data length = 0...64 + // special conversion: if data contain 2 or 3 (STX, ETX) then write two bytes: 0x1B (=ESC) and data|0x80 + // so maxlength = 5 + 2 x 64 (if all data are 2 or 3) without 2,3: maxlength = 5 + 64 + + uint8_t myBuf[140], pp=0, nn, uctmp, currLen=0; + uint16_t calcCrc; + + tslib_strclr(myBuf, 0, 140); + + myBuf[pp++]=2; // STX + myBuf[pp++]=Cmd; + LastBLcmd=Cmd; + + // append data: + for (nn=0; nn>8) & 0x00FF); + myBuf[pp++]=3; + currLen=pp; + + return currLen; +} + +// some special commands (right out of bootloader manual) +uint8_t tslib_readBLversion(uint8_t *sendData) +{ + // minimum size of sendData-buffer: 5byte retval: length + uint8_t myBuf[2]; + tslib_strclr(myBuf, 0, 2); + return tslib_prepareDC_BLcmd(0x11, 0, myBuf, sendData); +} + +uint8_t tslib_readFWversion(uint8_t *sendData) +{ + // minimum size of sendData-buffer: 5byte retval: length + uint8_t myBuf[2]; + tslib_strclr(myBuf, 0, 2); + return tslib_prepareDC_BLcmd(0x12, 0, myBuf, sendData); +} + +uint8_t tslib_exitBL(uint8_t *sendData) +{ + // minimum size of sendData-buffer: 5byte retval: length + uint8_t myBuf[2]; + tslib_strclr(myBuf, 0, 2); + return tslib_prepareDC_BLcmd(0x18, 0, myBuf, sendData); +} + +uint8_t tslib_sendFlashStartAddr2BL(uint32_t startAddr, uint8_t *sendData) +{ + // minimum size of sendData-buffer: 13byte retval: length (9...13) + uint8_t myBuf[2]; + tslib_strclr(myBuf, 0, 2); + return tslib_prepareDC_BLcmd(0x11, 0, myBuf, sendData); +} +*/ + +// ----------------------------------------------------------------------------------------------- + +bool tslib_plausiChkTime(uint8_t hour, uint8_t min, uint8_t sec ) +{ + // retval: true: time is OK + bool ret=true; + + if (hour>23) ret=false; + if (min>59) ret=false; + if (sec>59) ret=false; + + return ret; +} + +// ----------------------------------------------------------------------------------------------- + +bool tslib_plausiChkDate(uint8_t year, uint8_t month, uint8_t dom ) +{ + // retval: true: time is OK + bool ret=true; + + if (year<23) ret=false; + if (month<1 || month>12) ret=false; + if (dom<1 || dom>31) ret=false; + + return ret; +} + +// ----------------------------------------------------------------------------------------------- + +UCHAR swl_LengthCurrentMonth(UCHAR month, UCHAR year) +{ + // return nr of days for this month, respecting leap years + if (month==2) + { + // Sonderfall Februar: + if (year%4) + return 28; // Rest wenn durch 4 geteilt wird + else + return 29; // durch 4 teilbar ohne Rest + } else + if (month==1 || month==3 || month==5 || month==7 || + month==8 || month==10 || month==12) + { + return 31; + } else + return 30; + +} + +// ----------------------------------------------------------------------------------------------- + +UINT swl_GetDaysOfaCompleteYear(UCHAR year) +{ + // year: 0=2000 4=2004 99=2099 + // retval: 365 or 366 (leap year) + UCHAR jahr; + + jahr=year; + if (jahr & 3) // wenn bits 0 und 1 low sind dann Vielfaches von 4 + { + // dann kein Schaltjahr + return(365); + } else + { + // Schaltjahr + return(366); + } + +} + +// ----------------------------------------------------------------------------------------------- + +UINT swl_GetDaysOfYear(UCHAR year, UCHAR month, UCHAR day) +{ + // number of days of momentary year from 1. Jan until + // (inclusive) given date with respect to leap years + // year: 0..99 month=1..12 day=1..31 + + int summe=0; + UCHAR mo, ta, yy, mm, uctmp; + + yy=year; + mo=month; + ta=day; + if (mo==0 || mo>12 || ta==0 || ta>31 || yy>99) + return(0); // Fehler + + // Beispiel: mo=5: summiere Tage des Jan, Feb, März und April + // der Mai ist noch nicht komplett abgelaufen! + mm=1; // start mit Januar + while (mo>1) + { + uctmp=swl_LengthCurrentMonth(mm,yy); + summe += (int)uctmp; + mo--; mm++; + } + + summe+=ta; + return(summe); +} + +// ----------------------------------------------------------------------------------------------- + +unsigned long swl_getNrOfDaysSince2000Jan1(UCHAR thisYear, UCHAR thisMonth, UCHAR thisDay) +{ + // till today + ULONG ultmp=0; + UCHAR jj; + + for (jj=0; jj +#include + +typedef uint8_t UCHAR; +typedef uint16_t UINT; +typedef uint32_t ULONG; + +#define LOWBYTE false +#define HIGHBYTE true + +uint16_t uchar2uint(char Highbyte, char Lowbyte); +uint16_t uchar2uint(uint8_t Highbyte, uint8_t Lowbyte); +uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t Lowbyte); + +uint8_t uint2uchar(uint16_t uival, bool getHighB); + + +void delay(uint16_t MilliSec); + +#define MITSEK 1 +#define OHNESEK 0 +#define HourSys12h 1 +#define HourSys24h 0 + +void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf); + // generate time as ascii string from integers hours/minutes/seconds + // System12h=0: 24h system =1: 12h System + // ShowSec=0: String has 5 digits (hh:mm) =1: String has 8 digits (hh:mm:ss) + // return String in *buf // 12 byte für buf! + +#define DateFormatDeutsch 0 +#define DateFormatAmerica 1 +#define UsePointSeperator 0 +#define UseSlashSeperator 1 + + +void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf); + // generate date as ascii string from integers day/month/year + // yearhigh in europe always 20 (not in arabia) + // format= 0: dd.mm.yyyy (deutsch) + // 1: mm.dd.yyyy (amerika) + // 2: yyyy.mm.dd (Iran, Dubai) + // 3: dd.yyyy.mm + // 4: mm.yyyy.dd + // 5: yyyy.dd.mm + // sep: 0: use . as seperator 1: use / as seperator + // return String in *buf // 11 byte für buf! + + +void GetShortDateString(uint8_t day, uint8_t month, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf); + // generate date as ascii string from integers day/month/year + // format= 0: dd.mm.yy (deutsch) + // 1: mm.dd.yy (amerika) + // 2: yy.mm.dd (Iran, Dubai) + // 3: dd.yy.mm + // 4: mm.yy.dd + // 5: yy.dd.mm + // sep: 0: use . as seperator 1: use / as seperator + // return String in *buf // 11byte für buf! + + +uint16_t tslib_strlen(char *buf); + +void tslib_strclr(char *buf, char clrsign, uint16_t len); +void tslib_strclr(uint8_t *buf, char clrsign, uint16_t len); + +void tslib_strcpy(char *srcbuf, char *destbuf, uint16_t len); +void tslib_strcpy(char *srcbuf, uint8_t *destbuf, uint16_t len); +void tslib_strcpy(uint8_t *srcbuf, uint8_t *destbuf, uint16_t len); + + +uint16_t tslib_calcCrcCcitt(uint16_t BufLength, uint8_t *buf); + +bool tslib_isDecAsciiNumber(char sign); +bool tslib_isHexAsciiNumber(char sign); + + +int tslib_getMinimum(int val1, int val2); + +void tslib_text2array(QByteArray text, char *aray, uint16_t maxArayLen); + // usage: tslib_text2array("my text", ctmp, 50); + +bool tslib_strComp(uint8_t *buf, char *compStr); + +bool tslib_plausiChkTime(uint8_t hour, uint8_t min, uint8_t sec ); + // retval: true: time is OK + +bool tslib_plausiChkDate(uint8_t year, uint8_t month, uint8_t dom ); + // retval: true: time is OK + +UCHAR swl_LengthCurrentMonth(UCHAR month, UCHAR year); + // return nr of days for this month, respecting leap years + +UINT swl_GetDaysOfaCompleteYear(UCHAR year); + // year: 0=2000 4=2004 99=2099 + // retval: 365 or 366 (leap year) + +UINT swl_GetDaysOfYear(UCHAR year, UCHAR month, UCHAR day); + // number of days of momentary year from 1. Jan until + // (inclusive) given date with respect to leap years + // year: 0..99 month=1..12 day=1..31 + +unsigned long swl_getNrOfDaysSince2000Jan1(UCHAR thisYear, UCHAR thisMonth, UCHAR thisDay); + // till today + +unsigned long swl_getNrOfHoursSince_Midnight2000Jan1(UCHAR thisYear, UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow); + +unsigned long swl_getNrOfMinutesSince_Midnight2000Jan1(UCHAR thisYear, \ + UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow, UCHAR minuteNow); + +unsigned long swl_getNrOfSecondsSince_Midnight2000Jan1(UCHAR thisYear, \ + UCHAR thisMonth, UCHAR thisDay, UCHAR hoursNow, UCHAR minuteNow, UCHAR secondNow); + +char swl_isLeap(UCHAR year); + +UCHAR swl_getNextLeapYear(UCHAR year); + +UCHAR swl_getLastLeapYear(UCHAR year); + +UCHAR swl_hoursOfThisWeek(UCHAR dow, UCHAR hoursNow); + // always calculate from monday 0 o'clock + // dow: 1=monday 7=sunday + +UINT swl_minutesOfThisWeek(UCHAR dow, UCHAR hoursNow, UCHAR minutesNow); + // always calculate from monday 0 o'clock + // dow: 1=monday 7=sunday + +UINT swl_hoursOfThisMonth(UCHAR thisDay, UCHAR hoursNow); + +UINT swl_minutesOfThisMonth(UCHAR thisDay, UCHAR hoursNow, UCHAR minutesNow); + +UINT swl_GetHoursOfYear(UCHAR year, UCHAR month, UCHAR day, UCHAR hourNow); + +ULONG swl_GetMinutesOfYear(UCHAR year, UCHAR month, UCHAR day, UCHAR hourNow, UCHAR minutesNow); + +UCHAR swl_weekday(UCHAR year, UCHAR month, UCHAR dayOfMonth); + // return 1...7 = monday...sunday, starting from 1.1.2000 + +QString swl_int2str(int val); +QString swl_hex2str(double val); + +void swl_text2ui8buf(QString text, uint8_t *outbuf, uint16_t length); + // copy text byte-by-byte to outbuf + +QString swl_ulong2str(uint32_t val); + +QString swl_long2str(long val); + +uint16_t swl_str2uint(QString myIntStr); + +uint32_t swl_str2ulong(QString myIntStr); + +QString swl_labelAndValToStr(QString label, uint32_t val); + +QString swl_8valInaRowToStr(QString label, uint8_t val[8]); + +QString swl_8valInaRowToStr(QString label, uint16_t val[8]); + +QString swl_8intsInaRowToStr(QString label, int val[8]); + +QString swl_centToEuroString(uint32_t amount_in_cent); + +#endif // TSLIB_H + +// qDebug << QDateTime::currentDateTime().toString(Qt::ISODateWithMs) << QByteArray((const char*)dataSendBuf,dataBufLen).toHex(':'); + diff --git a/versionHistory.txt b/versionHistory.txt new file mode 100755 index 0000000..7b996ca --- /dev/null +++ b/versionHistory.txt @@ -0,0 +1,13 @@ +#ifndef VERSIONHISTORY_H +#define VERSIONHISTORY_H + +APservice3.0 bis September2023 fuer DBM, Szeged + + +APservice3.2 12.10.23 + screen Abfolge komplett mit defines aufgebaut, kann jetzt in "stepList.h" veraendert werden + Neuen Screen Muenzwechsler und Banknote + passend zu CashAgent-Plugin: "Atb.Psa1256ptu5.software.HWapi/5.0" + Farben und Schriftgroessen vereinheitlichen (guidefs.h) + +#endif diff --git a/win01_com.cpp b/win01_com.cpp new file mode 100755 index 0000000..46501f5 --- /dev/null +++ b/win01_com.cpp @@ -0,0 +1,6 @@ +#include "win01_com.h" +#include "stepList.h" // define all working chain steps here +#include "datei.h" +#include "globVars.h" + + diff --git a/win01_com.h b/win01_com.h new file mode 100755 index 0000000..c5baaf0 --- /dev/null +++ b/win01_com.h @@ -0,0 +1,5 @@ +#ifndef WINCOMPORT_H +#define WINCOMPORT_H + + +#endif diff --git a/win02_home.cpp b/win02_home.cpp new file mode 100755 index 0000000..ab6f02c --- /dev/null +++ b/win02_home.cpp @@ -0,0 +1,471 @@ +#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())); + + + + + 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); + } + +} + +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_OFF | 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); + } + + 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; +} + diff --git a/win02_home.h b/win02_home.h new file mode 100755 index 0000000..107adc2 --- /dev/null +++ b/win02_home.h @@ -0,0 +1,123 @@ +#ifndef WIN02_HOME_H +#define WIN02_HOME_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include +#include +#include "guidefs.h" +#include "datei.h" +#include "globVars.h" + + +class T_win02 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + void updateGui(void); + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *labMaNu1, *labMaNu2; + QLabel *lab3; + QTimer *myTO; + + QLabel *labState; + QLabel *labLoc1, *labLoc2; + QLabel *labTimeDate; + QLabel *labZone, *labBez; + + QPushButton *pb1; + QPushButton *pb2; + QPushButton *pb3; + QPushButton *pb4; + QPushButton *pb5; + QPushButton *pb6; + QPushButton *pb7; + QPushButton *pb8; + QPushButton *pb9; + QPushButton *pb10; + QPushButton *pb11; + QPushButton *AutSendButton; + + void SysDiag(void); + void sysPowerOnDiag_ISR(void); + uint8_t sub_componentAssessment(void); + uint8_t sys_superviseSystem(void); + uint8_t sys_getSystemErrors(void); + + + QTimer *systemStartUpTimer; + QTimer *systemSupervisionTimer; + int sysStartupStep; + int sysVendingNow; + + QTime *systTime; + QDate *systDate; + + QLabel *labUID; + + + //QLabel *movingTest; + //QString moveTestStr; + QPlainTextEdit *pt_loc; + + +public: + explicit T_win02(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win02(); + +private slots: +// void sysSuper_ISR(void); + + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void ButtonPb1Clicked(void); + void ButtonPb2Clicked(void); + void ButtonPb3Clicked(void); + void ButtonPb4Clicked(void); + void ButtonPb5Clicked(void); + void ButtonPb6Clicked(void); + void ButtonPb7Clicked(void); + void ButtonPb8Clicked(void); + void ButtonPb9Clicked(void); + void ButtonPb10Clicked(void); + void ButtonPb11Clicked(void); + void callAutoSend(void); + +signals: + void quitMyApp(void); + + +}; + +#endif diff --git a/win02cpp b/win02cpp new file mode 100755 index 0000000..cf6df4c --- /dev/null +++ b/win02cpp @@ -0,0 +1,82 @@ +#include "win02.h" + + + + +T_win02::T_win02(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + //setStyleSheet("background-color: yellow"); // geht aber schaut bescheiden aus + this->HWaccess=HWaccess; + + // headline + QGridLayout *GeneralLayout = new QGridLayout(); + QLabel *fileName1 = new QLabel(tr("win02")); + //GeneralLayout->addWidget(fileName1, 0, 0, 2, 0, Qt::AlignLeft); // Left Right HCenter Justify + // Top Bottm VCenter Baseline + GeneralLayout->addWidget(fileName1, 0, 0); + + + + setLayout(GeneralLayout); +// HWaccess = new hwinf(); + //HWaccess->dc_getTemperaturStr(); // just to see if access is allowed + myNextStep=0; +} + + +void T_win02::Nav_back(void) +{ + myNextStep=1; +} +void T_win02::Nav_home(void) +{ + +} +void T_win02::Nav_next(void) +{ + +} + +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) + *nextScreen=0; // needed 0=no change + *useNavi=0; // bit1,2,3: use buttons next, home, back + myNextStep=0; + *useNavi=SWITCH_BACK_ON | SWITCH_HOME_OFF | SWITCH_NEXT_OFF; + 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 + + // this->updateGui(); + *nextScreen=0; // 0=no change + *useNavi=0; // bit1,2,3: use buttons next, home, back + + if (myNextStep) + { + //qDebug()<<"fenster1 working: "<< myNextStep; + *nextScreen=WCS_SERVICE_MAIN; + myNextStep=0; + } + + return true; +} + + +T_win02::~T_win02() +{ + this->close(); +} + +void T_win02::updateGui(void) +{ + + +} + diff --git a/win03_time.cpp b/win03_time.cpp new file mode 100755 index 0000000..3c1613f --- /dev/null +++ b/win03_time.cpp @@ -0,0 +1,350 @@ +#include "win03_time.h" + + +struct Trtc_DateTime localTime; +/* + { + uint8_t rtc_hour; + uint8_t rtc_min; + uint8_t rtc_sec; + uint8_t rtc_dayOfMonth; + uint8_t rtc_month; + uint8_t rtc_year; + uint8_t rtc_dayOfWeek; + }; + */ + + +T_win03::T_win03(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab1 =new QLabel(tr("Date / Time")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab4 =new QLabel(tr("DeviceController")); + lab4->setFont(myTabFont); + myLayout->addWidget(lab4,4,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + labDate =new QLabel(tr("-")); + labDate->setFont(myTabFont); + myLayout->addWidget(labDate,4,1); + + labTime =new QLabel(tr("-")); + labTime->setFont(myTabFont); + myLayout->addWidget(labTime,4,2); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + butSetSysTime = new QPushButton("-->PTU"); + butSetSysTime->setFont(myTabFont); + myLayout->addWidget(butSetSysTime,4,3); + connect(butSetSysTime, SIGNAL(clicked()), this, SLOT(ButtonTime2sysClicked())); + + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab10 =new QLabel(" "); + myLayout->addWidget(lab10,5,0); + + QLabel *lab6 =new QLabel(tr("PTU5 / System")); + lab6->setFont(myTabFont); + myLayout->addWidget(lab6,6,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + labSysDate =new QLabel(tr("-")); + labSysDate->setFont(myTabFont); + myLayout->addWidget(labSysDate,6,1); + + labSysTime =new QLabel(tr("-")); + labSysTime->setFont(myTabFont); + myLayout->addWidget(labSysTime,6,2); + + systTime = new QTime(); + systDate = new QDate(); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + butSetDCTime = new QPushButton("-->DC"); + butSetDCTime->setFont(myTabFont); + myLayout->addWidget(butSetDCTime,6,3); + connect(butSetDCTime, SIGNAL(clicked()), this, SLOT(ButtonTime2dcClicked())); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab11 =new QLabel(" "); + myLayout->addWidget(lab11,7,0); + + QLabel *lab14 =new QLabel("set date/time"); + lab14->setFont(myTabFont); + myLayout->addWidget(lab14,8,0); + + myTabFont.setPixelSize(22); + chgDate = new QDateEdit(); + chgDate->setFont(myTabFont); + chgDate->setMinimumHeight(50); + myLayout->addWidget(chgDate,8,1); + + chgTime = new QTimeEdit(); + chgTime->setFont(myTabFont); + chgTime->setDisplayFormat("HH:mm:ss"); + chgTime->setMinimumHeight(50); + myLayout->addWidget(chgTime,8,2); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + butSetManual = new QPushButton("-->DC"); + butSetManual->setFont(myTabFont); + myLayout->addWidget(butSetManual,8,3); + connect(butSetManual, SIGNAL(clicked()), this, SLOT(ButtonSetTimeClicked())); + + QLabel *lab12 =new QLabel(" "); + myLayout->addWidget(lab12,9,0); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab16 =new QLabel("DC HW Version:"); + lab16->setFont(myTabFont); + myLayout->addWidget(lab16,12,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + hwVersion1 =new QLabel(" "); + hwVersion1->setFont(myTabFont); + myLayout->addWidget(hwVersion1,12,1); + + hwVersion2 =new QLabel(" "); + hwVersion2->setFont(myTabFont); + myLayout->addWidget(hwVersion2,12,2); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab17 =new QLabel("DC SW Version:"); + lab17->setFont(myTabFont); + myLayout->addWidget(lab17,13,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + swVersion =new QLabel(" "); + swVersion->setFont(myTabFont); + myLayout->addWidget(swVersion,13,1); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab7 =new QLabel(tr("Battery:")); + lab7->setFont(myTabFont); + myLayout->addWidget(lab7,20,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + labVolt =new QLabel(tr("-")); + labVolt->setFont(myTabFont); + myLayout->addWidget(labVolt,20,1); + + labCelsius =new QLabel(tr("-")); + labCelsius->setFont(myTabFont); + myLayout->addWidget(labCelsius,20,2); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win03::~T_win03() +{ + close(); +} + +void T_win03::Nav_back(void) +{ + myNextStep=WCS_WIN03BAK; +} +void T_win03::Nav_home(void) +{ + myNextStep=WCS_WIN03MID; +} +void T_win03::Nav_next(void) +{ + myNextStep=WCS_WIN03FWD; +// qDebug()<<"fenster1 nav next pressed "<< myNextStep; + +} + +void T_win03::ButtonTime2sysClicked(void) +{ + + HWaccess->rtc_getDateTime(&localTime); + + if (tslib_plausiChkTime(localTime.rtc_hour, localTime.rtc_min, localTime.rtc_sec) && + tslib_plausiChkDate(localTime.rtc_year, localTime.rtc_month, localTime.rtc_dayOfMonth)) + { + QTime(localTime.rtc_hour, localTime.rtc_min, localTime.rtc_sec); + QDate(localTime.rtc_year, localTime.rtc_month, localTime.rtc_dayOfMonth); + //qDebug()<<"send date/time to PTU "; + //qDebug()<<"date: " << localTime.rtc_year << localTime.rtc_month << localTime.rtc_dayOfMonth << localTime.rtc_dayOfWeek ; + //qDebug()<<"time: " << localTime.rtc_hour << localTime.rtc_min << localTime.rtc_sec; + } +} + +void T_win03::ButtonTime2dcClicked(void) +{ + localTime.rtc_hour = systTime->currentTime().hour(); + localTime.rtc_min = systTime->currentTime().minute(); + localTime.rtc_sec = systTime->currentTime().second(); + localTime.rtc_year = uint8_t(systDate->currentDate().year()%100); + localTime.rtc_month= systDate->currentDate().month(); + localTime.rtc_dayOfMonth= systDate->currentDate().day(); + //localTime.rtc_dayOfWeek = swl_weekday(systDate->currentDate().year(), systDate->currentDate().month(), systDate->currentDate().day()); + localTime.rtc_dayOfWeek = systDate->currentDate().dayOfWeek(); // oder so + HWaccess->rtc_setTimeDateDirect(&localTime); + //qDebug()<<"send date/time to DC "; + //qDebug()<<"date: " << localTime.rtc_year << localTime.rtc_month << localTime.rtc_dayOfMonth << localTime.rtc_dayOfWeek ; + //qDebug()<<"time: " << localTime.rtc_hour << localTime.rtc_min << localTime.rtc_sec; + +} + +void T_win03::ButtonSetTimeClicked(void) +{ + QDate myDate; + QTime myTime; + + myDate=chgDate->date(); + myTime=chgTime->time(); + + //qDebug()<<"date: " <rtc_setTimeDateDirect(&localTime); + //qDebug()<<"send manual date/time to DC "; + //qDebug()<<"date: " << localTime.rtc_year << localTime.rtc_month << localTime.rtc_dayOfMonth << localTime.rtc_dayOfWeek ; + //qDebug()<<"time: " << localTime.rtc_hour << localTime.rtc_min << localTime.rtc_sec; + +} + + +bool T_win03::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_win03::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 nn; //, yl, yh; + char cbuf34[34]; + uint8_t buf[64]; + uint16_t uitmp; + QString myStr, tmpStr; + int ii, pp=0; + + *nextScreen=0; // 0=no change + *useNavi=0; + + + + HWaccess->rtc_getDateTime(&localTime); + + if (tslib_plausiChkTime(localTime.rtc_hour, localTime.rtc_min, localTime.rtc_sec) && + tslib_plausiChkDate(localTime.rtc_year, localTime.rtc_month, localTime.rtc_dayOfMonth)) + { + + for (nn=0; nn<20; nn++) + cbuf34[nn]=0; + GetTimeString(localTime.rtc_hour, localTime.rtc_min, localTime.rtc_sec, 0, 1, buf); + //void GetTimeString(uint8_t hours, uint8_t minutes, uint8_t seconds, uint8_t System12h, uint8_t ShowSec, uint8_t *buf); + for (nn=0; nn<12; nn++) + cbuf34[nn]=buf[nn]; + labTime->setText(cbuf34); + + for (nn=0; nn<20; nn++) + cbuf34[nn]=0; + GetDateString(localTime.rtc_dayOfMonth, localTime.rtc_month, 0x20, localTime.rtc_year,0, 0, buf); + // void GetDateString(uint8_t day, uint8_t month, uint8_t yearhigh, uint8_t yearlow, uint8_t format, uint8_t sep, uint8_t *buf); + for (nn=0; nn<12; nn++) + cbuf34[nn]=buf[nn]; + labDate->setText(cbuf34); + } + + + for (nn=0; nn<20; nn++) + cbuf34[nn]=0; + GetTimeString(systTime->currentTime().hour(), \ + systTime->currentTime().minute(), \ + systTime->currentTime().second(), 0, 1, buf); + for (nn=0; nn<12; nn++) + cbuf34[nn]=buf[nn]; + labSysTime->setText(cbuf34); + + for (nn=0; nn<20; nn++) + cbuf34[nn]=0; + uitmp= systDate->currentDate().year(); + tmpStr.clear(); + tmpStr.append(QString::number(uitmp)); + + GetDateString( systDate->currentDate().day(), \ + systDate->currentDate().month(), 0, 0, 0, 0, buf); + for (nn=0; nn<12; nn++) + cbuf34[nn]=buf[nn]; + cbuf34[6]=tmpStr.at(0).toLatin1(); + cbuf34[7]=tmpStr.at(1).toLatin1(); + cbuf34[8]=tmpStr.at(2).toLatin1(); + cbuf34[9]=tmpStr.at(3).toLatin1(); + + labSysDate->setText(cbuf34); + + // hwVersion1->setText(HWaccess->dc_getHWversion() ); + // in 2 Teile zerlegen weil sonst 2.Spalte zu breit + tmpStr.clear(); + tmpStr = HWaccess->dc_getHWversion(); + for (ii=0; iisetText(myStr); + myStr=tmpStr.right(pp+1); + hwVersion2->setText(myStr); + + swVersion->setText(HWaccess->dc_getSWversion() ); + labVolt->setText( HWaccess->dc_getVoltagStr()); + labCelsius->setText( HWaccess->dc_getTemperaturStr()); + + if (myNextStep) + { + //qDebug()<<"fenster1 working: "<< myNextStep; + *nextScreen=myNextStep; + myNextStep=0; + } + + return false; +} + + diff --git a/win03_time.h b/win03_time.h new file mode 100755 index 0000000..10fa43a --- /dev/null +++ b/win03_time.h @@ -0,0 +1,86 @@ +#ifndef WIN03_TIME_H +#define WIN03_TIME_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "QDateEdit" +#include "QTimeEdit" +#include "guidefs.h" + + +class T_win03 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + + QLabel *labDate; + QLabel *labTime; + QPushButton *butSetSysTime; + + QLabel *labSysDate; + QLabel *labSysTime; + QTime *systTime; + QDate *systDate; + QPushButton *butSetDCTime; + + QLabel *labVolt; + QLabel *labCelsius; + + QDateEdit *chgDate; + QTimeEdit *chgTime; + QPushButton *butSetManual; + + QLabel *hwVersion1, *hwVersion2; + QLabel *swVersion; + + +public: + explicit T_win03(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win03(); + + + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void ButtonTime2sysClicked(void); + void ButtonTime2dcClicked(void); + void ButtonSetTimeClicked(void); + + +}; + +#endif diff --git a/win04_stat.cpp b/win04_stat.cpp new file mode 100755 index 0000000..7195060 --- /dev/null +++ b/win04_stat.cpp @@ -0,0 +1,446 @@ +#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(); + +//} + + + + diff --git a/win04_stat.h b/win04_stat.h new file mode 100755 index 0000000..892f558 --- /dev/null +++ b/win04_stat.h @@ -0,0 +1,74 @@ +#ifndef WIN04_STAT_H +#define WIN04_STAT_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win04 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QLabel *lab4; + QLabel *lab5; + QTimer *myTO; + + QPushButton *pb_refresh; + + QListWidget *win4_showErrors; + QListWidget *win4_devParameters; + QListWidget *win4_showDeviceState; + QListWidget *win4_showMachineState; + + void entryDevState(QString label, uint8_t val); + void entryMachineCond(QString label, uint32_t val); + void entryArray(QString label, uint8_t *buff); + + uint8_t sub_componentAssessment(void); + uint8_t sys_getSystemErrors(void); + + +public: + explicit T_win04(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win04(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void ButtonRefreshClicked(void); + +}; + +#endif diff --git a/win05_doors.cpp b/win05_doors.cpp new file mode 100755 index 0000000..11b83c5 --- /dev/null +++ b/win05_doors.cpp @@ -0,0 +1,618 @@ +#include "win05_doors.h" + +#define TIME_DISPLAY_SIGNALS_MS 5000 + +T_win05::T_win05(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + QFont myTabFont; + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab1 =new QLabel(tr("Doors")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,0,0); + + // ----------------------------------------------------------------------------------------------------- + + // Spalten anlegen + QLabel *EncLabEmpty = new QLabel(" "); + QLabel *EncLabWide = new QLabel(" "); + //myLayout->addWidget(EncLabEmpty, 0,9); + myLayout->addWidget(EncLabWide, 0,1); + myLayout->addWidget(EncLabEmpty, 0,2); + myLayout->addWidget(EncLabEmpty, 0,3); + myLayout->addWidget(EncLabWide, 0,4); + myLayout->addWidget(EncLabWide, 0,5); + myLayout->addWidget(EncLabEmpty, 0,6); + myLayout->addWidget(EncLabWide, 0,7); + myLayout->addWidget(EncLabWide, 7,0); + + // linke Spalte Tür- und Kassenschalter + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab_swPow = new QLabel("Power4switches"); + lab_swPow->setFont(myTabFont); + myLayout->addWidget(lab_swPow, 1,0); + + LEDpwrOn = new QLabel(tr(" ")); + LEDpwrOn->setFrameStyle(QFrame::Panel | QFrame::Raised); + LEDpwrOn->setLineWidth(3); // 1,2,3 + LEDpwrOn->setFont(myTabFont); + LEDpwrOn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + myLayout->addWidget(LEDpwrOn, 1,1); + + // obere Tür + QLabel *EncLab2 = new QLabel(tr("Upper Door")); + EncLab2->setFont(myTabFont); + myLayout->addWidget(EncLab2, 2,0); + + EncDoorUp = new QLabel(tr("opened")); + EncDoorUp->setFrameStyle(QFrame::Panel | QFrame::Raised); + EncDoorUp->setLineWidth(3); // 1,2,3 + EncDoorUp->setFont(myTabFont); + EncDoorUp->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + myLayout->addWidget(EncDoorUp, 2,1); + + // mittlere Tür + QLabel *EncLab3 = new QLabel(tr("Vault Door")); + EncLab3->setFont(myTabFont); + myLayout->addWidget(EncLab3, 3,0); + + EncDoorMid = new QLabel("opened"); + EncDoorMid->setFrameStyle(QFrame::Panel | QFrame::Raised); + EncDoorMid->setLineWidth(3); // 1,2,3 + EncDoorMid->setFont(myTabFont); + EncDoorMid->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + myLayout->addWidget(EncDoorMid, 3,1); + + // Bill box + QLabel *EncLab5 = new QLabel(tr("Bill Box")); + EncLab5->setFont(myTabFont); + myLayout->addWidget(EncLab5, 4,0); + + EncBillBox = new QLabel("missed"); + EncBillBox->setFrameStyle(QFrame::Box | QFrame::Raised); + EncBillBox->setLineWidth(3); // 1,2,3 + //EncBillBox->setMaximumWidth(60); + EncBillBox->setFont(myTabFont); + EncBillBox->setStyleSheet("background-color: white"); + myLayout->addWidget(EncBillBox, 4,1); + + // Coin box + QLabel *EncLab6 = new QLabel(tr("Coin Box")); + EncLab6->setFont(myTabFont); + myLayout->addWidget(EncLab6, 5,0); + + EncCoinBox = new QLabel("missed"); + EncCoinBox->setFrameStyle(QFrame::Box | QFrame::Raised); + EncCoinBox->setLineWidth(3); // 1,2,3 + //EncCoinBox->setMaximumWidth(60); + EncCoinBox->setFont(myTabFont); + EncCoinBox->setStyleSheet("background-color: white"); + myLayout->addWidget(EncCoinBox, 5,1); + + // untere Tür + QLabel *EncLab4 = new QLabel(tr("Lower Door")); + EncLab4->setFont(myTabFont); + myLayout->addWidget(EncLab4, 6,0); + + EncDoorDn = new QLabel("opened"); + EncDoorDn->setFrameStyle(QFrame::Panel | QFrame::Raised); + EncDoorDn->setLineWidth(3); // 1,2,3 + EncDoorDn->setFont(myTabFont); + EncDoorDn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + myLayout->addWidget(EncDoorDn, 6,1); + + // mittlere Spalte: Tasten +// QLabel *EncLab11 = new QLabel(tr("lock/unlock doors")); +// EncLab11->setFont(myTabFont); +// myLayout->addWidget(EncLab11, 0,3); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + PB_uplockOpen = new QPushButton(tr("open\n")); + myLayout->addWidget(PB_uplockOpen, 2,3); + PB_uplockOpen->setFont(myTabFont); + connect(PB_uplockOpen, SIGNAL(clicked()), this, SLOT(ua_osd())); + + /* nur PSA2020 + PB_uplockClos = new QPushButton(tr("close\n")); + myLayout->addWidget(PB_uplockClos, 2,4); + PB_uplockClos->setFont(myTabFont); + connect(PB_uplockClos, SIGNAL(clicked()), this, SLOT(ua_csd())); + */ + PB_lowlockOpen = new QPushButton(tr("open\n")); + PB_lowlockOpen->setFont(myTabFont); + myLayout->addWidget(PB_lowlockOpen, 3,3); + connect(PB_lowlockOpen, SIGNAL(clicked()), this, SLOT(ua_obd())); + + PB_vaultDoor = new QPushButton(tr("open safe\n")); + PB_vaultDoor->setFont(myTabFont); + myLayout->addWidget(PB_vaultDoor, 4,3); + connect(PB_vaultDoor, SIGNAL(clicked()), this, SLOT(ua_vd())); + + PB_siren = new QPushButton(tr("alarm\nsiren")); + PB_siren->setCheckable(false); // true = toggle button + PB_siren->setFont(myTabFont); + myLayout->addWidget(PB_siren, 6,3); + connect(PB_siren, SIGNAL(clicked()), this, SLOT(switchSiren())); + +/* nur PSA2020 + // 3. Spalte nur für PSA2020 - Riegelleisten + QLabel *EncLab10 = new QLabel(tr("PSA2020\nLockbars")); + EncLab10->setFont(myTabFont); + myLayout->addWidget(EncLab10, 0,6); + + PB_uplockForw = new QPushButton(tr("upper motor\nforward")); + PB_uplockForw->setFont(myTabFont); + myLayout->addWidget(PB_uplockForw, 1,6); + connect(PB_uplockForw, SIGNAL(clicked()), this, SLOT(ua_ulu())); + + PB_uplockStop = new QPushButton(tr("upper motor\n stopp")); + PB_uplockStop->setFont(myTabFont); + myLayout->addWidget(PB_uplockStop, 2,6); + connect(PB_uplockStop, SIGNAL(clicked()), this, SLOT(ua_uls())); + + PB_uplockRev = new QPushButton(tr("upper motor\nreverse")); + PB_uplockRev->setFont(myTabFont); + myLayout->addWidget(PB_uplockRev, 3,6); + connect(PB_uplockRev, SIGNAL(clicked()), this, SLOT(ua_uld())); + + PB_lowlockForw = new QPushButton(tr("lower motor\nforward")); + PB_lowlockForw->setFont(myTabFont); + myLayout->addWidget(PB_lowlockForw, 5,6); + connect(PB_lowlockForw, SIGNAL(clicked()), this, SLOT(ua_llu())); + + PB_lowlockStop = new QPushButton(tr("lower motor\n stopp")); + PB_lowlockStop->setFont(myTabFont); + myLayout->addWidget(PB_lowlockStop, 6,6); + connect(PB_lowlockStop, SIGNAL(clicked()), this, SLOT(ua_lls())); + + // display Lock-bar contacts, upper lock up + lockbarContactUU = new QLabel("ulu"); + lockbarContactUU->setFrameStyle(QFrame::Panel | QFrame::Raised); + lockbarContactUU->setLineWidth(3); // 1,2,3 + lockbarContactUU->setMaximumWidth(40); + lockbarContactUU->setMaximumHeight(25); + lockbarContactUU->setFont(myTabFont); + lockbarContactUU->setStyleSheet("background-color: white"); + myLayout->addWidget(lockbarContactUU, 1,7); + + // upper lock down + lockbarContactUD = new QLabel("uld"); + lockbarContactUD->setFrameStyle(QFrame::Panel | QFrame::Raised); + lockbarContactUD->setLineWidth(3); // 1,2,3 + lockbarContactUD->setMaximumWidth(40); + lockbarContactUD->setMaximumHeight(25); + lockbarContactUD->setFont(myTabFont); + lockbarContactUD->setStyleSheet("background-color: yellow"); + myLayout->addWidget(lockbarContactUD, 3,7); + + lockbarContactDU = new QLabel("lld"); + lockbarContactDU->setFrameStyle(QFrame::Panel | QFrame::Raised); + lockbarContactDU->setLineWidth(3); // 1,2,3 + lockbarContactDU->setMaximumWidth(40); + lockbarContactDU->setMaximumHeight(25); + lockbarContactDU->setFont(myTabFont); + lockbarContactDU->setStyleSheet("background-color: white"); + myLayout->addWidget(lockbarContactDU, 5,7); +*/ + + + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorServiceDoorOpened()), this, SLOT(door_slotUpOpen())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorVaultDoorOpened()), this, SLOT(door_slotLowOpen())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorCoinBoxRemoved()), this, SLOT(door_slotBoxOut())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorCoinBoxInserted()), this, SLOT(door_slotBoxIn())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorCBinAndAllDoorsClosed()), this, SLOT(door_slotCBin_AllClosed())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_doorAllDoorsClosed()), this, SLOT(door_slotAllClosed())); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + showSignals = new QLineEdit(); + showSignals->setFrame(true); + showSignals->setText(" "); + showSignals->setReadOnly(true); + showSignals->setFont(myTabFont); + showSignals->setStyleSheet("background-color: white"); + myLayout->addWidget(showSignals,1,4); + + timerClrDisp = new QTimer(); + timerClrDisp->setSingleShot(true); + //timerClrDisp->start(1000); + connect(timerClrDisp, SIGNAL(timeout()), this, SLOT(door_slotClrSig())); + + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(TIME_DISPLAY_SIGNALS_MS); + +} + + +void T_win05::door_slotUpOpen(void) +{ + showSignals->setText("signal service door was opened"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen +} + +void T_win05::door_slotLowOpen(void) +{ + showSignals->setText("signal middlee door was opened"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + +} + +void T_win05::door_slotBoxOut(void) +{ + showSignals->setText("signal coinBox was removed"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + +} + +void T_win05::door_slotBoxIn(void) +{ + showSignals->setText("signal coinBox was inserted"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + +} + +void T_win05::door_slotCBin_AllClosed(void) +{ + showSignals->setText("signal all doors was closed with box in"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + +} + +void T_win05::door_slotAllClosed(void) +{ + showSignals->setText("signal all doors was closed"); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + +} + +void T_win05::door_slotClrSig(void) +{ + showSignals->clear(); +} + +T_win05::~T_win05() +{ + close(); +} + +void T_win05::Nav_back(void) +{ + myNextStep=WCS_WIN05BAK; +} +void T_win05::Nav_home(void) +{ + myNextStep=WCS_WIN05MID; +} +void T_win05::Nav_next(void) +{ + myNextStep=WCS_WIN05FWD; +} + + +bool T_win05::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_win05::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; + + // Türen: EncDoorUp EncDoorMid EncDoorDn + // LEDpwrOn; EncDoorUp;EncDoorMid;EncBillBox;EncCoinBox;EncDoorDn; + + if (HWaccess->door_isContactPowerOn()) + LEDpwrOn->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + else + LEDpwrOn->setStyleSheet("background-color: white"); + + if (HWaccess->door_isUpperDoorOpen()) + { + // Tür oben offen + EncDoorUp->setText(" open "); + EncDoorUp->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + } else + { + // Tür oben zu + EncDoorUp->setText("closed"); + EncDoorUp->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + } + + if (HWaccess->vault_isVaultDoorOpen()) + { + // Tür Mitte (Tresor) offen: + EncDoorMid->setText(" open "); + EncDoorMid->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + } else + { + EncDoorMid->setText("closed"); + EncDoorMid->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + } + + if (HWaccess->door_isLowerDoorOpen()) + { + // EncDoorDn->setText(" o\n p\n e\n n"); + EncDoorDn->setText(" open "); + EncDoorDn->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + //qDebug() << "batt door is open"; + } else + { + // EncDoorDn->setText(" c\n l\n o\n s\n e\n d"); + EncDoorDn->setText("closed"); + EncDoorDn->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + //qDebug() << "batt door is closed"; + } + + + if (HWaccess->vault_isBillVaultIn()) + { + // Bill box drin + // EncBillBox->setText(" B\n I\n L\n L"); + EncBillBox->setText(" IN"); + EncBillBox->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + } else + { + EncBillBox->setText("OUT"); + EncBillBox->setStyleSheet("background-color: white"); + } + + if (HWaccess->vault_isCoinVaultIn()) + { + // Bill box drin + EncCoinBox->setText(" IN"); + EncCoinBox->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + + } else + { + EncCoinBox->setText("OUT"); + EncCoinBox->setStyleSheet("background-color: white"); + + } + +/* nur PSA2020 + uint8_t ret=HWaccess->door_getLocks(); + // retval bit0: upper lever is up + // bit1: upper lever is down + // bit2: lower lever is up + // bit3: lower lever is down + + if (ret & 1) + { + lockbarContactUU->setStyleSheet("background-color: yellow"); + } else + { + lockbarContactUU->setStyleSheet("background-color: white"); + } + + if (ret & 2) + lockbarContactUD->setStyleSheet("background-color: yellow"); + else + lockbarContactUD->setStyleSheet("background-color: white"); + + if (ret & 8) // 4 gibts nicht + lockbarContactDU->setStyleSheet("background-color: yellow"); + else + lockbarContactDU->setStyleSheet("background-color: white"); + + // if (ret & 8) + // lockbarContactDD->setStyleSheet("background-color: yellow"); + // else + // lockbarContactDD->setStyleSheet("background-color: white"); + + + if (HWaccess->door_upperDoorIsUnlocked()) + LedUdoorIsOpen->setStyleSheet("background-color: yellow"); + else + LedUdoorIsOpen->setStyleSheet("background-color: white"); + + if (HWaccess->door_upperDoorIsLocked()) + LedUdoorIsClosed->setStyleSheet("background-color: yellow"); + else + LedUdoorIsClosed->setStyleSheet("background-color: white"); + + // if (HWaccess->door_lowerDoorIsUnlocked()) // dennSchalter gibt's nicht! + if (HWaccess->door_lowerDoorIsLocked()) + LedLdoorIsOpen->setStyleSheet("background-color: yellow"); + else + LedLdoorIsOpen->setStyleSheet("background-color: white"); + + // if (HWaccess->door_lowerDoorIsLocked()) + // LedLdoorIsClosed->setStyleSheet("background-color: yellow"); + // else + // LedLdoorIsClosed->setStyleSheet("background-color: white"); + */ + + /* + // crash + // safe door cannot be opened if printer fuse is blown, display: + uint8_t fuseState=HWaccess->prn_PrnFuseIsOk(); + //retval: 0: fuse blown 1: fuse OK 2:unknown as printer power is off + if (fuseState==0) + dispFuse->setText("cannot open, \nprinter fuse blown!"); + else + dispFuse->setText("cannot open, \nprinter fuse OK!"); +*/ +/* + if (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } +*/ + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + +// %%%%%%%%%%%%%%%%%%%% aus TabDoors +/* nur 2020 +void T_win05::ua_ulu(void) +{ + // user action (=button pressed) + // upper lock up = forward + HWaccess->lock_switchUpperLock(1); +} + +void T_win05::ua_uld(void) +{ + // upper lock down = reverse + HWaccess->lock_switchUpperLock(2); + +} + +void T_win05::ua_uls(void) +{ + // upper lock stop + HWaccess->lock_switchUpperLock(0); + +} + +void T_win05::ua_llu(void) +{ + // user action (=button pressed) + // upper lock up = forward + HWaccess->lock_switchLowerLock(1); +} +*/ +/* void T_win05::ua_lld(void) +{ + // upper lock down = reverse + HWaccess->lock_switchLowerLock(2); + +}*/ +/* nur 2020 +void T_win05::ua_lls(void) +{ + // upper lock stop + HWaccess->lock_switchLowerLock(0); + +}*/ + +void T_win05::ua_osd(void) +{ + // open service door + HWaccess->lock_triggerUpperSolenoid(); +} + +/* nur 2020 +void T_win05::ua_csd(void) +{ + // clsoe service door + HWaccess->lock_closeUpperDoor(); + +}*/ + +void T_win05::ua_obd(void) +{ + // open battery/lower door + HWaccess->lock_triggerLowerSolenoid(); + +} +/* +void T_win05::ua_cbd(void) +{ + HWaccess->lock_closeLowerDoor(); + +}*/ + +void T_win05::ua_vd(void) +{ + + //qDebug() << "GUI: button open vault"; + HWaccess->lock_switchVaultDoor(); + +} + +void T_win05::switchPwr(void) +{ + + if (PB_lockPwr->isChecked() ) + HWaccess->lock_switchContactPower(1); + else + HWaccess->lock_switchContactPower(0); + +} + +void T_win05::switchSiren(void) +{ + +// if (PB_siren->isChecked() ) + HWaccess->alarm_switchSiren(1); +// else +// HWaccess->alarm_switchSiren(0); + +} + + + + diff --git a/win05_doors.h b/win05_doors.h new file mode 100755 index 0000000..dff7ab2 --- /dev/null +++ b/win05_doors.h @@ -0,0 +1,118 @@ +#ifndef WIN05_DOORS_H +#define WIN05_DOORS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "QLineEdit" +#include "guidefs.h" + +class T_win05 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + + QPushButton *PB_lockPwr; + QPushButton * PB_uplockForw; + QPushButton *PB_uplockStop; + QPushButton *PB_uplockRev; + QPushButton *PB_lowlockForw; + QPushButton *PB_lowlockStop; + QPushButton *PB_uplockOpen; + QPushButton *PB_uplockClos; + QPushButton *PB_lowlockOpen; + QPushButton *PB_vaultDoor; + QPushButton *PB_siren; + + QLabel *LEDpwrOn; + QLabel *EncDoorUp; + QLabel *EncDoorMid; + QLabel *EncBillBox; + QLabel *EncCoinBox; + QLabel *EncDoorDn; + QLabel *lockbarContactUU; + QLabel *lockbarContactUD; + QLabel *lockbarContactDU; + QLabel *LedUdoorIsOpen; + QLabel *LedUdoorIsClosed; + QLabel *LedLdoorIsOpen; + + QLineEdit *showSignals; + QTimer *timerClrDisp; + +public: + explicit T_win05(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win05(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); +/* nur 2020: + void ua_ulu(void); + void ua_uld(void); + void ua_uls(void); + void ua_llu(void); + void ua_lls(void); +*/ + void ua_osd(void); +// void ua_csd(void); + void ua_obd(void); + void ua_vd(void); + void switchPwr(void); + void switchSiren(void); + + void door_slotUpOpen(void); + void door_slotLowOpen(void); + void door_slotBoxOut(void); + void door_slotBoxIn(void); + void door_slotCBin_AllClosed(void); + void door_slotAllClosed(void); + void door_slotClrSig(void); + +}; + +#endif + + + + + + + + + + + + diff --git a/win06_prn.cpp b/win06_prn.cpp new file mode 100755 index 0000000..93856c0 --- /dev/null +++ b/win06_prn.cpp @@ -0,0 +1,667 @@ +#include "win06_prn.h" + + + + +T_win06::T_win06(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + int nn; + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab1 =new QLabel(tr("Printer")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + butPrnPow = new QPushButton("Power"); + myLayout->addWidget(butPrnPow,1,1); + butPrnPow->setFont(myTabFont); + butPrnPow->setStyleSheet("background-color: white"); + butPrnPow->setCheckable(true); // true = toggle button + butPrnPow->setAutoDefault(false); // beim start aus + butPrnPow->setMinimumWidth(100); + butPrnPow->setMinimumHeight(40); + butPrnPow->setChecked(true); + connect(butPrnPow, SIGNAL(clicked()), this, SLOT(slot_powerButton())); + + myTabFont.setPixelSize(14); + QLabel *lab14 =new QLabel(tr("external low paper sensor:")); + lab14->setFont(myTabFont); + lab14->setAlignment( Qt::AlignRight); + myLayout->addWidget(lab14,1,2); + + lab15 =new QLabel(tr(" ")); + lab15->setFont(myTabFont); + lab15->setStyleSheet("background-color: white"); + lab15->setFrameStyle(3); + myLayout->addWidget(lab15,1,3); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab12 =new QLabel(tr("State:")); + lab12->setFont(myTabFont); + myLayout->addWidget(lab12,3,0); + + myTabFont.setPixelSize(22); + showPrnState1 =new QLabel(tr(" ")); + showPrnState1->setFont(myTabFont); + showPrnState1->setFrameStyle(1); + myLayout->addWidget(showPrnState1,3,1); + + // selection box for Template-number to be printed + myTabFont.setPixelSize(20); + cb_templNr = new QComboBox(); + myLayout->addWidget(cb_templNr,3,2); + for (nn=1; nn<=32; nn++) + cb_templNr->addItem(swl_int2str(nn)); + cb_templNr->setFont(myTabFont); + cb_templNr->setCurrentIndex(0); // war 28 (=29) + cb_templNr->setMaxVisibleItems(5); + cb_templNr->setStyleSheet("QScrollBar:vertical { width: 30px; }"); + + cb_kombiNr = new QComboBox(); + myLayout->addWidget(cb_kombiNr,5,2); + for (nn=1; nn<=8; nn++) + cb_kombiNr->addItem(swl_int2str(nn)); + cb_kombiNr->setFont(myTabFont); + cb_kombiNr->setCurrentIndex(0); + cb_kombiNr->setMaxVisibleItems(5); +// cb_kombiNr->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); +// cb_kombiNr->view()->setVerticalScrollBar(QScrollBar::setMinimumWidth(20)); + //cb_kombiNr->view()->setVerticalScrollBar()->setMinimumWidth(20); + cb_kombiNr->setStyleSheet("QScrollBar::vertical { width: 30px; }"); // geht :)) + // cb_kombiNr->setStyleSheet(QComboBox::downarrow {width: 30px; }); + //cb_kombiNr->adjustSize(); + + //myTabFont.setPixelSize(14); + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + QPushButton *butPrint2 = new QPushButton(" print\ntemplate"); + myLayout->addWidget(butPrint2,3,3); + connect(butPrint2, SIGNAL(clicked()), this, SLOT(slot_printVaris())); + + QPushButton *butPrint6 = new QPushButton(" print\ncombi"); + myLayout->addWidget(butPrint6,5,3); + connect(butPrint6, SIGNAL(clicked()), this, SLOT(slot_printCombi())); + +// myTabFont.setPixelSize(14); + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab13 =new QLabel(tr("Result:")); + lab13->setFont(myTabFont); + myLayout->addWidget(lab13,4,0); + + myTabFont.setPixelSize(PIXELSIZE_BIGFONT); + showPrnResult =new QLabel(tr(" ")); + showPrnResult->setFont(myTabFont); + showPrnResult->setFrameStyle(1); + myLayout->addWidget(showPrnResult,4,1); + +// myTabFont.setPixelSize(14); + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab16 =new QLabel(tr("Signals:")); + lab16->setFont(myTabFont); + myLayout->addWidget(lab16,5,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + labSignal =new QLabel(tr(" ")); + labSignal->setFont(myTabFont); + labSignal->setFrameStyle(1); + myLayout->addWidget(labSignal,5,1); + + myTabFont.setPixelSize(PIXELSIZE_SMALLFONT); + QLabel *lab10 =new QLabel(tr("send dummy values: ")); + lab10->setFont(myTabFont); + myLayout->addWidget(lab10,13,0); + + QPushButton *butSendDyn1 = new QPushButton("V1_abcde V2_ghijk V3_mnopq V4_stuvw\nV5_ABCDE V6_GHIJK V7_MNOPQ V8_STUVW"); + myLayout->addWidget(butSendDyn1,13,1); + connect(butSendDyn1, SIGNAL(clicked()), this, SLOT(slot_sendDD1())); + + QPushButton *butSendDyn2 = new QPushButton("V1_00011 V2_00022 V3_00033 V4_00044\nV5_00055 V6_00066 V7_00077 V8_00088"); + myLayout->addWidget(butSendDyn2,13,2); + connect(butSendDyn2, SIGNAL(clicked()), this, SLOT(slot_sendDD2())); + + + lab6 =new QLabel(tr("read back: ")); + lab6->setFont(myTabFont); + myLayout->addWidget(lab6,16,0); + + lab7 =new QLabel(tr(" ")); + lab7->setFont(myTabFont); + lab7->setFrameStyle(1); + myLayout->addWidget(lab7,16,1); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + QPushButton *butGetDD = new QPushButton("read\nback"); + myLayout->addWidget(butGetDD,16,2); + connect(butGetDD, SIGNAL(clicked()), this, SLOT(slot_rdBackDD())); + + QPushButton *butPrint3 = new QPushButton("print \nLogo"); + myLayout->addWidget(butPrint3,19,0); + connect(butPrint3, SIGNAL(clicked()), this, SLOT(slot_printLogo())); + + QPushButton *butPrint4 = new QPushButton("print \nAcc.Bill"); + myLayout->addWidget(butPrint4,19,1); + connect(butPrint4, SIGNAL(clicked()), this, SLOT(slot_printAcc())); + + QPushButton *butPrintTicket = new QPushButton("print \nTicket"); + myLayout->addWidget(butPrintTicket,19,2); + connect(butPrintTicket, SIGNAL(clicked()), this, SLOT(slot_printTicket())); + + QPushButton *butPrint5 = new QPushButton(" CUT \n"); + myLayout->addWidget(butPrint5,19,3); + connect(butPrint5, SIGNAL(clicked()), this, SLOT(slot_printCut())); + + + // ------------------------------------------------------------- + // 25.6.23 dazu: + QPushButton *butPrint10 = new QPushButton("Send\nText"); + myLayout->addWidget(butPrint10,22,0); + connect(butPrint10, SIGNAL(clicked()), this, SLOT(slot_sendText())); + + QPushButton *butPrint11 = new QPushButton("Setup"); + myLayout->addWidget(butPrint11,22,1); + connect(butPrint11, SIGNAL(clicked()), this, SLOT(slot_setup())); + + QPushButton *butPrint12 = new QPushButton("Move \n Paper"); + myLayout->addWidget(butPrint12,22,2); + connect(butPrint12, SIGNAL(clicked()), this, SLOT(slot_movPap())); + + QPushButton *butPrint15 = new QPushButton("Paper \n back"); + myLayout->addWidget(butPrint15,22,3); + connect(butPrint15, SIGNAL(clicked()), this, SLOT(slot_movBack())); + + + QPushButton *butPrint13 = new QPushButton(" set \nFonts"); + myLayout->addWidget(butPrint13,23,1); + connect(butPrint13, SIGNAL(clicked()), this, SLOT(slot_fonts())); + + QPushButton *butPrint14 = new QPushButton(" set \nLetters"); + myLayout->addWidget(butPrint14,23,2); + connect(butPrint14, SIGNAL(clicked()), this, SLOT(slot_letters())); + + + + + QPushButton *butPrint20 = new QPushButton("Print QR\n"); + myLayout->addWidget(butPrint20,23,0); + connect(butPrint20, SIGNAL(clicked()), this, SLOT(slot_printQr())); + + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(1000); + + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(signalPrnDone())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(signalPrnErr())); + + HWaccess->prn_switchPower(0); + + + + + dummyText.clear(); + /* + dummyText.append(" Quod equidem non reprehendo; Lorem ipsum dolor sit amet, consectetur adipiscing elit. "); + dummyText.append(" Quibus natura iure responderit non esse verum aliunde finem beate vivendi, "); + dummyText.append(" a se principia rei gerendae peti; Quae enim adhuc protulisti, popularia sunt, "); + dummyText.append(" ego autem a te elegantiora desidero. Duo Reges: constructio interrete. "); + dummyText.append("Tum Lucius: Mihi vero ista valde probata sunt, quod item fratri puto. "); + dummyText.append("Bestiarum vero nullum iudicium puto. Nihil enim iam habes, quod ad corpus referas; "); + dummyText.append("Deinde prima illa, quae in congressu solemus: Quid tu, inquit, huc? Et homini, qui "); + dummyText.append("ceteris animantibus plurimum praestat, praecipue a natura nihil datum esse dicemus? "); + dummyText.append("Iam id ipsum absurdum, maximum malum neglegi. Quod ea non occurrentia fingunt, vincunt Aristonem; "); + dummyText.append("Atqui perspicuum est hominem e corpore animoque constare, cum primae sint animi partes, "); + dummyText.append("secundae corporis. Fieri, inquam, Triari, nullo pacto potest, ut non dicas, quid non probes eius "); + dummyText.append(" a quo dissentias. Equidem e Cn. An dubium est, quin virtus ita maximam partem optineat "); + dummyText.append("in rebus humanis, ut reliquas obruat? "); + dummyText.append("Summus dolor plures dies manere non potest? Dicet pro me ipsa virtus nec dubitabit isti vestro "); + dummyText.append("beato M. Tubulum fuisse, qua illum, cuius is condemnatus est rogatione, P. Quod si ita sit, cur "); + dummyText.append("opera philosophiae sit danda nescio. valde probata sunt, quod item fratri puto"); + dummyText.truncate(1278); + */ + dummyText.append("abcdefghijklmnopqrstuvwxyz0123ABCDEFGHIJKLMNOPQRSTUVWXYZ4567"); // 60byte + dummyText.append("abcdefghijklmnopqrstuvwxyz0123ABCDEFGHIJKLMNOPQRSTUVWXYZ4567"); // 60byte + dummyText.append("abcdefghijklmnopqrstuvwxyz0123ABCDEFGHIJKLMNOPQRSTUVWXYZ4567"); // 60byte + + + + +} + +T_win06::~T_win06() +{ + close(); +} + + +void T_win06::Nav_back(void) +{ + myNextStep=WCS_WIN06BAK; +} +void T_win06::Nav_home(void) +{ + myNextStep=WCS_WIN06MID; +} +void T_win06::Nav_next(void) +{ + myNextStep=WCS_WIN06FWD; +} + +void T_win06::slot_sendDD1(void) +{ + uint8_t buf[66]; + + // schicke V1_abcdef V2_ghijkl V3_mnopqr V4_stuvwx\nV5_ABCDEF V6_GHIJKL V7_MNOPQR V8_STUVWX als dyn.Drucker variablen + swl_text2ui8buf("V1_abcdef", &buf[0],8); + swl_text2ui8buf("V2_ghijkl", &buf[8],8); + swl_text2ui8buf("V3_mnopqr", &buf[16],8); + swl_text2ui8buf("V4_stuvwx", &buf[24],8); + swl_text2ui8buf("V5_ABCDEF", &buf[32],8); + swl_text2ui8buf("V6_GHIJKL", &buf[40],8); + swl_text2ui8buf("V7_MNOPQR", &buf[48],8); + swl_text2ui8buf("V8_STUVWX", &buf[56],8); + HWaccess->prn_sendDynamicPrnValues(buf); + +} + + +void T_win06::slot_rdBackDD(void) +{ + HWaccess->prn_requestCurrentDynData(); +} + +void T_win06::slot_printVaris(void) +{ + int val=cb_templNr->currentIndex(); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + val++; + HWaccess->prn_printTemplate(val); + +} + +void T_win06::slot_printCombi(void) +{ + int val=cb_kombiNr->currentIndex(); + val++; + HWaccess->prn_printKombiticket(val); +} + +void T_win06::slot_printTicket(void) +{ + +// HWaccess->prn_printTemplate(1); +// HWaccess->prn_printTemplate(2); +// HWaccess->prn_printTemplate(3); + + HWaccess->prn_printKombiticket(1); +} + + +void T_win06::slot_sendDD2(void) +{ + uint8_t buf[66]; + + // send V1_000111 V2_000222 V3_000333 V4_000444\nV5_000555 V6_000666 V7_000777 V8_000888 + swl_text2ui8buf("V1_000111", &buf[0],8); + swl_text2ui8buf("V2_000222", &buf[8],8); + swl_text2ui8buf("V3_000333", &buf[16],8); + swl_text2ui8buf("V4_000444", &buf[24],8); + swl_text2ui8buf("V5_000555", &buf[32],8); + swl_text2ui8buf("V6_000666", &buf[40],8); + swl_text2ui8buf("V7_000777", &buf[48],8); + swl_text2ui8buf("V8_000888", &buf[56],8); + HWaccess->prn_sendDynamicPrnValues(buf); + +} + +void T_win06::signalPrnDone(void) +{ + labSignal->setText("signal printing finished"); + myTO->start(2000); +} + +void T_win06::signalPrnErr(void) +{ + labSignal->setText("signal printing ERROR"); + myTO->start(2000); +} + + +void T_win06::slot_powerButton(void) +{ + + if (butPrnPow->isChecked()) + { + HWaccess->prn_switchPower(1); + } else + { + HWaccess->prn_switchPower(0); + } + +} + +void T_win06::slot_printLogo(void) +{ + HWaccess->prn_switchPower(1); + HWaccess->prn_printLogo(1,0); +} + +void T_win06::slot_printAcc(void) +{ + HWaccess->prn_switchPower(1); + HWaccess->prn_printAccountReceipt(); +} + +void T_win06::slot_printCut(void) +{ + HWaccess->prn_switchPower(1); + HWaccess->prn_cut(1); +} + + + +void T_win06::slot_sendText(void) +{ + HWaccess->prn_switchPower(1); + HWaccess->prn_sendText(&dummyText); + // up to 1280 bytes + +} + +void T_win06::slot_setup(void) +{ + uint16_t paperSpeed=240; + uint8_t density=25; + uint8_t alignment='c'; + uint8_t orientation=0; + + HWaccess->prn_switchPower(1); + HWaccess->prn_sendPrnSetup(paperSpeed, density, alignment, orientation); + // send 5 byte: byte 0,1: speed 5...250 mm/s + // byte2: density 0....(25)....50 + // byte3: alignment 'l', 'c', 'r' = left, center, right + // byte4: orientation 0, 90, 180 = 0°, 90°, 180° rotation (by now not supported!) + // not batched! don't use twice within 100ms + +} + +void T_win06::slot_movPap(void) +{ + uint8_t wayInMm=30; + uint8_t direction=1; + + HWaccess->prn_switchPower(1); + HWaccess->prn_movePaper(wayInMm, direction); + //direction: 1=forward 2=backward + + //void prn_newLine(uint8_t nrOfLines) const override; + +} + +void T_win06::slot_movBack(void) +{ + uint8_t wayInMm=30; + uint8_t direction=2; + + HWaccess->prn_switchPower(1); + HWaccess->prn_movePaper(wayInMm, direction); + //direction: 1=forward 2=backward + + //void prn_newLine(uint8_t nrOfLines) const override; + +} + +void T_win06::slot_fonts(void) +{ + uint8_t font=10; + uint8_t size=5; + uint8_t width=1; + uint8_t height=2; + + HWaccess->prn_switchPower(1); + HWaccess->prn_setFonts(font, size, width, height); + // font = kind of font 5...11 (0..22) + // size = seem to be dots/mm 1..10=nice >15=ugly + // [size = 6...20, 9..9: too tiny 10: small ...12 = normal size ...20=huge] (for some fonts) + // width: 0...4 0=1x 1=2x 2=4x (huge!) 3=8x 4=16x (3,4 make no sense) + // heigth: 0...7 = 1x...8x only 0,1,2,(3) make sense + +} + + +void T_win06::slot_printQr(void) +{ + HWaccess->prn_printQRcode(); +} + + void T_win06::slot_letters(void) +{ + uint8_t bold=1; + uint8_t invers=0; + uint8_t underlined=0; + + HWaccess->prn_switchPower(1); + HWaccess->prn_setLetters(bold, invers, underlined); + // bold: 0/1 + // invers: 0/1 + // underlined: 0/1 + + +} + +/* +void T_win06::slot_(void) +{ + HWaccess->prn_ +} +void T_win06::slot_(void) +{ + HWaccess->prn_ +} +void T_win06::slot_(void) +{ + HWaccess->prn_ +} +*/ + + + + +bool T_win06::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_win06::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; + uint8_t buf[66]; + char ctmp; + uint8_t uctmp; + bool btmp; + + // Ruecklesen und anzeigen der dyn. Variablen + myStr.clear(); + btmp=HWaccess->prn_getCurrentDynamicPrnValuesFromDC(buf); + if (btmp) + { + for (int nn=0; nn<32; nn++) + { + ctmp=char(buf[nn]); + myStr.append(ctmp); + } + myStr.append('\n'); + for (int nn=32; nn<64; nn++) + { + ctmp=char(buf[nn]); + myStr.append(ctmp); + } + + lab7->setText(myStr); + + if (HWaccess->prn_dynDataAreEqual(buf)) + //lab9->setText("equal"); + lab7->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + else + //lab9->setText("wrong"); + lab7->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + } + + // clear signals after 2s: + if (!myTO->isActive()) + labSignal->setText(" "); + + +// HWaccess->sys_getDynMachineConditions(&myDynMachCond); + + uctmp=HWaccess->prn_getCurrentPrinterState(); + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + myStr.clear(); + myStr.append(QString::number(uctmp)); + myStr.append(" "); + if (uctmp&0x80) myStr.append("serial rec.error"); else + if (uctmp&0x40) myStr.append("no response"); else + if (uctmp&0x20) myStr.append("Prn not Ready"); else + if (uctmp&0x10) myStr.append("Paper jam"); else + if (uctmp&0x08) myStr.append("head open"); else + if (uctmp&0x04) myStr.append("too hot"); else + if (uctmp&0x02) myStr.append("no paper"); else + if (uctmp&0x01) myStr.append("near paper end"); + showPrnState1->setText(myStr); + + + //btmp=HWaccess->prn_isUpAndReady(); geht nicht richtig + //if (btmp) // up and ready + + if (uctmp<2) + showPrnState1->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + else + showPrnState1->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + + uctmp=HWaccess->prn_getPrintResult(); + // return: 0: unknown + // 1: OK - last template was printed succesful + // 2: error - last template was not printed + + myStr.clear(); + myStr.append(QString::number(uctmp)); + myStr.append(" "); + if (uctmp==1) myStr.append("- OK"); else + if (uctmp==2) myStr.append("- error"); else + if (uctmp==3) myStr.append("- 3"); else + myStr.append("- unknown"); + showPrnResult->setText(myStr); + + uctmp=HWaccess->cash_getLowPaperSensor(); + // 0: Sensor sees paper 1: no paper 99: off + if (uctmp==0) + lab15->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + else if (uctmp==1) + lab15->setStyleSheet("background-color: yellow"); + else + lab15->setStyleSheet("background-color: white"); + + + if (HWaccess->prn_isPrinterPowerOn()) + { + if (HWaccess->prn_PrnFuseIsOk()==0) + { + // fuse is blown + butPrnPow->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + butPrnPow->setText("FUSE blown"); + } else + { + // on + butPrnPow->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + butPrnPow->setText(" O N "); + } + } else + { + butPrnPow->setStyleSheet("background-color: white"); + butPrnPow->setText("Power"); + } + +/* + uctmp=HWaccess->log_getAnswerToLastCmdBatch(); + // 0xFF: no command sent by now + // 0: started, in progress + // 1: done and OK + // 2: done and error + + myStr.clear(); + myStr.append(QString::number(uctmp)); + label16->setText(myStr); + + + uctmp=HWaccess->log_getAnswerToLastSlaveRequest(); + // use only for ONE request/command + // return: 0xFF: result unknown by now as sending is ongoing + // 0=OK + // 1= wrong length 2=wrong start sign 5= wrong crc + // 6= slave: master cmd was wrong 7: slave: could not write/read data + // 8=timeout, got no response from slave + + myStr.clear(); + myStr.append(QString::number(uctmp)); + label17->setText(myStr); +*/ + + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + + + diff --git a/win06_prn.h b/win06_prn.h new file mode 100755 index 0000000..5d6d2e0 --- /dev/null +++ b/win06_prn.h @@ -0,0 +1,102 @@ +#ifndef WIN06_PRN_H +#define WIN06_PRN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win06 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QLabel *lab4; + QLabel *lab5; + QLabel *lab6; + QLabel *lab7; + QLabel *lab8; + QLabel *lab9; + QLabel *labSignal; + QLabel *lab15; + + QLabel *label16; + QLabel *label17; + + QTimer *myTO; + + QPushButton *butPrnPow; + + QLabel *showPrnState1; + QLabel *showPrnState2; + QLabel *showPrnResult; + + QComboBox * cb_templNr; + QComboBox * cb_kombiNr; + + QByteArray dummyText; + + +public: + explicit T_win06(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win06(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_sendDD1(void); + void slot_sendDD2(void); + void slot_rdBackDD(void); + void slot_printVaris(void); + void slot_printCombi(void); + void slot_printTicket(void); + void signalPrnDone(void); + void signalPrnErr(void); + void slot_powerButton(void); + + void slot_printLogo(void); + void slot_printAcc(void); + void slot_printCut(void); + + void slot_sendText(void); + void slot_setup(void); + void slot_movPap(void); + void slot_movBack(void); + void slot_fonts(void); + void slot_letters(void); + void slot_printQr(void); + + +}; + +#endif diff --git a/win07_coin.cpp b/win07_coin.cpp new file mode 100755 index 0000000..5eb67cc --- /dev/null +++ b/win07_coin.cpp @@ -0,0 +1,511 @@ +#include "win07_coin.h" + + + +T_win07::T_win07(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + myLayout = new QGridLayout; + + QFont myTabFont; + + // Überschrift + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *LAB_HEAD = new QLabel("Cash Devices"); + LAB_HEAD->setFont(myTabFont); + myLayout->addWidget(LAB_HEAD, 0,0); + QLabel *Led_empty = new QLabel(" "); + myLayout->addWidget(Led_empty, 0,2); + myLayout->addWidget(Led_empty, 0,5); + myLayout->addWidget(Led_empty, 6,0); + myLayout->addWidget(Led_empty, 8,0); + + + QLabel *ShutLab3 = new QLabel(tr(" MDB Bus")); + ShutLab3->setFont(myTabFont); + myLayout->addWidget(ShutLab3, 1,0); + + QLabel *ShutLab4 = new QLabel(tr("Coin Blocker")); + ShutLab4->setFont(myTabFont); + myLayout->addWidget(ShutLab4, 1,3); + + QLabel *ShutLab5 = new QLabel(tr("Coin Escrow")); + ShutLab5->setFont(myTabFont); + myLayout->addWidget(ShutLab5, 1,6); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + shut_PB1 = new QPushButton(" MDB\nPower"); + shut_PB1->setCheckable(true); // true = toggle button + shut_PB1->setAutoDefault(true); // beim start ein (weil mdb Spannung default EIN ist) + shut_PB1->setFont(myTabFont); + myLayout->addWidget(shut_PB1, 2,0); + connect(shut_PB1, SIGNAL(clicked()), this, SLOT(pbMdbPow())); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + labMdbPowDev = new QLabel("dev"); + labMdbPowDev->setFrameStyle(QFrame::Box | QFrame::Sunken); + labMdbPowDev->setLineWidth(3); // 1,2,3 + labMdbPowDev->setMaximumWidth(60); + labMdbPowDev->setStyleSheet("background-color: white"); // white red green + labMdbPowDev->setFont(myTabFont); + myLayout->addWidget(labMdbPowDev, 2,1); + + QLabel *ShutLab30 = new QLabel(tr(" MDB 5V\nalways on")); + ShutLab30->setFont(myTabFont); + myLayout->addWidget(ShutLab30, 3,0); + + labMdbPowBus = new QLabel("bus"); + labMdbPowBus->setFrameStyle(QFrame::Box | QFrame::Sunken); + labMdbPowBus->setLineWidth(3); // 1,2,3 + labMdbPowBus->setMaximumWidth(60); + labMdbPowBus->setStyleSheet("background-color: white"); // white red green + labMdbPowBus->setFont(myTabFont); + myLayout->addWidget(labMdbPowBus, 3,1); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + shut_PB2 = new QPushButton(" MDB wake\n out"); + shut_PB2->setCheckable(true); // true = toggle button + shut_PB2->setAutoDefault(true); // beim start ein + shut_PB2->setFont(myTabFont); + myLayout->addWidget(shut_PB2, 4,0); + connect(shut_PB2, SIGNAL(clicked()), this, SLOT(pbMdbWak())); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + labMdbWakIn = new QLabel("wake\n In"); + labMdbWakIn->setFrameStyle(QFrame::Box | QFrame::Sunken); + labMdbWakIn->setLineWidth(3); // 1,2,3 + labMdbWakIn->setMaximumWidth(60); + //labMdbWakIn->setMaximumHeight(60); + labMdbWakIn->setStyleSheet("background-color: white"); // white red green + labMdbWakIn->setFont(myTabFont); + myLayout->addWidget(labMdbWakIn, 4,1); + +/* motor dauerlauf nicht nötig + rejMot_PB5 = new QPushButton(" reject motor:"); + rejMot_PB5->setCheckable(true); // true = toggle button + rejMot_PB5->setAutoDefault(false); // beim start aus + rejMot_PB5->setStyleSheet("background-color: white"); + rejMot_PB5->setFont(myTabFont); + myLayout->addWidget(rejMot_PB5, 5,1); + connect(rejMot_PB5, SIGNAL(clicked()), this, SLOT(PB5clicked())); +*/ + + QLabel *empty2 = new QLabel(" "); + empty2->setFont(myTabFont); + myLayout->addWidget(empty2, 5,0); + + QLabel *rej_label = new QLabel("reject motor"); + rej_label->setFont(myTabFont); + myLayout->addWidget(rej_label, 6,0); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + QPushButton *rejMot_PB6 = new QPushButton(" Turn"); + rejMot_PB6->setCheckable(false); // true = toggle button + rejMot_PB6->setAutoDefault(false); // beim start aus + rejMot_PB6->setFont(myTabFont); + myLayout->addWidget(rejMot_PB6, 7,0); + connect(rejMot_PB6, SIGNAL(clicked()), this, SLOT(pbRejectTurn())); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + labRejSw = new QLabel(" "); + labRejSw->setFrameStyle(QFrame::Box | QFrame::Sunken); + labRejSw->setLineWidth(3); // 1,2,3 + labRejSw->setMaximumWidth(60); + labRejSw->setMaximumHeight(40); + labRejSw->setStyleSheet("background-color: white"); // white red green + labRejSw->setFont(myTabFont); + myLayout->addWidget(labRejSw, 7,1); + + // 2. Spalte + + // read Coin-Attached-Input + labBlockFree = new QLabel(" - "); + labBlockFree->setFrameStyle(QFrame::Box | QFrame::Sunken); + labBlockFree->setLineWidth(3); // 1,2,3 + labBlockFree->setMaximumWidth(80); + labBlockFree->setMaximumHeight(40); + labBlockFree->setStyleSheet("background-color: white"); + labBlockFree->setFont(myTabFont); + myLayout->addWidget(labBlockFree, 2,3); + + // readback Slot is Open (right from uC-output) + labSlotPower = new QLabel(""); + labSlotPower->setFrameStyle(QFrame::Box | QFrame::Sunken); + labSlotPower->setLineWidth(3); // 1,2,3 + labSlotPower->setMaximumWidth(25); + labSlotPower->setMaximumHeight(25); + labSlotPower->setStyleSheet("background-color: white"); + labSlotPower->setFont(myTabFont); + myLayout->addWidget(labSlotPower, 3,4); + + // coin blocker + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + Led_PB17 = new QPushButton("Open Slot\n"); + Led_PB17->setCheckable(true); // true = toggle button + Led_PB17->setAutoDefault(false); // beim start aus + Led_PB17->setFont(myTabFont); + myLayout->addWidget(Led_PB17, 3,3); + connect(Led_PB17, SIGNAL(clicked()), this, SLOT(pbShutOpen())); + + // Coin Blocker: open for 3s + QPushButton *Led_PB27 = new QPushButton("Open for 3s\n"); + Led_PB27->setCheckable(false); // true = toggle button + Led_PB27->setAutoDefault(false); // beim start aus + Led_PB27->setFont(myTabFont); + myLayout->addWidget(Led_PB27, 4,3); + connect(Led_PB27, SIGNAL(clicked()), this, SLOT(pbShut3s())); + + /* nicht nötig + QPushButton *Led_PB28 = new QPushButton("\nOpen 4 Coin\n"); + Led_PB28->setCheckable(true); // true = toggle button + Led_PB28->setAutoDefault(false); // beim start aus + Led_PB28->setFont(myTabFont); + myLayout->addWidget(Led_PB28, 4,3); + connect(Led_PB28, SIGNAL(clicked()), this, SLOT(PB28clicked())); + */ + + pb_ledas = new QPushButton("LED issue"); + pb_ledas->setCheckable(true); // true = toggle button + pb_ledas->setAutoDefault(false); // beim start aus + pb_ledas->setFont(myTabFont); + myLayout->addWidget(pb_ledas, 7,3); + connect(pb_ledas, SIGNAL(clicked()), this, SLOT(pbLEDclicked())); + + + + + // coin Escrow, 3. Spalte + myTabFont.setPixelSize(PIXELSIZE_LABEL); + labEscrowSw = new QLabel(" switch"); + labEscrowSw->setFrameStyle(QFrame::Box | QFrame::Sunken); + labEscrowSw->setLineWidth(3); // 1,2,3 + labEscrowSw->setStyleSheet("background-color: white"); + labEscrowSw->setFont(myTabFont); + myLayout->addWidget(labEscrowSw, 2,6); + + /* nicht nötig + Led_PB18 = new QPushButton("\nOpen Take"); + Led_PB18->setCheckable(true); // true = toggle button + Led_PB18->setAutoDefault(false); // beim start aus + Led_PB18->setFont(myTabFont); + myLayout->addWidget(Led_PB18, 3,6); + connect(Led_PB18, SIGNAL(clicked()), this, SLOT(PB18clicked())); + + Led_PB19 = new QPushButton("\nOpen Give"); + Led_PB19->setCheckable(true); // true = toggle button + Led_PB19->setAutoDefault(false); // beim start aus + Led_PB19->setFont(myTabFont); + myLayout->addWidget(Led_PB19, 4,6); + connect(Led_PB19, SIGNAL(clicked()), this, SLOT(PB19clicked())); + */ + + // Coin Escrow Level2: open flap for 1s + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + QPushButton *Led_PB30 = new QPushButton("\n Take Coins"); + Led_PB30->setCheckable(false); // true = toggle button + Led_PB30->setAutoDefault(false); // beim start aus + Led_PB30->setMinimumHeight(50); + Led_PB30->setFont(myTabFont); + myLayout->addWidget(Led_PB30, 3,6); + connect(Led_PB30, SIGNAL(clicked()), this, SLOT(pbEscrowTake())); + + // Coin Escrow Level2: open flap for 1s + QPushButton *Led_PB31 = new QPushButton("\nReturn Coins"); + Led_PB31->setCheckable(false); // true = toggle button + Led_PB31->setAutoDefault(false); // beim start aus + Led_PB31->setMinimumHeight(50); + Led_PB31->setFont(myTabFont); + myLayout->addWidget(Led_PB31, 4,6); + connect(Led_PB31, SIGNAL(clicked()), this, SLOT(pbEscrowRet())); + + + + + + // Barrier + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab_barr = new QLabel("Barrier"); + lab_barr->setFont(myTabFont); + myLayout->addWidget(lab_barr, 6,6); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + pb_relay = new QPushButton("Relais\nBarrier"); + pb_relay->setCheckable(true); // true = toggle button + pb_relay->setAutoDefault(false); // beim start aus + pb_relay->setFont(myTabFont); + myLayout->addWidget(pb_relay, 7,6); + connect(pb_relay, SIGNAL(clicked()), this, SLOT(pbRELclicked())); + + // Barrier INPUTs: + myTabFont.setPixelSize(PIXELSIZE_LABEL); + labBarOk = new QLabel(" OK "); + labBarOk->setFrameStyle(QFrame::Box | QFrame::Sunken); + labBarOk->setLineWidth(3); // 1,2,3 + labBarOk->setMaximumWidth(80); + labBarOk->setMaximumHeight(40); + labBarOk->setStyleSheet("background-color: white"); + labBarOk->setFont(myTabFont); + myLayout->addWidget(labBarOk, 6,8); + + labBarOpen = new QLabel(" open"); + labBarOpen->setFrameStyle(QFrame::Box | QFrame::Sunken); + labBarOpen->setLineWidth(3); // 1,2,3 + labBarOpen->setMaximumWidth(80); + labBarOpen->setMaximumHeight(40); + labBarOpen->setStyleSheet("background-color: white"); + labBarOpen->setFont(myTabFont); + myLayout->addWidget(labBarOpen, 7,8); + + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + + HWaccess->mdb_switchPower(1); + +} + +T_win07::~T_win07() +{ + close(); +} + +void T_win07::Nav_back(void) +{ + myNextStep=WCS_WIN07BAK; +} +void T_win07::Nav_home(void) +{ + myNextStep=WCS_WIN07MID; +} +void T_win07::Nav_next(void) +{ + myNextStep=WCS_WIN07FWD; +} + + +bool T_win07::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_win07::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; +/* + */ + + // U_device: + if (HWaccess->mdb_deviceVoltageOK()) // MDB12V + labMdbPowDev->setStyleSheet("background-color: green"); // white red green + else + labMdbPowDev->setStyleSheet("background-color: white"); // white red green + + if (HWaccess->mdb_busVoltageOk()) // =MDB-Bus-Pwr (5V), wird im DC auf 1 gehalten + labMdbPowBus->setStyleSheet("background-color: yellow"); // white red green + else + labMdbPowBus->setStyleSheet("background-color: white"); // white red green + + if (HWaccess->mdb_WakeINisActive()) + labMdbWakIn->setStyleSheet("background-color: yellow"); // white red green + else + labMdbWakIn->setStyleSheet("background-color: white"); // white red green + + if (HWaccess->cash_getRejectMotorHomePos()) + labRejSw->setStyleSheet("background-color: green"); + else + labRejSw->setStyleSheet("background-color: white"); + + // readback Coin Slot is Open (right from uC-output) + if (HWaccess->coin_shutterIsOpen()) + labSlotPower->setStyleSheet("background-color: green"); + else + labSlotPower->setStyleSheet("background-color: white"); + + // read Coin-Attached-Input + if (HWaccess->coid_isAttached()) + { + labBlockFree->setText("COIN"); + labBlockFree->setStyleSheet("background-color: green"); + } else + { + labBlockFree->setText("FREE"); + labBlockFree->setStyleSheet("background-color: white"); + } + // Coin Escrow Flap is Open + if (HWaccess->coin_escrowIsOpen()) + // retval: 1:return flap is open 2:take flap is open 0:closed + labEscrowSw->setStyleSheet("background-color: green"); + else + labEscrowSw->setStyleSheet("background-color: white"); + + // read OptoCouplers: + + if (HWaccess->bar_optoIn1isOn()) + labBarOk->setStyleSheet("background-color: yellow"); + else + labBarOk->setStyleSheet("background-color: white"); + + if (HWaccess->bar_optoIn2isOn()) + labBarOpen->setStyleSheet("background-color: yellow"); + else + labBarOpen->setStyleSheet("background-color: white"); + + + + /* + if (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } */ + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + +void T_win07::pbMdbPow(void) +{ + if (shut_PB1->isChecked()) + HWaccess->mdb_switchPower(1); + else + HWaccess->mdb_switchPower(0); + +} + +void T_win07::pbMdbWak(void) +{ + if (shut_PB2->isChecked()) + HWaccess->mdb_switchWake(1); + else + HWaccess->mdb_switchWake(0); + +} + +void T_win07::pbRejectTurn(void) +{ + HWaccess->coin_rejectCoins(); +} + +void T_win07::pbShutOpen(void) +{ + if (Led_PB17->isChecked()) + { + //qDebug()<<"main app 1"; + HWaccess->shut_move(1); + } else + { + //qDebug()<<"main app 0"; + + HWaccess->shut_move(0); + + } +} + + +void T_win07::pbShut3s(void) +{ + // coin shutter, open for shutter-time + HWaccess->shut_sendOpeningTime(3000); + HWaccess->shut_openOnce(); +} + +void T_win07::pbLEDclicked(void) +{ + if (pb_ledas->isChecked()) + HWaccess->led_switchLedPaper(1,0,0); + else + HWaccess->led_switchLedPaper(0,0,0); + +} + +void T_win07::pbEscrowTake(void) +{ + HWaccess->esc_takeMoney(); + +} + +void T_win07::pbEscrowRet(void) +{ + HWaccess->esc_returnMoney(); + +} + +void T_win07::pbRELclicked(void) +{ + // Relay (Barrier) + if (pb_relay->isChecked()) + HWaccess->bar_OpenBarrier(1); + else + HWaccess->bar_OpenBarrier(0); + +} + + diff --git a/win07_coin.h b/win07_coin.h new file mode 100755 index 0000000..c18ad9d --- /dev/null +++ b/win07_coin.h @@ -0,0 +1,86 @@ +#ifndef WIN07_COIN_H +#define WIN07_COIN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win07 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + + QLabel *labMdbPowDev; + QLabel *labMdbPowBus; + QLabel *labMdbWakIn; + QLabel *labRejSw; + QLabel *labBlockFree; + QLabel *labSlotPower; + QLabel *labEscrowSw; + QLabel *labBarOpen; + QLabel *labBarOk; + + QPushButton *shut_PB1; + QPushButton *shut_PB2; + QPushButton *Led_PB17; + QPushButton *pb_ledas; + QPushButton *pb_relay; + + + + + + +public: + explicit T_win07(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win07(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void pbMdbPow(void); + void pbMdbWak(void); + void pbRejectTurn(void); + void pbShutOpen(void); + void pbShut3s(void); + void pbLEDclicked(void); + void pbEscrowTake(void); + void pbEscrowRet(void); + void pbRELclicked(void); + +}; + +#endif diff --git a/win08_mif.cpp b/win08_mif.cpp new file mode 100755 index 0000000..80fd747 --- /dev/null +++ b/win08_mif.cpp @@ -0,0 +1,423 @@ +#include "win08_mif.h" + + + +T_win08::T_win08(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(18); +/* + lab1 =new QLabel(tr("Mifare Card\n Reader")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,0,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,1); +*/ + pbMifPwr = new QPushButton("Power"); + pbMifPwr->setCheckable(true); // true = toggle button + pbMifPwr->setAutoDefault(false); // beim start aus + pbMifPwr->setFont(myTabFont); + pbMifPwr->setStyleSheet("background-color: white"); + myLayout->addWidget(pbMifPwr, 2, 4); + connect(pbMifPwr, SIGNAL(clicked()), this, SLOT(pbMifPower())); + + QLabel *lab3 =new QLabel("Mifare Card\n Reader"); +// QLabel *lab3 =new QLabel(tr("Reader State:")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,2,0); + + myTabFont.setPixelSize(18); + labReaderState =new QLabel(); //QListWidget(); + labReaderState->setFont(myTabFont); + //labReaderState->setMinimumWidth(300); + //labReaderState->setMinimumHeight(150); + labReaderState->setLineWidth(3); // 1,2,3 + labReaderState->setStyleSheet("background-color: white"); + labReaderState->setFont(myTabFont); + myLayout->addWidget(labReaderState,2,2); + + myTabFont.setPixelSize(18); + QLabel *lab6 =new QLabel(tr("Card tapped?")); + lab6->setFont(myTabFont); + myLayout->addWidget(lab6,4,0); + + labCardTap =new QLabel(tr(" ")); + labCardTap->setFont(myTabFont); + labCardTap->setMinimumWidth(300); + labCardTap->setLineWidth(3); // 1,2,3 + labCardTap->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardTap,4,2); + + + QLabel *lab4 =new QLabel(tr("Card ID: ")); + lab4->setFont(myTabFont); + myLayout->addWidget(lab4,6,0); + + labCardUid =new QLabel(" "); + labCardUid->setFont(myTabFont); + labCardUid->setMinimumWidth(300); + labCardUid->setLineWidth(3); // 1,2,3 + labCardUid->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardUid,6,2); + + + + QLabel *lab10 =new QLabel(tr(" card size: ")); + lab10->setFont(myTabFont); + myLayout->addWidget(lab10,8,0); + + labCardSiz =new QLabel(" "); + labCardSiz->setFont(myTabFont); + labCardSiz->setMinimumWidth(300); + labCardSiz->setLineWidth(3); // 1,2,3 + labCardSiz->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardSiz,8,2); + + + QLabel *lab11 =new QLabel(tr("ATBcard CuNu: ")); + lab11->setFont(myTabFont); + myLayout->addWidget(lab11,10,0); + + labCardCunu =new QLabel(" "); + labCardCunu->setFont(myTabFont); + labCardCunu->setMinimumWidth(300); + labCardCunu->setLineWidth(3); // 1,2,3 + labCardCunu->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardCunu,10,2); + + // kind of card and card valid: + QLabel *lab12 =new QLabel(tr("ATB Type\n and validty: ")); + lab12->setFont(myTabFont); + myLayout->addWidget(lab12,12,0); + + labCardValid =new QLabel(" "); + labCardValid->setFont(myTabFont); + labCardValid->setMinimumWidth(300); + labCardValid->setLineWidth(3); // 1,2,3 + labCardValid->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardValid,12,2); + + + QLabel *lab13 =new QLabel(tr("personal code:")); + lab13->setFont(myTabFont); + myLayout->addWidget(lab13,14,0); + + labCardPerso =new QLabel(" "); + labCardPerso->setFont(myTabFont); + labCardPerso->setMinimumWidth(300); + labCardPerso->setLineWidth(3); // 1,2,3 + labCardPerso->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardPerso,14,2); + + + QLabel *lab14 =new QLabel(tr("expire time:")); + lab14->setFont(myTabFont); + myLayout->addWidget(lab14,16,0); + + labCardExpire =new QLabel(" "); + labCardExpire->setFont(myTabFont); + labCardExpire->setMinimumWidth(300); + labCardExpire->setLineWidth(3); // 1,2,3 + labCardExpire->setStyleSheet("background-color: white"); + myLayout->addWidget(labCardExpire,16,2); + + + /* + QLabel *lab5 =new QLabel(tr("Seg.0 binary:")); + lab5->setFont(myTabFont); + myLayout->addWidget(lab5,8,0); + + myTabFont.setPixelSize(16); + dispCardData =new QListWidget(); + dispCardData->setFont(myTabFont); + dispCardData->setMinimumWidth(300); + dispCardData->setLineWidth(3); // 1,2,3 + dispCardData->setStyleSheet("background-color: white"); + myLayout->addWidget(dispCardData,8,2); + + QLabel *lab7 =new QLabel(tr("ATB Card Data:")); + lab7->setFont(myTabFont); + myLayout->addWidget(lab7,9,0); + + myTabFont.setPixelSize(16); + dispATBdata =new QListWidget(); + dispATBdata->setFont(myTabFont); + dispATBdata->setMinimumWidth(300); + dispATBdata->setLineWidth(3); // 1,2,3 + dispATBdata->setStyleSheet("background-color: white"); + myLayout->addWidget(dispATBdata,9,2); +*/ +/* + pbMiftest = new QPushButton(" TEST"); + pbMiftest->setCheckable(false); // true = toggle button + pbMiftest->setAutoDefault(false); // beim start aus + pbMiftest->setFont(myTabFont); + pbMiftest->setStyleSheet("background-color: white"); + myLayout->addWidget(pbMiftest, 9, 4); + connect(pbMiftest, SIGNAL(clicked()), this, SLOT(pbMifTest())); +*/ + + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win08::~T_win08() +{ + close(); +} + +void T_win08::pbMifPower(void) +{ + if (pbMifPwr->isChecked()) + { + HWaccess->mif_readerOn(1); + } else + HWaccess->mif_readerOn(0); +} + +//void T_win08::pbMifTest(void) +//{ + +// HWaccess->prn_sendPrnSysCmd(0x12, 0x34, 0x56789012); + +//} + +void T_win08::Nav_back(void) +{ + myNextStep=WCS_WIN08BAK; +} +void T_win08::Nav_home(void) +{ + myNextStep=WCS_WIN08MID; +} +void T_win08::Nav_next(void) +{ + myNextStep=WCS_WIN08FWD; +} + + +static UCHAR sendingOrder; + +bool T_win08::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; + sendingOrder=0; + return false; +} + +bool T_win08::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 mifData[66]; + QString myStr; + //char myChr; + + *nextScreen=0; // 0=no change + *useNavi=0; + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + + // Power Taste + if (HWaccess->mif_isMifarePowerOn()) + { + pbMifPwr->setStyleSheet("background-color: green"); + } else + { + pbMifPwr->setStyleSheet("background-color: white"); + labReaderState->clear(); + labCardTap->clear(); + labCardUid->clear(); + //dispCardData->clear(); + //dispATBdata->clear(); + labCardTap->setStyleSheet("background-color: white"); + labCardSiz->clear(); + labCardCunu->clear(); + labCardValid->clear(); + labCardPerso->clear(); + labCardExpire->clear(); + return 0; + } + + struct T_moduleCondition myDevCond; + HWaccess->sys_getDeviceConditions(&myDevCond); + uint8_t readerState=myDevCond.mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error + + // request Mifare data. As we need all this data just for test it's not requested automatically + sendingOrder++; // inc every 100ms + if (sendingOrder==10) + sendingOrder=1; + else if (sendingOrder==2) + HWaccess->request_MifareID(); + else if (sendingOrder==6) + HWaccess->request_MifareAtbType(); + + switch (readerState) + { + case 0: labReaderState->setText(" state unknown"); break; + case 1: labReaderState->setText(" reader OK"); break; + case 200: labReaderState->setText(" no response from reader"); break; + case 201: labReaderState->setText(" wrong response from reader"); break; + case 202: labReaderState->setText(" reader HW error"); break; + } + + if (HWaccess->mif_readerIsOK()) + { + labReaderState->setStyleSheet("background-color: green"); + } else + { + labReaderState->setStyleSheet("background-color: red"); + labCardUid->clear(); + labCardTap->clear(); + //dispCardData->clear(); + //dispATBdata->clear(); + labCardSiz->clear(); + labCardCunu->clear(); + labCardValid->clear(); + labCardPerso->clear(); + labCardExpire->clear(); + + } + + if (readerState==1) + { +// myStr.clear(); +// myStr.append(" reader OK, Type="); // besser nicht anzeigen, gefaerdet Ersatzteil-business +// myStr.append(HWaccess->mif_getReaderType()); +// labReaderState->setText(myStr); + // Type anzeigen + } else + { + labCardTap->clear(); + labCardTap->setStyleSheet("background-color: white"); + labCardUid->clear(); + //dispCardData->clear(); + //dispATBdata->clear(); + labCardSiz->clear(); + labCardCunu->clear(); + labCardValid->clear(); + labCardPerso->clear(); + labCardExpire->clear(); + + return 0; + } + + // Card-attached? + if (HWaccess->mif_cardIsAttached()) + { + labCardTap->setText(" CARD attached"); + + if (HWaccess->mif_readResult()>0) + labCardTap->setStyleSheet("background-color: green"); + else + labCardTap->setStyleSheet("background-color: yellow"); + + } else + { + labCardTap->setText("-no card-"); + labCardTap->setStyleSheet("background-color: white"); + labCardUid->clear(); + //dispCardData->clear(); + labCardUid->clear(); + //dispATBdata->clear(); + labCardSiz->clear(); + labCardCunu->clear(); + labCardValid->clear(); + labCardPerso->clear(); + labCardExpire->clear(); + return false; + } + + labCardUid->setText(HWaccess->mif_cardUID()); + + uint8_t cardSize, idLeng; + + HWaccess->mif_getCardSize(&cardSize, &idLeng); + //cardSize=1k or 4kByte idLeng =4Byte or 7 byte + myStr.clear(); + myStr.append(" memSize: "); + myStr.append(QString::number(cardSize,10)); + myStr.append(" length_of_ID: "); + myStr.append(QString::number(idLeng)); + myStr.append(" byte"); + labCardSiz->setText(myStr); + + labCardCunu->setText(QString::number(HWaccess->mif_getAtbCardCuNu())); + + if (HWaccess->mif_isValidAtbCard()) + { + labCardValid->setStyleSheet("background-color: green"); + } else + { + labCardValid->setStyleSheet("background-color: yellow"); + } + + uint8_t ret=HWaccess->mif_getAtbCardTyp(); + // return 1=upper door card 1=lower door 3=printer-test 4=coin-test + // 0: not a valid atb2020 card + switch (ret) + { + case 1: labCardValid->setText(" upper door "); break; + case 2: labCardValid->setText(" lower door "); break; + case 3: labCardValid->setText(" printer test"); break; + case 4: labCardValid->setText(" coin test "); break; + default: labCardValid->setText(" --- no atb card ---"); break; + } + + labCardPerso->setText(HWaccess->mif_getAtbCardPerso()); + + uint8_t year, month, day, hour, minute; + HWaccess->mif_getAtbCardExpire(&year, &month, &day, &hour, &minute); + //mif_getAtbCardExpire(uint8_t *year, uint8_t *month, uint8_t *day, uint8_t *hour, uint8_t *minute) + myStr.clear(); + myStr.append(" expires at (d.m.y h:m): "); + myStr.append(QString::number(day,10)); + myStr.append("."); + myStr.append(QString::number(month,10)); + myStr.append("."); + myStr.append(QString::number(year,10)); + myStr.append(" "); + myStr.append(QString::number(hour,10)); + myStr.append(":"); + myStr.append(QString::number(minute,10)); + labCardExpire->setText(myStr); + + return false; +} + + + + diff --git a/win08_mif.h b/win08_mif.h new file mode 100755 index 0000000..9ba2062 --- /dev/null +++ b/win08_mif.h @@ -0,0 +1,69 @@ +#ifndef WIN08_MIF_H +#define WIN08_MIF_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include +#include "guidefs.h" + +class T_win08 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + + QPushButton *pbMifPwr; //, *pbMiftest; + QLabel *labCardTap; +// QListWidget *labReaderState; + QLabel *labReaderState; + + QLabel *labCardUid; +// QListWidget *dispCardData, *dispATBdata; + QLabel *labCardSiz, *labCardCunu, *labCardValid, *labCardPerso, *labCardExpire; + + +public: + explicit T_win08(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win08(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void pbMifPower(void); + //void pbMifTest(void); + +}; + +#endif diff --git a/win09_gsm.cpp b/win09_gsm.cpp new file mode 100755 index 0000000..a96b8e4 --- /dev/null +++ b/win09_gsm.cpp @@ -0,0 +1,308 @@ +#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(false); // 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())); + + + 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); + } else + HWaccess->credit_switchPower(false); +} + +void T_win09::slot_CreditWake(void) +{ + HWaccess->credit_switchWake(true); + myTO->start(200); + 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); + 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 + pbCreditPwr->setStyleSheet("background-color: white"); + + bret=HWaccess->cred_isCreditPowerOn(); + 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; +} + + diff --git a/win09_gsm.h b/win09_gsm.h new file mode 100755 index 0000000..378c046 --- /dev/null +++ b/win09_gsm.h @@ -0,0 +1,64 @@ +#ifndef WIN09_GSM_H +#define WIN09_GSM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win09 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1, *lab2, *lab3, *lab4, *lab5, *lab6, *lab7, *lab8, *lab9, *lab10, *lab11; + QTimer *myTO; + + QPushButton *pbModemPwr, *pbModemWake, *pbCreditPwr, *pbCreditWake, *pbModemRes; + QLabel *showModemCondition; + + +public: + explicit T_win09(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win09(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_ModemPower(void); + void slot_ModemWake(void); + void slot_CreditPower(void); + void slot_CreditWake(void); + void slot_startTest(void); + void slot_ModemRes(void); + +}; + +#endif diff --git a/win10_pay.cpp b/win10_pay.cpp new file mode 100755 index 0000000..e76cd75 --- /dev/null +++ b/win10_pay.cpp @@ -0,0 +1,609 @@ +#include "win10_pay.h" + +#define TIME_DISPLAY_SIGNALS_MS 2000 + +static uint8_t win10_paymentStarted; +static uint32_t win10_value; + +T_win10::T_win10(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(PIXELSIZE_LABEL); + + lab1 =new QLabel(tr("Testing Payment")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + QLabel *labs2 =new QLabel(tr(" ")); + labs2->setFont(myTabFont); + myLayout->addWidget(labs2,1,1); + +// QLabel *labs3 =new QLabel(tr(" ")); +// labs3->setFont(myTabFont); +// myLayout->addWidget(labs3,1,2); + + QLabel *labs4 =new QLabel(tr(" ")); + labs4->setFont(myTabFont); + myLayout->addWidget(labs4,1,3); + + QLabel *labs5 =new QLabel(tr(" ")); + labs5->setFont(myTabFont); + myLayout->addWidget(labs5,1,4); + + +// lab2 =new QLabel(tr(" ")); +// lab2->setFont(myTabFont); +// myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr("Amount in cent:")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + insertedCoin = new QLineEdit(); + insertedCoin->setMaxLength(10); + insertedCoin->setFrame(true); + insertedCoin->setText("-"); + insertedCoin->setReadOnly(true); + insertedCoin->setFont(myTabFont); + insertedCoin->setMaxLength(100); + insertedCoin->setStyleSheet("background-color: white"); + myLayout->addWidget(insertedCoin,3,1); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab4 =new QLabel(tr("inserted total: ")); + lab4->setFont(myTabFont); + myLayout->addWidget(lab4,4,0); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + insertedTotal = new QLineEdit(); + insertedTotal->setMaxLength(10); + insertedTotal->setFrame(true); + insertedTotal->setText("-"); + insertedTotal->setReadOnly(true); + insertedTotal->setFont(myTabFont); + insertedTotal->setMaxLength(100); + insertedTotal->setStyleSheet("background-color: white"); + myLayout->addWidget(insertedTotal,4,1); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab8 =new QLabel(tr("inserted: ")); + lab8->setFont(myTabFont); + myLayout->addWidget(lab8,5,0); + + // display ALL inserted coins: + myTabFont.setPixelSize(PIXELSIZE_DATA); + allCoins = new QListWidget; + allCoins->setFont(myTabFont); + allCoins->setMinimumHeight(100); + myLayout->addWidget(allCoins,5,1); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab5 =new QLabel(tr("Amount to pay:")); + lab5->setFont(myTabFont); + myLayout->addWidget(lab5,6,0); + + + + myKeypad = new T_keypad(); + myLayout->addWidget(myKeypad,5,1); + connect(myKeypad, SIGNAL(keyEntryFinished()), this, SLOT(valueIsSet())); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + pb_enterPrice = new QPushButton("click to select"); + pb_enterPrice->setFont(myTabFont); + myLayout->addWidget(pb_enterPrice,6,1); + //pb_enterPrice->setText("0"); + connect(pb_enterPrice, SIGNAL(clicked()), this, SLOT(Button_enterPriceClicked())); + + pb_statPay = new QPushButton("START\n"); + pb_statPay->setFont(myTabFont); + myLayout->addWidget(pb_statPay,6,2); + connect(pb_statPay, SIGNAL(clicked()), this, SLOT(ButtonStartClicked())); + + pb_stopPay = new QPushButton("STOP\n Pay"); + pb_stopPay->setFont(myTabFont); + myLayout->addWidget(pb_stopPay,8,0); + connect(pb_stopPay, SIGNAL(clicked()), this, SLOT(ButtonStopClicked())); + + pb_cancelPay = new QPushButton("CANCEL\n Pay"); + pb_cancelPay->setFont(myTabFont); + myLayout->addWidget(pb_cancelPay,8,1); + connect(pb_cancelPay, SIGNAL(clicked()), this, SLOT(ButtonCancelClicked())); + + pb_vendSucc = new QPushButton(" VEND\nsuccess"); + pb_vendSucc->setFont(myTabFont); + myLayout->addWidget(pb_vendSucc,8,2); + connect(pb_vendSucc, SIGNAL(clicked()), this, SLOT(ButtonSuccClicked())); + + pb_vendFail = new QPushButton(" VEND\nfailed"); + pb_vendFail->setFont(myTabFont); + myLayout->addWidget(pb_vendFail,8,3); + connect(pb_vendFail, SIGNAL(clicked()), this, SLOT(ButtonFailClicked())); + + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab7 =new QLabel(tr(" ")); + lab7->setFont(myTabFont); + myLayout->addWidget(lab7,9,0); + + // rechts oben, zeige Bezahlstatus: + QLabel *lab8 =new QLabel(tr("pay state:")); + lab8->setFont(myTabFont); + myLayout->addWidget(lab8,3,2); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + coinPayState = new QLineEdit(); + coinPayState->setFrame(true); + coinPayState->setText(" "); + coinPayState->setReadOnly(true); + coinPayState->setFont(myTabFont); + //coinPayState->setMaxLength(100); + myLayout->addWidget(coinPayState,3,3); + coinPayState->setStyleSheet("background-color: white"); + // "background-color: white" "background-color: yellow" + // "background-color: rgb(150,230,150)"); // hell grün + // "background-color: rgb(250,150,150)"); // hell rot + + // darunter Signale anzeigen: + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab9 =new QLabel(tr("last Signal:")); + lab9->setFont(myTabFont); + myLayout->addWidget(lab9,4,2); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + coinPaySignals = new QLineEdit(); + coinPaySignals->setFrame(true); + coinPaySignals->setText(" "); + coinPaySignals->setReadOnly(true); + coinPaySignals->setFont(myTabFont); + coinPaySignals->setStyleSheet("background-color: white"); + myLayout->addWidget(coinPaySignals,4,3); + + empState = new QListWidget; + empState->setFont(myTabFont); + myLayout->addWidget(empState,5,3); + + setLayout(myLayout); + myNextStep=0; + myStep=99; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + + timerClrDisp = new QTimer(); + timerClrDisp->setSingleShot(true); + //timerClrDisp->start(1000); + connect(timerClrDisp, SIGNAL(timeout()), this, SLOT(win10_slotClrSig())); + + // Eingangssignal auf QObject casten, weil hwinf kein QObject ist + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_gotNewCoin()), this, SLOT(signalGotNewCoin())); + + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinCollectionJustStarted()), this, SLOT(signalJustStarted())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinCollectionAborted()), this, SLOT(signalCollectAbort())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByMax()), this, SLOT(signalStopByMax())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByPushbutton()), this, SLOT(signalStopByUser())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByEscrow()), this, SLOT(signalStopByEscrow())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByError()), this, SLOT(signalStopByError())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByTimeout()), this, SLOT(signalStopTO())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payCancelled()), this, SLOT(signalCancelled())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinProcessJustStopped()), this, SLOT(signalProcessStop())); + + win10_paymentStarted=0; + + win10_value=0; +} + +void T_win10::addDigit2Val(uint8_t digi) +{ + QString myStr; + + win10_value*=10; + win10_value+=digi; + myStr.clear(); + myStr.append(QString::number(win10_value)); + startAmount->setText(myStr); +} + +T_win10::~T_win10() +{ + close(); +} + +void T_win10::Nav_back(void) +{ + myNextStep=WCS_WIN10BAK; +} +void T_win10::Nav_home(void) +{ + myNextStep=WCS_WIN10MID; +} +void T_win10::Nav_next(void) +{ + myNextStep=WCS_WIN10FWD; +} + + +void T_win10::Button_enterPriceClicked(void) +{ + myKeypad->show(); +} + +void T_win10::ButtonStartClicked() +{ + QString myStr, tmpStr; + uint32_t val; + + myStr.clear(); + tmpStr.clear(); + insertedCoin->clear(); + insertedTotal->clear(); + allCoins->clear(); + //myStr=startAmount->text(); + myStr=pb_enterPrice->text(); + val=myStr.toULong(); + //tmpStr.append(QString::number(uitmp)); + //qDebug()<<"from box: " << myStr << " dec: " << val; + HWaccess->cash_startPayment(val); + + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText("starting..."); + win10_paymentStarted=1; + +} + +void T_win10::ButtonStopClicked() +{ + HWaccess->cash_stopPayment(); + coinPayState->setStyleSheet("background-color: yellow"); + coinPayState->setText(" "); +} + +void T_win10::ButtonCancelClicked() +{ + HWaccess->cash_cancelPayment(); + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} + +void T_win10::ButtonSuccClicked() +{ + HWaccess->vend_success(); + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); + +} + +void T_win10::ButtonFailClicked() +{ + HWaccess->vend_failed(); + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} + +void T_win10::signalGotNewCoin() +{ + uint32_t ultmp; + QString myStr; + uint16_t types[66], values[66]; + int nn; + +//qDebug()<<"signal got new coin"; + + myStr.clear(); + ultmp=HWaccess->getLastInsertedCoin(); + //if (ultmp>0 && ultmp<1000) + { + myStr.append(QString::number(ultmp)); + insertedCoin->setText(myStr); + } + +//qDebug()<getInsertedAmount(); + //if (ultmp>0 && ultmp<65000) + { + myStr.append(QString::number(ultmp)); + insertedTotal->setText(myStr); + } +//qDebug()<getAllInsertedCoins(types, values); + // all inserted coins (max 64) since "cash_startPayment" + allCoins->clear(); + nn=0; + do + { + myStr.clear(); + if (types[nn]>0 && values[nn]>0) + { + myStr.append("Index: "); + myStr.append(QString::number(nn)); + myStr.append(" Type: "); + myStr.append(QString::number(types[nn])); + myStr.append(" Val: "); + myStr.append(QString::number(values[nn])); + allCoins->addItem(myStr); + } + } while (++nn<64); + + coinPaySignals->setText("got new coin "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen +} + +void T_win10::signalJustStarted() +{ + coinPaySignals->setText("just started "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + + coinPayState->setStyleSheet("background-color: green"); + coinPayState->setText("insert coins...."); + +} + +void T_win10::signalCollectAbort() +{ + coinPaySignals->setText("collect aborted "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); + +} + +void T_win10::signalStopByMax() +{ + coinPaySignals->setText("stopped by max "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: yellow"); + coinPayState->setText(" "); +} + +void T_win10::signalStopByUser() +{ + coinPaySignals->setText("stopped by user "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: yellow"); + coinPayState->setText(" "); +} + +void T_win10::signalStopByEscrow() +{ + coinPaySignals->setText("STOPPED BY ESCROW "); + timerClrDisp->start(1000); // wieder loeschen + coinPayState->setStyleSheet("background-color: yellow"); + coinPayState->setText(" "); +} + +void T_win10::signalStopByError() +{ + coinPaySignals->setText("stopped by error "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} +void T_win10::signalStopTO() +{ + coinPaySignals->setText("stopped by TO "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} + +void T_win10::signalCancelled() +{ + coinPaySignals->setText("canncelled "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} + +void T_win10::signalProcessStop() +{ + coinPaySignals->setText("processing stopped "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen + coinPayState->setStyleSheet("background-color: white"); + coinPayState->setText(" "); +} + +void T_win10::win10_slotClrSig() +{ + coinPaySignals->setText(" "); + timerClrDisp->start(TIME_DISPLAY_SIGNALS_MS); // wieder loeschen +} + +void T_win10::valueIsSet(void) +{ + pb_enterPrice->setText( myKeypad->getValueString() ); +} + + +void T_win10::pay_slotClrSig(void) +{ + coinPaySignals->clear(); +} + + +bool T_win10::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; +} + +#define SENDINGGRID_MS 300 + + +//itmp=globVar_GetCoinChecker(); + + +bool T_win10::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; + struct T_emp empStat; + struct T_dynamicCondition myDynMachCond; + //uint8_t prbuf[66]; + + myStr.clear(); + *nextScreen=0; // 0=no change + *useNavi=0; + + //myStr=startAmount->text(); + + HWaccess->emp_getAllParameters(&empStat); +/* +struct T_emp +{ + + // Fixdata from EMP: + uint8_t shaft; // = changer level + uint16_t countryCode; + uint8_t scale; + uint8_t decimals; + uint8_t coinValues[16]; + uint16_t routing; + + // Master specs: + uint8_t gotSetup; // 1: got specifications from master 0: no specs + uint16_t coinAccept; // bit 0 = coin1 bit H=accept + uint8_t tokenChannel; + uint16_t denomination[16]; + + // dynamic: + uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine): + // 0=Emp & Bus power off, 1=powered, poll off 2=polling on + // 3=device responded, requesting status + // 4=waiting for status 5=have status, + // 6: IDLE, have paramters from master, polling running, ready for payment + // Master can stop/start polling and acceptance + // 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin) + // 8: transaction running, polling on, acceptance on, reporting coins, + + uint8_t pollingRunning; + uint8_t paymentRunning; + +}; +*/ + empState->clear(); + myStr.clear(); + myStr.append("EMP State: "); + myStr.append(QString::number(empStat.state)); + empState->addItem(myStr); + + myStr.clear(); + myStr.append("polling: "); + myStr.append(QString::number(empStat.pollingRunning)); + empState->addItem(myStr); + + myStr.clear(); + myStr.append("pay active: "); + myStr.append(QString::number(empStat.paymentRunning)); + empState->addItem(myStr); + + HWaccess->sys_getDynMachineConditions(&myDynMachCond); + + myStr.clear(); + myStr.append("paym. in progress: "); + myStr.append(QString::number(myDynMachCond.paymentInProgress)); + empState->addItem(myStr); + + + uint8_t curStat; + curStat = HWaccess->cash_paymentProcessing(); + // return value: + // 0: stopped 1: starting up 2: coin collection + // 3: finished by User (Push button) 4: finished, Max-Value collected + // 5: finished by escrow + // 6: money encashed + // 7: cancelled + // 10,11: error cannot start + // 12: timeout while payment, coins returned + // 13: stopped by unexpected error + + myStr.clear(); + myStr.append("paym.Processing: "); + myStr.append(QString::number(curStat)); + empState->addItem(myStr); + + myStr.clear(); + myStr.append("paym.Started: "); + myStr.append(QString::number(win10_paymentStarted)); + empState->addItem(myStr); + + if (win10_paymentStarted==1) + { +/* + if (curStat<2 || curStat==6 || curStat==7) + coinPayState->setStyleSheet("background-color: white"); + else + if (curStat==2) + coinPayState->setStyleSheet("background-color: rgb(150,230,150)"); // hell grün + // "background-color: white" "background-color: yellow" + // "background-color: rgb(150,230,150)"); // hell grün + // "background-color: rgb(250,150,150)"); // hell rot + else + if (curStat>=3 && curStat<=5) + coinPayState->setStyleSheet("background-color: yellow"); + else + if (curStat>=10) + coinPayState->setStyleSheet("background-color: rgb(250,150,150)"); // hell rot + + switch (curStat) + { + case 1: //coinPayState->setText("starting..."); break; + //coinPayState->clear(); + break; + case 2: coinPayState->setText("wait for coins"); break; + case 3: coinPayState->setText("finished by user"); break; + case 4: coinPayState->setText("got full amount"); break; + case 5: coinPayState->setText("escrow full"); break; + case 7: coinPayState->setText("cancelled"); break; + + case 10: coinPayState->setText("Hardware error"); break; + case 11: coinPayState->setText("cannot start"); break; + case 12: coinPayState->setText("timeout"); break; + case 13: coinPayState->setText("unknown error"); break; + } +*/ + if (curStat==0) + win10_paymentStarted++; // nur 1x anzeigen + + } + + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + + + + diff --git a/win10_pay.h b/win10_pay.h new file mode 100755 index 0000000..7469922 --- /dev/null +++ b/win10_pay.h @@ -0,0 +1,105 @@ +#ifndef WIN10_PAY_H +#define WIN10_PAY_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "keypad.h" +#include "guidefs.h" + + +class T_win10 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QLabel *lab4; + QLabel *lab5; + QLabel *lab6; + QLabel *lab7; + QLabel *lab8; + QLabel *lab9; + QTimer *myTO; + QTimer *timerClrDisp; + QLineEdit *startAmount; + QLineEdit *insertedTotal; + QLineEdit *insertedCoin; + QLineEdit *coinPayState; + QLineEdit *coinPaySignals; + QListWidget *allCoins; + QPushButton *pb_statPay; + QPushButton *pb_stopPay; + QPushButton *pb_cancelPay; + QPushButton *pb_vendSucc; + QPushButton *pb_vendFail; + QListWidget *empState; + QGroupBox *numPad; + //void drawNumPad(void); + QPushButton *pb_enterPrice; + + T_keypad *myKeypad; + +public: + explicit T_win10(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win10(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void ButtonStartClicked(); + + void ButtonStopClicked(); + void ButtonCancelClicked(); + void ButtonSuccClicked(); + void ButtonFailClicked(); + void signalGotNewCoin(); + void signalJustStarted(); + void signalCollectAbort(); + void signalStopByMax(); + void signalStopByUser(); + void signalStopByEscrow(); + void signalStopByError(); + void signalStopTO() ; + void signalCancelled() ; + void signalProcessStop(); + void win10_slotClrSig(); + void addDigit2Val(uint8_t digi); + void Button_enterPriceClicked(void); + void valueIsSet(void); + void pay_slotClrSig(void); + +}; + +#endif diff --git a/win11_abr.cpp b/win11_abr.cpp new file mode 100755 index 0000000..97893fd --- /dev/null +++ b/win11_abr.cpp @@ -0,0 +1,663 @@ +#include "win11_abr.h" + +#define BUTTONCOLOR0 "background-color: white" +#define BUTTONCOLORWAIT "background-color: yellow" +#define BUTTONCOLORGOT "background-color: green" +#define BUTTONCOLORBAD "background-color: red" +#define BUTTONCOLORGOOD "background-color: green" + +static char updateList, wait4data; +static uint8_t pwreq; +/* + void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const override; + // returns all acc nrs of the backuped vault records + // use: uint16_t backupedAccNumbers[8] + // will be requested automatically + + bool log_selectVaultRecord(uint16_t accountNr ) const override; + // return true if sending, false if cmd-stack is full + // and trigger transfer + + bool log_chkIfVaultRecordAvailable(void) const override; + // return true if completly received + + bool log_getVaultRecord(struct T_vaultRecord *retVR) const override; + // which was selected by: log_selectVaultRecord() + // to be forwarded to Ismas + + bool prn_printAccountReceipt(void) const override; + // return true if sending to DC OK, false if cmd-stack is full + +*/ + +T_win11::T_win11(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + //myLayout = new QGridLayout; + mainHLayout = new QHBoxLayout; + leftLayout = new QVBoxLayout; + RightLayout = new QVBoxLayout; + + + QFont myTabFont; + myTabFont.setPixelSize(20); + +// availAccNrList.append("1"); +// availAccNrList.append("2"); +// availAccNrList.append("3"); +// availAccNrList.append("4"); +// availAccNrList.append("5"); +// availAccNrList.append("6"); +// availAccNrList.append("7"); +// availAccNrList.append("8"); + availAccNrList.clear(); + + // left side: big ListWindow to show accounting record + + but2 = new QPushButton(" Load Data"); + leftLayout->addWidget(but2); + connect(but2, SIGNAL(clicked()), this, SLOT(slot_loadData())); + but2->setStyleSheet(BUTTONCOLOR0); // BUTTONCOLORWAIT BUTTONCOLORGOT + but2->setFont(myTabFont); + + QLabel *lab1 =new QLabel("accounting data:"); + leftLayout->addWidget(lab1); + lab1->setFont(myTabFont); + + myTabFont.setPixelSize(16); + win11_showVaultRecord = new QListWidget; + win11_showVaultRecord->setFont(myTabFont); + //win11_showVaultRecord->setMinimumHeight(200); + win11_showVaultRecord->setMinimumWidth(500); + leftLayout->addWidget(win11_showVaultRecord); + //win11_showVaultRecord->addItem("data 123"); + win11_showVaultRecord->setLineWidth(3); + + + + // right side: + myTabFont.setPixelSize(20); + but1 = new QPushButton(" Reload Acc. Nrs"); + RightLayout->addWidget(but1); + connect(but1, SIGNAL(clicked()), this, SLOT(slot_loadNumbers())); + but1->setFont(myTabFont); + but1->setStyleSheet(BUTTONCOLOR0); // BUTTONCOLORWAIT BUTTONCOLORGOT + + //QLabel *lab6 =new QLabel(" "); + //RightLayout->addWidget(lab6); + + QLabel *lab4 =new QLabel("select Acc. Nr.:"); + RightLayout->addWidget(lab4); + lab4->setFont(myTabFont); + + QFont myCBfont; + myCBfont.setPixelSize(16); + //myCBfont.setPointSize(16); + myCBfont.setPointSize(myCBfont.pixelSize() - 5); + + cb_selAccNr = new QComboBox(); + cb_selAccNr->addItems(availAccNrList); + //cb_selAccNr->setFont(myCBfont); // aendert nur die Liste, Eingabezeile bleibt klein + //cb_selAccNr->setCurrentIndex(7); + cb_selAccNr->setEditable(true); + cb_selAccNr->setMaxVisibleItems(8); + cb_selAccNr->setStyleSheet("QComboBox { font-size: 20px; }"); // gilt fuer Liste und Eingabezeile + //cb_selAccNr->setStyleSheet("QScrollBar:vertical { width: 30px; }"); + RightLayout->addWidget(cb_selAccNr); + + //myTabFont.setPixelSize(16); + //QLabel *lab5 =new QLabel(" "); + //RightLayout->addWidget(lab5); + //lab5->setFont(myTabFont); +/* + myTabFont.setPixelSize(16); + QLabel *lab2 =new QLabel("available AccNrs.:"); + lab2->setFont(myTabFont); + RightLayout->addWidget(lab2); + + myTabFont.setPixelSize(16); + win11_showAccNrs = new QListWidget; + win11_showAccNrs->setFont(myTabFont); + //win11_showAccNrs->setMinimumHeight(200); + //win11_showAccNrs->setMinimumWidth(100); + win11_showAccNrs->setLineWidth(3); + win11_showAccNrs->clear(); + win11_showAccNrs->addItems(availAccNrList); + RightLayout->addWidget(win11_showAccNrs); +*/ + //QLabel *lab3 =new QLabel(" "); + //RightLayout->addWidget(lab3); + + but3 = new QPushButton(" print "); + RightLayout->addWidget(but3); + connect(but3, SIGNAL(clicked()), this, SLOT(slot_printSel())); + but3->setStyleSheet(BUTTONCOLOR0); + but3->setFont(myTabFont); + + but4 = new QPushButton(" verify "); + RightLayout->addWidget(but4); + connect(but4, SIGNAL(clicked()), this, SLOT(slot_crc())); + but4->setStyleSheet(BUTTONCOLOR0); + but4->setFont(myTabFont); + + but5 = new QPushButton("read acc-nr"); + RightLayout->addWidget(but5); + connect(but5, SIGNAL(clicked()), this, SLOT(slot_readNr())); + but5->setStyleSheet(BUTTONCOLOR0); + but5->setFont(myTabFont); + + //disp_CurrentAccNr=new QLabel(); + disp_CurrentAccNr=new QLineEdit(); // mit Eingabemoeglichkeit! + RightLayout->addWidget(disp_CurrentAccNr); + disp_CurrentAccNr->setFont(myTabFont); + //disp_CurrentAccNr->setLineWidth(3); + disp_CurrentAccNr->setStyleSheet(BUTTONCOLOR0); + disp_CurrentAccNr->setEnabled(true); + + myTabFont.setPixelSize(16); + //QLabel *lab5 =new QLabel(" "); + //RightLayout->addWidget(lab5); + //lab5->setFont(myTabFont); + + myKeypad = new T_keypad(); + leftLayout->addWidget(myKeypad); + connect(myKeypad, SIGNAL(keyEntryFinished()), this, SLOT(valueIsSet())); + + but6 = new QPushButton("set acc-nr"); + RightLayout->addWidget(but6); + connect(but6, SIGNAL(clicked()), this, SLOT(slot_setAccNr())); + but6->setStyleSheet(BUTTONCOLOR0); + but6->setFont(myTabFont); + + but7 = new QPushButton("delete all DC-data"); + RightLayout->addWidget(but7); + connect(but7, SIGNAL(clicked()), this, SLOT(slot_deleteAccData())); + but7->setStyleSheet(BUTTONCOLOR0); + but7->setFont(myTabFont); + + but8 = new QPushButton("delete all Totals"); + RightLayout->addWidget(but8); + connect(but8, SIGNAL(clicked()), this, SLOT(slot_deleteTotals())); + but8->setStyleSheet(BUTTONCOLOR0); + but8->setFont(myTabFont); + + + + + mainHLayout->addLayout(leftLayout); + mainHLayout->addLayout(RightLayout); + + setLayout(mainHLayout); + + updateList=1; + wait4data=0; + myNextStep=0; + myStep=0; + pwreq=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->stop(); + +} + +T_win11::~T_win11() +{ + close(); +} + +void T_win11::Nav_back(void) +{ + myNextStep=WCS_WIN11BAK; +} + +void T_win11::Nav_home(void) +{ + myNextStep=WCS_WIN11MID; +} + +void T_win11::Nav_next(void) +{ + myNextStep=WCS_WIN11FWD; +} + + +void T_win11::slot_loadData(void) +{ + bool ok=0; + int selNr; + QString anStr; + + but3->setStyleSheet(BUTTONCOLOR0); + but2->setStyleSheet(BUTTONCOLORWAIT); // BUTTONCOLORGOT + but2->setText("loading..."); + //int anInt=cb_selAccNr->currentIndex(); + anStr=cb_selAccNr->currentText(); + selNr=anStr.toUInt(&ok); + if (ok) + { + if (selNr==0) + { + sub_displayCurrentCashbox(); + } else + { + HWaccess->log_selectVaultRecord(uint16_t(selNr)); + win11_showVaultRecord->clear(); + wait4data=1; + } + } + + myStep++; + +} + +void T_win11::slot_loadNumbers(void) +{ + updateList=1; +} + +void T_win11::slot_printSel(void) +{ + bool ok=0; + QString anStr=cb_selAccNr->currentText(); + uint16_t selNr=anStr.toUInt(&ok); + if (ok && selNr>0) + { + HWaccess->prn_printOneAccountReceipt(selNr); + myTO->start(3000); + } +} + +void T_win11::slot_crc(void) +{ + + bool ret=0; + ret=HWaccess->log_verifyVaultRecordByCrc(); + if (ret) + but4->setStyleSheet(BUTTONCOLORGOOD); + else + but4->setStyleSheet(BUTTONCOLORBAD); +} + +void T_win11::slot_readNr(void) +{ + uint16_t nxtAn=0; + + nxtAn= HWaccess->log_DC_getNextAccountNumber(); + QString myStr; + + myStr.clear(); + myStr.append(QString::number(nxtAn)); + disp_CurrentAccNr->setText(myStr); + +} + +void T_win11::slot_setAccNr(void) +{ + // set new accouning number + // request password before + pwreq=1; + myKeypad->keysVisible(2); + myKeypad->show(); // display pinpad for password entry +} + +void T_win11::slot_deleteAccData(void) +{ + pwreq=2; + myKeypad->keysVisible(2); + myKeypad->show(); +} + +void T_win11::slot_deleteTotals(void) +{ + pwreq=3; + myKeypad->keysVisible(2); + myKeypad->show(); +} + +void T_win11::valueIsSet(void) +{ + // password was entered + bool ok=0; + QString myPW, myStr; + + myPW=myKeypad->getValueString(); // get entered password + if (pwreq==1) // pw-entry requested for acc-nr + { + if (myPW=="92706") // compare password + { + //qDebug()<<"PW correct"; + myStr=disp_CurrentAccNr->text(); // new value was set before PW + uint16_t nxtAn=myStr.toUInt(&ok,10); + if (ok) + { + HWaccess->log_DC_setNextAccountNumber(nxtAn); + disp_CurrentAccNr->setText("->new acc.nr set"); + } + } + } else + if (pwreq==2) // pw-entry requested for deleteAccData + { + if (myPW=="92637") // compare password + { + HWaccess->log_DC_deleteAllVaultrecordsInDc(); + disp_CurrentAccNr->setText("->all acc.data deleted"); + } + } else + if (pwreq==3) // pw-entry requested for delete totals + { + if (myPW=="92702") // compare password + { + HWaccess->log_DC_deleteAllTotalCounters(); + disp_CurrentAccNr->setText("->all totals deleted"); + } + } + + pwreq=0; +} + + +void T_win11::enterAccData(QString label, uint32_t val) +{ + QString myStr; + + myStr.clear(); + myStr.append(label); + myStr.append(QString::number(val)); + win11_showVaultRecord->addItem(myStr); +} + +void T_win11::enterString(QString label, char *buff, int len) +{ + QString myStr; + char myChar; + int nn, LL=len; + + myStr.clear(); + myStr.append(label); + for (nn=0; nnaddItem(myStr); +} + +void T_win11::enterArray(QString label, uint16_t *buff, int len) +{ + QString myStr; + + int nn, LL=len; + uint16_t val; + + myStr.clear(); + myStr.append(label); + for (nn=0; nnaddItem(myStr); +} + +void T_win11::enterArray(QString label, uint32_t *buff, int len) +{ + QString myStr; + int nn, LL=len; + uint32_t val; + + myStr.clear(); + myStr.append(label); + for (nn=0; nnaddItem(myStr); +} + +bool T_win11::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_win11::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 nrOfVals, nn; + uint16_t accNr[34], val; + QString myStr; + struct T_vaultRecord retVR; + + //uint8_t temp[400]; + + if (updateList) + { + HWaccess->log_getHoldAccountNumbers(&nrOfVals, &accNr[0] ); + //void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const override; + // returns all acc nrs of the backuped vault records + // use: uint16_t backupedAccNumbers[8] + // will be requested automatically + + if (nrOfVals>32) nrOfVals=32; + availAccNrList.clear(); + availAccNrList.append("0"); // 0 = immer akt. Kasseninhalt + for (nn=0; nn< nrOfVals; nn++) + { + myStr.clear(); + val=accNr[nn]; + myStr.append( QString::number(val,10) ); + availAccNrList.append(myStr); + } + + if (nrOfVals>0) + { + cb_selAccNr->clear(); + cb_selAccNr->addItems(availAccNrList); + //win11_showAccNrs->clear(); + //win11_showAccNrs->addItems(availAccNrList); + updateList=0; + } + + } + + //blksRdy=HWaccess->log_getAvailableVaultBlocks(); + // return 0x0011 1111 if all 6 blocks arer loaded (one bit per block) + //if (blksRdy==0x3F && wait4data) + if (HWaccess->log_chkIfVaultRecordAvailable() && wait4data) + { + wait4data=0; + win11_showVaultRecord->clear(); + but2->setStyleSheet(BUTTONCOLORGOT); + but2->setText("loaded"); + + // get data from local memory and display to left window + HWaccess->log_getVaultRecord(&retVR); + enterString ("Start : ", retVR.startbuffer, 4); + enterAccData("Acc.Nr. : ", retVR.AccountingNumber ); + enterAccData("Cu.Nr. : ", retVR.CUNU ); + enterAccData("MachNr. : ", retVR.MANU ); + enterAccData("reserve : ", retVR.resint1 ); + enterString ("--- : ", retVR.label1buffer, 4 ); + enterAccData("Year : ", retVR.year ); + enterAccData("Month : ", retVR.month ); + enterAccData("Day : ", retVR.dom ); + enterAccData("Hour : ", retVR.hour ); + enterAccData("Min : ", retVR.min ); + enterAccData("Sec : ", retVR.sec ); + enterAccData("Weekday : ", retVR.DoW ); + enterAccData("reserve : ", retVR.reschar3 ); + enterString ("--- : ", retVR.label2buffer, 4 ); + enterAccData("Total : ", retVR.AbsIncome1 ); + enterAccData("abs.Res : ", retVR.AbsReserve ); + enterAccData("abs.Cut : ", retVR.AbsNrOfCuts ); + enterString ("--- : ", retVR.label3buffer, 4 ); + enterArray ("ins.Coins: ", retVR.VKcoinsInserted, 16 ); + enterArray ("ret Coins: ", retVR.VKcoinsReturned, 6 ); + enterArray ("fillCoins: ", retVR.ServCoinsInserted, 16 ); + enterArray ("takeCoins: ", retVR.ServCoinsReturned, 6 ); + enterAccData("reserve : ", retVR.resint3 ); + enterAccData("reserve : ", retVR.resint4 ); + enterArray ("tubeCont.: ", retVR.currentTubeContent,6 ); + enterAccData("reserve : ", retVR.resint5 ); + enterAccData("reserve : ", retVR.resint6 ); + enterString("--- : ", retVR.label4buffer, 4 ); + enterArray ("nr.Coins : ", retVR.coinsInVault, 16 ); + enterArray ("nr.Bills : ", retVR.billsInStacker, 8 ); + enterString("--- : ", retVR.label5buffer, 4 ); + enterArray ("coinDenom: ", retVR.coinDenomination, 16 ); + enterArray ("billDenom: ", retVR.billDenom, 8 ); + enterArray ("tubeDenom: ", retVR.tubeDenom, 6 ); + enterAccData("exchgRate: ", retVR.exchangeRate ); + enterAccData("reserve : ", retVR.resint9 ); + + enterAccData("Cuts CB : ", retVR.cutsSinceCBchange); + enterAccData("Amount CB: ", retVR.CBcontent_cent); + enterAccData("Coins CB : ", retVR.CBnrofCoins); + enterString("End : ", retVR.endofblock, 4 ); + // 332 bytes + + enterAccData("CRC : ", retVR.CRC16); + enterAccData("res : ", retVR.resint11); + enterString("End : ", retVR.endofRecord, 4 ); + + } + + if (myTO->isActive()) + { + uint8_t uctmp=HWaccess->prn_getPrintResult(); + // return: 0: unknown + // 1: OK - last template was printed succesful + // 2: error - last template was not printed + if (uctmp==2) + but3->setStyleSheet(BUTTONCOLORBAD); + else if (uctmp==1) + but3->setStyleSheet(BUTTONCOLORGOOD); + else + but3->setStyleSheet(BUTTONCOLOR0); + } + + if (myStep==0) + { + //myStep++; + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + HWaccess->bna_requestStackerLevel(); + //qDebug()<<"win11 requ bills"; + } + } else + + if (myStep==2) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + } + } else + + if (myStep==3) + { + if (!myTO->isActive()) + { + myStep=1; // nur 1x auf Tastendruck anfordern + myTO->start(200); + HWaccess->changer_requestTubelevel(); + //qDebug()<<"win11 requ tubes"; + } + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + + *useNavi=0; + return false; +} + + + +void T_win11::sub_displayCurrentCashbox(void) +{ + // "Daily" anzeigen, also akt. Kasseninhalt + + wait4data=0; + but2->setStyleSheet(BUTTONCOLORGOOD); + but2->setText("loaded"); + + win11_showVaultRecord->clear(); + win11_showVaultRecord->addItem("\nCurrent cashbox content\n"); + + struct T_dynamicCondition myDynMachCond; + HWaccess->sys_getDynMachineConditions(&myDynMachCond); + enterAccData("nr of coins in Box: ", myDynMachCond.nrCoinsInBox); + enterAccData("Amount in coin Box: ", myDynMachCond.amountInBox); + win11_showVaultRecord->addItem(" "); + + uint32_t amountInStacker; + uint16_t countOfBills[16], totalBills; + totalBills=HWaccess->bna_getStackerLevel(&amountInStacker, countOfBills); + // countOfBills[0...7]=Anzahl der jew. Werte countOfBills[8...15]=Wertigkeit + + enterAccData("nr of bills in Box: ", totalBills); + enterAccData("Amount of bills : ", (amountInStacker/100) ); + enterAccData("Nr of 5€ Bills: ", countOfBills[0]); + enterAccData("Nr of 10€ Bills: ", countOfBills[1]); + enterAccData("Nr of 20€ Bills: ", countOfBills[2]); + enterAccData("Nr of 50€ Bills: ", countOfBills[3]); + enterAccData("Nr of 100€ Bills: ", countOfBills[4]); + win11_showVaultRecord->addItem(" "); + + struct T_chg_Tub changer; + HWaccess->changer_getTubelevel(&changer); + // don't use tubeDispens[], it's not yet correct! + QString myStr; + win11_showVaultRecord->addItem("\n Coin changer content: "); + + for (int nn=0; nn<6; nn++) + { + myStr.clear(); + if (changer.tubeValues[nn]>0) + { + myStr.append(swl_long2str(changer.tubeValues[nn])); + myStr.append(" : "); + myStr.append(swl_long2str(changer.tubeLevel[nn])); + if (changer.tubeFull[nn]>0) + myStr.append(" F"); + win11_showVaultRecord->addItem(myStr); + } + } + +} + diff --git a/win11_abr.h b/win11_abr.h new file mode 100755 index 0000000..9c086be --- /dev/null +++ b/win11_abr.h @@ -0,0 +1,90 @@ +#ifndef WIN11_ABR_H +#define WIN11_ABR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include +#include "keypad.h" +#include "guidefs.h" + + +class T_win11 : public QWidget +{ + Q_OBJECT + + //QGridLayout *myLayout; + QHBoxLayout *mainHLayout; + QVBoxLayout *leftLayout; + QVBoxLayout *RightLayout; + QListWidget *win11_showVaultRecord; + //QListWidget *win11_showAccNrs; + QStringList availAccNrList; + QComboBox *cb_selAccNr; + QPushButton *but1, *but2, *but3, *but4, *but5, *but6, *but7, *but8; + + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QTimer *myTO; + + //QLabel *disp_CurrentAccNr; + QLineEdit *disp_CurrentAccNr; + + T_keypad *myKeypad; + + + void enterAccData(QString label, uint32_t val); + void enterString(QString label, char *buff, int len); + + void enterArray(QString label, uint16_t *buff, int len); + void enterArray(QString label, uint32_t *buff, int len); + + void sub_displayCurrentCashbox(void); + +public: + explicit T_win11(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win11(); + +private slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_loadNumbers(void); + void slot_loadData(void); + void slot_printSel(void); + void slot_crc(void); + void slot_readNr(void); + void slot_setAccNr(void); + void slot_deleteAccData(void); + void slot_deleteTotals(void); + void valueIsSet(void); + + +}; + +#endif diff --git a/win12_BL.cpp b/win12_BL.cpp new file mode 100755 index 0000000..09cfefa --- /dev/null +++ b/win12_BL.cpp @@ -0,0 +1,473 @@ +#include "win12_BL.h" + + + +#define BUTTONCOLOR0 "background-color: white" +#define BUTTONCOLORWAIT "background-color: yellow" +#define BUTTONCOLORGOT "background-color: green" +#define BUTTONCOLORBAD "background-color: red" +#define BUTTONCOLORGOOD "background-color: green" + +static bool win12_startProgramming; +static uint16_t win12_nrOfFWblocks, win12_currentBlkNr; + + +T_win12::T_win12(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myVmainlayer= new QVBoxLayout; + myH0layer = new QHBoxLayout; + myH1layer = new QHBoxLayout; + myVlayer_left = new QVBoxLayout; + myVlayer_midd = new QVBoxLayout; + myVlayer_right = new QVBoxLayout; + + myVmainlayer->addLayout(myH0layer); + myVmainlayer->addLayout(myH1layer); + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("program DC-firmware")); + lab1->setFont(myTabFont); + myH0layer->addWidget(lab1); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myH0layer->addWidget(lab2); + + myH1layer->addLayout(myVlayer_left); + myH1layer->addLayout(myVlayer_midd); + myH1layer->addLayout(myVlayer_right); + + // linke Spalte: controls + QLabel *lab7 = new QLabel(" "); + lab7->setFont(myTabFont); + myVlayer_left->addWidget(lab7); + + but9 = new QPushButton("Starting \nBootloader"); + myVlayer_left->addWidget(but9); + connect(but9, SIGNAL(clicked()), this, SLOT(slot_b9())); + but9->setStyleSheet(BUTTONCOLOR0); + but9->setFont(myTabFont); + + QLabel *lab3 = new QLabel(" "); + lab3->setFont(myTabFont); + myH0layer->addWidget(lab3); + + but4 = new QPushButton("load Bin-File"); + myVlayer_left->addWidget(but4); + connect(but4, SIGNAL(clicked()), this, SLOT(slot_b4())); + but4->setStyleSheet(BUTTONCOLOR0); + but4->setFont(myTabFont); + + QLabel *lab4 = new QLabel(" "); + lab4->setFont(myTabFont); + myH0layer->addWidget(lab4); + + but5 = new QPushButton(" send file to DC"); + myVlayer_left->addWidget(but5); + connect(but5, SIGNAL(clicked()), this, SLOT(slot_b5())); + but5->setStyleSheet(BUTTONCOLOR0); + but5->setFont(myTabFont); + + QLabel *lab5 = new QLabel(" "); + lab5->setFont(myTabFont); + myH0layer->addWidget(lab5); + +/* + but6 = new QPushButton(" "); + myVlayer_left->addWidget(but6); + connect(but6, SIGNAL(clicked()), this, SLOT(slot_b6())); + but6->setStyleSheet(BUTTONCOLOR0); + but6->setFont(myTabFont); + + but7 = new QPushButton(" "); + myVlayer_left->addWidget(but7); + connect(but7, SIGNAL(clicked()), this, SLOT(slot_b7())); + but7->setStyleSheet(BUTTONCOLOR0); + but7->setFont(myTabFont); + + but8 = new QPushButton(" "); + myVlayer_left->addWidget(but8); + connect(but8, SIGNAL(clicked()), this, SLOT(slot_b8())); + but8->setStyleSheet(BUTTONCOLOR0); + but8->setFont(myTabFont); +*/ +/* + but9 = new QPushButton("complete start"); + myVlayer_left->addWidget(but9); + connect(but9, SIGNAL(clicked()), this, SLOT(slot_b9())); + but9->setStyleSheet(BUTTONCOLOR0); + but9->setFont(myTabFont); +*/ + + myTabFont.setPixelSize(14); + but1 = new QPushButton("restart DC: "); + myVlayer_left->addWidget(but1); + connect(but1, SIGNAL(clicked()), this, SLOT(slot_b1())); + but1->setStyleSheet(BUTTONCOLOR0); + but1->setFont(myTabFont); + + but2 = new QPushButton("Start BL: "); + myVlayer_left->addWidget(but2); + connect(but2, SIGNAL(clicked()), this, SLOT(slot_b2())); + but2->setStyleSheet(BUTTONCOLOR0); + but2->setFont(myTabFont); + + but3 = new QPushButton("check BL: "); + myVlayer_left->addWidget(but3); + connect(but3, SIGNAL(clicked()), this, SLOT(slot_b3())); + but3->setStyleSheet(BUTTONCOLOR0); + but3->setFont(myTabFont); + + QLabel *lab6 = new QLabel(" "); + lab6->setFont(myTabFont); + myH0layer->addWidget(lab6); + + myTabFont.setPixelSize(22); + but10 = new QPushButton("stop BL: "); + myVlayer_left->addWidget(but10); + connect(but10, SIGNAL(clicked()), this, SLOT(slot_b10())); + but10->setStyleSheet(BUTTONCOLOR0); + but10->setFont(myTabFont); + + // Mitte: anzeigen + showState =new QLabel("BL is off"); + showState->setFont(myTabFont); + myVlayer_midd->addWidget(showState); + + myTabFont.setPixelSize(14); + showFile =new QLabel(" --- no file loaded ---"); + showFile->setFont(myTabFont); + myVlayer_midd->addWidget(showFile); + + showProgress = new QTextEdit(); + myVlayer_midd->addWidget(showProgress); + myTabFont.setPixelSize(14); + showProgress->setFont(myTabFont); + showProgress->setStyleSheet("background-color: white"); + showProgress->append(" "); + + setLayout(myVmainlayer); + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2); + trigger_BLstartup=false; + win12_startProgramming=0; + win12_nrOfFWblocks=0; + win12_currentBlkNr=0; +} + +T_win12::~T_win12() +{ + close(); +} + +void T_win12::Nav_back(void) +{ + myNextStep=WCS_WIN12BAK; +} +void T_win12::Nav_home(void) +{ + myNextStep=WCS_WIN12MID; +} +void T_win12::Nav_next(void) +{ + myNextStep=WCS_WIN12FWD; +} + +void T_win12::slot_b1(void) +{ + showProgress->append(" rebooting"); + HWaccess->dc_autoRequest(false); + HWaccess->bl_rebootDC(); +} + +void T_win12::slot_b2(void) +{ + HWaccess->dc_autoRequest(false); + HWaccess->bl_startBL(); +} + +void T_win12::slot_b3(void) +{ + HWaccess->dc_autoRequest(false); + showState->setText(" "); + HWaccess->bl_checkBL(); + myTO->stop(); + myTO->start(200); + myStep=20; +} + +void T_win12::slot_b4(void) +{ + QString myStr; + QString fileName; + + win12_nrOfFWblocks=0; + fileName.clear(); + fileName = QFileDialog::getOpenFileName(this, ("Select DC firmware file:"), + "C:/own/work2023/PSA1256ptu5/PTU SW", + ("binary file(*.bin)")); + + //qDebug()<<"T_win12: selected file: "<bl_storeFirmware(fileName); + win12_nrOfFWblocks = HWaccess->bl_getNrOfFirmwareBlocks(); + if (ret) + { + myStr.clear(); + myStr=" file "; + myStr.append(fileName); + myStr.append(" \n loaded with "); + myStr.append(swl_ulong2str(win12_nrOfFWblocks)); + myStr.append(" blocks"); + showFile->setText(myStr); + } else + showFile->setText(" cannot load file :-( "); +} + +void T_win12::slot_b5(void) +{ + win12_startProgramming=true; + myStep=5; +} + +void T_win12::slot_b6(void) +{ +} + +void T_win12::slot_b7(void) +{ +} + +void T_win12::slot_b8(void) +{ +} + +void T_win12::slot_b9(void) +{ + showState->setText(" Bootloader is off "); + showFile->setText(" "); + + //trigger_BLstartup=true; + //myStep=0; + + // neu, 29.9: Start-Schrittkette jetzt in HWapi: + HWaccess->bl_completeStart(); +} + +void T_win12::slot_b10(void) +{ + showState->setText(" Bootloader is off "); + showFile->setText(" "); + HWaccess->bl_stopBL(); + HWaccess->dc_autoRequest(true); +} + +bool T_win12::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_win12::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; + int8_t iresult; + + if (myStep==0) + { + + if (trigger_BLstartup) + { + HWaccess->dc_autoRequest(false); + myStep++; + } + + } else + + if (myStep==1) + { + //qDebug()<<"win12 chain step 1"; + if (trigger_BLstartup) + { + //qDebug()<<"starting up BL step1"; + trigger_BLstartup=false; + HWaccess->bl_rebootDC(); + myTO->stop(); + myTO->start(1000); // restart + retryCtr=0; + myStep++; + //qDebug()<<"win12 chain step 2"; + } + } else + + if (myStep==2) + { + if (!myTO->isActive()) + { + qDebug()<<"starting BL"; + HWaccess->bl_startBL(); + myTO->stop(); + myTO->start(100); + myStep++; + //qDebug()<<"win12 chain step 3"; + } + } else + + if (myStep==3) + { + if (!myTO->isActive()) + { + HWaccess->bl_checkBL(); + myTO->stop(); + myTO->start(100); + myStep++; + //qDebug()<<"win12 chain step 4"; + } + + } else + + if (myStep==4) + { + if (!myTO->isActive()) + { + //qDebug()<<"starting up BL step4"; + myTO->stop(); + if (HWaccess->bl_isUp()) + { + myStep++; + //qDebug()<<"win12 chain step 5"; + showState->setText(" --- BL is up and running ---"); + //qDebug()<<"BL laeuft!!!"; + } else + { + + retryCtr++; // start again + if (retryCtr>=15) + { + myStep=99; + //qDebug()<<"win12 chain step 99"; + showState->setText(" --- BL error! ---"); + //qDebug()<<"BL error!!!"; + } else + { + myStep=3; + //qDebug()<<"BL retry..."; + //qDebug()<<"win12 chain step 3"; + } + } + } + } else + + if (myStep==5) + { + if (win12_startProgramming) + { + win12_nrOfFWblocks = HWaccess->bl_getNrOfFirmwareBlocks(); + if (win12_nrOfFWblocks>10) + { + // qDebug()<<"win12 chain step 6"; + myStep++; + } + win12_currentBlkNr=0; + showProgress->append("transfering file:"); + win12_startProgramming=0; + } + } else + + if (myStep==6) + { + //qDebug()<<"starting transfer"; + HWaccess->bl_blockAutoLoad(win12_currentBlkNr); + showProgress->append(swl_int2str(win12_currentBlkNr)); + myStep++; + //qDebug()<<"win12 chain step 6->7"; + } else + + if (myStep==7) + { + iresult=HWaccess->bl_blockAutoResponse(); + // 0: wait 1: OK, blk was sent 2: OK, transfer complete 3: error + if (iresult==1) + { + win12_currentBlkNr++; + if (win12_currentBlkNr <= win12_nrOfFWblocks) + { + myStep=6; + //qDebug()<<"win12 chain step 7->6"; + + } else + { + showProgress->append("finished"); + //qDebug()<<"win12 chain step 99"; + myStep=99; + } + } else + if (iresult==2) + { + // fertisch + showProgress->append("finished"); + myStep=99; + } else + if (iresult==3) + { + // fehler + showProgress->append("cancel due to error"); + myStep=99; + } + } else + + if (myStep==8) + { + + } else + { + + } + + if (myStep==20) + { + if (!myTO->isActive()) + { + //qDebug()<<"win12 step0"; + if (HWaccess->bl_isUp()) + showState->setText(" Bootloader is running"); + //else + // lab7->setText(" Bootloader is off "); + myTO->stop(); + myStep=99; + } + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win12_BL.h b/win12_BL.h new file mode 100755 index 0000000..ba21a56 --- /dev/null +++ b/win12_BL.h @@ -0,0 +1,82 @@ +#ifndef WIN12_BL_H +#define WIN12_BL_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "QPushButton" +#include "QTextEdit" +#include "QFileDialog" +#include "QStringList" +#include "guidefs.h" + + +class T_win12 : public QWidget +{ + Q_OBJECT + + //QGridLayout *myLayout; + QHBoxLayout *myH0layer, *myH1layer; + QVBoxLayout *myVmainlayer, *myVlayer_left; + QVBoxLayout *myVlayer_midd; + QVBoxLayout *myVlayer_right; + + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + QLabel *showState, *showFile; + QPushButton *but1, *but2, *but3, *but4, *but5, *but6, *but7, *but8, *but9, *but10; + bool trigger_BLstartup; + int retryCtr; + QTextEdit *showProgress; + +public: + explicit T_win12(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win12(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + + void slot_b1(void); + void slot_b2(void); + void slot_b3(void); + void slot_b4(void); + void slot_b5(void); + void slot_b6(void); + void slot_b7(void); + void slot_b8(void); + void slot_b9(void); + void slot_b10(void); + +}; + +#endif diff --git a/win13_json.cpp b/win13_json.cpp new file mode 100755 index 0000000..0aa3382 --- /dev/null +++ b/win13_json.cpp @@ -0,0 +1,330 @@ +#include "win13_json.h" + + +// load Json file from HDD and send it to DC: + +//virtual bool sys_sendJsonFileToDc(uint8_t kindOfFile, uint8_t nrOfTemplate, uint8_t *content ) const =0; + // kindOfFile: 1=config, 2=device, 3=cash, 4=serial, 5=time, 6=printer + // nrOfTemplate=1...32 if kindOfFile==6 + // content = content of the Json file, max 800byte ascii signs + // file is 0-terminated! + // return false if sending is not possible, wait a second + + + +T_win13::T_win13(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + //myLayout = new QGridLayout; + myVmainlayer= new QVBoxLayout; + myH0layer = new QHBoxLayout; + myH1layer = new QHBoxLayout; + myVlayer_left = new QVBoxLayout; + myVlayer_midd = new QVBoxLayout; + myVlayer_right = new QVBoxLayout; + + myVmainlayer->addLayout(myH0layer); + myVmainlayer->addLayout(myH1layer); + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("send Jsonfiles from ../smd to DC")); + lab1->setFont(myTabFont); + myH0layer->addWidget(lab1); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myH0layer->addWidget(lab2); + + myH1layer->addLayout(myVlayer_left); + myH1layer->addLayout(myVlayer_midd); + myH1layer->addLayout(myVlayer_right); + + // linke Spalte: laden + pB1 = new QPushButton("load config"); + myVlayer_left->addWidget(pB1); + pB1->setFont(myTabFont); + connect(pB1, SIGNAL(clicked()), this, SLOT(slot_pb1())); + + pB2 = new QPushButton("load devices"); + myVlayer_left->addWidget(pB2); + pB2->setFont(myTabFont); + connect(pB2, SIGNAL(clicked()), this, SLOT(slot_pb2())); + + pB3 = new QPushButton("load cash"); + myVlayer_left->addWidget(pB3); + pB3->setFont(myTabFont); + connect(pB3, SIGNAL(clicked()), this, SLOT(slot_pb3())); + + pB4 = new QPushButton("load print32"); + myVlayer_left->addWidget(pB4); + pB4->setFont(myTabFont); + connect(pB4, SIGNAL(clicked()), this, SLOT(slot_pb4())); + + + + // Mitte: anzeigen + showFile = new QTextEdit(); + myVlayer_midd->addWidget(showFile); + myTabFont.setPixelSize(14); + showFile->setFont(myTabFont); + showFile->setStyleSheet("background-color: white"); + showFile->append("content of the loaded file:"); + showFile->append(" "); + showFile->append(" "); + + // rechte Spalte: zum DC senden + myTabFont.setPixelSize(22); + pB5 = new QPushButton("send config"); + myVlayer_right->addWidget(pB5); + pB5->setFont(myTabFont); + connect(pB5, SIGNAL(clicked()), this, SLOT(slot_pb5())); + + pB6 = new QPushButton("send devices"); + myVlayer_right->addWidget(pB6); + pB6->setFont(myTabFont); + connect(pB6, SIGNAL(clicked()), this, SLOT(slot_pb6())); + + pB7 = new QPushButton("send cash"); + myVlayer_right->addWidget(pB7); + pB7->setFont(myTabFont); + connect(pB7, SIGNAL(clicked()), this, SLOT(slot_pb7())); + + pB8 = new QPushButton("send print32"); + myVlayer_right->addWidget(pB8); + pB8->setFont(myTabFont); + connect(pB8, SIGNAL(clicked()), this, SLOT(slot_pb8())); + + + + + + setLayout(myVmainlayer); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win13::~T_win13() +{ + close(); +} + +void T_win13::Nav_back(void) +{ + myNextStep=WCS_WIN13BAK; +} +void T_win13::Nav_home(void) +{ + myNextStep=WCS_WIN13MID; +} +void T_win13::Nav_next(void) +{ + myNextStep=WCS_WIN13FWD; +} + +void T_win13::slot_pb1(void) +{ + showFile->clear(); + if (datei_ifFileExists(FILENAME_CONFIG)) + { + loadedFile=datei_readFromFile(FILENAME_CONFIG); + showFile->append(loadedFile); + } else + { + showFile->append("file not found"); + } +} + +void T_win13::slot_pb2(void) +{ + showFile->clear(); + if (datei_ifFileExists(FILENAME_DEVICE)) + { + loadedFile=datei_readFromFile(FILENAME_DEVICE); + showFile->append(loadedFile); + } else + { + showFile->append("file not found"); + } +} + +void T_win13::slot_pb3(void) +{ + showFile->clear(); + if (datei_ifFileExists(FILENAME_CASH)) + { + loadedFile=datei_readFromFile(FILENAME_CASH); + showFile->append(loadedFile); + } else + { + showFile->append("file not found"); + } +} + +void T_win13::slot_pb4(void) +{ + showFile->clear(); + if (datei_ifFileExists(FILENAME_PRINT)) + { + loadedFile=datei_readFromFile(FILENAME_PRINT); + showFile->append(loadedFile); + } else + { + showFile->append("file not found"); + } +} + +// send selected file: +void T_win13::slot_pb5(void) // send config +{ + uint8_t buf800[800]; + uint16_t ii, len; + + len=loadedFile.size(); + memset(buf800,0,800); + for (ii=0; iisys_sendJsonFileToDc(1, 0, buf800); + +} + +void T_win13::slot_pb6(void) +{ + uint8_t buf800[800]; + uint16_t ii, len; + + len=loadedFile.size(); + memset(buf800,0,800); + for (ii=0; iisys_sendJsonFileToDc(2, 0, buf800); + +} + +void T_win13::slot_pb7(void) +{ + uint8_t buf800[800]; + uint16_t ii, len; + + len=loadedFile.size(); + memset(buf800,0,800); + for (ii=0; iisys_sendJsonFileToDc(3, 0, buf800); + +} + +void T_win13::slot_pb8(void) +{ + uint8_t buf800[800]; + uint16_t ii, len; + + len=loadedFile.size(); + memset(buf800,0,800); + for (ii=0; iisys_sendJsonFileToDc(4, 32, buf800); + +} + + +bool T_win13::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_win13::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win13_json.h b/win13_json.h new file mode 100755 index 0000000..021d9f8 --- /dev/null +++ b/win13_json.h @@ -0,0 +1,76 @@ +#ifndef WIN13_JSON_H +#define WIN13_JSON_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "QTextEdit" +#include "datei.h" +#include "QDir" +#include "guidefs.h" + +class T_win13 : public QWidget +{ + Q_OBJECT + + //QGridLayout *myLayout; + QHBoxLayout *myH0layer, *myH1layer; + QVBoxLayout *myVmainlayer, *myVlayer_left; + QVBoxLayout *myVlayer_midd; + QVBoxLayout *myVlayer_right; + + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + QPushButton *pB1, *pB2, *pB3, *pB4, *pB5, *pB6, *pB7, *pB8; + QTextEdit *showFile; + QByteArray loadedFile; + + +public: + explicit T_win13(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win13(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_pb1(void); + void slot_pb2(void); + void slot_pb3(void); + void slot_pb4(void); + void slot_pb5(void); + void slot_pb6(void); + void slot_pb7(void); + void slot_pb8(void); + +}; + +#endif diff --git a/win14_mw.cpp b/win14_mw.cpp new file mode 100755 index 0000000..200164f --- /dev/null +++ b/win14_mw.cpp @@ -0,0 +1,689 @@ +#include "win14_mw.h" + + + +T_win14::T_win14(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myHmainlayer= new QHBoxLayout; +// myV1mainlayer= new QVBoxLayout; +// myV2mainlayer= new QVBoxLayout; + + myH0layer = new QHBoxLayout; + myH1layer = new QHBoxLayout; + myH2layer = new QHBoxLayout; + myH3layer = new QHBoxLayout; + myH4layer = new QHBoxLayout; + myH5layer = new QHBoxLayout; + myH6layer = new QHBoxLayout; + myH7layer = new QHBoxLayout; + + myVlayer_left = new QVBoxLayout; + //myVlayer_midd = new QVBoxLayout; + myVlayer_right = new QVBoxLayout; + + myHmainlayer->addLayout(myVlayer_left); + myHmainlayer->addLayout(myVlayer_right); + + myVlayer_left->addLayout(myH0layer); + myVlayer_left->addLayout(myH1layer); + myVlayer_left->addLayout(myH2layer); + myVlayer_left->addLayout(myH3layer); + myVlayer_left->addLayout(myH4layer); + myVlayer_left->addLayout(myH5layer); + myVlayer_left->addLayout(myH6layer); + myVlayer_left->addLayout(myH7layer); + + + + QFont myTabFont; + myTabFont.setPixelSize(PIXELSIZE_LABEL); + + lab1 =new QLabel(tr("Coin Changer")); + lab1->setFont(myTabFont); + myH0layer->addWidget(lab1); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myH0layer->addWidget(lab2); + + QLabel *lab40 =new QLabel(tr("Inserted Coin Value: ")); + myH1layer->addWidget(lab40); + lab40->setFont(myTabFont); + // Wert: + //myTabFont.setPixelSize(PIXELSIZE_DATA); + myTabFont.setPixelSize(PIXELSIZE_LABEL); + insertedCoin =new QLabel(); + insertedCoin->setText(" 0 "); + insertedCoin->setFont(myTabFont); + insertedCoin->setStyleSheet(COLORWHITE); + insertedCoin->setAlignment(Qt::AlignCenter); + insertedCoin->setMinimumHeight(50); + myH1layer->addWidget(insertedCoin); + + //QLabel *lab3 =new QLabel(tr(" ")); + QLabel *lab3 =new QLabel(tr(" ")); + myH1layer->addWidget(lab3); + lab3->setFont(myTabFont); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + pb_powerOn = new QPushButton("Power ON"); + myH1layer->addWidget(pb_powerOn); + pb_powerOn->setFont(myTabFont); + pb_powerOn->setCheckable(true); // true = toggle button + pb_powerOn->setAutoDefault(true); // beim start ein + pb_powerOn->setStyleSheet(COLORWHITE); + connect(pb_powerOn, SIGNAL(clicked()), this, SLOT(slot_powerOn())); + + QLabel *lab53 =new QLabel(tr(" ")); + myH1layer->addWidget(lab53); + lab53->setFont(myTabFont); + + // 6 Fenster nebeneinander (Roehren) + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab52 =new QLabel(tr("Tubes: 1 2 3 4 5 6")); + myH3layer->addWidget(lab52); + lab52->setFont(myTabFont); + + QLabel *lab50 =new QLabel(tr("Value [cent]: ")); + myH4layer->addWidget(lab50); + lab50->setFont(myTabFont); + QLabel *lab51 =new QLabel(tr("Nr.of Coins: ")); + myH5layer->addWidget(lab51); + lab51->setFont(myTabFont); + + // Wert: + myTabFont.setPixelSize(PIXELSIZE_DATA); + lab20 =new QLabel(); + lab20->setText(" - "); + lab20->setFont(myTabFont); + lab20->setStyleSheet(COLORYELLOW); + lab20->setAlignment(Qt::AlignCenter); + myH4layer->addWidget(lab20); + + // Inhalt: + lab30 =new QLabel(); + myH5layer->addWidget(lab30); + lab30->setText(" 0 "); + lab30->setFont(myTabFont); + lab30->setStyleSheet(COLORWHITE); + lab30->setAlignment(Qt::AlignCenter); + + // Wert: + lab21 =new QLabel(); + myH4layer->addWidget(lab21); + lab21->setText(" - "); + lab21->setFont(myTabFont); + lab21->setStyleSheet(COLORYELLOW); + lab21->setAlignment(Qt::AlignCenter); + // Inhalt: + lab31 =new QLabel(); + myH5layer->addWidget(lab31); + lab31->setText(" 0 "); + lab31->setFont(myTabFont); + lab31->setStyleSheet(COLORWHITE); + lab31->setAlignment(Qt::AlignCenter); + + lab22 =new QLabel(); + myH4layer->addWidget(lab22); + lab22->setText(" - "); + lab22->setFont(myTabFont); + lab22->setStyleSheet(COLORYELLOW); + lab22->setAlignment(Qt::AlignCenter); + + // Inhalt: + lab32 =new QLabel(); + myH5layer->addWidget(lab32); + lab32->setText(" 0 "); + lab32->setFont(myTabFont); + lab32->setStyleSheet(COLORWHITE); + lab32->setAlignment(Qt::AlignCenter); + + lab23 =new QLabel(); + myH4layer->addWidget(lab23); + lab23->setText(" - "); + lab23->setFont(myTabFont); + lab23->setStyleSheet(COLORYELLOW); + lab23->setAlignment(Qt::AlignCenter); + + // Inhalt: + lab33 =new QLabel(); + myH5layer->addWidget(lab33); + lab33->setText(" 0 "); + lab33->setFont(myTabFont); + lab33->setStyleSheet(COLORWHITE); + lab33->setAlignment(Qt::AlignCenter); + + lab24 =new QLabel(); + myH4layer->addWidget(lab24); + lab24->setText(" - "); + lab24->setFont(myTabFont); + lab24->setStyleSheet(COLORYELLOW); + lab24->setAlignment(Qt::AlignCenter); + + // Inhalt: + lab34 =new QLabel(); + myH5layer->addWidget(lab34); + lab34->setText(" 0 "); + lab34->setFont(myTabFont); + lab34->setStyleSheet(COLORWHITE); + lab34->setAlignment(Qt::AlignCenter); + + lab25 =new QLabel(); + myH4layer->addWidget(lab25); + lab25->setText(" - "); + lab25->setStyleSheet(COLORYELLOW); + lab25->setFont(myTabFont); + lab25->setAlignment(Qt::AlignCenter); + + // Inhalt: + lab35 =new QLabel(); + myH5layer->addWidget(lab35); + lab35->setText(" 0 "); + lab35->setFont(myTabFont); + lab35->setStyleSheet(COLORWHITE); + lab35->setAlignment(Qt::AlignCenter); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + QLabel *lab5 =new QLabel(tr("Total content: ")); + myH6layer->addWidget(lab5); + lab5->setFont(myTabFont); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + labTotalContent =new QLabel(); + myH6layer->addWidget(labTotalContent); + labTotalContent->setFont(myTabFont); + + + showDynamics = new QTextEdit("dynamic values:"); + myH7layer->addWidget(showDynamics); + showDynamics->setFont(myTabFont); + showDynamics->setStyleSheet("background-color: white"); + showDynamics->append(" "); + + /* + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + pb_powerOn = new QPushButton(" Power ON "); + myVlayer_right->addWidget(pb_powerOn); + pb_powerOn->setFont(myTabFont); + pb_powerOn->setCheckable(true); // true = toggle button + pb_powerOn->setAutoDefault(false); // beim start aus + pb_powerOn->setStyleSheet(COLORWHITE); + connect(pb_powerOn, SIGNAL(clicked()), this, SLOT(slot_powerOn())); +*/ + + pb_startPay = new QPushButton("Start filling"); + myVlayer_right->addWidget(pb_startPay); + pb_startPay->setFont(myTabFont); + pb_startPay->setCheckable(false); // true = toggle button + pb_startPay->setAutoDefault(false); // beim start aus + pb_startPay->setStyleSheet(COLORWHITE); + connect(pb_startPay, SIGNAL(clicked()), this, SLOT(ButtonStartClicked())); + + pb_stopPay = new QPushButton("Stop filling"); + pb_stopPay->setFont(myTabFont); + myVlayer_right->addWidget(pb_stopPay); + connect(pb_stopPay, SIGNAL(clicked()), this, SLOT(ButtonStopClicked())); + + pb_vendSucc = new QPushButton("Finish, or:"); + pb_vendSucc->setFont(myTabFont); + myVlayer_right->addWidget(pb_vendSucc); + connect(pb_vendSucc, SIGNAL(clicked()), this, SLOT(ButtonSuccClicked())); + + pb_giveChange = new QPushButton("Payout 185cent"); + myVlayer_right->addWidget(pb_giveChange); + pb_giveChange->setFont(myTabFont); + pb_giveChange->setCheckable(false); // true = toggle button + pb_giveChange->setStyleSheet(COLORWHITE); + connect(pb_giveChange, SIGNAL(clicked()), this, SLOT(slot_giveChange())); + + pb_giveAll = new QPushButton("Empty completely"); + myVlayer_right->addWidget(pb_giveAll); + pb_giveAll->setFont(myTabFont); + pb_giveAll->setCheckable(false); // true = toggle button + pb_giveAll->setStyleSheet(COLORWHITE); + connect(pb_giveAll, SIGNAL(clicked()), this, SLOT(slot_giveAll())); + + showChangeRes =new QLabel(" "); + myVlayer_right->addWidget(showChangeRes); + //showChangeRes->setText(" "); + showChangeRes->setFont(myTabFont); + showChangeRes->setStyleSheet(COLORWHITE); + showChangeRes->setAlignment(Qt::AlignCenter); + showChangeRes->setMaximumHeight(80); + + + + // Eingangssignal auf QObject casten, weil hwinf kein QObject ist + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_gotNewCoin()), this, SLOT(signalGotNewCoin())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinCollectionJustStarted()), this, SLOT(signalJustStarted())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinCollectionAborted()), this, SLOT(signalCollectAbort())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByMax()), this, SLOT(signalStopByMax())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByPushbutton()), this, SLOT(signalStopByUser())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByEscrow()), this, SLOT(signalStopByEscrow())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByError()), this, SLOT(signalStopByError())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payStopByTimeout()), this, SLOT(signalStopTO())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_payCancelled()), this, SLOT(signalCancelled())); + connect( dynamic_cast(HWaccess), SIGNAL(hwapi_coinProcessJustStopped()), this, SLOT(signalProcessStop())); + + setLayout(myHmainlayer); + myNextStep=0; + myStep=0; + fl_payStarted=false; + fl_storeStartVal=true; + fl_displayLevel=false; + for (int ii=0; ii<8; ii++) + { + diffLevel[ii]=0; + mw_BeginLevel[ii]=0; + } + diffAmount=0; totalContent=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(200); + +} + +T_win14::~T_win14() +{ + close(); +} + +void T_win14::Nav_back(void) +{ + myNextStep=WCS_WIN14BAK; +} +void T_win14::Nav_home(void) +{ + myNextStep=WCS_WIN14MID; +} +void T_win14::Nav_next(void) +{ + myNextStep=WCS_WIN14FWD; +} + + +void T_win14::slot_powerOn(void) +{ + + if (pb_powerOn->isChecked()) + { + HWaccess->mdb_switchPower(true); + } else + { + HWaccess->mdb_switchPower(false); + } +} + +void T_win14::ButtonStartClicked(void) +{ + HWaccess->cash_startPayment(0); + insertedCoin->clear(); + fl_payStarted=true; + fl_storeStartVal=true; + for (int ii=0; ii<8; ii++) + { + diffLevel[ii]=0; + } + diffAmount=0; + showDynamics->clear(); +} + +void T_win14::ButtonStopClicked(void) +{ + HWaccess->cash_stopPayment(); + pb_startPay->setStyleSheet(COLORYELLOW); +} + +void T_win14::ButtonSuccClicked(void) +{ + HWaccess->vend_success(); + pb_startPay->setStyleSheet(COLORWHITE); +} + +void T_win14::slot_giveChange(void) +{ + HWaccess->changer_returnCoins(185); + pb_startPay->setStyleSheet(COLORWHITE); + showChangeRes->setText(" busy... "); +} + +void T_win14::slot_giveAll(void) +{ + HWaccess->changer_returnCoins(totalContent); + pb_startPay->setStyleSheet(COLORWHITE); + showChangeRes->setText(" busy... "); +} + +void T_win14::signalGotNewCoin() +{ + uint32_t ultmp; + QString myStr; + //uint16_t types[66], values[66]; + //int nn; + + myStr.clear(); + ultmp=HWaccess->getLastInsertedCoin(); + { + myStr.append(QString::number(ultmp)); + insertedCoin->setText(myStr); + } + + +} + +void T_win14::signalJustStarted() +{ + pb_startPay->setStyleSheet("background-color: green"); +} + +void T_win14::signalCollectAbort() +{ + pb_startPay->setStyleSheet("background-color: white"); +} + +void T_win14::signalStopByMax() +{ + pb_startPay->setStyleSheet("background-color: yellow"); +} + +void T_win14::signalStopByUser() +{ + pb_startPay->setStyleSheet("background-color: yellow"); +} + +void T_win14::signalStopByEscrow() +{ + pb_startPay->setStyleSheet("background-color: yellow"); +} + +void T_win14::signalStopByError() +{ + pb_startPay->setStyleSheet("background-color: white"); +} +void T_win14::signalStopTO() +{ + pb_startPay->setStyleSheet("background-color: white"); +} + +void T_win14::signalCancelled() +{ + pb_startPay->setStyleSheet("background-color: white"); +} + +void T_win14::signalProcessStop() +{ + pb_startPay->setStyleSheet("background-color: white"); +} + +bool T_win14::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; + this->ButtonSuccClicked(); + return false; +} + +bool T_win14::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 buf8t[8], res; + char ctmp; + int pp, ii; + uint32_t oneSum; + + QString myStr; + bool found; + + myStr.clear(); + + *nextScreen=0; // 0=no change + *useNavi=0; + struct T_chg_Tub tubLevel; + struct T_changer mw; + uint32_t returnedAmount; + + if (HWaccess->mdb_isMdbPowerOn()) + pb_powerOn->setStyleSheet(COLORGREEN); + else + pb_powerOn->setStyleSheet(COLORWHITE); + + HWaccess->changer_getAllParameters(&mw); + + if (mw.paymentRunning && fl_payStarted) + { + pb_startPay->setStyleSheet(COLORGREEN); + fl_payStarted=false; + } + + HWaccess->changer_getTubelevel(&tubLevel); + + if (fl_storeStartVal) + { + // call only at program start + found=false; + // wait until levels are known (at least one >0) + for (ii=0; ii<6; ii++) + { + if (tubLevel.tubeLevel[ii]>0) + found=true; + } + if (found) + { + // store current levels + for (ii=0; ii<8; ii++) + mw_BeginLevel[ii] = tubLevel.tubeLevel[ii]; + fl_storeStartVal=false; + fl_displayLevel=true; + } + } + + showDynamics->clear(); + showDynamics->append(swl_labelAndValToStr("Country Code (6520=EURO): ", mw.countryCode)); + showDynamics->append(swl_labelAndValToStr("Scale multiplier: ", mw.scale)); + showDynamics->append(swl_labelAndValToStr("Currency decimals: ", mw.decimals)); + for (ii=0; ii<8; ii++) + { + res=mw.coinSetup[ii]; + if (res !=3) + res *= mw.scale; // Tokenwert 3 nicht veraendern + buf8t[ii]=res; + } + showDynamics->append(swl_8valInaRowToStr("accepted coin 1-8 : ", buf8t)); + /* + //showDynamics->append(swl_8valInaRowToStr("accepted coin9-16: ", &mw.coinSetup[8])); // nur 0er + int pp=1; + for (ii=0; ii<6; ii++) + { + if (mw.availableTubes & pp) + buf8t[ii]=mw.coinSetup[ii] * mw.scale; + else + buf8t[ii]=0; + pp<<=1; + } + showDynamics->append(swl_8valInaRowToStr("available tubes : ", buf8t)); + */ + + + showDynamics->append(swl_8valInaRowToStr("level of tubes : ", tubLevel.tubeLevel)); + lab30->setText(swl_ulong2str(tubLevel.tubeLevel[0])); + lab31->setText(swl_ulong2str(tubLevel.tubeLevel[1])); + lab32->setText(swl_ulong2str(tubLevel.tubeLevel[2])); + lab33->setText(swl_ulong2str(tubLevel.tubeLevel[3])); + lab34->setText(swl_ulong2str(tubLevel.tubeLevel[4])); + lab35->setText(swl_ulong2str(tubLevel.tubeLevel[5])); + /* + pp=1; + for (ii=0; ii<6; ii++) + { + if (mw.availableTubes & pp) + buf8t[ii]=mw.coinSetup[ii] * mw.scale; + else + buf8t[ii]=0; + pp<<=1; + } + buf8t[6]=0; buf8t[7]=0; + showDynamics->append(swl_8valInaRowToStr("value of tubes : ", buf8t)); +*/ + // Feld rot wenn Roehre voll: + if (tubLevel.tubeFull[0] && tubLevel.tubeValues[0]>0) lab30->setStyleSheet(COLOR_LIGHTRED); else lab30->setStyleSheet(COLORWHITE); + if (tubLevel.tubeFull[1] && tubLevel.tubeValues[1]>0) lab31->setStyleSheet(COLOR_LIGHTRED); else lab31->setStyleSheet(COLORWHITE); + if (tubLevel.tubeFull[2] && tubLevel.tubeValues[2]>0) lab32->setStyleSheet(COLOR_LIGHTRED); else lab32->setStyleSheet(COLORWHITE); + if (tubLevel.tubeFull[3] && tubLevel.tubeValues[3]>0) lab33->setStyleSheet(COLOR_LIGHTRED); else lab33->setStyleSheet(COLORWHITE); + if (tubLevel.tubeFull[4] && tubLevel.tubeValues[4]>0) lab34->setStyleSheet(COLOR_LIGHTRED); else lab34->setStyleSheet(COLORWHITE); + if (tubLevel.tubeFull[5] && tubLevel.tubeValues[5]>0) lab35->setStyleSheet(COLOR_LIGHTRED); else lab35->setStyleSheet(COLORWHITE); + for (int ii=0; ii<8; ii++) + { + ctmp=char(tubLevel.tubeFull[ii]); + buf8t[ii]=ctmp; + } + showDynamics->append(swl_8valInaRowToStr("full tubes : ", buf8t)); + + showDynamics->append(swl_8valInaRowToStr("tube values : ", tubLevel.tubeValues)); + // Roehren-Wertigkeiten oben in gelben Feldern anzeigen: + lab20->setText(swl_ulong2str(tubLevel.tubeValues[0])); + lab21->setText(swl_ulong2str(tubLevel.tubeValues[1])); + lab22->setText(swl_ulong2str(tubLevel.tubeValues[2])); + lab23->setText(swl_ulong2str(tubLevel.tubeValues[3])); + lab24->setText(swl_ulong2str(tubLevel.tubeValues[4])); + lab25->setText(swl_ulong2str(tubLevel.tubeValues[5])); + + //showDynamics->append(swl_8valInaRowToStr("filled tubes : ", tubLevel.tubeFilled)); + //showDynamics->append(swl_8valInaRowToStr("dispensed tubes : ", tubLevel.tubeDispens)); // stimmt nicht ist aber auch nicht nötig + + // Anzeige Wechsler Gesamtinhalt: + totalContent=0; + for (ii=0; ii<6; ii++) + { + oneSum = tubLevel.tubeLevel[ii] * tubLevel.tubeValues[ii]; + totalContent += oneSum; + } + labTotalContent->setText(swl_centToEuroString(totalContent)); + + if (fl_displayLevel) + { + // display filled/dispensed coins and their value, start first when tubelevel is known + // int diffLevel[6]; + // long diffAmount; + diffLevel[6]=0; diffLevel[7]=0; + for (ii=0; ii<6; ii++) + { + diffLevel[ii]= tubLevel.tubeLevel[ii] - mw_BeginLevel[ii]; + } +// Testwerte: + //diffLevel[1]=-6; diffLevel[2]=2; diffLevel[3]=-10; diffLevel[4]=3; + //showDynamics->append(swl_8valInaRowToStr("start level : ", mw_BeginLevel)); + + diffAmount=0; + for (ii=0; ii<6; ii++) + { + pp = diffLevel[ii] * tubLevel.tubeValues[ii]; + diffAmount += pp; + } + showDynamics->append( swl_8intsInaRowToStr(" tubes changes: ", diffLevel)); + myStr="Inserted in total: "; + if (diffAmount>=0) + { + myStr.append(swl_centToEuroString(diffAmount)); + } else + { + myStr.append(swl_long2str(diffAmount)); + myStr.append(" cents"); + } + showDynamics->append(myStr); + + } + + + res=HWaccess->changer_getChangeResult(&returnedAmount); + // get result of coin dispensing + // receivedData[0]: 0: not yet started 1:amount returned + // 2:only partial return 3: no return possible + // receivedData[2,3,4,5]: returned amount + myStr.clear(); + + //if (res==0) + // showChangeRes->setText(" --- \n"); + //else + + if (res==1) + { + myStr.append("amount \nreturned"); + //myStr.append(swl_ulong2str(returnedAmount)); // ist hier immer 0 + //myStr.append(" cent remain"); + showChangeRes->setText(myStr); + } else + + if (res==2) + { + myStr.append("partial returned\n"); + myStr.append(swl_ulong2str(returnedAmount)); + myStr.append("cent \nremain"); + showChangeRes->setText(myStr); + } else + + if (res==3) + showChangeRes->setText("not possible"); + + + if (myStep<=1) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + uint16_t acc=0x07; // accept 5c,10c,20c + uint16_t coinVal[16]; + memset(coinVal,0,32); + coinVal[0]=2; + coinVal[3]=49; + coinVal[10]=230; + HWaccess->emp_sendSettings(acc, 12, coinVal); // getestet 19.10.23TS + } + } else + + if (myStep==2) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + HWaccess->changer_requestChangeResult(); + } + } else + + if (myStep==3) + { + if (!myTO->isActive()) + { + myStep=2; + myTO->start(200); + HWaccess->changer_requestTubelevel(); + } + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + diff --git a/win14_mw.h b/win14_mw.h new file mode 100755 index 0000000..5b57447 --- /dev/null +++ b/win14_mw.h @@ -0,0 +1,111 @@ +#ifndef WIN14_MW_H +#define WIN14_MW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win14 : public QWidget +{ + Q_OBJECT + + //QGridLayout *myLayout; + QHBoxLayout *myH0layer, *myH1layer, *myH2layer, *myH3layer, *myH4layer; + QHBoxLayout *myH5layer, *myH6layer, *myH7layer; + QVBoxLayout *myVmainlayer, *myVlayer_left; + QVBoxLayout *myVlayer_midd; + QVBoxLayout *myVlayer_right; + + QHBoxLayout *myHmainlayer; + QVBoxLayout *myV1mainlayer, *myV2mainlayer; + + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + + QTimer *myTO; + //QPushButton *pB1, *pB2, *pB3, *pB4, *pB5, *pB6, *pB7, *pB8; + QLabel *lab20, *lab21, *lab22, *lab23, *lab24, *lab25; + QLabel *lab30, *lab31, *lab32, *lab33, *lab34, *lab35; + QLabel *lab41, *lab43, *insertedCoin, *showChangeRes; + QLabel *labTotalContent; + + //QTextEdit *showStatics; + QTextEdit *showDynamics; + QPushButton *pb_stopPay, *pb_vendSucc; + QPushButton *pb_startPay; + QPushButton *pb_powerOn, *pb_giveChange, *pb_giveAll; + + bool fl_payStarted; + bool fl_storeStartVal; + bool fl_displayLevel; + + uint8_t mw_BeginLevel[8]; + int diffLevel[8]; + long diffAmount; + uint32_t totalContent; + +public: + explicit T_win14(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win14(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_powerOn(void); + void ButtonStartClicked(); + void ButtonStopClicked(void); + void ButtonSuccClicked(void); + void slot_giveChange(void); + void slot_giveAll(void); + + void signalGotNewCoin(); + void signalJustStarted(); + void signalCollectAbort(); + void signalStopByMax(); + void signalStopByUser(); + void signalStopByEscrow(); + void signalStopByError(); + void signalStopTO() ; + void signalCancelled() ; + void signalProcessStop(); + +/* + void slot_pb3(void); + void slot_pb4(void); + void slot_pb5(void); + void slot_pb6(void); + void slot_pb8(void); +*/ + + +}; + +#endif diff --git a/win15_bna.cpp b/win15_bna.cpp new file mode 100755 index 0000000..9caa0c1 --- /dev/null +++ b/win15_bna.cpp @@ -0,0 +1,484 @@ +#include "win15_bna.h" + + + +T_win15::T_win15(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); + + + QFont myTabFont; + myTabFont.setPixelSize(22); + + myTabFont.setPixelSize(PIXELSIZE_LABEL); + lab1 =new QLabel(tr("Bank note reader")); + lab1->setFont(myTabFont); + //myLayout->addWidget(lab1,1,1); + myVlayer_left->addWidget(lab1); + + myTabFont.setPixelSize(PIXELSIZE_DATA); + showDynamics = new QTextEdit("dynamic values:"); + showDynamics->setFont(myTabFont); + showDynamics->setStyleSheet("background-color: white"); + showDynamics->append(" "); + //myLayout->addWidget(showDynamics,3,1); + myVlayer_left->addWidget(showDynamics); + + lab4 =new QLabel(tr("Stacker / Billbox:")); + lab4->setFont(myTabFont); + //myLayout->addWidget(lab4,4,1); + myVlayer_left->addWidget(lab4); + + showStacker = new QTextEdit("stacker content:"); + showStacker->setFont(myTabFont); + showStacker->setStyleSheet("background-color: white"); + showStacker->append(" "); + showStacker->setMinimumHeight(250); + //myLayout->addWidget(showStacker,5,1); + myVlayer_left->addWidget(showStacker); + + lab5 =new QLabel(tr("Reader Data:")); + lab5->setFont(myTabFont); + //myLayout->addWidget(lab5,6,1); + myVlayer_midd->addWidget(lab5); + + showStatics = new QTextEdit("static values:"); + showStatics->setFont(myTabFont); + showStatics->setStyleSheet("background-color: white"); + showStatics->append(" "); + //myLayout->addWidget(showStatics,7,1); + myVlayer_midd->addWidget(showStatics); + + myTabFont.setPixelSize(PIXELSIZE_BUTTONS); + pb_powerOn = new QPushButton(" Power ON"); + pb_powerOn->setFont(myTabFont); + pb_powerOn->setCheckable(true); // true = toggle button + pb_powerOn->setAutoDefault(true); // beim start ein + pb_powerOn->setStyleSheet(COLORWHITE); + connect(pb_powerOn, SIGNAL(clicked()), this, SLOT(slot_powerOn())); + //myLayout->addWidget(pb_powerOn,2,2); + myVlayer_right->addWidget(pb_powerOn); + + pb_sendDefault = new QPushButton("All Bills on"); + pb_sendDefault->setFont(myTabFont); + pb_sendDefault->setStyleSheet(COLORWHITE); + connect(pb_sendDefault, SIGNAL(clicked()), this, SLOT(slot_sendDef())); + //myLayout->addWidget(pb_sendDefault,3,2); + myVlayer_right->addWidget(pb_sendDefault); + + pb_startPay = new QPushButton("Start Payment"); + pb_startPay->setFont(myTabFont); + pb_startPay->setCheckable(false); // true = toggle button + pb_startPay->setAutoDefault(false); // beim start aus + pb_startPay->setStyleSheet(COLORWHITE); + connect(pb_startPay, SIGNAL(clicked()), this, SLOT(slot_start())); + //myLayout->addWidget(pb_startPay, 4,2); + myVlayer_right->addWidget(pb_startPay); + + pb_only10_5 = new QPushButton(" only 10€ & 5€"); + pb_only10_5->setFont(myTabFont); + pb_only10_5->setStyleSheet(COLORWHITE); + connect(pb_only10_5, SIGNAL(clicked()), this, SLOT(slot_send10_5())); + //myLayout->addWidget(pb_only10_5,5,2); + myVlayer_right->addWidget(pb_only10_5); + + pb_only5 = new QPushButton(" only 5€"); + pb_only5->setFont(myTabFont); + pb_only5->setStyleSheet(COLORWHITE); + connect(pb_only5, SIGNAL(clicked()), this, SLOT(slot_send5())); + //myLayout->addWidget(pb_only5,6,2); + myVlayer_right->addWidget(pb_only5); + + pb_stopPay = new QPushButton("Stop Payment"); + pb_stopPay->setFont(myTabFont); + pb_stopPay->setStyleSheet(COLORWHITE); + connect(pb_stopPay, SIGNAL(clicked()), this, SLOT(slot_stop())); + //myLayout->addWidget(pb_stopPay, 7,2); + myVlayer_right->addWidget(pb_stopPay); + + //setLayout(myLayout); + setLayout(myH0layer); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + paymentStarted=false; +} + + +T_win15::~T_win15() +{ + close(); +} + +void T_win15::Nav_back(void) +{ + myNextStep=WCS_WIN15BAK; +} +void T_win15::Nav_home(void) +{ + myNextStep=WCS_WIN15MID; +} +void T_win15::Nav_next(void) +{ + myNextStep=WCS_WIN15FWD; +} + + +void T_win15::slot_powerOn(void) +{ + + if (pb_powerOn->isChecked()) + { + HWaccess->mdb_switchPower(true); + } else + { + HWaccess->mdb_switchPower(false); + } +} + +void T_win15::slot_sendDef(void) +{ + uint16_t bilVals[16]; + + memset(bilVals,0,32); + bilVals[0]=500; + bilVals[1]=1000; + bilVals[2]=2000; + bilVals[3]=5000; + + HWaccess->bna_sendSettings(0b0000000000001111, 0, bilVals, 35000); +} + +void T_win15::slot_start(void) +{ + HWaccess->cash_startPayment(0); + showDynamics->clear(); + showDynamics->setStyleSheet("background-color: white"); + pb_startPay->setStyleSheet(COLORWHITE); + paymentStarted=true; +} + +void T_win15::slot_send10_5(void) +{ + HWaccess->bna_setCurrentAcceptance(0b0000000000000011); +} + +void T_win15::slot_send5(void) +{ + HWaccess->bna_setCurrentAcceptance(0b0000000000000001); +} + +void T_win15::slot_stop(void) +{ + //HWaccess->cash_stopPayment(); + HWaccess->vend_success(); + pb_startPay->setStyleSheet(COLORWHITE); + showDynamics->clear(); + showDynamics->setStyleSheet("background-color: white"); + paymentStarted=false; +} + +bool T_win15::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_win15::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" + + struct T_dynamicCondition myDynMachCond; + *nextScreen=0; // 0=no change + *useNavi=0; + + if (HWaccess->mdb_isMdbPowerOn()) + pb_powerOn->setStyleSheet(COLORGREEN); + else + pb_powerOn->setStyleSheet(COLORWHITE); + + HWaccess->sys_getDynMachineConditions(&myDynMachCond); + if (myDynMachCond.paymentInProgress==2) + { + pb_startPay->setStyleSheet(COLORGREEN); + displayDynamics(); + } + + displayStacker(); + + displayStatics(); + + if (myStep==0) + { + myStep++; + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + HWaccess->bna_requestParameters(); + //qDebug()<<"win15 requesting bna parameters"; + } + } else + + if (myStep==2) + { + if (!myTO->isActive()) + { + myStep++; + myTO->start(200); + HWaccess->bna_requestCurrentNotes(); +//qDebug()<<"win15 requesting bna new bills"; + } + + } else + + if (myStep==3) + { + if (!myTO->isActive()) + { + myStep=1; + myTO->start(200); + HWaccess->bna_requestStackerLevel(); + + } + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + +void T_win15::displayDynamics(void) +{ + uint8_t ret; + uint16_t currentNotes[8]; + uint32_t amount; + static uint8_t lastNoteCount; + + ret= HWaccess->bna_getCurrentNotes(0, currentNotes); + // returns number of collected bank notes since start-command (current transaction) + // latestBill: not used + // currentNotes[0] = last bill value + // currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker) + // currentNotes[2,3] = total sum of collected bills within this transaction + + if (paymentStarted==false) + { + + } else + if (ret==99 ) + { + showDynamics->clear(); + showDynamics->append("BNA ERROR"); + //qDebug() << "BNA ERROR "<< currentNotes[0] <<" "<< currentNotes[1] <<" " + // << currentNotes[2] <<" "<< currentNotes[3]; + if (currentNotes[0]>0) + showDynamics->append(swl_int2str(currentNotes[0])); + if (currentNotes[1]>0) + showDynamics->append(swl_int2str(currentNotes[1])); + if (currentNotes[2]>0) + showDynamics->append(swl_int2str(currentNotes[2])); + if (currentNotes[3]>0) + showDynamics->append(swl_int2str(currentNotes[3])); + showDynamics->setStyleSheet("background-color: red"); + + } else + + if (ret != lastNoteCount) + { + lastNoteCount=ret; + showDynamics->setStyleSheet("background-color: white"); + showDynamics->clear(); + showDynamics->append(swl_labelAndValToStr("count : ", ret)); + showDynamics->append(swl_labelAndValToStr("Last bill: ", currentNotes[0])); + //showDynamics->append(swl_labelAndValToStr("stacked : ", currentNotes[1])); + if (currentNotes[1]==1) + showDynamics->append("in escrow"); + else + showDynamics->append("stacked"); + amount=currentNotes[3]; + amount<<=16; + amount |=currentNotes[2]; + showDynamics->append(swl_labelAndValToStr("total : ", amount)); + } +} + +void T_win15::displayStacker(void) +{ + uint16_t ret; + uint32_t amountInStacker; + uint16_t countOfBills[16]; + static uint16_t stacker_lastCount; + + + ret= HWaccess->bna_getStackerLevel(&amountInStacker, countOfBills); + // return val: nr of bills in stacker + // countOfBills[0..7] = count of bills of bill-type 0..7 (e.g. countOfBills[0]=nr of 5€-bills in stacker) + // countOfBills[8..15] = value of bill-type 0...7 + + if (ret>0 && ret != stacker_lastCount) + { + qDebug()<<"win15 displ stacker "<< ret << " " << stacker_lastCount; + + stacker_lastCount=ret; + showStacker->clear(); + showStacker->append(swl_labelAndValToStr("count of bills : ", ret)); + showStacker->append(swl_labelAndValToStr("total amount : ", amountInStacker)); + showStacker->append(swl_labelAndValToStr("count of bill 0: ", countOfBills[0])); + showStacker->append(swl_labelAndValToStr("count of bill 1: ", countOfBills[1])); + showStacker->append(swl_labelAndValToStr("count of bill 2: ", countOfBills[2])); + showStacker->append(swl_labelAndValToStr("count of bill 3: ", countOfBills[3])); + showStacker->append(swl_labelAndValToStr("count of bill 4: ", countOfBills[4])); + showStacker->append(swl_labelAndValToStr("count of bill 5: ", countOfBills[5])); + showStacker->append(swl_labelAndValToStr("count of bill 6: ", countOfBills[6])); + showStacker->append(swl_labelAndValToStr("count of bill 7: ", countOfBills[7])); + + showStacker->append(swl_labelAndValToStr("value of bill 0: ", countOfBills[8])); + showStacker->append(swl_labelAndValToStr("value of bill 1: ", countOfBills[9])); + showStacker->append(swl_labelAndValToStr("value of bill 2: ", countOfBills[10])); + showStacker->append(swl_labelAndValToStr("value of bill 3: ", countOfBills[11])); + showStacker->append(swl_labelAndValToStr("value of bill 4: ", countOfBills[12])); + showStacker->append(swl_labelAndValToStr("value of bill 5: ", countOfBills[13])); + showStacker->append(swl_labelAndValToStr("value of bill 6: ", countOfBills[14])); + showStacker->append(swl_labelAndValToStr("value of bill 7: ", countOfBills[15])); + showStacker->moveCursor(QTextCursor::Start); + + } + +} + +void T_win15::displayStatics(void) +{ + struct T_bna bna; + static uint16_t lastCountryCode, lastStackLev; + + HWaccess->bna_getAllParameters(&bna); + /* struct T_bna + uint8_t setup; // 0: not 1: got valid parameters from device + uint8_t FeatureLevel; + uint16_t countryCode; // programmed in EMP + uint16_t scalingFactor; // z.B. 5 + uint8_t decimalPlace; + uint8_t pad1; + uint16_t stackerCap; + uint16_t billSecureLevel; + uint8_t hasEscrow; + uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0 + uint16_t currentStackerLevel; // requested number of notes in billbox + + // settings from Master + uint16_t intendedAccept; // bit 0 =5€ + uint16_t pad2; + uint16_t billDenomination[16]; + }; */ + + //if (bna.countryCode>0) + // qDebug()<<"win15 got CountryCode" << bna.countryCode; + + if (bna.countryCode>0 && (lastCountryCode!=bna.intendedAccept || lastStackLev != bna.currentStackerLevel)) + { + lastCountryCode = bna.intendedAccept; + lastStackLev = bna.currentStackerLevel; + + showStatics->clear(); + showStatics->append(swl_labelAndValToStr("Parameter valid:", bna.setup)); + showStatics->append(swl_labelAndValToStr("countryCode: ", bna.countryCode )); + showStatics->append(swl_labelAndValToStr("scalingFactor: ", bna.scalingFactor)); + showStatics->append(swl_labelAndValToStr("decimals: ", bna.decimalPlace )); + showStatics->append(swl_labelAndValToStr("stackerCap: ", bna.stackerCap )); + showStatics->append(swl_labelAndValToStr("curr. st.Level: ", bna.currentStackerLevel )); + showStatics->append(swl_labelAndValToStr("intend accept : ", bna.intendedAccept )); + showStatics->append(" "); + showStatics->append(swl_labelAndValToStr("accBillTypes 1: ", bna.accBillTypes[0] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 2: ", bna.accBillTypes[1] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 3: ", bna.accBillTypes[2] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 4: ", bna.accBillTypes[3] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 5: ", bna.accBillTypes[4] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 6: ", bna.accBillTypes[5] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 7: ", bna.accBillTypes[6] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 8: ", bna.accBillTypes[7] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes 9: ", bna.accBillTypes[8] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes10: ", bna.accBillTypes[9] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes11: ", bna.accBillTypes[10] *bna.scalingFactor )); + showStatics->append(swl_labelAndValToStr("accBillTypes12: ", bna.accBillTypes[11] *bna.scalingFactor )); + + //showStatics->append(swl_labelAndValToStr("curr. st.Level: ", bna.currentStackerLevel )); + //showStatics->append(swl_labelAndValToStr("intend accept : ", bna.intendedAccept )); + showStatics->append(swl_labelAndValToStr("intend denom 1: ", bna.billDenomination[0] )); + showStatics->append(swl_labelAndValToStr("intend denom 2: ", bna.billDenomination[1] )); + showStatics->append(swl_labelAndValToStr("intend denom 3: ", bna.billDenomination[2] )); + showStatics->append(swl_labelAndValToStr("intend denom 4: ", bna.billDenomination[3] )); + showStatics->append(swl_labelAndValToStr("intend denom 5: ", bna.billDenomination[4] )); + showStatics->append(swl_labelAndValToStr("intend denom 16 ", bna.billDenomination[5] )); + showStatics->append(swl_labelAndValToStr("intend denom 7: ", bna.billDenomination[6] )); + showStatics->append(swl_labelAndValToStr("intend denom 8: ", bna.billDenomination[7] )); + showStatics->append(swl_labelAndValToStr("intend denom 9: ", bna.billDenomination[8] )); + showStatics->append(swl_labelAndValToStr("intend denom10: ", bna.billDenomination[9] )); + showStatics->append(swl_labelAndValToStr("intend denom11: ", bna.billDenomination[10] )); + showStatics->append(swl_labelAndValToStr("intend denom12: ", bna.billDenomination[11] )); + showStatics->moveCursor(QTextCursor::Start); + } + +} + + diff --git a/win15_bna.h b/win15_bna.h new file mode 100755 index 0000000..c4173c2 --- /dev/null +++ b/win15_bna.h @@ -0,0 +1,78 @@ +#ifndef WIN15_BNA_H +#define WIN15_BNA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win15 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + QHBoxLayout *myH0layer; + QVBoxLayout *myVlayer_left; + QVBoxLayout *myVlayer_midd; + QVBoxLayout *myVlayer_right; + + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1, *lab2, *lab3, *lab4, *lab5; + QTimer *myTO; + + QPushButton *pb_powerOn, *pb_sendDefault, *pb_only10_5, *pb_only5; + QTextEdit *showDynamics, *showStatics, *showStacker; + QPushButton *pb_startPay, *pb_stopPay; + + void displayDynamics(void); + void displayStacker(void); + void displayStatics(void); + + bool paymentStarted; + +public: + explicit T_win15(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win15(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + void slot_powerOn(void); + void slot_sendDef(void); + void slot_send10_5(void); + void slot_send5(void); + void slot_start(void); + void slot_stop(void); + + + + +}; + +#endif diff --git a/win16.cpp b/win16.cpp new file mode 100755 index 0000000..9bf7507 --- /dev/null +++ b/win16.cpp @@ -0,0 +1,137 @@ +#include "win16.h" + + + +T_win16::T_win16(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("win16")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + 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; +} + + +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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win16.h b/win16.h new file mode 100755 index 0000000..4d3ecc7 --- /dev/null +++ b/win16.h @@ -0,0 +1,56 @@ +#ifndef WIN16_H +#define WIN16_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win16 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win16(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win16(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif diff --git a/win17.cpp b/win17.cpp new file mode 100755 index 0000000..4f61cd0 --- /dev/null +++ b/win17.cpp @@ -0,0 +1,136 @@ +#include "win17.h" + + + +T_win17::T_win17(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("win17")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win17::~T_win17() +{ + close(); +} + +void T_win17::Nav_back(void) +{ + myNextStep=WCS_WIN17BAK; +} +void T_win17::Nav_home(void) +{ + myNextStep=WCS_WIN17MID; +} +void T_win17::Nav_next(void) +{ + myNextStep=WCS_WIN17FWD; +} + +bool T_win17::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_win17::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win17.h b/win17.h new file mode 100755 index 0000000..a3484e3 --- /dev/null +++ b/win17.h @@ -0,0 +1,56 @@ +#ifndef WIN17_H +#define WIN17_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win17 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win17(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win17(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif diff --git a/win18.cpp b/win18.cpp new file mode 100755 index 0000000..13a6eed --- /dev/null +++ b/win18.cpp @@ -0,0 +1,137 @@ +#include "win18.h" + + + +T_win18::T_win18(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("win18")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win18::~T_win18() +{ + close(); +} + +void T_win18::Nav_back(void) +{ + myNextStep=WCS_WIN18BAK; +} +void T_win18::Nav_home(void) +{ + myNextStep=WCS_WIN18MID; +} +void T_win18::Nav_next(void) +{ + myNextStep=WCS_WIN18FWD; +} + + +bool T_win18::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_win18::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win18.h b/win18.h new file mode 100755 index 0000000..bb892e9 --- /dev/null +++ b/win18.h @@ -0,0 +1,56 @@ +#ifndef WIN18_H +#define WIN18_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win18 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win18(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win18(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif diff --git a/win19.cpp b/win19.cpp new file mode 100755 index 0000000..caf98b8 --- /dev/null +++ b/win19.cpp @@ -0,0 +1,137 @@ +#include "win19.h" + + + +T_win19::T_win19(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("win19")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win19::~T_win19() +{ + close(); +} + +void T_win19::Nav_back(void) +{ + myNextStep=WCS_WIN19BAK; +} +void T_win19::Nav_home(void) +{ + myNextStep=WCS_WIN19MID; +} +void T_win19::Nav_next(void) +{ + myNextStep=WCS_WIN19FWD; +} + + +bool T_win19::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_win19::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win19.h b/win19.h new file mode 100755 index 0000000..9982cc7 --- /dev/null +++ b/win19.h @@ -0,0 +1,56 @@ +#ifndef WIN19_H +#define WIN19_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win19 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win19(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win19(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif diff --git a/win20.cpp b/win20.cpp new file mode 100755 index 0000000..da09cd6 --- /dev/null +++ b/win20.cpp @@ -0,0 +1,136 @@ +#include "win20.h" + + + +T_win20::T_win20(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("win20")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win20::~T_win20() +{ + close(); +} + +void T_win20::Nav_back(void) +{ + myNextStep=WCS_WIN20BAK; +} +void T_win20::Nav_home(void) +{ + myNextStep=WCS_WIN20MID; +} +void T_win20::Nav_next(void) +{ + myNextStep=WCS_WIN20FWD; +} + +bool T_win20::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_win20::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win20.h b/win20.h new file mode 100755 index 0000000..758db9a --- /dev/null +++ b/win20.h @@ -0,0 +1,56 @@ +#ifndef WIN20_H +#define WIN20_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win20 : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win20(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win20(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif diff --git a/win_template.cpp b/win_template.cpp new file mode 100755 index 0000000..ab9b300 --- /dev/null +++ b/win_template.cpp @@ -0,0 +1,139 @@ +#include "win_template.h" + + + +T_win_template::T_win_template(hwinf *HWaccess, QWidget *parent) : QWidget(parent) +{ + this->HWaccess = HWaccess; + + myLayout = new QGridLayout; + + QFont myTabFont; + myTabFont.setPixelSize(22); + + lab1 =new QLabel(tr("template screen")); + lab1->setFont(myTabFont); + myLayout->addWidget(lab1,1,0); + + lab2 =new QLabel(tr(" ")); + lab2->setFont(myTabFont); + myLayout->addWidget(lab2,2,0); + + lab3 =new QLabel(tr(" ")); + lab3->setFont(myTabFont); + myLayout->addWidget(lab3,3,0); + + setLayout(myLayout); + myNextStep=0; + myStep=0; + + myTO = new QTimer(); + myTO->setSingleShot(true); + myTO->start(2000); + +} + +T_win_template::~T_win_template() +{ + close(); +} + +void T_win_template::Nav_back(void) +{ + myNextStep=WCS_WIN99BAK; + +} +void T_win_template::Nav_home(void) +{ + myNextStep=WCS_WIN99MID; +} +void T_win_template::Nav_next(void) +{ + myNextStep=WCS_WIN99FWD; + +} + +bool T_win_template::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_OFF | SWITCH_HOME_ON | SWITCH_NEXT_ON; + myNextStep=0; + return false; +} + +bool T_win_template::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 (myStep==0) + { + myTO->start(); // restart + } else + + if (myStep==1) + { + if (!myTO->isActive()) + { + // time out + } + } else + + if (myStep==2) + { + + } else + + if (myStep==3) + { + + } else + if (myStep==4) + { + + } else + if (myStep==5) + { + + } else + + if (myStep==6) + { + + } else + + if (myStep==7) + { + + } else + { + + } + + if (myNextStep) + { + //qDebug()<<"fenster1 working: "<< myNextStep; + *nextScreen=myNextStep; + myNextStep=0; + } + return false; +} + + diff --git a/win_template.h b/win_template.h new file mode 100755 index 0000000..7d80241 --- /dev/null +++ b/win_template.h @@ -0,0 +1,56 @@ +#ifndef WIN_TEMPLATE_H +#define WIN_TEMPLATE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tslib.h" +#include "stepList.h" +#include "plugin.h" +#include "guidefs.h" + +class T_win_template : public QWidget +{ + Q_OBJECT + + QGridLayout *myLayout; + hwinf *HWaccess; + uint16_t myNextStep; + uint8_t myStep; + QLabel *lab1; + QLabel *lab2; + QLabel *lab3; + QTimer *myTO; + +public: + explicit T_win_template(hwinf *HWaccess = nullptr, QWidget *parent = nullptr); + bool work_ini(uint16_t *nextScreen, uint8_t *useNavi); + // useNavi=0: no change + // bit0,1: enable/disable button "next" + // bit2,3: enable/disable button "home" + // bit4,5: enable/disable button "back" + bool working (uint16_t *nextScreen, uint8_t *useNavi); + ~T_win_template(); + +public slots: + void Nav_back(void); + void Nav_home(void); + void Nav_next(void); + +}; + +#endif