Update interface hwapi 3.6

This commit is contained in:
Siegfried Siegert 2023-06-05 12:51:55 +02:00
parent de1dc88e51
commit 2717c614e3
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 1757 additions and 1727 deletions

259
include/interfaces.h Normal file → Executable file
View File

@ -2,9 +2,12 @@
#define INTERFACE_H
#include <QtPlugin>
#include <QStringList>
struct T_emp {
struct T_emp
{
// Fixdata from EMP:
uint8_t shaft; // = changer level
uint16_t countryCode;
@ -21,19 +24,29 @@ struct T_emp {
// 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,
// 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 {
struct Trtc_DateTime
{
uint8_t rtc_hour;
uint8_t rtc_min;
uint8_t rtc_sec;
@ -43,7 +56,8 @@ struct Trtc_DateTime {
uint8_t rtc_dayOfWeek;
};
struct Tprn_hw_state {
struct Tprn_hw_state
{
// hardware (IO's)
bool powerRdBk; // prn pwr is on
bool rsSwOk; // serial switch (printer or modem) is set to printer
@ -60,7 +74,8 @@ struct Tprn_hw_state {
bool badResponse;
};
struct Tprn_currentSettings {
struct Tprn_currentSettings
{
uint8_t currFont;
uint8_t currSize;
uint8_t currHeigth;
@ -73,18 +88,23 @@ struct Tprn_currentSettings {
bool nowAligned;
};
struct T_dynDat {
// obsolete
struct T_dynDat
{
uint8_t licensePlate[8];
uint8_t vendingPrice[8];
uint8_t parkingEndTime[8];
uint8_t parkingEndDate[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 {
struct T_vaultRecord
{
// Kassenbeleg (Abrechnungsdatensatz = Kassenwechsel-Datensatz)
char startbuffer[4]; // Psa> // never move or change this 1st entry
uint16_t AccountingNumber;
@ -111,23 +131,26 @@ struct T_vaultRecord {
//16
char label3buffer[4]; // mw >
// Verkauf, Tür zu:
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
// Verkauf, Tür zu:
uint32_t VKcoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
uint32_t VKcoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
//88
// Service, Tür offen:
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
// Service, Tür offen:
uint16_t ServCoinsInserted[16]; // nur für Wechsler, soviel wurde eingeworfen
uint16_t ServCoinsReturned[6]; // nur für Wechsler, Anzahl Münzen pro Typ, soviel wurde zurückgegeben
uint16_t resint3;
uint16_t resint4;
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
uint16_t currentTubeContent[6]; // nur für Wechsler, aktueller Füllstand
uint16_t resint5;
uint16_t resint6;
// 56
char label4buffer[4]; // box>
uint16_t coinsInVault[16];
uint16_t billsInStacker[8];
// 48
char label5buffer[4]; // val>
// actually constant unless exchange rate is changed
uint16_t coinDenomination[16]; // 5..50000 (z.B. 2? sind in Ungarn 760Ft)
@ -135,12 +158,17 @@ struct T_vaultRecord {
uint16_t tubeDenom[6];
uint16_t exchangeRate;
uint16_t resint9;
// 64
char endofblock[4]; // end>
// 316 byte Block im Speicher
};
struct T_moduleCondition {
struct T_moduleCondition
{
// store conditon of all system components, hold in RAM
// 0 means unknown, not yet tested/used
// 1 means OK
@ -182,26 +210,41 @@ struct T_moduleCondition {
uint8_t ResetReason;
uint8_t allModulesChecked;
uint8_t alarmState;
uint8_t res11;
uint8_t res12;
uint8_t res13;
};
struct T_dynamicCondition {
char allDoorsDebounced; // 99: undefined, 0=all closed, bit1=upper door open 2=midlle door open 3=lower door open
struct T_dynamicCondition
{
char allDoorsDebounced;
char openedAuthorized;
uint8_t CBinDebounced;
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; // not used, always 0
char reserve;
char billBox;
char modeAbrech;
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
char nowCardTest;
char nowPayment;
char nowPayment; // not used, always 0
char lastMifCardType;
uint8_t lastSDoorState;
uint8_t lastVDoorState;
uint8_t lastCBstate; // 99: undefined 0:not there 1:insered
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;
@ -229,10 +272,12 @@ struct T_dynamicCondition {
// bit6: no response bit7: serial rec. error
// bit5: printer not ready
uint8_t startupTestIsRunning;
//54
};
struct T_extTime {
struct T_extTime
{
uint8_t Hours;
uint8_t Min;
uint8_t Sec;
@ -258,8 +303,10 @@ struct T_extTime {
uint8_t res4;
uint16_t res5;
uint32_t MinutesOfMillenium;
};
typedef uint8_t UCHAR;
typedef uint16_t UINT;
@ -268,7 +315,7 @@ 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 c² (MW)
UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW)
UCHAR kindOfMifareReader; // by now only stronglink SL025 =1
UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep
@ -293,14 +340,14 @@ struct T_devices
};
class hwinf {
public:
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
enum class FileTypeJson {CONFIG=1, DEVICE, CASH, SERIAL, TIME, PRINTER};
class hwinf
{
public:
virtual ~hwinf() {}
virtual QStringList dc_getStatus() const = 0;
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// Use serial interface and protocol stack in Cashagent-Library
@ -317,7 +364,7 @@ public:
// ComName: for example "COM48"
// connect: 0, 1
virtual bool dc_closeSerial(void) const = 0;
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
@ -332,21 +379,7 @@ public:
virtual bool test_serialIsOn(void) const =0;
virtual bool dc_updateDC(QString binFileName,
QString baudrate,
QString comPort) const = 0;
// download binary file down into device controller
virtual bool dc_updatePrinterTemplate(enum FileTypeJson type,
QVector<int> templateIdx,
QVector<QString> fnames,
QString br,
QString serial = QString()) const = 0;
virtual bool dc_printTemplate(enum FileTypeJson type,
QVector<int> templateIdx,
QString br,
QString serial = QString()) const = 0;
virtual void dc_autoRequest(bool on) const =0;
// on = true: select that all READ-Requests are sent automatically
@ -363,7 +396,7 @@ public:
// 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­z=size of host buffer
// plBufSiz­z=size of host buffer
virtual void dc_requTestResponse() const =0;
// tell DC2 to send a test-string, useful to see if cable and baudrate is OK
@ -484,10 +517,10 @@ public:
// Analog values:
virtual uint32_t dc_getTemperature(void) const =0;
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
// in Sax-Format 0...400 (0=-50,0°C 100=0,0°C 141=20,5°C 400=150,0°C)
virtual QString dc_getTemperaturStr(void) const =0;
// as string like "-12,5°C"
// as string like "-12,5°C"
virtual uint32_t dc_getVoltage(void) const =0;
// as value in mV, 0...65,535V
@ -642,7 +675,7 @@ public:
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: C²_changer
// kindOfCoinChecker: 0:off 1:EMP820 2:EMP900 3: C²_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)
@ -748,7 +781,7 @@ public:
// 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!)
// byte4: orientation 0, 90, 180 = 0°, 90°, 180° 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;
@ -806,29 +839,36 @@ public:
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
// example: print current time at this point (the time of printing not the storage time!!)
virtual void pri_startTicketDesign(void) const =0;
// obsolete
//virtual void pri_startTicketDesign(void) const =0;
// start for every new printer document, reseting collecting buffer
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
// return val of the appending functions: true=ok false=too long, buffer full
virtual int pri_TD_getCurrentSize(void) const =0;
// obsolete
//virtual int pri_TD_getCurrentSize(void) const =0;
// retval: 0...1278
virtual bool pri_TD_addText(QByteArray text) const =0;
// obsolete
//virtual bool pri_TD_addText(QByteArray text) const =0;
// example: pri_TD_addText("Hello") const =0;
// example: pri_TD_addText(tempStr) const =0;
// retval: true=ok false=too long, buffer full
virtual bool pri_TD_addValue(int val) const =0;
// obsolete
//virtual bool pri_TD_addValue(int val) const =0;
// +/- 0...2^(31)
virtual bool pri_TD_addNewLine(void) const =0;
// obsolete
//virtual bool pri_TD_addNewLine(void) const =0;
virtual bool pri_TD_addSign(char sign) const =0;
// obsolete
//virtual bool pri_TD_addSign(char sign) const =0;
// example: '.' ' ' 0x20 'W' '$'
virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
// obsolete
//virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
/* complete list of possible commands:
group 50 : paper
@ -869,11 +909,13 @@ public:
*/
virtual char prn_clearDocument(uint8_t documentNumber) const =0;
// obsolete
//virtual char prn_clearDocument(uint8_t documentNumber) const =0;
// clear memory buffer for ONE document
// function takes a second! don't send right before "store doc"
virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
// obsolete
//virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
// send the predefined Layout (generated with above TD functions) to DeviceController to save
// documentNumber=0...15
// maximal 1280 bytes each
@ -884,7 +926,8 @@ public:
// the place in the ticket layout is predefined (already in DC memory)
// the dynamics are first calculated at printing time
virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
// obsolete
//virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
// 36
@ -1279,7 +1322,7 @@ public:
virtual void bl_startBL(void) const =0;
// send command within 4s after DC power-on, otherwise bl is left
virtual bool bl_checkBL(void) const = 0;
virtual void bl_checkBL(void) const =0;
// send command to verify if bl is up
virtual bool bl_isUp(void) const =0;
@ -1316,7 +1359,7 @@ public:
// Komplett-schreib Funktion, noch nicht getestet
// Nachteil: keine Rückmeldung wie lang's noch dauert
// Nachteil: keine Rückmeldung wie lang's noch dauert
//virtual void bl_startSending(void) const=0;
// call once after BL is working and file is loaded
//virtual void bl_sendFile(void) const=0;
@ -1342,7 +1385,7 @@ public:
buf[4]=GlobTime.Month;
buf[5]=GlobTime.Day;
buf[6]=GlobTime.DOW;
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
buf[7]=' '; // immer auf 32bit auffüllen sonst Speicherproblem beim Master!
uitmp=GlobTime.MinOfDay;
buf[8]=swl_getOneByteFromUint(uitmp, 0);
buf[9]=swl_getOneByteFromUint(uitmp, 1);
@ -1453,6 +1496,15 @@ public:
// 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;
@ -1530,6 +1582,8 @@ public:
*/
virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
/*
@ -1602,8 +1656,10 @@ public:
virtual uint16_t cash_getNrCoinsInVault(void) const=0;
virtual uint8_t prn_getPrintResult() const=0;
// return: 0: unknown
// 1: OK - last template was printed succesful
// 2: error - last template was not printed
// in case of print-error get detailed error:
virtual uint8_t prn_getCurrentPrinterState() const=0;
@ -1614,61 +1670,27 @@ public:
// 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;
virtual bool sys_areDCdataValid(void) const=0;
/* ---------------------------------------------------------------------------------------------
// ------------ supervise all hardware components
// ------------ assess the machine state
virtual bool sys_sendingTest(void) const =0;
1. check if DC startup test is through, retrigger if not
2. get results and find errors
3. in case of error check if component is used (e.g. billreader is seldom used)
4: check doors
5. return value: 0: no response from DC
1: no Test results and Test not running. need retrigger!
2: state not clear by now, test ongoing, wait
3: Service or battery door is open, goto INTRUSION MODE
from here: after valid ID-card goto SERVICE MODE
4: vault door is open, goto INTRUSION MODE
from here: after valid ID-card and vault door closed goto TEST MODE
in TEST MODE: complete system check decides if vending mode allowed
5: All doors are closed but errors found,
goto OOO MODE (out-of-order)
from here: run system test until problem is fixed
6: All doors are closed, no error, maybe warnings,
goto VENDING MODE (normal operation)
(priority sinks from 0 to 6)
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 override;
virtual uint8_t sys_componentAssessment(void) const=0;
// this function decides if vending mode is possible, independant from door
// return >0 in case of error
// is inncluded in sys_superviseSystem
virtual bool prn_dynDataAreEqual(uint8_t *buf) const =0;
virtual uint8_t sys_superviseSystem(void) const=0;
// this function proofs if vending is possible depending of doors state
virtual uint8_t sys_getSystemErrors(void) const=0;
virtual bool prn_printKombiticket(uint8_t nrOfKombi) const=0;
// print four of the templates loaded by Json prior
// nr = 1..8
// retrigger System-Check with:
// bool hwapi::sys_runCompleteTest(void) const
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------
signals:
virtual void hwapi_templatePrintFinished_OK(void) const=0;
@ -1707,12 +1729,19 @@ signals:
// 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
//#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.5"
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6"

View File

@ -122,10 +122,11 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8));
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
memcpy((char*)dynTicketData->parkingEndTime, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
memcpy((char*)dynTicketData->parkingEndDate, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
// ! and yes... 'ParkingEndDate' is 'currentTime'
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy"));
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));