394 lines
15 KiB
C++
394 lines
15 KiB
C++
#ifndef VMC_H
|
|
#define VMC_H
|
|
|
|
#include "com_interface.h"
|
|
#include "VMC/ReceiveBuffer.h"
|
|
#include "SendBuffer.h"
|
|
#include <QObject>
|
|
#include <QByteArray>
|
|
#include <QStateMachine>
|
|
#include <QDebug>
|
|
#include <QTimer>
|
|
#include <QList>
|
|
#include <QSettings>
|
|
#include "version.h"
|
|
|
|
|
|
#define VMC_RECEIVE_TIMEOUT 1000
|
|
|
|
|
|
|
|
|
|
#define VMC_CMD_SW_VERSION 0x10
|
|
#define VMC_CMD_STATUS_REQUEST 0x11
|
|
|
|
#define VMC_CMD_SCREEN 0x44
|
|
#define VMC_CMD_LANGUAGE 0x46
|
|
|
|
#define VMC_CMD_DISP_LICENCE_PLATE 0x48
|
|
#define VMC_CMD_DISP_PRODUCT 0x49
|
|
#define VMC_CMD_DISP_PARKTIME_END 0x50
|
|
#define VMC_CMD_DISP_PRICE 0x51
|
|
#define VMC_CMD_DATE_TIME 0x52
|
|
#define VMC_CMD_DISP_LINE1 0x53
|
|
#define VMC_CMD_DISP_LINE2 0x54
|
|
#define VMC_CMD_USER_MESSAGE 0x55
|
|
#define VMC_CMD_DISP_AMOUNT_TO_PAY 0x56
|
|
|
|
#define VMC_CMD_TEXT 0x60
|
|
#define VMC_CMD_TEXT_ENC 0x61
|
|
|
|
#define VMC_CMD_MACHINE_NR 0x62
|
|
#define VMC_CMD_SYSTEM 0x63
|
|
#define VMC_CMD_PSA_CONFIG 0x64
|
|
|
|
#define VMC_CMD_BUSY 0x66
|
|
#define VMC_CMD_MESSAGE_BOX 0x67
|
|
|
|
#define VMC_CMD_END_PRG 0x70 // kill ATBQT
|
|
#define VMC_CMD_SHUTDOWN_SYSTEM 0x71 // 'halt'
|
|
#define VMC_CMD_RESTART_PRG 0x72 // restart ATBQT
|
|
#define VMC_CMD_RESTART_SYSTEM 0x73 // reboot ptu
|
|
|
|
#define VMC_CMD_SCREEN_CFG 0x90
|
|
|
|
#define VMC_CMD_FORMATED_STRING 0xD0
|
|
|
|
#define VMC_CMD_VMC_SYSTEM 0xE0
|
|
|
|
#define VMC_CMD_SCREEN_INVALID 0x00
|
|
#define VMC_CMD_SCREEN_START 0x30
|
|
#define VMC_CMD_SCREEN_LICPLT 0x31
|
|
#define VMC_CMD_SCREEN_PRODUCT 0x32
|
|
#define VMC_CMD_SCREEN_PARKEND 0x33
|
|
#define VMC_CMD_SCREEN_PAYMETH 0x34
|
|
#define VMC_CMD_SCREEN_CREDITCARD 0x35
|
|
#define VMC_CMD_SCREEN_WAIT_FOR 0x36
|
|
#define VMC_CMD_SCREEN_GOODBYE 0x37
|
|
#define VMC_CMD_SCREEN_CASHPAY 0x38
|
|
#define VMC_CMD_SCREEN_PIN 0x39
|
|
#define VMC_CMD_SCREEN_RESIDENT 0x3A
|
|
#define VMC_CMD_SCREEN_GOODBYE2 0x3B
|
|
#define VMC_CMD_SCREEN_RECEIPT 0x3C
|
|
#define VMC_CMD_SCREEN_FREEPARK 0x3D
|
|
#define VMC_CMD_SCREEN_DEFBUTTONS 0x3E
|
|
#define VMC_CMD_SCREEN_PAYMETHODE1 0x3F
|
|
#define VMC_CMD_SCREEN_PAYMETHODE2 0x40
|
|
#define VMC_CMD_SCREEN_PAYMETHODE3 0x41
|
|
#define VMC_CMD_SCREEN_PAYMETHODE4 0x42
|
|
#define VMC_CMD_SCREEN_CARDSTATUS 0x43
|
|
#define VMC_CMD_SCREEN_PAYMETHODE5 0x44
|
|
#define VMC_CMD_SCREEN_PAYMETHODE6 0x45
|
|
#define VMC_CMD_SCREEN_PAYMETHODE7 0x46
|
|
#define VMC_CMD_SCREEN_CREDITCARDABORT 0x47
|
|
#define VMC_CMD_SCREEN_PAYMETHODE8 0x48
|
|
#define VMC_CMD_SCREEN_REMOVECARD 0x49
|
|
#define VMC_CMD_SCREEN_GOODBYE3 0x4A
|
|
#define VMC_CMD_SCREEN_GENERALABORT 0x4B
|
|
#define VMC_CMD_SCREEN_ABORT2 0x4C
|
|
#define VMC_CMD_SCREEN_ABORT3 0x4D
|
|
#define VMC_CMD_SCREEN_GOODBYE4 0x4E
|
|
#define VMC_CMD_SCREEN_GOODBYE5 0x4F
|
|
// note: SCREEN_COMMON is 0x50
|
|
#define VMC_CMD_SCREEN_FINEPAYMENT 0x51
|
|
#define VMC_CMD_SCREEN_CREDITCARD2 0x52
|
|
#define VMC_CMD_SCREEN_CREDITCARD3 0x53
|
|
#define VMC_CMD_SCREEN_RECEIPT2 0x54
|
|
#define VMC_CMD_SCREEN_CREDITCARD4 0x55
|
|
#define VMC_CMD_SCREEN_TWO_PRODUCTS1 0x56
|
|
#define VMC_CMD_SCREEN_TWO_PRODUCTS2 0x57
|
|
#define VMC_CMD_SCREEN_PARKTIME1 0x5a
|
|
#define VMC_CMD_SCREEN_PARKTIME2 0x5b
|
|
#define VMC_CMD_SCREEN_DATETIME1 0x5c
|
|
#define VMC_CMD_SCREEN_DATETIME2 0x5d
|
|
#define VMC_CMD_SCREEN_DIAG 0x60
|
|
#define VMC_CMD_SCREEN_WELCOME1 0x61
|
|
#define VMC_CMD_SCREEN_WELCOME2 0x62
|
|
#define VMC_CMD_SCREEN_WELCOME3 0x63
|
|
#define VMC_CMD_SCREEN_WELCOME4 0x64
|
|
#define VMC_CMD_SCREEN_OOO 0x65
|
|
#define VMC_CMD_SCREEN_WAIT1 0x6A
|
|
#define VMC_CMD_SCREEN_WAIT2 0x6B
|
|
#define VMC_CMD_SCREEN_WAIT3 0x6C
|
|
#define VMC_CMD_SCREEN_WAIT4 0x6D
|
|
#define VMC_CMD_SCREEN_TARIF 0x70
|
|
#define VMC_CMD_SCREEN_HELP1 0x71
|
|
#define VMC_CMD_SCREEN_HELP2 0x72
|
|
#define VMC_CMD_SCREEN_HELP3 0x73
|
|
#define VMC_CMD_SCREEN_HELP4 0x74
|
|
#define VMC_CMD_SCREEN_HELP5 0x75
|
|
#define VMC_CMD_SCREEN_ABORT4 0x80
|
|
#define VMC_CMD_SCREEN_ABORT5 0x81
|
|
#define VMC_CMD_SCREEN_BARCODE 0x82
|
|
#define VMC_CMD_SCREEN_AGEVERIFICATION 0x83
|
|
#define VMC_CMD_SCREEN_DEFBUTTONS2 0x84
|
|
#define VMC_CMD_SCREEN_DEFBUTTONS3 0x85
|
|
#define VMC_CMD_SCREEN_PRINT2 0x86
|
|
#define VMC_CMD_SCREEN_PRINT3 0x87
|
|
#define VMC_CMD_SCREEN_QRCODE_RECEIPT 0x88
|
|
#define VMC_CMD_SCREEN_LICPLT2 0x90
|
|
#define VMC_CMD_SCREEN_LICPLT3 0x91
|
|
#define VMC_CMD_SCREEN_LICPLT4 0x92
|
|
#define VMC_CMD_SCREEN_ABORT6 0x93
|
|
#define VMC_CMD_SCREEN_ABORT7 0x94
|
|
#define VMC_CMD_SCREEN_PARKEND2 0xA0
|
|
#define VMC_CMD_SCREEN_PARKEND3 0xA1
|
|
|
|
|
|
#define VMC_CMD_SCREEN_COMMON 0x50
|
|
#define VMC_CMD_SCREEN_MESSAGE_BOX 0xF1
|
|
// CARD_SERVICE_ERROR_TEXTS 0xFA
|
|
|
|
#define ACK 0x06
|
|
#define NACK 0x15
|
|
|
|
class ReceiveBuffer;
|
|
class SendBuffer;
|
|
|
|
using FormatedStringList = QList<QByteArray>;
|
|
|
|
|
|
class VMC : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
|
|
private:
|
|
QObject *m_appControl;
|
|
COM_interface *com_interface;
|
|
ReceiveBuffer *receiveBuffer;
|
|
SendBuffer *sendBuffer;
|
|
QSettings const *m_settings;
|
|
|
|
// internal: write a ByteArray to com-port:
|
|
int SendMessage(QByteArray ba, bool enqueue = false);
|
|
|
|
quint16 parseSystemCommand(QByteArray & cmd);
|
|
quint8 parseTextCommand(QByteArray & cmd);
|
|
quint8 parseTextCommandEnc(QByteArray & cmd);
|
|
quint8 parseDataDisplayCommand(QByteArray & cmd);
|
|
quint8 parseDateCommand(QByteArray & cmd);
|
|
quint8 parseUserMessageCommand(QByteArray & cmd);
|
|
quint8 parseLanguageCommand(QByteArray & cmd);
|
|
quint8 parseBusyCommand(QByteArray & cmd);
|
|
quint8 parseScreenConfigCommand(QByteArray & cmd);
|
|
quint8 parsePSAConfigCommand(QByteArray & cmd);
|
|
quint8 parseShowMessageBoxCommand(QByteArray & cmd);
|
|
quint8 parseVMCSystemMessage(QByteArray & cmd);
|
|
quint8 parseVMCFormatedString(QByteArray & cmd);
|
|
|
|
QString & privateHandleDataCommand_Amount(quint8 data, QString & dataString);
|
|
QString & privateHandleDataCommand_AmountToPay(quint8 data, QString & dataString);
|
|
|
|
QTimer *sendDelayTimer;
|
|
QString delayedMessage;
|
|
|
|
quint8 flag_blockVMCScreen;
|
|
quint16 currentCachedScreen;
|
|
|
|
private slots:
|
|
void onDelayedMessageTimerTimeout();
|
|
|
|
void skipDiscount();
|
|
|
|
public:
|
|
explicit VMC(QObject *eventReceiver, QSettings const *settings,
|
|
QObject *parent = nullptr);
|
|
~VMC();
|
|
|
|
int SendMessage(QString msg);
|
|
int SendMessageDelayed(QString msg, int delay);
|
|
|
|
int SendACK();
|
|
int SendNACK();
|
|
|
|
int sendButtonChar(QChar c);
|
|
|
|
int SendButton0(); // 0 - 3E 45 31 30 E4
|
|
int SendButton1(); // 1 - 3E 45 31 31 E5
|
|
int SendButton2(); // 2 - 3E 45 31 32 E6
|
|
int SendButton3(); // 3 - 3E 45 31 33 E7
|
|
int SendButton4(); // 4 - 3E 45 31 34 E8
|
|
int SendButton5(); // 5 - 3E 45 31 35 E9
|
|
int SendButton6(); // 6 - 3E 45 31 36 EA
|
|
int SendButton7(); // 7 - 3E 45 31 37 EB
|
|
int SendButton8(); // 8 - 3E 45 31 38 EC
|
|
int SendButton9(); // 9 - 3E 45 31 39 ED
|
|
|
|
int SendButtonNext(); // 10 - 3E 45 31 3A EE
|
|
int SendButtonBack(); // 11 - 3E 45 31 3B EF
|
|
int SendButtonCancel(); // 12 - 3E 45 31 3C F0
|
|
|
|
int SendButtonStart(); // 13 - 3E 45 31 3D F1
|
|
int SendButtonHelp(); // 14 - 3E 45 31 3E F2
|
|
int SendButtonTarif(); // 15 - 3E 45 31 3F F3
|
|
|
|
int SendButtonStart2(); // - 3E 45 31 A0 cs
|
|
int SendButtonStart3(); // - 3E 45 31 A1 cs
|
|
int SendButtonStart4(); // - 3E 45 31 A2 cs
|
|
|
|
int SendButtonArrowLeft(); // 16 - 3E 45 31 83 cs
|
|
int SendButtonArrowRight(); // 17 - 3E 45 31 84 cs -
|
|
int SendButtonArrowUp(); // 18 - 3E 45 31 85 cs -
|
|
int SendButtonArrowDown(); // 19 - 3E 45 31 86 cs -
|
|
|
|
int SendButtonCardTypeLeft(); // 20 - 3E 45 31 87 cs -
|
|
int SendButtonCardTypeRight(); // 21 - 3E 45 31 88 cs -
|
|
|
|
int SendButtonA(); // 'A' - 3E 45 31 41 F5
|
|
int SendButtonB(); // 'B' - 3E 45 31 42 F6
|
|
int SendButtonC(); // 'C' - 3E 45 31 43 F7
|
|
int SendButtonD(); // 'D' - 3E 45 31 44 F8
|
|
int SendButtonE(); // 'E' - 3E 45 31 45 F9
|
|
int SendButtonF(); // 'F' - 3E 45 31 46 FA
|
|
int SendButtonG(); // 'G' - 3E 45 31 47 FB
|
|
int SendButtonH(); // 'H' - 3E 45 31 48 FC
|
|
int SendButtonI(); // 'I' - 3E 45 31 49 FD
|
|
int SendButtonJ(); // 'J' - 3E 45 31 4A FE
|
|
int SendButtonK(); // 'K' - 3E 45 31 4B FF
|
|
int SendButtonL(); // 'L' - 3E 45 31 4C 00
|
|
int SendButtonM(); // 'M' - 3E 45 31 4D 01
|
|
int SendButtonN(); // 'N' - 3E 45 31 4E 02
|
|
int SendButtonO(); // 'O' - 3E 45 31 4F 03
|
|
int SendButtonP(); // 'P' - 3E 45 31 50 04
|
|
int SendButtonQ(); // 'Q' - 3E 45 31 51 05
|
|
int SendButtonR(); // 'R' - 3E 45 31 52 06
|
|
int SendButtonS(); // 'S' - 3E 45 31 53 07
|
|
int SendButtonT(); // 'T' - 3E 45 31 54 08
|
|
int SendButtonU(); // 'U' - 3E 45 31 55 09
|
|
int SendButtonV(); // 'V' - 3E 45 31 56 0A
|
|
int SendButtonW(); // 'W' - 3E 45 31 57 0B
|
|
int SendButtonX(); // 'X' - 3E 45 31 58 0C
|
|
int SendButtonY(); // 'Y' - 3E 45 31 59 0D
|
|
int SendButtonZ(); // 'Z' - 3E 45 31 5A 0E
|
|
int SendButtonUE(); // 'Ü' - 3E 45 31 DC - ISO 8859-1 (Latin-1): 'Ü'
|
|
int SendButtonOE(); // 'Ö' - 3E 45 31 D6 - ISO 8859-1 (Latin-1): 'Ö'
|
|
int SendButtonAE(); // 'Ä' - 3E 45 31 C4 - ISO 8859-1 (Latin-1): 'Ä'
|
|
|
|
int SendButtonDEL(); // DELL - 3E 45 31 7F 33
|
|
|
|
int SendButtonDash(); // '-' - 3E 45 31 2D E1
|
|
int SendButtonSpace(); // ' ' - 3E 45 31 20 D4
|
|
|
|
int SendButtonClose(); // - 3E 45 31 80 cs
|
|
int SendButtonYes(); // - 3E 45 31 81 cs
|
|
int SendButtonNo(); // - 3E 45 31 82 cs
|
|
|
|
int SendButtonVehicleDefintion1(); // 0x90 - 3E 45 31 90 cs
|
|
int SendButtonVehicleDefintion2(); // 0x91 - 3E 45 31 91 cs
|
|
int SendButtonVehicleDefintion3(); // 0x92 - 3E 45 31 92 cs
|
|
int SendButtonVehicleDefintion4(); // 0x93 - 3E 45 31 93 cs
|
|
int SendButtonVehicleDefintion5(); // 0x94 - 3E 45 31 94 cs
|
|
int SendButtonVehicleDefintion6(); // 0x95 - 3E 45 31 95 cs
|
|
int SendButtonVehicleDefintion7(); // 0x96 - 3E 45 31 96 cs
|
|
int SendButtonVehicleDefintion8(); // 0x97 - 3E 45 31 97 cs
|
|
|
|
int SendButtonPaymethode1(); // 0x98 - 3E 45 31 98 cs
|
|
int SendButtonPaymethode2(); // 0x99 - 3E 45 31 99 cs
|
|
int SendButtonPaymethode3(); // 0x9a - 3E 45 31 9a cs
|
|
int SendButtonPaymethode4(); // 0x9b - 3E 45 31 9b cs
|
|
|
|
int SendSystemMessage(quint8 nr); // 0xF0 - 3E F0 31 nr cs
|
|
int SendSystemMessageStart(); // 0xF0 - 3E F0 31 31 cs
|
|
int SendSystemMessageTimeout(); // 0xF0 - 3E F0 31 32 cs
|
|
|
|
|
|
|
|
int SendButtonServiceOK(QString MessageString);
|
|
|
|
// deprecated:
|
|
int SendLicPlate(QString licplate);
|
|
int SendBarcode(QString barcode);
|
|
int SendAmountDueTax(QString amount);
|
|
int SendAmountDueNet(QString amount);
|
|
int SendAmountDuePeriodStart(QString startTime);
|
|
int SendAmountDuePeriodEnd(QString endTime);
|
|
int SendCracePeriod(QString minute);
|
|
int SendGeneratedPinNumber(QString pin);
|
|
|
|
// from former "Bewonerscode": send code and id
|
|
int SendId(QString id);
|
|
int SendCode(QString code);
|
|
|
|
|
|
int SendFormatedString(QString formatString);
|
|
int SendFormatedStringError(QString errorString);
|
|
|
|
int SendLangSwitch(quint8 nr);
|
|
|
|
int SendVersion(QString VersionString); // 3E 10 14 .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. CRC
|
|
|
|
int SendCurrentState();
|
|
|
|
void blockScreenSwitch(quint8 mode);
|
|
quint16 getCurrentCachedScreen();
|
|
|
|
signals:
|
|
void CommandProcessed(); // sent to ReceiveBuffer if a command is processed
|
|
|
|
void retriggerModeSell();
|
|
|
|
void setBusy();
|
|
void resetBusy();
|
|
|
|
void showMessageBox(quint8 type, quint8 text);
|
|
|
|
void sysCommand(quint16 cmd, QByteArray data);
|
|
//void PSAconfig(quint16 cust_nr, quint16 group_nr, quint16 zone_nr, quint16 machine_nr);
|
|
void setCustNr(const QString & cust_nr);
|
|
void setGroupNr(const QString & group_nr);
|
|
void setZoneNr(const QString & zone_nr);
|
|
void setMachineNr(const QString & machine_nr);
|
|
void displayData(quint8 infoFild, QString text);
|
|
void newDateTime(const QString & dateTimeString);
|
|
|
|
void setLanguage(quint8 lang);
|
|
void setDefaultLanguage(quint8 lang);
|
|
|
|
|
|
void userMessage(quint8 messagenr, quint8 action);
|
|
|
|
void writeLog(QString str);
|
|
void writeLogReceived(QByteArray ba);
|
|
void writeLogSent(QByteArray ba);
|
|
|
|
void wakeVMC();
|
|
|
|
void ccStartTransaction();
|
|
void ccConfirmTransaction();
|
|
void ccCancelTransaction();
|
|
void ccStartPreauthorisation();
|
|
void ccConfirmPreauthorisation();
|
|
void ccCancelPreauthorisation();
|
|
void ccStartReadCard();
|
|
|
|
void ccWakup();
|
|
void ccSleep();
|
|
|
|
#ifdef USE_BARCODESCANNER
|
|
void requestNewBarcode();
|
|
#endif
|
|
|
|
void VMCSystemSellingProcessStart();
|
|
void VMCSystemSellingProcessStop();
|
|
void VMCSystemTransactionSuccess();
|
|
|
|
void VMCFormatedString(FormatedStringList);
|
|
|
|
void setVendingData(QString key, QByteArray value);
|
|
|
|
public slots:
|
|
void CommandAvaliable(QByteArray message); // called when a message is in receive buffer
|
|
void onReceiveError(RECEIVE_ERROR error); // for response on wrong vmc commands
|
|
void onSendError(SEND_ERROR error); // for react on e.g. a non answering vmc
|
|
|
|
int SendLongFormatedString(QString formatString);
|
|
int SendLongFormatedStringReference(QString & formatedString);
|
|
|
|
void ccStartTransactionRequest(); // called to start/restart a CC transaction
|
|
void ccStartConfirmTransaction(); // called to start confirmation
|
|
void ccPrintReceipt(QString receipt); // called to send receipt to vmc
|
|
};
|
|
|
|
#endif // VMC_H
|