490 lines
13 KiB
C
490 lines
13 KiB
C
|
|
||
|
#ifndef STOREINDATA_H
|
||
|
#define STOREINDATA_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include "tslib.h"
|
||
|
#include <QString>
|
||
|
|
||
|
|
||
|
#define MAXNROF_AO 3
|
||
|
#define MAXNROF_GENSTR 16
|
||
|
#define MAXNROF_CONTR_PORTS 11
|
||
|
#define MAXNROF_DIports 2
|
||
|
#define MAXNROF_DOports 2
|
||
|
#define MAXNROF_CTR 2
|
||
|
#define MEASCHAN_TEMPERATURE 0
|
||
|
#define MEASCHAN_VOLTAGE 1
|
||
|
|
||
|
|
||
|
// gpi: DC-driver stores data for graphic peripheral interface
|
||
|
// epi: gui reads values from external peripheral interface
|
||
|
|
||
|
|
||
|
// store power on/off condition of the devices to control the data request
|
||
|
|
||
|
void indat_storePrinterPower(bool isOn);
|
||
|
bool indat_isPrinterOn();
|
||
|
|
||
|
void indat_storeMifarePower(bool isOn);
|
||
|
bool indat_isMifareOn();
|
||
|
|
||
|
void indat_storeMDBisOn(bool isOn);
|
||
|
bool indat_isMdbOn();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
||
|
uint8_t parity, uint8_t NrStopBits);
|
||
|
|
||
|
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
||
|
uint8_t *parity, uint8_t *NrStopBits);
|
||
|
|
||
|
QString epi_getSlaveParamSTR();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
void gpi_storeGenerals(uint8_t genNr, QString text);
|
||
|
// 0=HW 1=SW 2=State
|
||
|
|
||
|
QString epi_loadGenerals(uint8_t genNr);
|
||
|
// genNr=0=HW 1=SW 2=State
|
||
|
|
||
|
|
||
|
void gpi_storeUID(uint8_t *buf8byteUid);
|
||
|
// buffer size: 8 byte
|
||
|
|
||
|
void epi_getUIDdec(uint8_t *buf8byteUid);
|
||
|
// buffer size: 8 byte
|
||
|
|
||
|
QString epi_getUIDstr();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
// Time and Date
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
uint8_t epi_getSquareMode();
|
||
|
void gpi_backupSquareMode(uint8_t squMode);
|
||
|
|
||
|
void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng);
|
||
|
void epi_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss);
|
||
|
void epi_getDate(uint8_t *yy, uint8_t *mm, uint8_t *dd);
|
||
|
void epi_getToday(uint8_t *dow, uint16_t *minOfToday, uint32_t *secOfToday);
|
||
|
bool epi_isLeapYear(uint8_t *lastLeapYear, uint8_t *NextLeapYear);
|
||
|
bool epi_isLeapYear();
|
||
|
void epi_getSpecialWeekTimeDate(uint8_t *DayOfWeek, uint8_t *HoursOfWeek, uint16_t *MinutesOfWeek);
|
||
|
void epi_getSpecialMonthTimeDate(uint8_t *DayOfMonth, uint16_t *HoursOfMonth, uint16_t *MinutesOfMonth);
|
||
|
void epi_getSpecialYearTimeDate(uint16_t *DayOfYear, uint16_t *HoursOfYear, uint32_t *MinutesOfYear);
|
||
|
|
||
|
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
// Analog values
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
|
||
|
#define MAXNROF_AI 4
|
||
|
|
||
|
void gpi_storeAIs(uint8_t aiNr, uint16_t val); // rs -> Sdata
|
||
|
|
||
|
uint8_t gpi_getMaxNrAIs();
|
||
|
|
||
|
uint16_t epi_loadAIs(uint8_t aiNr); // Sdata -> gui
|
||
|
// return value of one ADC with channel nr: aiNr 0...15
|
||
|
|
||
|
uint32_t epi_loadMeasureValue(uint8_t ValueNr);
|
||
|
// ValueNr 0=ADC0, 1=ADC1 aso...
|
||
|
|
||
|
void gpi_storeMeasureValue(uint8_t ValueNr, uint32_t val);
|
||
|
// in mV, also bis 65,535V
|
||
|
|
||
|
QString epi_getSlaveTemperatureStr();
|
||
|
|
||
|
QString epi_getSlaveVoltageStr();
|
||
|
// value in "meas_volt" in mV, also bis 65,535V. Value range [6000...16000] (6V...16V)
|
||
|
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
// digital inputs
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaultDoor);
|
||
|
|
||
|
uint8_t epi_getDI_doorSwitches(void);
|
||
|
// bit0: upper door 1: low door 2:vault door
|
||
|
|
||
|
void gpi_storeDI_vaultSwitches(uint8_t CashBoxIn, uint8_t BillBoxIn);
|
||
|
|
||
|
uint8_t epi_getDI_vaultSwitches(void);
|
||
|
// bit0: cash box 1: bill box in
|
||
|
|
||
|
void gpi_storeDI_lockSwitches(uint8_t indatUL, uint8_t indatLL);
|
||
|
// D5: bit 0: upper lockbar up bit1:down
|
||
|
// D6: bit 0: lower lockbar up bit1:down
|
||
|
|
||
|
uint8_t epi_getDI_lockSwitches(void);
|
||
|
// retval: bit 0: upper lockbar up bit1: upper lockbar is down
|
||
|
// bit 2: lower lockbar up bit1: lower lockbar is down
|
||
|
|
||
|
|
||
|
void gpi_storeDI_optos(uint8_t indatOpto);
|
||
|
// OptoIn bit 0,1: optoin 1,2
|
||
|
|
||
|
uint8_t epi_getDI_optos(void);
|
||
|
// bit0: opto in 1 1: opto in 2
|
||
|
|
||
|
void gpi_storeDI_auxIn(uint8_t indatAuxIn);
|
||
|
// Aux0...5
|
||
|
|
||
|
uint8_t epi_getDI_auxIn(void);
|
||
|
// bit0: auxin 1 ... 5: auxin 6
|
||
|
|
||
|
void gpi_storeDI_ptuWake(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_ptuWake(void);
|
||
|
|
||
|
void gpi_storeDI_mbdWake(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_mdbWake(void);
|
||
|
|
||
|
void gpi_storeDI_prnReady(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_prnReady(void);
|
||
|
|
||
|
void gpi_storeDI_CoinAttach(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_CoinAttach(void);
|
||
|
|
||
|
void gpi_storeDI_CoinEscrow(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_CoinEscrow(void);
|
||
|
|
||
|
void gpi_storeDI_mifareCardTapped(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_mifareCardTapped(void);
|
||
|
|
||
|
void gpi_storeDI_modemWake(uint8_t indat);
|
||
|
|
||
|
bool epi_getDI_modemWake(void);
|
||
|
|
||
|
|
||
|
void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn);
|
||
|
|
||
|
bool epi_getDI_contactPwr(void);
|
||
|
|
||
|
void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn);
|
||
|
|
||
|
bool epi_getDI_mifarePwr(void);
|
||
|
|
||
|
void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd);
|
||
|
|
||
|
bool epi_getDI_mdbTxd(void);
|
||
|
|
||
|
void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn);
|
||
|
|
||
|
bool epi_getDI_auxPwr(void);
|
||
|
|
||
|
void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn);
|
||
|
|
||
|
bool epi_getDI_gsmPwr(void);
|
||
|
|
||
|
void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn);
|
||
|
|
||
|
bool epi_getDI_creditPwr(void);
|
||
|
|
||
|
void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn);
|
||
|
|
||
|
bool epi_getDI_printerPwr(void);
|
||
|
|
||
|
void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn);
|
||
|
|
||
|
bool epi_getDI_mdbPwr(void);
|
||
|
|
||
|
|
||
|
void gpi_storeDI_rejMot_home(bool di);
|
||
|
|
||
|
bool epi_getDI_rejectMotor_homepos(void);
|
||
|
|
||
|
void gpi_storeDI_paperLow(uint8_t di);
|
||
|
|
||
|
uint8_t epi_getDI_npe_sensor(void);
|
||
|
// 0: Sensor sees paper 1: no paper 99: off
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
// readback digital outputs
|
||
|
// ///////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
void gpi_storeDO_mdbRxTst(uint8_t do_mbdRxTst);
|
||
|
|
||
|
bool epi_getDO_mdbRxTestOut(void);
|
||
|
|
||
|
|
||
|
void gpi_storeDO_motorOutputs(uint8_t Pwr);
|
||
|
|
||
|
uint8_t epi_getDO_motorOuts(void);
|
||
|
// bit0: upper lock forward bit 1 backward
|
||
|
// bit2: lower lock forward bit 3 backward
|
||
|
|
||
|
|
||
|
void gpi_storeDO_serialSwitch(uint8_t state);
|
||
|
// serial drv on/off, Serial mux1, Serial mux2
|
||
|
|
||
|
uint8_t epi_getDO_serialSwitch(void);
|
||
|
// serial drv on/off, Serial mux1, Serial mux2
|
||
|
|
||
|
bool epi_getDO_serialDriverIsOn(void);
|
||
|
|
||
|
bool epi_getDO_serialMux1isSetToPrinter(void);
|
||
|
// mux1 off: serial is switched to printer
|
||
|
|
||
|
bool epi_getDO_serialMux1isSetToModem(void);
|
||
|
// mux1 on: serial is switched to modem
|
||
|
|
||
|
bool epi_getDO_serialMux2isSetToCredit(void);
|
||
|
// mux2 off: serial is switched to credit card terminal
|
||
|
|
||
|
bool epi_getDO_serialMux2isSetToMifare(void);
|
||
|
// mux2 on: serial is switched to mifare reader
|
||
|
|
||
|
|
||
|
void gpi_storeDO_ledsAndFan(uint8_t ledState);
|
||
|
|
||
|
bool epi_getDO_led_coin(void);
|
||
|
|
||
|
bool epi_getDO_led_front(void);
|
||
|
|
||
|
bool epi_getDO_led_ticket(void);
|
||
|
|
||
|
bool epi_getDO_led_pin(void);
|
||
|
|
||
|
bool epi_getDO_led_start(void);
|
||
|
|
||
|
bool epi_getDO_led_inside(void);
|
||
|
|
||
|
bool epi_getDO_fan(void);
|
||
|
|
||
|
void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay);
|
||
|
|
||
|
bool epi_getDO_sirene(void);
|
||
|
|
||
|
bool epi_getDO_relay(void);
|
||
|
|
||
|
void gpi_storeDO_ptuWake(uint8_t state);
|
||
|
|
||
|
bool epi_getDO_ptuWake(void);
|
||
|
|
||
|
void gpi_storeDO_auxPower(uint8_t pwr);
|
||
|
|
||
|
bool epi_getDO_auxPower(void);
|
||
|
|
||
|
|
||
|
void gpi_storeDO_coinShutter(uint8_t state);
|
||
|
|
||
|
bool epi_getDO_coinShutterOpen(void);
|
||
|
|
||
|
bool epi_getDO_coinShutterTest(void);
|
||
|
|
||
|
|
||
|
void gpi_storeDO_coinEscrow(uint8_t state);
|
||
|
|
||
|
uint8_t epi_getDO_coinEscrow(void);
|
||
|
// retval: 1:return flap is open 2:take flap is open 0:closed
|
||
|
|
||
|
|
||
|
void gpi_storeDO_printerPwrOn(uint8_t state);
|
||
|
|
||
|
uint8_t epi_getDO_printerPwr(void);
|
||
|
|
||
|
|
||
|
|
||
|
// ---------------------------------------------------------------------------------------------
|
||
|
// counterchecks, make sure that DC-outputs are correct
|
||
|
|
||
|
/*
|
||
|
bool epi_cntchk_wakePtu(void);
|
||
|
bool epi_cntchk_enabDrv01(void); // no communication possible if 0 !!!!!
|
||
|
bool epi_cntchk_swRs1toModem(void);
|
||
|
bool epi_cntchk_modemWake(void);
|
||
|
bool epi_cntchk_enabDrv2(void);
|
||
|
bool epi_cntchk_swRs2toMIF(void);
|
||
|
|
||
|
bool epi_cntchk_shutterIsOpen(void);
|
||
|
// counter check if shutter is really open, PJ4 must be OUT and HIGH, PB5 must be OUT and HIGH
|
||
|
// retval TRUE: shutter is open FALSE: shutter is closed
|
||
|
|
||
|
bool epi_cntchk_escrowReturnIsOpen(void);
|
||
|
bool epi_cntchk_escrowTakeIsOpen(void);
|
||
|
bool epi_cntchk_aux1DirOut(uint8_t auxNr);
|
||
|
bool epi_cntchk_aux1OutHigh(uint8_t auxNr);
|
||
|
|
||
|
bool epi_cntchk_ledPaperOn(void);
|
||
|
bool epi_cntchk_ledPinpadOn(void);
|
||
|
bool epi_cntchk_ledStartOn(void);
|
||
|
bool epi_cntchk_ledServiceOn(void);
|
||
|
bool epi_cntchk_ledCoinOn(void);
|
||
|
bool epi_cntchk_ledIllumOn(void);
|
||
|
bool epi_cntchk_FanOn(void);
|
||
|
bool epi_cntchk_RelaisOn(void);
|
||
|
bool epi_cntchk_LaermOn(void);
|
||
|
bool epi_cntchk_Mot1Ron(void);
|
||
|
bool epi_cntchk_Mot1Fon(void);
|
||
|
bool epi_cntchk_Mot2Ron(void);
|
||
|
bool epi_cntchk_Mot2Fon(void);
|
||
|
*/
|
||
|
|
||
|
|
||
|
// ------------------------------------------------------------------------------------
|
||
|
// MDB Sendind Data are store here for next transport to DC (Device Controller)
|
||
|
// Transport to Slave runs every 100ms, answer from mdb-slave (e.g. coin changer) comes right
|
||
|
// with next slave answer
|
||
|
|
||
|
// start with: SENDDIRCMD_EXCHGMDB,
|
||
|
// send crude data from here to DC, DC to mdb slaves, mdb answer, return here within 50ms
|
||
|
|
||
|
uint8_t gpi_storeMdbRecData(uint8_t length, uint8_t *buf);
|
||
|
// datif store received mdb data
|
||
|
|
||
|
uint8_t epi_getMdbResponse(void);
|
||
|
// 0=no response 1=ACK 2=NAK 3=ACK with data
|
||
|
|
||
|
uint8_t epi_getMdbRecLength(void);
|
||
|
// 0...31
|
||
|
|
||
|
uint8_t epi_restoreMdbRecData(uint8_t *buf);
|
||
|
// hwapi reads received mdb data from PI
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf);
|
||
|
|
||
|
/* data description:
|
||
|
byte 0: 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,2: read data length from card
|
||
|
3: 1=reader is OK (reported serial nr is OK) 0=wrong or no reader
|
||
|
4...15: reader version, expected "SL025-1.8"
|
||
|
byte16: 1=card is present 0:not
|
||
|
17: 0
|
||
|
18: card type reported from reader
|
||
|
19: 1=allowed card type 0=not
|
||
|
20: card size: 1 or 4 (dec) = card size
|
||
|
21: LengthOfUID: 4 or 7 (dec) (byte)
|
||
|
22: UID 8 byte in hex
|
||
|
byte 30: sector logged: 0
|
||
|
byte 31: current sector: 0
|
||
|
byte 32: result, always 0
|
||
|
*/
|
||
|
|
||
|
uint8_t epi_restoreMifState(uint8_t *buf, uint8_t maxBufferSize);
|
||
|
// retval 0=OK 1=error host buffer too small
|
||
|
|
||
|
void gpi_storeMifCardData(uint8_t blkNr, uint8_t *receivedData);
|
||
|
// blkNr=0...11 receivedData[64]
|
||
|
|
||
|
uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize);
|
||
|
// blkNr=0...11 return buf[64]
|
||
|
// retval: 1=error 0=OK
|
||
|
|
||
|
|
||
|
|
||
|
#define pi_prnStateArraySize 20
|
||
|
#define pi_prnFontArraySize 20
|
||
|
|
||
|
void epi_restorePrinterState(uint8_t *buf);
|
||
|
|
||
|
void gpi_storePrinterState(uint8_t *buf);
|
||
|
|
||
|
void epi_restorePrinterFonts(uint8_t *buf);
|
||
|
|
||
|
void gpi_storePrinterFonts(uint8_t *buf);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
void gpi_storeMdbState(uint8_t busReady, uint8_t V12on, uint8_t V5on );
|
||
|
|
||
|
bool epi_restoreMdbBusReady(void);
|
||
|
|
||
|
bool epi_restoreMdbV12Ready(void);
|
||
|
|
||
|
bool epi_restoreMdbV5Ready(void);
|
||
|
|
||
|
|
||
|
void gpi_storeMdbResponse(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
void epi_restoreMdbResponse(uint8_t *leng, uint8_t *data);
|
||
|
// last received mdb answer (from mdb device)
|
||
|
// only needed if a special command was sent directly
|
||
|
// DB0: mdb Device-Nr
|
||
|
// DB1: last sent mdb command
|
||
|
// DB2: nr of received (payload) data bytes (apart from ACK, can be 0....34)
|
||
|
// DB3...DB38: rec.data (payload)
|
||
|
|
||
|
|
||
|
void gpi_storeEmpSettings(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data);
|
||
|
|
||
|
|
||
|
/*
|
||
|
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
void epi_restoreEmpCoinSignal(uint8_t *leng, uint8_t *data);
|
||
|
// return 5 byte:
|
||
|
// data[0]=got coin 0xFF=emp reported an error 0=got nothing
|
||
|
// data[1]=emp-signal of last inserted coin
|
||
|
// data[2,3]=emp-value of last inserted coin
|
||
|
// data[4] = emp-error or warning
|
||
|
|
||
|
void epi_clearEmpCoinSignal();
|
||
|
*/
|
||
|
|
||
|
#define MEMDEPTH_GOTCOINS 16
|
||
|
|
||
|
void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
uint8_t epi_isNewCoinLeft(void);
|
||
|
// retval: 0...16 coins left in FIFO
|
||
|
|
||
|
void epi_restoreEmpCoinSignal(uint8_t *valid, uint8_t *signal, uint8_t *error, uint16_t *value);
|
||
|
|
||
|
|
||
|
|
||
|
void gpi_storeDeviceSettings(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
void epi_restoreDeviceSettings(uint8_t *leng, uint8_t *data);
|
||
|
|
||
|
void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *data);
|
||
|
|
||
|
void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data);
|
||
|
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|