#include <qlabcashboxinterfacedefinition.h>
Inheritance diagram for QlabCashboxInterfaceDefinition:
This class is a definition only for all hardware used in cashboxes. Its objective is providing an opaque interface to the hardware, so the application logic does not even have to know about the display, printing, scanner or whatever could be installed in the box.
Hardware abstraction is not really easy, specifically when we have to deal with non standard hardware. It is the implementers job to connect hardware to standard methods.
One has to map whatever can happen to something able to send signals to connected widgets and slots that interact naturally with various hardware pieces.
This version is by no ways a definitive one. Some parts of the abstraction could not be built as I did not have the needed hardware for, namely scale and fiscal printers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Builds a new instance of QlabCashboxInterfaceDefinition with parent and name. All private member vars are initialized to known values. The constructor Always calls the QlabCashboxInterfaceDefinition::initDevices() method. |
|
Destroys the instance. One should not have to call this, as Qt does this for us. |
|
Return the active printer.
Reimplemented in QlabIbm4694. |
|
This signal is emited whenever an active status changes.
|
|
Returns the current barcode height. See QlabCashboxInterfaceDefinition::setBarCodeHeight() for details.
|
|
This signal is emited whenever the chase complete sequence is fired.
|
|
This signal is emited whenever a check has been read by MICR device.
|
|
Clears keyboard buffer.
|
|
Clears the Display device dev. This Method _MUST_ be overloaded by inheritors. sample implementation: void QlabIbm4694::clearScreen( int dev ) { device d = deviceList[dev] ; if ( d.descriptor > 0 ) { if ( PosIOCtl( d.descriptor, POS_DSP_CLEAR_SCREEN, NULL, 0 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (Clear Screen )on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Close all opened devices at once. It's up to implementor to do the real thing with this. Sample Implementation Code: void QlabIbm4694::closeAll() { QMap<uint, device>::Iterator it ; for ( it = deviceList.begin(); it != deviceList.end(); ++it ) { device dev = it.data() ; if ( dev.descriptor > 0 ) { if ( PosClose( dev.descriptor ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Unable to close device %1" ) ) .arg( dev.name ) ) ; } } } } Reimplemented in QlabIbm4694. |
|
Closes a named device. It's up to implementor to do the real thing with this. Sample Implementation Code: void QlabIbm4694::closeDevice( int dev ) { device devx = deviceList[dev] ; if ( devx.descriptor > 0 ) { if ( PosClose( devx.descriptor ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Unable to close device %1" ) ) .arg( devx.name ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Returns the current Print Attribute information.
|
|
Returns the current hardware active Status.
|
|
This signal is emited whenever a device error raises. Not every piece of hardware is able to signal errors. The signal, when emited, places a string description for the error. |
|
This signal is emited whenever Online status for a device changes. Not every piece of hardware is able to signal online status changes. The signal, when emited, places a string description for the status change. |
|
Device Status changes processor.
void QlabIbm4694::deviceStatus( POSQMSG *pMsg ) { if ( POSM_SYS_DEVICE_ONLINE == pMsg->msg || POSM_SYS_DEVICE_OFFLINE == pMsg->msg ) { emit deviceOnlineStatusChanged( QString( "%1 - %2, %3, %4: (%5)" ) .arg( GetTableEntry(QMsgTable, (int) pMsg->msg) ) .arg( GetTableEntry(SlotTable, (int) (pMsg->mp1 >> 24) & 0xFF) ) .arg( GetTableEntry(PortTable, (int) (pMsg->mp1 >> 16) & 0xFF) ) .arg( GetTableEntry(TypeTable, (int) (pMsg->mp1 ) & 0xFF) ) .arg( GetTableEntry(DevTable, (int) (pMsg->mp1 >> 8) & 0xFF) ) ) ; } else { emit deviceStatusChanged( QString( "%1 - %2 " ) .arg( pMsg->mp1 & 0xFFFF ) .arg( GetTableEntry(QMsgTable, (long) pMsg->msg ) ) ) ; } } |
|
This signal is emited whenever a device status changes. Not every piece of hardware is able to signal status changes. The signal, when emited, places a string description for the status change. |
|
Display in full screen emulation. Write msg on device dev starting at cursor pos cursor. Note that many pitfalls exist here. This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::displayFullScreen( int dev, const QString & msg, int cursor ) { device d = deviceList[dev] ; PosArg set_cursor ; int length = 40 - cursor ; ssize_t written ; set_cursor.name = PosNdisplayCursor ; set_cursor.value = (long) cursor ; QString mess = msg.leftJustify( length, ' ', TRUE ) ; if ( d.descriptor > 0 ) { clearScreen( dev ) ; if ( PosIOCtl( d.descriptor, POS_SYS_SET_VALUES, &set_cursor, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DFS) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ( ( written = PosWrite( d.descriptor, mess, (size_t) length ) ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DFS) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if ( written != (ssize_t) length ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display %1 wrote: %2 of %3 bytes" ) ) .arg( d.name ).arg( written ).arg( length ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Displays a right justified message msg on display dev at line lineno. This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::displayItemRight( int dev, const QString & msg, int lineno ) { device d = deviceList[dev] ; PosArg set_cursor ; ssize_t written; QString mess = msg ; if ( mess.isEmpty() ) { displayString( dev, QString( " " ), 20 ) ; return ; } int length = mess.length() ; // mess.length() ; if ( length > 0 ) { set_cursor.name = PosNdisplayCursor ; set_cursor.value = (long) ( lineno == 0 ? 20 - length : 40 - length ) ; if ( d.descriptor > 0 ) { if ( PosIOCtl( d.descriptor, POS_SYS_SET_VALUES, &set_cursor, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DIR) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ((written = PosWrite( d.descriptor, msg, (size_t) length)) == -1) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DIR) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if (written != (ssize_t) length) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display %1 wrote: %2 of %3 bytes" ) ) .arg( d.name ).arg( written ).arg( length ) ) ; } } } } Reimplemented in QlabIbm4694. |
|
Displays string msg on display & dev at position cursor This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::displayString( int dev, const QString & msg, int cursor ) { device d = deviceList[dev] ; PosArg set_cursor ; ssize_t written ; QString buffer = msg.leftJustify( 20, ' ', TRUE ) ; set_cursor.name = PosNdisplayCursor ; set_cursor.value = cursor >= 20 ? (long) 20 : (long) 0 ; if ( d.descriptor > 0 ) { if ( PosIOCtl( d.descriptor, POS_SYS_SET_VALUES, &set_cursor, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DS) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ( ( written = PosWrite( d.descriptor, buffer, (size_t) 20 ) ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display Error (DS) on %1: %2" ) ) .arg( d.name ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if ( written != (ssize_t) 20 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Display %1 wrote: %2 of %3 bytes" ) ) .arg( d.name ).arg( written ).arg( 20 ) ) ; } } } Reimplemented in QlabIbm4694. |
|
This signal is emited whenever the cash drawer closes.
|
|
This signal is emited whenever the cash drawer opens.
|
|
Returns current cash drawer status. Sample implementation code: long QlabIbm4694::drawerStatus() { PosArg args ; if ( deviceList[TIL].descriptor > 0) { args.name = PosNtillStatus ; args.value = 0 ; if ( PosIOCtl( deviceList[TIL].descriptor, POS_SYS_GET_VALUES, &args, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Cash Drawer Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } return args.value ; } Reimplemented in QlabIbm4694. |
|
Evaluates line and returns a converted version with dash lines if withdash is TRUE.
This Method _MUST_ be overloaded by inheritors.
QString QlabIbm4694::evalPrintLine( const QString & line, bool withdash ) { QString newline = "\r\n" ; QString boldstart = "\x1b\x45" ; QString boldend = "\x1b\x46" ; QString dblstart = "\x1b\x17\x1b\x0e" ; QString dblstop = "\x1b\x3b" ; QString dashme = QString( "" ).leftJustify( 38, '-', TRUE ) ; QString footprint = "" ; QStringList footlist = QStringList::split( "\n", line, FALSE ) ; if ( !line.isEmpty() ) { for ( QStringList::Iterator it = footlist.begin(); it != footlist.end(); ++it ) { bool center = FALSE ; bool dblw = FALSE ; QString li = *it ; if ( li.contains( "<center>") != 0 ) { center = TRUE ; li = li.replace( "<center>", "" ) ; li = li.replace( "</center>", "" ) ; } if ( li.contains( "<doublesize>" ) != 0 ) { dblw = TRUE ; li = li.replace( "<doublesize>", dblstart ) ; li = li.replace( "</doublesize>", dblstop ) ; } int bolds = li.contains( "<bold>" ) ; bolds = bolds * 4 ; li = li.replace( "<bold>", boldstart ) ; li = li.replace( "</bold>", boldend ) ; if ( dblw && center ) { li = li.rightJustify( 19 + bolds, ' ', TRUE ) ; } else if ( center ) { uint ll = li.length() + bolds ; ll = 38 + bolds - ll ; li.prepend( QString( "" ).leftJustify( ll, ' ', TRUE ) ) ; } li.append( newline ) ; footprint.append( li ) ; } footprint.prepend( newline ) ; } if ( withdash ) { footprint.prepend( dashme ) ; footprint.prepend( newline ) ; footprint.append( dashme ) ; footprint.append( newline ) ; } return footprint ; } Reimplemented in QlabIbm4694. |
|
This signal is emited whenever a non alphanumeric (function) key is hit.
|
|
Starts the event management loop for the hardware. On non graphics hardware, this acts as a Message Queue, and on graphics cashboxes, this should activate the exec() method for the dialog. While the loop stays alive, we scan the messages and send signals when we need them. An in depth explanation of message loops and message queues can be found in Qt documentation. example: Snippet code usable with IBM 4694 cashbox family. This snippet uses some IBM 4694 specific calls such as PosRead(). You could have whatever the Hard Vendor Interface says instead of 4694 specific function calls. This is by no way a full implementation. See sample QlabIbm4694::exec() for a more complete sample. void QlabIbm4694::exec() { ssize_t rc ; long till_open_tm = 0 ; // this has only to deal with some harware functionning. // Grabbed from IBM reference Manual. setvbuf( stdout, NULL, _IOFBF, 8192 ) ; setvbuf( stderr, NULL, _IONBF, 0 ) ; emit activeStatusChanged( PosStatusSignedOff ) ; while ( !exitRequired ) { // Wait for messages in queue while ( ( ( rc = PosRead( 0, &qmsg, EVENT_MESSAGE_SIZE ) ) == EVENT_MESSAGE_SIZE) && ( !exitRequired ) ) { switch ( qmsg.msg ) { case POSM_SCAN_DATA_AVAIL: processScannerData() ; break ; // MSR received a card read. case POSM_KBD_WM_CHAR: processCharacterMessage( &qmsg ) ; break ; default: deviceStatus( &qmsg ) ; break ; } // switch( qmsg.msg ) } // while ( PosRead(... ) ) } // while ( !exitRequired ) } Reimplemented in QlabIbm4694. |
|
Requires the exit from event loop event. This method does the same as QDialog::accept() in grphicas dialogs. Thus the event processor will leave the main event loop and close the hardware. Be very carefull when dealing with this as some hardware need to be unlocked, released or reset if you don't want a full blown hardware crash. A (sometimes) long poking in Vendor Reference Manual is a must do before implementing the real stuff. |
|
Returns cashbox available features. The available feature list is left to implementor's choice. The preconized style for the list is (note: no QStringList declaration, only a result): OperatorDisplay_YES CustomerDisplay_YES CustomerReceiptPrinter_YES DocumentInsertPrinter_NO CheckPrinter_NO Scanner_YES MagneticStripReader_NO ElectronicPayment_NO FlyingSaucerGenerator_YES AlienFood_YES and so on for all features. Reimplemented in QlabIbm4694. |
|
Reads Keyboard buffer.
|
|
Returns the active Tabs list.
|
|
Hardware Devices initialization code. This can be whatever init sequence Hardware Vendors need and, for Graphics systems, building of main window or dialogs, init shortcuts... Reimplemented in QlabIbm4694. |
|
Installs the keymap mapname into the system. Keymaps are virtual keyboard mappings. While graphics applications can use standard shortcuts to enable this, specific hardware must install a keymap. The keymap is a binary KeyCode/KeyAction table. You have to map each and every key code to a key action. It's up to implementer's to generate the keymap bindings.
|
|
This signal is emited whenever keyboard buffer changes.
|
|
This signal is emited whenever Enter key is hit.
|
|
Returns the Keyboard Supervisor Key Status. It's up to implementor to do the real thing with this. Sample Implementation Code: long QlabIbm4694::keyboardSupervisorStatus() { PosArg args ; device d = deviceList[KEYBOARD] ; if ( d.descriptor > 0 ) { args.name = PosNkeyLock ; args.value = 0 ; if ( PosIOCtl( d.descriptor, POS_SYS_GET_VALUES, &args, 1) == -1) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Keyboard Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return 0 ; } } return args.value ; } Reimplemented in QlabIbm4694. |
|
Locks device dev. It's up to implementor to do the real thing with this. Sample Implementation Code: void QlabIbm4694::lockDevice( int dev ) { device d = deviceList[dev] ; if ( d.descriptor > 0 ) { if ( PosIOCtl( d.descriptor, POS_SYS_LOCK_DEVICE, NULL, 0 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Unable to lock device %1" ) ) .arg( d.name ) ) ; } } } Reimplemented in QlabIbm4694. |
|
This signal is emited whenever Magnetic Strip data is available.
|
|
Sends the CashDrawerOpen command. This is highly hardware dependant. sample implementation code: void QlabIbm4694::openCashDrawer() { if ( deviceList[TIL].descriptor > 0) { if ( PosIOCtl( deviceList[TIL].descriptor, POS_TILL_OPEN_TILL, NULL, 0 ) == -1) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Cash Drawer Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Pops saved status from status Stack. Logically, you should not have to deal with this, except on (more than) rare occasions. The only reason for it to be here is to allow processing for those funky FarTEK Boxes (mainly used in Asia) which change hardware status when supervisor key is trotated and loose the previous status.
|
|
Prints a barcode of type bc with value .
This is only useful if the print device is smart enough to produce scanner readable barcodes. Only some thermal and inkjet print devices produce quality barcodes, most of them generating some kind of trashy unusable black stripes.
|
|
This signal is emited whenever the active print device changes.
|
|
Returns the current Printer Status. This Method _MUST_ be overloaded by inheritors.
long QlabIbm4694::printerStatus() { PosArg args ; if ( deviceList[PRINTER].descriptor > 0) { args.name = PosNprintStatus ; args.value = 0 ; if ( PosIOCtl( deviceList[PRINTER].descriptor, POS_SYS_GET_VALUES, &args, 1) == -1) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Error while stating Printer Status: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } return args.value ; } Reimplemented in QlabIbm4694. |
|
Print a line li to current Printer using current Print Attribute. This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::printLine( const QString & li ) { printLineBuffer = evalPrintLine( li ) ; if ( currentPrinter == PrinterCustomerReceipt ) { if ( deviceList[PRINTER].number != PosDEVICE_PRINTER_4610 ) { writeToCRandSJstations( printLineBuffer ) ; } else { writeToCRstation( printLineBuffer ) ; } } else if ( currentPrinter == PrinterDocumentInsert ) { writeToDIstation( printLineBuffer ) ; } else { emit deviceError( 38421, SeverityError, QString( tr( "Program Error: Trying to print to %1" "while no printer has been defined as" "print device." ) ) ) ; } } Reimplemented in QlabIbm4694. |
|
Print a text stream txt to current Printer using current Print Attribute. This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::printText( const QString & txt ) { printLineBuffer = evalPrintLine( txt ) ; if ( currentPrinter == PrinterCustomerReceipt ) { QStringList lst = QStringList::split( printLineBuffer, "\r\n" ) ; for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { if ( deviceList[PRINTER].number != PosDEVICE_PRINTER_4610 ) { writeToCRandSJstations( *it ) ; } else { writeToCRstation( *it ) ; } } } else if ( currentPrinter == PrinterDocumentInsert ) { writeToDIstation( printLineBuffer ) ; } else { emit deviceError( 38421, SeverityError, QString( tr( "Program Error: Trying to print to %1" "while no printer has been defined as" "print device." ) ) ) ; } } Reimplemented in QlabIbm4694. |
|
Processes the Keyboard Char event.
This is where we dispatch keyboard events between standard chars and Key Events.
void QlabIbm4694::processCharacterMessage( POSQMSG *qmsg ) { // Refer to Reference Manual for message cookbook :-) unsigned char keyFlags = (unsigned short)( ( qmsg->mp2 >> 16 ) & 0xFFFF ) ; if ( keyFlags & PosKC_KEYUP ) { // ignore KeyRelease events return ; } else { unsigned char scanCode = ( (unsigned char)( qmsg->mp2 & 0xFF ) ) ; unsigned char keyCode = sioKeys[scanCode] ; if ( keyCode >= _0_ && keyCode <= _9_ ) { kbdBuffer.append( QChar( keyCode ) ) ; emit keyboardBufferChanged( kbdBuffer ) ; } else if ( keyCode == _00_ ) { kbdBuffer.append( "00" ) ; emit keyboardBufferChanged( kbdBuffer ) ; } else if ( keyCode == _ENTER_1_ || keyCode == _ENTER_2_ ) { emit keyboardDataAvailable( kbdBuffer ) ; } else { emit eventKey( keyCode ) ; } } } |
|
Processes the Chase Full Completion Code. Mostly used to send a signal to application logic and reset some hardware to known state.
void QlabIbm4694::processChaseComplete() { displayFullScreen( DISPLAY, tr( "Close Drawer" ), 0 ) ; while ( drawerStatus() && PosDRAWER_OPEN ) { } clearScreen( DISPLAY ) ; emit chaseComplete() ; } Reimplemented in QlabIbm4694. |
|
Processes Magnetic Strip Reader available data.
Beware, Keyboard and USB readers are seen as keyboards in most cases. Serial and proprietary connected reader send data to the msrBuffer. You have to parse the data, eventually strip the MSRSignature prefix if present, acquit the device and unlock it with some models... sample code: QString QlabIbm4694::processMsrData() { int length ; QString data = QString( "" ).fill( '0', 127 ) ; if ( deviceList[MSR].descriptor > 0 ) { ssize_t readc ; if ( ( readc = PosRead( deviceList[MSR].descriptor, &data, (size_t) & length ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: MSR Read Error on: %1, Err %2" ) ) .arg( deviceList[MSR].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } msrBuffer = data ; emit msrDataAvailable( msrBuffer ) ; return data ; } Reimplemented in QlabIbm4694. |
|
Processes data returned by print device.
void QlabIbm4694::processPrinterData( POSQMSG *qmsg ) { long prnDataLen = (long) qmsg->mp2 & 0xFFFF ; if ( activeStatus == PosStatusReadCheck ) { micrBuffer = readMicr( prnDataLen ) ; MicrInfoRequested = FALSE ; emit checkIdentAvailable( micrBuffer ) ; } // More processing code for various status... } |
|
Processes print device errors.
sample code: void QlabIbm4694::processPrinterError( POSQMSG *qmsg ) { QString buffer = QString( tr( "Printer Error %1 - %2" ) ).arg( qmsg->mp1 ).arg( qmsg->mp2 ) ; displayFullScreen(DISPLAY, buffer, 0); activeStatus = PosStatusPrintError ; MicrInfoRequested = FALSE ; waitForErrorRecover = TRUE ; emit deviceError( 65534, SeverityError, buffer ) ; } |
|
Printer Status Change Processor.
void QlabIbm4694::processPrinterStatus( POSQMSG *qmsg ) { long change = (qmsg->mp1 >> 16) & 0xFFFF; long status = qmsg->mp2; // First verify if we need MICR information (only when we process check tender status) if ( MicrInstalled && !MicrInfoRequested && activeStatus == PosStatusReadCheck ) { // The document is not yet registered... if ( ( ( change == PosCHANGE_DOCUMENT_AT_FRONT ) && ( status & PosSTATUS_DOCUMENT_AT_FRONT ) && !( status & PosSTATUS_DOCUMENT_READY ) ) || ( ( change == PosCHANGE_DOCUMENT_AT_TOP ) && ( status & PosSTATUS_DOCUMENT_AT_TOP ) && !( status & PosSTATUS_DOCUMENT_READY ) ) ) { // Register Document selectFullPage() ; writeToDIstation( p4610RegisterDocument ) ; } else if ( change == PosCHANGE_DOCUMENT_REGISTER ) { // check registered. Try to read information. // This will end up with a POSM_PRN_DATA_AVAIL message. if ( status & PosSTATUS_DOCUMENT_READY ) { selectFullPage() ; MicrInfoRequested = TRUE ; writeToDIstation( p4610ReadMicrInfo ) ; displayString( DISPLAY, "Reading Check", 0 ) ; } } else if ( ( activeStatus == PosStatusRemoveCheck ) && ((change == PosCHANGE_DOCUMENT_AT_FRONT || change == PosCHANGE_DOCUMENT_AT_TOP || change == PosCHANGE_DOCUMENT_REGISTER) && !(status & (PosSTATUS_DOCUMENT_READY | PosSTATUS_DOCUMENT_AT_FRONT | PosSTATUS_DOCUMENT_AT_TOP)))) { selectRollPaper(); } } |
|
Processes scanner available data.
Beware, Keyboard and USB scanners are seen as keyboards in most cases. Serial and proprietary connected scanners send data to the scannerBuffer. You have to parse the data, eventually strip the BarCodeType prefix if present, acquit the scanner and unlock it... sample code: void QlabIbm4694::processScannerData() { int scnDataLen = SCANNER_BUFFER_SIZE ; union { PosScannerDataHdr scnHdr ; char scnBuffer[SCANNER_BUFFER_SIZE] ; } scnData ; int readc ; lockDevice( deviceList[SCANNER].descriptor ) ; // Get the wonderful things the scanner proposes to us if ( ( readc = PosRead( deviceList[SCANNER].descriptor, scnData.scnBuffer, (size_t) &scnDataLen ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Scanner: %1" ) ) .arg( GetTableEntry(ErrnoTable, PosErrno() ) ) ) ; return ; } // Expulse scanner header from received data scannerBuffer = scnData.scnBuffer[8] ; emit scannerDataAvailable( scannerBuffer ) ; unlockDevice( deviceList[SCANNER].descriptor ) ; } Reimplemented in QlabIbm4694. |
|
Processes the DrawerClose event with till_open_tm duration stamp. Mostly used to send a signal to application logic. The till_open_tm initializes a time counter which can be used to implement whatever you need.
void QlabIbm4694::processTillClosed( long *till_open_tm ) { emit drawerClosed() ; till_open_tm = 0 ; } Reimplemented in QlabIbm4694. |
|
Processes the DrawerOpen event with till_open_tm duration stamp. Mostly used to send a signal to application logic. The till_open_tm initializes a time counter which can be used to implement a loop waiting for drawer close event or whatever you need.
void QlabIbm4694::processTillOpened( long *till_open_tm ) { emit drawerOpen() ; till_open_tm = 0 ; } Reimplemented in QlabIbm4694. |
|
Pushes the current hardware status on stack. Logically, you should not have to deal with this, except on (more than) rare occasions. The only reason for it to be here is to allow processing for those funky FarTEK Boxes (mainly used in Asia) which change hardware status when supervisor key is trotated and loose the previous status. |
|
Reads MICR Data and returns check number. Highly MICR reader hardware dependant.
QString QlabIbm4694::readMicr( long size ) { QString data = QString( "" ).fill( '0', 128 ) ; MicrInfoRequested = FALSE ; if ( deviceList[PRINTER].descriptor != -1 ) { ssize_t readc ; if ( ( readc = PosRead( deviceList[PRINTER].descriptor, &data, (size_t) & size ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: MICR Read Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } return data ; } Reimplemented in QlabIbm4694. |
|
Forces reading scanner data. This MUST be reimplemented as various scanners do not work the same way. Reimplemented in QlabIbm4694. |
|
Releases all locked devices at once. It's up to implementor to do the real thing with this. Sample Implementation Code: void QlabIbm4694::releaseAll() { QMap<uint, device>::Iterator it ; for ( it = deviceList.begin(); it != deviceList.end(); ++it ) { device dev = it.data() ; if ( dev.descriptor > 0 ) { if ( PosIOCtl( dev.descriptor, POS_SYS_RELEASE_DEVICE, NULL, 0 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Unable to release device %1" ) ) .arg( dev.name ) ) ; } } } } Reimplemented in QlabIbm4694. |
|
This signal is emited whenever scan data is available.
|
|
Selects the desired character cs set in the active code page.
|
|
Selects the desired code page from ICodePages list. You MUST oberload this method as not all printers honour all code pages. |
|
Sets the Document Insert (Slip Paper) Printer as Default Print device. This Method _MUST_ be overloaded by inheritors. Sample implementation code: bool QlabIbm4694::selectFullPage() { qDebug( "SelectFullPage called" ) ; device d = deviceList[PRINTER] ; int rc = -1 ; if ( d.descriptor != -1 ) { if ( ( rc = PosIOCtl( d.descriptor, POS_PRN_ENABLE_DI_PRINTING, 0, 0 ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Printer Error enabling DI: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return FALSE ; } else { PosArg resource; resource.name = PosNprintStation; resource.value = PosPRINT_STATION_DI; if ( ( rc = PosIOCtl( d.descriptor, POS_SYS_SET_VALUES, &resource, 1 ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Printer Error enabling DI: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return FALSE ; } } } if ( rc != -1 ) { currentPrinter = PrinterDocumentInsert ; emit printerChanged( currentPrinter ) ; } return TRUE ; } Reimplemented in QlabIbm4694. |
|
Sets the Customer Receipt Printer as Default Print device. This Method _MUST_ be overloaded by inheritors. Sample implementation code: bool QlabIbm4694::selectRollPaper() { device d = deviceList[PRINTER] ; int rc = -1 ; if ( d.descriptor != -1 ) { if ( ( rc = PosIOCtl( d.descriptor, POS_PRN_DISABLE_DI_PRINTING, 0, 0 ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Printer Error disabling DI: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return FALSE ; } else { PosArg resource; resource.name = PosNprintStation; resource.value = PosPRINT_STATION_CR; if ( ( rc = PosIOCtl( d.descriptor, POS_SYS_SET_VALUES, &resource, 1 ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Printer Error enabling CR: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return FALSE ; } } } if ( rc != -1 ) { currentPrinter = PrinterCustomerReceipt ; emit printerChanged( currentPrinter ) ; } return TRUE ; } Reimplemented in QlabIbm4694. |
|
Sets the active Printer to device prn. Example overloading for QlabIbl4694 class: void QlabIbm4694::setActivePrinter( ActivePrintDevice prn ) { currentPrinter = prn ; if ( prn == PrinterCustomerReceipt ) { selectRollPaper() ; } else if ( prn == PrinterDocumentInsert ) { selectFullPage() ; } } |
|
Sets the barcode Height to height. This is highly hardware dependant. You'll have to overload the method and dig in Reference Manual to find what the hell the hardware agrees with.
|
|
Sets Bar Code Type to bct for barcode printing.
This is only useful if the print device is smart enough to produce scanner readable barcodes. Only some thermal and inkjet print devices produce quality barcodes, most of them generating some kind of trashy unusable black stripes.
|
|
Sets the current print attribute to mdInfo.
void MysampleClass::setCurrentPrintInfo( QlabCashboxInterfaceDefinition::PrintModeData mdInfo ) { prnInfo = mdInfo ; QString mx ; switch ( mdInfo ) { case SelectEmphasis : mx = "\x1b\x45" ; break ; case DeselectEmphasis : mx = "\x1b\x46" ; break ; default : break ; } writeToCRStation( mx ) ; } |
|
Sets the current hardware active status to newStatus.
|
|
Sets the tabstops for print device.
|
|
Sets the current Supervise mode to super.
|
|
Sets up everything for normal use. This method must be called before starting the exec() event loop. It mainly checks all hardware, opens and acquires devices and reports hardware failures...
void QlabIbm4694::setup() { PosArg timeOutArg ; timeOutArg.name = PosNreadTimeout ; timeOutArg.value = SLEEP_MILLISECONDS ; if ( PosInitialize( "qlabibmcashbox", "/opt/lab/etc/ibmpossubsys.res", 0, 0, &timeOutArg, 1 ) == -1 ) { emit deviceError( 1, SeverityFatal, tr( "Fatal Error: Cashbox hardware initialization error", "This message is emited when PosInitialize() method fails\n" "This message is transmited to the application error processor\n" ) ) ; } activeStatus = PosStatusSignedOff ; emit activeStatusChanged( activeStatus ) ; exitRequired = FALSE ; } Reimplemented in QlabIbm4694. |
|
Parametrized soundTone for Errors
Reimplemented in QlabIbm4694. |
|
Parametrized soundTone for DataRejection
Reimplemented in QlabIbm4694. |
|
Sounds a tone with frequency in Hertz, duration in 1/10th second and volume in 0-100%. This is a VERY HIGHLY hardware dependant method. You should read carefully the Vendor Reference Manual.
void QlabIbm4694::soundTone( int frequency, int duration, int volume ) { if ( deviceList[KEYBOARD].descriptor > 0 ) { PosArg args ; args.name = PosNtoneFreq ; args.value = frequency ; if ( PosIOCtl( deviceList[KEYBOARD].descriptor, POS_SYS_SET_VALUES, &args, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Keyboard Tone Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return ; } args.name = PosNtoneDuration ; args.value = duration ; if ( PosIOCtl( deviceList[KEYBOARD].descriptor, POS_SYS_SET_VALUES, &args, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Keyboard Tone Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return ; } args.name = PosNtoneVolume ; args.value = volume ; if ( PosIOCtl( deviceList[KEYBOARD].descriptor, POS_SYS_SET_VALUES, &args, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Keyboard Tone Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; return ; } if ( PosIOCtl( deviceList[KEYBOARD].descriptor, POS_KBD_SOUND_TONE, &args, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Keyboard Tone Error: %1" ) ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Parametrized soundTone for Warnings
Reimplemented in QlabIbm4694. |
|
Returns the current supervise mode. When TRUE you are in Supervisor Mode. |
|
This signal is emited whenever the Supervise status changes.
|
|
unlocks device dev It's up to implementor to do the real thing with this. Sample Implementation Code: void QlabIbm4694::unlockDevice( int dev ) { device d = deviceList[dev] ; if ( d.descriptor > 0 ) { if ( PosIOCtl( d.descriptor, POS_SYS_UNLOCK_DEVICE, NULL, 0 ) == -1 ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: Unable to unlock device %1" ) ) .arg( d.name ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Waits till the operator closes cash drawer. Sample implementation code: void QlabIbm4694::waitForDrawerClosed() { while ( drawerStatus() != 1 ) {} } Reimplemented in QlabIbm4694. |
|
Writes line to both Customer Receipt and Serialized Journal print devices.
Both methods are needed due to some inconsistencies in most hardware drivers.
void QlabIbm4694::writeToCRandSJstations( const QString & buffer ) { if ( deviceList[PRINTER].descriptor != -1 ) { PosArg set_station ; ssize_t written ; size_t length = (size_t)buffer.length() ; set_station.name = PosNprintStation ; set_station.value = PosPRINT_STATION_CR + PosPRINT_STATION_SJ ; if ( PosIOCtl( deviceList[PRINTER].descriptor, POS_SYS_SET_VALUES, &set_station, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: CR+SJ Printer Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ( ( written = PosWrite( deviceList[PRINTER].descriptor, buffer, length ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: CR+SJ Printer Write Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if ( written != (ssize_t) length ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: CR+SJ Printer %1 wrote %1 on %2 bytes" ) ) .arg( deviceList[PRINTER].clsname ) .arg( written ) .arg( length ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Writes line to Customer Receipt print device.
Both methods are needed due to some inconsistencies in most hardware drivers.
void QlabIbm4694::writeToCRstation( const QString & line ) { if ( deviceList[PRINTER].descriptor != -1 ) { QString printLineBuffer = evalPrintLine( line ) ; PosArg set_station ; ssize_t written ; size_t length = (size_t)printLineBuffer.length() ; set_station.name = PosNprintStation ; set_station.value = PosPRINT_STATION_CR ; if ( PosIOCtl( deviceList[PRINTER].descriptor, POS_SYS_SET_VALUES, &set_station, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: Customer Receipt Printer Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ( ( written = PosWrite( deviceList[PRINTER].descriptor, printLineBuffer, length ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: CR Printer Write Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if ( written != (ssize_t) length ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: CR Printer %1 wrote %1 on %2 bytes" ) ) .arg( deviceList[PRINTER].clsname ) .arg( written ) .arg( length ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Writes line to Document Insert (Slip Paper) print devices. This Method _MUST_ be overloaded by inheritors.
void QlabIbm4694::writeToDIstation( const QString & buffer ) { qDebug( "writeToDIstation" ) ; size_t length = (size_t)buffer.length() ; if ( deviceList[PRINTER].descriptor != -1 ) { PosArg set_station ; ssize_t written ; set_station.name = PosNprintStation ; set_station.value = PosPRINT_STATION_DI ; if ( PosIOCtl( deviceList[PRINTER].descriptor, POS_SYS_SET_VALUES, &set_station, 1 ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: DI Printer Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } if ( ( written = PosWrite( deviceList[PRINTER].descriptor, buffer, length ) ) == -1 ) { emit deviceError( PosErrno(), SeverityError, QString( tr( "Device Error: DI Printer Write Error on: %1, Err %2" ) ) .arg( deviceList[PRINTER].clsname ) .arg( GetTableEntry( ErrnoTable, PosErrno() ) ) ) ; } else if ( written != (ssize_t) length ) { emit deviceError( PosErrno(), SeverityWarning, QString( tr( "Device Error: DI Printer %1 wrote %1 on %2 bytes" ) ) .arg( deviceList[PRINTER].clsname ) .arg( written ) .arg( length ) ) ; } } } Reimplemented in QlabIbm4694. |
|
Stores the Current Print Attribute.
For internal use only.
|
|
Current POS hardware status.
For internal use only.
|
|
Place holder for barcode height.
For internal use only.
|
|
Stores the chase end sequence.
For internal use only.
|
|
Max Columns for Customer Receipt Printer.
For internal use only.
|
|
Max Columns for Document Insert Printer.
For internal use only.
|
|
Stores the active printer device.
For internal use only.
|
|
Map to the existing devices.
For internal use only.
|
|
Event loop exit flag.
For internal use only.
|
|
Place holder for feature list.
For internal use only.
|
|
Character Map Storage. Used by QlabCashboxInterfaceDefinition::printLine() if charsets are managed.
For internal use only.
|
|
Supervisor mode flag.
For internal use only.
|
|
Keyboard buffer.
For internal use only.
|
|
Library signature.
For internal use only. Never change this. |
|
Check Reader buffer.
For internal use only.
|
|
Do we need Check Reader Information.
For internal use only.
|
|
Is Check Reader installed?
For internal use only.
|
|
Magnetic Strip Reader buffer.
For internal use only.
|
|
Mapping from XML to Sequences.
For internal use only.
|
|
Print device File view.
For internal use only.
|
|
Ready to print line buffer.
For internal use only.
|
|
Helper stream to physical printer.
For internal use only.
|
|
Place holder for current Print Attribute.
For internal use only.
|
|
Scanner buffer.
For internal use only.
|
|
Status Stack.
For internal use only.
|
|
Tabulation list.
For internal use only.
|
|
TRUE when waiting for hardware error recover method.
For internal use only.
|
|
May be used to know if setup finished and welcome message has been displayed.
For internal use only.
|