#include #include #include #include "storeINdata.h" #include "tslib.h" // gpi: grafical access to PI: access from external devices over device controller FOR GUI // epi: external access from GUI to PI: FOR external devices (DC) // store power on/off condition of the devices to control the data request static bool indat_savePrnPwr; void indat_storePrinterPower(bool isOn) { indat_savePrnPwr=isOn; } bool indat_isPrinterOn() { return indat_savePrnPwr; } static bool indat_saveMifPwr; void indat_storeMifarePower(bool isOn) { indat_saveMifPwr=isOn; } bool indat_isMifareOn() { return indat_saveMifPwr; } static bool indat_MdbIsOn; void indat_storeMDBisOn(bool isOn) { indat_MdbIsOn=isOn; } bool indat_isMdbOn() { return indat_MdbIsOn; } // ////////////////////////////////////////////////////////////////////////// static uint8_t ndbs, pari, nsb, br; void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits, uint8_t parity, uint8_t NrStopBits) { // store numbers ndbs=NrDataBits; pari=parity; nsb=NrStopBits; br=slaveBaudRate; } void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits, uint8_t *parity, uint8_t *NrStopBits) { *NrDataBits=ndbs; *parity=pari; *NrStopBits=nsb; *slaveBaudRate=br; } QString epi_getSlaveParamSTR() { QString mySt; mySt.clear(); switch (br) { case 1: mySt="1200 ";break; case 2: mySt="9600 ";break; case 3: mySt="19200 ";break; case 4: mySt="38400 ";break; case 5: mySt="57600 ";break; case 6: mySt="115200 ";break; } mySt.append(ndbs+0x30); mySt.append(pari); mySt.append(nsb+0x30); //mySt="Hallo"; return mySt; } static QString genStrings[3]; // 0=HW 1=SW 2=State void gpi_storeGenerals(uint8_t genNr, QString text) { // 0=HW 1=SW 2=State if (genNr<3) { genStrings[genNr]=text; //qDebug() << "store gen's: " << genNr << " " < umformen in hexstring QString myStr; for (int ii=0;ii<8; ii++) myStr+=QString::number(Sdata_UIDstr[ii],16); return myStr; } // /////////////////////////////////////////////////////////////////////////////////// // Time and Date // /////////////////////////////////////////////////////////////////////////////////// struct T_globTime { // Reihenfolge nicht vertauschen!!!!! uint8_t hour; uint8_t minute; uint8_t second; uint8_t Year; uint8_t Month; uint8_t DayOfMonth; uint8_t DayOfWeek; // 1=monday...7 uint8_t reserve1; uint16_t MinutesOfToday; uint16_t reserve2; uint32_t SecondsOfToday; uint8_t IsLeapyear; uint8_t nextLeap; uint8_t lastLeap; uint8_t hoursOfWeek; uint16_t minOfWeek; uint16_t hoursOfMonth; uint16_t minOfMonth; uint16_t dayOfYear; uint16_t hoursOfYear; uint16_t reserve3; uint32_t minOfYear; uint8_t squareOutMode; uint8_t free1; uint16_t reserve4; uint32_t minOfMillenium; // bis hierher 44byts uint32_t free2; uint32_t free3; uint32_t free4; }; static T_globTime getGlobalTime; void gpi_backupSquareMode(uint8_t squMode) { getGlobalTime.squareOutMode=squMode; } uint8_t epi_getSquareMode() { return getGlobalTime.squareOutMode; } void gpi_backupTime(uint8_t *timeBuffer, uint8_t Leng) { // Daten kommen in gleicher Reihenfolge vom Slave uint8_t *pTime; pTime=&getGlobalTime.hour; if (Leng>44) Leng=44; // mehr brauch ma ned for (int nn=0; nn05 mystr.append(':'); //tempStr.clear(); tempStr.setNum(getGlobalTime.minute,10); // mit 16 statt 10 wirds in HEX angezeigt //mystr.append(tempStr); mystr+=tempStr.rightJustified(2,'0',false); //mystr.append(':'); // so //mystr+=':'; // oder so, =gleich if (timeStyle==1) // hh:mm:ss { mystr.append(':'); tempStr.setNum(getGlobalTime.second,10); mystr.append(tempStr.rightJustified(2,'0',false)); // wie += } return mystr; } QString epi_getRtcDateStr(uint8_t dateStyle) { // 1=german dd.mm.yy 2=american yy/mm/dd 3=mm.dd.yy QString tmpStr=nullptr, YYstr=nullptr, MMstr=nullptr, DDstr=nullptr, mystr=nullptr; mystr.clear(); tmpStr.setNum(getGlobalTime.Year,10); // itoa decimal YYstr=tmpStr.rightJustified(4,'0',false); // immer vierstellig YYstr[0]='2'; // 2000 dazu tmpStr.setNum(getGlobalTime.Month,10); MMstr=tmpStr.rightJustified(2,'0',false); tmpStr.setNum(getGlobalTime.DayOfMonth,10); DDstr=tmpStr.rightJustified(2,'0',false); if (dateStyle==1) // Germany dd.mm.yy { mystr=DDstr + '.' + MMstr + '.' + YYstr; } else if (dateStyle==2) // american yy/mm/dd { mystr=YYstr + '/' + MMstr + '/' + DDstr; } else // mm.dd.yy { mystr=MMstr + '.' + DDstr + '.' + YYstr; } return mystr; } QString epi_getSlaveTimeDateStr() { QString myStr; myStr=epi_getRtcTimeStr(1) + " " + epi_getRtcDateStr(1); return myStr; } // /////////////////////////////////////////////////////////////////////////////////// // analog values // /////////////////////////////////////////////////////////////////////////////////// static uint16_t AI_val[MAXNROF_AI]; uint8_t gpi_getMaxNrAIs() { return MAXNROF_AI; } void gpi_storeAIs(uint8_t aiNr, uint16_t val) { if (aiNr9) { myStr[pp++]=char(vor/10)+0x30; } myStr[pp++]=char(vor%10)+0x30; myStr[pp++]=','; ke=char(nach/100); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; tmp32=nach%100; ke=char(tmp32/10); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; tmp32=nach%10; ke=char(tmp32); //qDebug() << "ke: " << ke; myStr[pp++]=char(ke)+0x30; myStr[pp++]='V'; myqStr.append(myStr); return myqStr; } // /////////////////////////////////////////////////////////////////////////////////// // digital inputs // /////////////////////////////////////////////////////////////////////////////////// /* come all in with 0x1201: D0: upper door D1: low door D2:vault door D3: cash box D4: bill box in D5: bit 0: upper lockbar up bit1:down D6: bit 0: lower lockbar up bit1:down D7: 0 D7: DI_contact Power Is On D8: OptoIn 1,2 D9: Aux0...5 D10:Wake from ptu D11: DI Wake From Mdb D12: Ready from printer D13: Coin Shutter Input D14: CoinEscrow switch D15: Mifare IN D16: Modem_Wake In D18: DI Mif Pwr is on D19: DI MDB_TxD_rdBack D20: DI Aux Pwr is on D21: DI GSM Pwr from PO2 is ON D22: DI Credit Pwr from PO2 is on =DI RdBack Credit Wake D23: DI Printer Pwr from PO2 is on D24: DI MDB Pwr from PO2 is on */ static uint8_t di_doorSwitch; void gpi_storeDI_doorSwitches(uint8_t upperDoor, uint8_t lowerDoor, uint8_t vaultDoor) { di_doorSwitch=0; if (upperDoor) di_doorSwitch |=1; if (lowerDoor) di_doorSwitch |=2; if (vaultDoor) di_doorSwitch |=4; } uint8_t epi_getDI_doorSwitches(void) { // bit0: upper door 1: low door 2:vault door return di_doorSwitch; } static uint8_t di_vaultSwitch; void gpi_storeDI_vaultSwitches(uint8_t CashBoxIn, uint8_t BillBoxIn) { di_vaultSwitch=0; if (CashBoxIn) di_vaultSwitch |=1; if (BillBoxIn) di_vaultSwitch |=2; } uint8_t epi_getDI_vaultSwitches(void) { // bit0: cash box 1: bill box in return di_vaultSwitch; } static uint8_t di_lockSwitch; 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 di_lockSwitch=0; if (indatUL & 1) di_lockSwitch |=1; if (indatUL & 2) di_lockSwitch |=2; if (indatLL & 1) di_lockSwitch |=4; if (indatLL & 2) di_lockSwitch |=8; } 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 return di_lockSwitch; } static uint8_t di_opto; void gpi_storeDI_optos(uint8_t indatOpto) { // OptoIn bit 0,1: optoin 1,2 di_opto=0; if (indatOpto & 1) di_opto |=1; if (indatOpto & 2) di_opto |=2; } uint8_t epi_getDI_optos(void) { // bit0: opto in 1 1: opto in 2 return di_opto; } static uint8_t di_aux; void gpi_storeDI_auxIn(uint8_t indatAuxIn) { // Aux0...5 di_aux=indatAuxIn; } uint8_t epi_getDI_auxIn(void) { // bit0: auxin 1 ... 5: auxin 6 return di_aux; } static bool di_wakeFromPtu; void gpi_storeDI_ptuWake(uint8_t indat) { if (indat) di_wakeFromPtu=true; else di_wakeFromPtu=false; } bool epi_getDI_ptuWake(void) { return di_wakeFromPtu; } static bool di_wakeFromMdb; void gpi_storeDI_mbdWake(uint8_t indat) { if (indat) di_wakeFromMdb=true; else di_wakeFromMdb=false; } bool epi_getDI_mdbWake(void) { return di_wakeFromMdb; } static bool di_PrnReady; void gpi_storeDI_prnReady(uint8_t indat) { if (indat) di_PrnReady=true; else di_PrnReady=false; } bool epi_getDI_prnReady(void) { return di_PrnReady; } static bool di_CoinAttach; void gpi_storeDI_CoinAttach(uint8_t indat) { if (indat) di_CoinAttach=true; else di_CoinAttach=false; } bool epi_getDI_CoinAttach(void) { return di_CoinAttach; } static bool di_CoinEscrowOpen; void gpi_storeDI_CoinEscrow(uint8_t indat) { if (indat) di_CoinEscrowOpen=true; else di_CoinEscrowOpen=false; } bool epi_getDI_CoinEscrow(void) { return di_CoinEscrowOpen; } static bool di_mifCardTap; void gpi_storeDI_mifareCardTapped(uint8_t indat) { if (indat) di_mifCardTap=true; else di_mifCardTap=false; } bool epi_getDI_mifareCardTapped(void) { return di_mifCardTap; } static bool di_wakeFromModem; void gpi_storeDI_modemWake(uint8_t indat) { if (indat) di_wakeFromModem=true; else di_wakeFromModem=false; } bool epi_getDI_modemWake(void) { return di_wakeFromModem; } static bool di_contactPwrOn; void gpi_storeDI_contactPowerIsOn(bool di_contact_PwrOn) { di_contactPwrOn=di_contact_PwrOn; } bool epi_getDI_contactPwr(void) { // invertiert! if (di_contactPwrOn) return false; return true; } static bool di_mifarePwrOn; void gpi_storeDI_MifarePowerIsOn(bool di_mifare_PwrOn) { di_mifarePwrOn=di_mifare_PwrOn; } bool epi_getDI_mifarePwr(void) { return di_mifarePwrOn; } static bool di_rdbk_mdbTxd; void gpi_storeDI_readbackMdbTxD(bool di_rdbkMdbTxd) { di_rdbk_mdbTxd=di_rdbkMdbTxd; } bool epi_getDI_mdbTxd(void) { return di_rdbk_mdbTxd; } static bool di_AuxPwrOn; void gpi_storeDI_AuxPowerIsOn(bool di_Aux_PwrOn) { di_AuxPwrOn=di_Aux_PwrOn; } bool epi_getDI_auxPwr(void) { return di_AuxPwrOn; } static bool di_gsmPwrOn; void gpi_storeDI_GsmPowerIsOn(bool di_gsm_PwrOn) { di_gsmPwrOn=di_gsm_PwrOn; } bool epi_getDI_gsmPwr(void) { return di_gsmPwrOn; } static bool di_creditPwrOn; void gpi_storeDI_CreditPowerIsOn(bool di_credit_PwrOn) { // invertieren!!! if (di_credit_PwrOn) di_creditPwrOn=0; else di_creditPwrOn=1; } bool epi_getDI_creditPwr(void) { return di_creditPwrOn; } static bool di_printerPwrOn; void gpi_storeDI_PrinterPowerIsOn(bool di_printer_PwrOn) { di_printerPwrOn=di_printer_PwrOn; } bool epi_getDI_printerPwr(void) { return di_printerPwrOn; } static bool di_mdbPwrOn; void gpi_storeDI_MdbPowerIsOn(bool di_mdb_PwrOn) { di_mdbPwrOn=di_mdb_PwrOn; } bool epi_getDI_mdbPwr(void) { return di_mdbPwrOn; } static bool di_rejMot_home; void gpi_storeDI_rejMot_home(bool di) { di_rejMot_home=di; } bool epi_getDI_rejectMotor_homepos(void) { return di_rejMot_home; } static bool di_npe_sensor; void gpi_storeDI_paperLow(bool di) { di_npe_sensor=di; } bool epi_getDI_npe_sensor(void) { return di_npe_sensor; } // /////////////////////////////////////////////////////////////////////////////////// // readaback digital outputs // /////////////////////////////////////////////////////////////////////////////////// /* D0 bit0: MDB devices 0=off 1=on bit1: MDB bus power bit2: MDB WakeOut D1=Printer D2=Credit D3=Modem D5: serial drv on/off, Serial mux1, Serial mux2 D6: Leds, Fan, D7: Siren and relay D8: PtuWakeOut D9: Power Aux/Barcode D10: AuxDir 1...6 D11: AuxOut 1...6 D12: Coin shutter output D13: CoinEscrow Outputs */ static uint8_t do_mbdRxTst; void gpi_storeDO_mdbRxTst(uint8_t mdbRxTst) { do_mbdRxTst=mdbRxTst; } bool epi_getDO_mdbRxTestOut(void) { if (do_mbdRxTst & 1) return true; return false; } static uint8_t do_motorBits; void gpi_storeDO_motorOutputs(uint8_t Pwr) { //D1: motor outputs bit0: upper lock forw bit 1 backw // Bit2: lowLock forw bit3: LL backw do_motorBits=Pwr; } uint8_t epi_getDO_motorOuts(void) { // bit0: upper lock forward bit 1 backward // bit2: lower lock forward bit 3 backward return do_motorBits; } static uint8_t do_serialSwitch; // serial drv on/off, Serial mux1, Serial mux2 void gpi_storeDO_serialSwitch(uint8_t state)// serial drv on/off, Serial mux1, Serial mux2 { do_serialSwitch=state; } uint8_t epi_getDO_serialSwitch(void) { // serial drv on/off, Serial mux1, Serial mux2 return do_serialSwitch; } bool epi_getDO_serialDriverIsOn(void) { if ( do_serialSwitch & 1) return true; return false; } bool epi_getDO_serialMux1isSetToPrinter(void) { // mux1 off: serial is switched to printer if ((do_serialSwitch & 2)==0) return true; return false; } bool epi_getDO_serialMux1isSetToModem(void) { // mux1 on: serial is switched to modem if ((do_serialSwitch & 2)>0) return true; return false; } bool epi_getDO_serialMux2isSetToCredit(void) { // mux2 off: serial is switched to credit card terminal if ((do_serialSwitch & 4)==0) return true; return false; } bool epi_getDO_serialMux2isSetToMifare(void) { // mux2 on: serial is switched to mifare reader if ((do_serialSwitch & 4)>0) return true; return false; } static uint8_t do_ledsAndFan; void gpi_storeDO_ledsAndFan(uint8_t ledState) { do_ledsAndFan=ledState; } bool epi_getDO_led_coin(void) { if (do_ledsAndFan & 1) return true; return false; } bool epi_getDO_led_front(void) { if (do_ledsAndFan & 2) return true; return false; } bool epi_getDO_led_ticket(void) { if (do_ledsAndFan & 4) return true; return false; } bool epi_getDO_led_pin(void) { if (do_ledsAndFan & 8) return true; return false; } bool epi_getDO_led_start(void) { if (do_ledsAndFan & 16) return true; return false; } bool epi_getDO_led_inside(void) { if (do_ledsAndFan & 32) return true; return false; } bool epi_getDO_fan(void) { if (do_ledsAndFan & 64) return true; return false; } static uint8_t do_laermUndRelay; void gpi_storeDO_sirenAndRelay(uint8_t sirenRelay) { do_laermUndRelay=sirenRelay; } bool epi_getDO_sirene(void) { if (do_laermUndRelay & 1) return true; return false; } bool epi_getDO_relay(void) { if (do_laermUndRelay & 2) return true; return false; } static uint8_t do_ptuWake; void gpi_storeDO_ptuWake(uint8_t state) { do_ptuWake=state; } bool epi_getDO_ptuWake(void) { if (do_ptuWake>0) return true; return false; } static uint8_t do_auxPower; void gpi_storeDO_auxPower(uint8_t pwr) { do_auxPower=pwr; } bool epi_getDO_auxPower(void) { if (do_auxPower>0) return true; return false; } static uint8_t do_coinShutter; void gpi_storeDO_coinShutter(uint8_t state) { do_coinShutter=state; } bool epi_getDO_coinShutterOpen(void) { // bit0: Coin shutter output, bit1: input-test-output if (do_coinShutter & 1) return true; return false; } bool epi_getDO_coinShutterTest(void) { // bit0: Coin shutter output, bit1: input-test-output if (do_coinShutter & 2) return true; return false; } static uint8_t do_coinEscrow; void gpi_storeDO_coinEscrow(uint8_t state) { do_coinEscrow=state; } uint8_t epi_getDO_coinEscrow(void) { // retval: 1:return flap is open 2:take flap is open 0:closed if (do_coinEscrow &1) return 1; // return flap is open if (do_coinEscrow &2) return 2; // take flap is open return 0; } static uint8_t do_printerPower; void gpi_storeDO_printerPwrOn(uint8_t state) { do_printerPower=state; } uint8_t epi_getDO_printerPwr(void) { return do_printerPower; } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //----------------------------- Mifare Card Reader ----------------------------------- #define NROFMIFSTATEBYTES 40 static uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES]; uint8_t gpi_storeMifReaderStateAndCardType(uint8_t *buf) { // retval 0=OK 1=error host buffer too small for (uint8_t nn=0; nn11 || maxBufferSize<64) return 1; // error for (uint8_t nn=0; nn<64; nn++) buf[nn]=Sdata_MIF_DATA[blkNr][nn]; return 0; // ois OK } //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ static uint8_t Sdata_PRN_STATE[pi_prnStateArraySize]; void epi_restorePrinterState(uint8_t *buf) { uint8_t nn; for (nn=0; nn64) leng=64; Sdata_empNrOfsettings=leng; tslib_strcpy(data, Sdata_emp_settingsBuff, leng); } void epi_restoreEmpSettings(uint8_t *leng, uint8_t *data) { *leng=Sdata_empNrOfsettings; tslib_strcpy(Sdata_emp_settingsBuff, data, Sdata_empNrOfsettings); } // ...................................................................... // Münzbuffer[10]: Münze für Münze auslesen (LIFO) // 4.5.21 struct T_coin { uint8_t valid; uint8_t signal; uint8_t error; uint8_t pad; uint16_t value; }; static struct T_coin gotCoin[MEMDEPTH_GOTCOINS]; static uint8_t ctr_gotCoin; void sub_enterData(uint8_t valid, uint8_t signal, uint8_t error, uint16_t value ) { if (ctr_gotCoin0) { vv=uchar2uint(data[pp+4], data[pp+3]); sub_enterData(data[pp], data[pp+1], data[pp+2], vv ); qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1] << " " <64) leng=64; Sdata_NrOfDeviceSetting=leng; tslib_strcpy(data, Sdata_DeviceSettingBuff, leng); } void epi_restoreDeviceSettings(uint8_t *leng, uint8_t *data) { *leng=Sdata_NrOfDeviceSetting; tslib_strcpy(Sdata_DeviceSettingBuff, data, Sdata_NrOfDeviceSetting); } static uint8_t Sdata_NrOfMachineIDSetting; static uint8_t Sdata_NrOfMachineIDBuff[66]; void gpi_storeMachineIDsettings(uint8_t leng, uint8_t *data) { if (leng>64) leng=64; Sdata_NrOfMachineIDSetting=leng; tslib_strcpy(data, Sdata_NrOfMachineIDBuff, leng); } void epi_restoreMachineIDsettings(uint8_t *leng, uint8_t *data) { *leng=Sdata_NrOfMachineIDSetting; tslib_strcpy(Sdata_NrOfMachineIDBuff, data, Sdata_NrOfMachineIDSetting); }