Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

QlabCashboxInterfaceDefinition Class Reference
[Cashbox Related Classes]

#include <qlabcashboxinterfacedefinition.h>

Inheritance diagram for QlabCashboxInterfaceDefinition:

QlabIbm4694 List of all members.

Detailed Description

The QlabCashboxInterfaceDefinition provides an abstract definition for a standard cashbox hardware interface.

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.

Todo:
Add more test cases, prefilter scanner data and format them...
Warning:
Never instanciate directly this class, as it only contains an opaque interface connected to nothing. You MUST inherit it when creating a new interface to an inherited QlabCashboxBase::QlabCashboxBase() class.

Public Types

Public Slots

Signals

Public Member Functions

Protected Slots

Protected Member Functions

Protected Attributes

Private Member Functions

Private Attributes


Member Enumeration Documentation

enum QlabCashboxInterfaceDefinition::ActivePrintDevice
 

Enumeration values:
PrinterNone  No printer has been opened or no printer installed
PrinterCustomerReceipt  Customer Receipt. Mainly Roll Paper
PrinterDocumentInsert  Document Insert. Sometimes called slip paper
PrinterFiscalPrinter  Fiscal Printer. Strongly bound to country/model
PrinterCheckWriter  Check Writer. Strogly bound to hardware w/wo MICR reader

enum QlabCashboxInterfaceDefinition::BarcodeTypes
 

Enumeration values:
UpcA  Standard American UPC version A
UpcE  Standard American UPC version B
Ean13  Standard European Code with 13 digits
Ean8  Standard European Code with 8 digits
Code39  Widely used Code 39 (alphanumeric)
Itf  Brain washer Interleaved encoding
Codabar  Classic Codabar encoding Mostly used in USA, Canada, Eire
Code93  Codabar variant with some more quirks
Code128  Seldom use, but one never knows...

enum QlabCashboxInterfaceDefinition::ICharsets
 

Enumeration values:
Usa  8 bit ASCII Charset
France  USA modified for accented
Germany  Adds umlaut and ss chars
Uk  USA modified for UK standards
Denmark1  First Danish variation
Sweeden  Sweedish extension
Italy  Looks like France with some char inversions
Spain1  Tilde and inverted ! added
Japan  Basic katakana
Norway  Norvegian variants with funny chars
Denmark2  Second Danish variation. Not compatible with Denmark1
Spain2  Second spanish variant
LatinAmerica  Latin America variant, mixes Spain and Portugal plus Fiscal chars
Korea  Korean alphabet. Be careful with this, as glyphs sounds strange

enum QlabCashboxInterfaceDefinition::ICodePages
 

Enumeration values:
Pc437  Was IBM PC first charset
Pc850  Introduced with MS-Dos 3.30 Adds European chars support
Pc860  Eastern European standard
Pc868  Pc850 extended for Euro glyph

enum QlabCashboxInterfaceDefinition::PosActiveStatus
 

Enumeration values:
PosStatusUnknown  Unknown status. Hardware did not terminate its setup.
PosStatusSignedOff  Only valid for hardware with a SignOff hardware key
PosStatusPaused  Only valid for hardware with a Pause hardware key
PosStatusReadCheck  Only valid when MICR is installed.
PosStatusRemoveCheck  Only valid when MICR is installed and a check is being read
PosStatusPrintError  Says the printer (or a print device) is on error

enum QlabCashboxInterfaceDefinition::PosErrorSeverity
 

Enumeration values:
SeverityInfo  Informational only. Example: the PaperNearEnd in TMH 6000
SeverityWarning  Warning. Not really an error, but something's wrong
SeverityError  Error. Inheritors must know if recoverable or not, depending on hardware
SeverityMemory  Memory error. Usually, very bad news. Unrecoverable error. Might crash the system
SeverityFatal  Fatal error. This usually sounds like a hardware problem

enum QlabCashboxInterfaceDefinition::PrintModeData
 

Enumeration values:
None  No attribute. Default Print size
SelectFontA  Select First internal font
SelectFontB  Select second internal font
SelectEmphasis  Select emphasis mode. Depends on hardware bold or italics
DeselectEmphasis  Deselects emphasis
SelectDoubleHeight  Selects Double height printing if available
UnselectDoubleHeight  Deselects Double Height
SelectDoubleWidth  Selects Double width if available
UnselectDoubleWidth  Deselects Double width
SelectDoubleSize  Selects Double Size = Double width + Double Height if available
UnselectDoubleSize  Deselects Double Size
SelectUnderline  Selects underlining. Depends on hardware. Single or double pass
UnselectUnderline  Deselects Underlining
SelectBlackRibbon  Selects standard black ribbon
SelectRedRibbon  Selects alternate color ribbon if available


Constructor & Destructor Documentation

QlabCashboxInterfaceDefinition::QlabCashboxInterfaceDefinition QObject *  parent = 0,
char *  name = 0
 

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.

QlabCashboxInterfaceDefinition::~QlabCashboxInterfaceDefinition  ) 
 

Destroys the instance.

One should not have to call this, as Qt does this for us.


Member Function Documentation

QlabCashboxInterfaceDefinition::ActivePrintDevice QlabCashboxInterfaceDefinition::activePrinter  )  const [virtual, slot]
 

Return the active printer.

Reimplemented in QlabIbm4694.

void QlabCashboxInterfaceDefinition::activeStatusChanged int  newStatus  )  [signal]
 

This signal is emited whenever an active status changes.

int QlabCashboxInterfaceDefinition::barcodeHeight  )  const [virtual, slot]
 

Returns the current barcode height. See QlabCashboxInterfaceDefinition::setBarCodeHeight() for details.

void QlabCashboxInterfaceDefinition::chaseComplete  )  [signal]
 

This signal is emited whenever the chase complete sequence is fired.

void QlabCashboxInterfaceDefinition::checkIdentAvailable const QString &  checkNumber  )  [signal]
 

This signal is emited whenever a check has been read by MICR device.

void QlabCashboxInterfaceDefinition::clearKeyboard  )  [virtual, slot]
 

Clears keyboard buffer.

Note:
If, for whatever reason, you need to overload this method, you must emit a QlabCashboxInterfaceDefinition::keyboardBufferChanged() signal informing the application that the buffer has changed. The signal must send the buffer contents.

void QlabCashboxInterfaceDefinition::clearScreen int  dev  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::closeAll  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::closeDevice int  dev  )  [virtual, slot]
 

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.

QlabCashboxInterfaceDefinition::PrintModeData QlabCashboxInterfaceDefinition::currentPrintInfo  )  const [virtual, slot]
 

Returns the current Print Attribute information.

QlabCashboxInterfaceDefinition::PosActiveStatus QlabCashboxInterfaceDefinition::currentStatus  )  const [virtual, slot]
 

Returns the current hardware active Status.

void QlabCashboxInterfaceDefinition::deviceError int  errNo,
int  sev,
const QString &  desc
[signal]
 

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.

void QlabCashboxInterfaceDefinition::deviceOnlineStatusChanged const QString &  desc  )  [signal]
 

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.

void QlabCashboxInterfaceDefinition::deviceStatus  )  [protected, virtual]
 

Device Status changes processor.

Warning:
It's up to implentation to send needed signals to application.
sample code:
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 ) ) ) ;
        }
}

void QlabCashboxInterfaceDefinition::deviceStatusChanged const QString &  desc  )  [signal]
 

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.

void QlabCashboxInterfaceDefinition::displayFullScreen int  dev,
const QString &  msg,
int  cursor = 0
[virtual, slot]
 

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.

Warning:
Carefully read the Hardware Vendor Reference about display devices. The cursor is a somewhat hard to domestic beast.
sample implementation:
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.

void QlabCashboxInterfaceDefinition::displayItemRight int  dev,
const QString &  msg,
int  lineno = 1
[virtual, slot]
 

Displays a right justified message msg on display dev at line lineno.
This is useful for formating numbers or other right aligned stuff.

This Method _MUST_ be overloaded by inheritors.

Warning:
Carefully read the Hardware Vendor Reference about display devices.
Even if lineno can be 0, most 2 line display devices only agrre with line 1.
I could not trace the reason for this.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::displayString int  dev,
const QString &  msg,
int  cursor = 0
[virtual, slot]
 

Displays string msg on display & dev at position cursor
Note that many pitfalls exist here.

This Method _MUST_ be overloaded by inheritors.

Warning:
Carefully read the Hardware Vendor Reference about display devices. The cursor is a somewhat hard to domestic beast. This tries to emulate nCurses, but the displays don't really do what we need. The only safe cursors are often 0 and 20 on dual line displays. Other values may lead to inconsistencies, depending on display versions and release levels.
sample implementation:
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.

void QlabCashboxInterfaceDefinition::drawerClosed  )  [signal]
 

This signal is emited whenever the cash drawer closes.

void QlabCashboxInterfaceDefinition::drawerOpen  )  [signal]
 

This signal is emited whenever the cash drawer opens.

long QlabCashboxInterfaceDefinition::drawerStatus  )  [virtual, slot]
 

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.

QString QlabCashboxInterfaceDefinition::evalPrintLine const QString &  line,
bool  withdash = FALSE
[virtual, slot]
 

Evaluates line and returns a converted version with dash lines if withdash is TRUE.

This Method _MUST_ be overloaded by inheritors.
XML tags are converted to printer dialect and dashes are eventually added.

Todo:
Document the full list of XML Tags supported
Here is a simplistic implementation sample:
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.

void QlabCashboxInterfaceDefinition::eventKey unsigned char  keyCode  )  [signal]
 

This signal is emited whenever a non alphanumeric (function) key is hit.

void QlabCashboxInterfaceDefinition::exec  )  [virtual]
 

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.

void QlabCashboxInterfaceDefinition::exitLoop  )  [virtual, slot]
 

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.

QStringList QlabCashboxInterfaceDefinition::features  )  [virtual]
 

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.

QString QlabCashboxInterfaceDefinition::getKeyboardBuffer  )  [virtual, slot]
 

Reads Keyboard buffer.

Note:
This method clears the keyboard buffer. Thus, this is a destructive Read. Be warned in implementations to respect this as applications should think the buffer has been cleaned up after a forced read.

QString QlabCashboxInterfaceDefinition::hTabs  )  const [virtual, slot]
 

Returns the active Tabs list.

void QlabCashboxInterfaceDefinition::initDevices  )  [protected, virtual]
 

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.

void QlabCashboxInterfaceDefinition::installKeymap const QString &  mapname  )  [virtual, slot]
 

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.

Todo:
Replace the funky siokeys test definition by something more sexy. Ideas welcome.

void QlabCashboxInterfaceDefinition::keyboardBufferChanged const QString &  msg  )  [signal]
 

This signal is emited whenever keyboard buffer changes.

void QlabCashboxInterfaceDefinition::keyboardDataAvailable const QString &  msg  )  [signal]
 

This signal is emited whenever Enter key is hit.

long QlabCashboxInterfaceDefinition::keyboardSupervisorStatus  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::lockDevice int  dev  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::msrDataAvailable const QString &  msrd  )  [signal]
 

This signal is emited whenever Magnetic Strip data is available.

void QlabCashboxInterfaceDefinition::openCashDrawer  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::popStatus  )  [virtual, slot]
 

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.

Note:
If you try to pop from an empty stack a deviceError() signal is emited with a SeverityMemory class.

bool QlabCashboxInterfaceDefinition::printBarcode BarcodeTypes  bc,
const QString &  value
[virtual, slot]
 

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.
You MUST overload this method according to some really hardware dependant commands.

Note:
Supported barcode types depend on hardware. Not all printers can print the BarCodeTypes full list.

You must set QlabCashboxInterfaceDefinition::setBarCodeHeight() before calling this method.

void QlabCashboxInterfaceDefinition::printerChanged int  prn  )  [signal]
 

This signal is emited whenever the active print device changes.

long QlabCashboxInterfaceDefinition::printerStatus  )  [virtual, slot]
 

Returns the current Printer Status.

This Method _MUST_ be overloaded by inheritors.

Note:
We use a long as status descriptor.
Your implementation _MUST_ polish defines corresponding to statuses.

Todo:
Document the Full List of desirable statuses (mostly sent by all print devices)
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::printLine const QString &  li  )  [virtual, slot]
 

Print a line li to current Printer using current Print Attribute.

This Method _MUST_ be overloaded by inheritors.

Note:
You can embed a subset of XML tags in the line source. This is evalled here and replaced by whatever the real printer wants.

Todo:
Document the full XML tag subset allowed.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::printText const QString &  txt  )  [virtual, slot]
 

Print a text stream txt to current Printer using current Print Attribute.

This Method _MUST_ be overloaded by inheritors.

Note:
You can embed a subset of XML tags in the text source. This is evalled here and replaced by whatever the real printer wants.

Todo:
Document the full XML tag subset allowed.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::processCharacterMessage  )  [protected, virtual]
 

Processes the Keyboard Char event.

This is where we dispatch keyboard events between standard chars and Key Events.
The logic behind is explained by the implementation sample. You'll have to deal with all possible keyboard sequences here and adjust to what the hardware assumes.

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 ) ;
                }
        }
}

void QlabCashboxInterfaceDefinition::processChaseComplete  )  [protected, virtual]
 

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.

QString QlabCashboxInterfaceDefinition::processMsrData  )  [protected, virtual]
 

Processes Magnetic Strip Reader available data.

Warning:
It's up to implentation to send needed signals to application.
This si tightly bound to MSR device.
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.

void QlabCashboxInterfaceDefinition::processPrinterData  )  [protected, virtual]
 

Processes data returned by print device.

Warning:
It's up to implentation to send needed signals to application.
sample code:
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...
}

void QlabCashboxInterfaceDefinition::processPrinterError  )  [protected, virtual]
 

Processes print device errors.

Warning:
It's up to implentation to send needed signals to application.
You will have to add coding for recovering printer errors. Most errors can be corrected using some cryptic ESC/P sequences, others need printer reset...

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 ) ;
}

void QlabCashboxInterfaceDefinition::processPrinterStatus  )  [protected, virtual]
 

Printer Status Change Processor.

Warning:
It's up to implentation to send needed signals to application.
sample code:
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();
        }
}

void QlabCashboxInterfaceDefinition::processScannerData  )  [protected, virtual]
 

Processes scanner available data.

Warning:
It's up to implentation to send needed signals to application.
This si tightly bound to hardware scanner device.
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.

void QlabCashboxInterfaceDefinition::processTillClosed long *  till_open_tm  )  [protected, virtual]
 

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.

void QlabCashboxInterfaceDefinition::processTillOpened long *  till_open_tm  )  [protected, virtual]
 

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.

void QlabCashboxInterfaceDefinition::pushStatus  )  [virtual, slot]
 

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.

QString QlabCashboxInterfaceDefinition::readMicr long  size  )  [protected, virtual]
 

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.

QString QlabCashboxInterfaceDefinition::readScannerData  )  [protected, virtual, slot]
 

Forces reading scanner data.

This MUST be reimplemented as various scanners do not work the same way.

Reimplemented in QlabIbm4694.

void QlabCashboxInterfaceDefinition::releaseAll  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::scannerDataAvailable const QString &  scanData  )  [signal]
 

This signal is emited whenever scan data is available.

void QlabCashboxInterfaceDefinition::selectCharSet ICharsets  cs  )  [virtual, slot]
 

Selects the desired character cs set in the active code page.

Note:
A valid Code page must have been enabled via the QlabCashboxInterfaceDefinition::selectCodePage() method before applying char sets.

void QlabCashboxInterfaceDefinition::selectCodePage ICodePages  cp  )  [virtual, slot]
 

Selects the desired code page from ICodePages list.

You MUST oberload this method as not all printers honour all code pages.

bool QlabCashboxInterfaceDefinition::selectFullPage  )  [virtual, slot]
 

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.

bool QlabCashboxInterfaceDefinition::selectRollPaper  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::setActivePrinter QlabCashboxInterfaceDefinition::ActivePrintDevice  prn  )  [virtual, slot]
 

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() ;
        }
}

void QlabCashboxInterfaceDefinition::setBarcodeHeight int  height  )  [virtual, slot]
 

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.

Note:
Some implementations need a multiple of 9 dots, others insists on 1/12 inch and some others talk in 1/72 inch and not all barcodes allow all heights. Good luck !

void QlabCashboxInterfaceDefinition::setBarCodeType QlabCashboxInterfaceDefinition::BarcodeTypes  bct  )  [virtual, slot]
 

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.
You MUST overload this method according to some really hardware dependant commands.

Note:
Supported barcode types depend on hardware. Not all printers can print the BarCodeTypes full list.

void QlabCashboxInterfaceDefinition::setCurrentPrintInfo QlabCashboxInterfaceDefinition::PrintModeData  mdInfo  )  [virtual, slot]
 

Sets the current print attribute to mdInfo.

Note:
: You should overload this method to send the needed printer required sequence to activate the print style data. Mostly, the sequence will be an ESC/P2 sequence.
Warning:
Most ESC/P printers do not accept multiple definitions at once, except for some models Emphasis plus Underline. Most mixes lead to unpredictable results. You should carefully test all accepted sequences before delivering the printer driver to customers.
example implementation:
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 ) ;
}

void QlabCashboxInterfaceDefinition::setCurrentStatus PosActiveStatus  newStatus  )  [virtual, slot]
 

Sets the current hardware active status to newStatus.

Warning:
You should not have to overload this method. If you do, you _MUST_ emit the QlabCashboxInterfaceDefinition::activeStatusChanged() signal to let application logic know you now are in Supervisor mode.

void QlabCashboxInterfaceDefinition::setHTabs const QString &  tlist  )  [virtual, slot]
 

Sets the tabstops for print device.
Tabs are tlist.

Note:
tlist uses the standard 8;14;34 format.
This is a HIGHLY print device dependant method. You must reimplement it according to Hardware Handbook.

Todo:
Find a sample in a documentation... as our first QlabIbm4694 does not use this facility.

void QlabCashboxInterfaceDefinition::setSupervise bool  super  )  [virtual, slot]
 

Sets the current Supervise mode to super.

Warning:
You should not need overloading this method. If you do, you _MUST_ emit the QlabCashboxInterfaceDefinition::superviseStatusChanged() signal to let application logic know you now are in Supervisor mode.
Note:
This method is only meaningful when your interface emulates the physical Supervisor key existing on classic cashbox keyboards.
When developing software using standard PC hardware with keyboard and mouse, you can bind this to some accelerator, button click or whatever you want or even ignore it if no Supervise Mode is needed.

void QlabCashboxInterfaceDefinition::setup  )  [virtual]
 

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...

Note:
This logically makes intensive use of hardware specific methods. Please cf the Hardware Vendor Referenec Manuals to know what you'll have to do to fulfill the goal: opening and acquiring devices.
If hardware setup fails, you MUST post a QlabCashboxInterfaceDefinition::deviceError() signal with a SeverityFatal severity, as failing hardware set the box as unusable.
example: Snippet code usable with IBM 4694 cashbox family. This snippet uses some IBM 4694 specific types such as PosArg and PosNreadTimeout. You could have whatever the Hard Vendor Interface says instead of 4694 specific function calls.
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.

void QlabCashboxInterfaceDefinition::soundError  )  [virtual, slot]
 

Parametrized soundTone for Errors
See QlabCashboxInterfaceDefinition::soundTone() for details.

Reimplemented in QlabIbm4694.

void QlabCashboxInterfaceDefinition::soundReject  )  [virtual, slot]
 

Parametrized soundTone for DataRejection
See QlabCashboxInterfaceDefinition::soundTone() for details.

Reimplemented in QlabIbm4694.

void QlabCashboxInterfaceDefinition::soundTone int  frequency = 440,
int  duration = 10,
int  volume = 25
[virtual, slot]
 

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.

Warning:
Depending on hardware, you may have only very few choices (cf IBM 4694). Thus, you must only present the routine valid values.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::soundWarning  )  [virtual, slot]
 

Parametrized soundTone for Warnings
See QlabCashboxInterfaceDefinition::soundTone() for details.

Reimplemented in QlabIbm4694.

bool QlabCashboxInterfaceDefinition::supervise  )  const [virtual, slot]
 

Returns the current supervise mode.

When TRUE you are in Supervisor Mode.

void QlabCashboxInterfaceDefinition::superviseStatusChanged bool  newStatus  )  [signal]
 

This signal is emited whenever the Supervise status changes.

void QlabCashboxInterfaceDefinition::unlockDevice int  dev  )  [virtual, slot]
 

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.

void QlabCashboxInterfaceDefinition::waitForDrawerClosed  )  [virtual, slot]
 

Waits till the operator closes cash drawer.

Sample implementation code:

void QlabIbm4694::waitForDrawerClosed()
{
        while ( drawerStatus() != 1 ) {}
}

Reimplemented in QlabIbm4694.

void QlabCashboxInterfaceDefinition::writeToCRandSJstations const QString &  buffer  )  [virtual, slot]
 

Writes line to both Customer Receipt and Serialized Journal print devices.
You can compare this to QlabCashboxInterfaceDefinition::writeToCRstation() method. Even if Serialized Journal is somewhat antiquated, some printers which are not yet been trashed go on using this.

Both methods are needed due to some inconsistencies in most hardware drivers.
This Method _MUST_ be overloaded by inheritors.

Note:
You can embed a subset of XML tags in the text source. This is evalled here and replaced by whatever the real printer wants.

Todo:
Document the full XML tag subset allowed.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::writeToCRstation const QString &  line  )  [virtual, slot]
 

Writes line to Customer Receipt print device.
You can compare this to QlabCashboxInterfaceDefinition::writeToCRandSJstations() method.

Both methods are needed due to some inconsistencies in most hardware drivers.
This Method _MUST_ be overloaded by inheritors.

Note:
You can embed a subset of XML tags in the text source. This is evalled here and replaced by whatever the real printer wants.

Todo:
Document the full XML tag subset allowed.
Sample implementation code:
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.

void QlabCashboxInterfaceDefinition::writeToDIstation const QString &  buffer  )  [virtual, slot]
 

Writes line to Document Insert (Slip Paper) print devices.
.

This Method _MUST_ be overloaded by inheritors.

Note:
You can embed a subset of XML tags in the text source. This is evalled here and replaced by whatever the real printer wants.
Warning:
Read VERY carefully Hardware Vendor Reference Manual as you'll have to deal with a bunch of messages such as TOF, BOF, POR, DOCR and such niceties.

Todo:
Document the full XML tag subset allowed.
Sample implementation code:
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.


Member Data Documentation

PrintModeData QlabCashboxInterfaceDefinition::activeModeData [protected]
 

Stores the Current Print Attribute.

For internal use only.

PosActiveStatus QlabCashboxInterfaceDefinition::activeStatus [protected]
 

Current POS hardware status.

For internal use only.

int QlabCashboxInterfaceDefinition::barcodesize [protected]
 

Place holder for barcode height.

For internal use only.

QString QlabCashboxInterfaceDefinition::chasePrint [protected]
 

Stores the chase end sequence.

For internal use only.

int QlabCashboxInterfaceDefinition::columnsCR [protected]
 

Max Columns for Customer Receipt Printer.

For internal use only.

int QlabCashboxInterfaceDefinition::columnsFP [protected]
 

Max Columns for Document Insert Printer.

For internal use only.

ActivePrintDevice QlabCashboxInterfaceDefinition::currentPrinter [protected]
 

Stores the active printer device.

For internal use only.

QMap<uint, cashboxdevice> QlabCashboxInterfaceDefinition::deviceList [protected]
 

Map to the existing devices.

For internal use only.

bool QlabCashboxInterfaceDefinition::exitRequired [protected]
 

Event loop exit flag.

For internal use only.

QStringList QlabCashboxInterfaceDefinition::featureList [protected]
 

Place holder for feature list.

For internal use only.

QMap< QChar, QChar > QlabCashboxInterfaceDefinition::ICharMap [protected]
 

Character Map Storage. Used by QlabCashboxInterfaceDefinition::printLine() if charsets are managed.

For internal use only.

bool QlabCashboxInterfaceDefinition::inSupervise [protected]
 

Supervisor mode flag.

For internal use only.

QString QlabCashboxInterfaceDefinition::kbdBuffer [protected]
 

Keyboard buffer.

For internal use only.

QString QlabCashboxInterfaceDefinition::labSignature [protected]
 

Library signature.

For internal use only.

Never change this.

QString QlabCashboxInterfaceDefinition::micrBuffer [protected]
 

Check Reader buffer.

For internal use only.

bool QlabCashboxInterfaceDefinition::MicrInfoRequested [protected]
 

Do we need Check Reader Information.

For internal use only.

bool QlabCashboxInterfaceDefinition::MicrInstalled [protected]
 

Is Check Reader installed?

For internal use only.

QString QlabCashboxInterfaceDefinition::msrBuffer [protected]
 

Magnetic Strip Reader buffer.

For internal use only.

QMap<QString, QString> QlabCashboxInterfaceDefinition::printcodes [protected]
 

Mapping from XML to Sequences.

For internal use only.

QFile* QlabCashboxInterfaceDefinition::printCtrl [protected]
 

Print device File view.

For internal use only.

QString QlabCashboxInterfaceDefinition::printLineBuffer [protected]
 

Ready to print line buffer.

For internal use only.

QTextStream QlabCashboxInterfaceDefinition::printStream [protected]
 

Helper stream to physical printer.

For internal use only.

PrintModeData QlabCashboxInterfaceDefinition::prnInfo [protected]
 

Place holder for current Print Attribute.

For internal use only.

QString QlabCashboxInterfaceDefinition::scannerBuffer [protected]
 

Scanner buffer.

For internal use only.

QValueStack<PosActiveStatus> QlabCashboxInterfaceDefinition::statusStack [protected]
 

Status Stack.

For internal use only.

QString QlabCashboxInterfaceDefinition::tabslist [protected]
 

Tabulation list.

For internal use only.

bool QlabCashboxInterfaceDefinition::waitForErrorRecover [protected]
 

TRUE when waiting for hardware error recover method.

For internal use only.

bool QlabCashboxInterfaceDefinition::welcomeDisplayed [protected]
 

May be used to know if setup finished and welcome message has been displayed.

For internal use only.

 

L.A.B. Project © 2001-2004 LAB Project & DJ Anubis