tereaderbase.h

00001 /****************************************************************************
00002 ** $Id: tereaderbase.h,v 1.10 2006/06/26 04:57:35 red75 Exp $
00003 **
00004 ** Trade equipment common portable library project
00005 **
00006 ** Copyright (C) 1999-2006 Leader InfoTech.  All rights reserved.
00007 ** Copyright (C) 1999-2006 Valery Grazdankin.  All rights reserved.
00008 **
00009 ** This file is part of the Library of the Ananas
00010 ** automation accounting system.
00011 **
00012 ** This file may be distributed and/or modified under the terms of the
00013 ** GNU General Public License version 2 as published by the Free Software
00014 ** Foundation and appearing in the file LICENSE.GPL included in the
00015 ** packaging of this file.
00016 **
00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00019 **
00020 ** See http://www.leaderit.ru/ or email sales@leaderit.ru
00021 **
00022 ** Contact org@leaderit.ru if any conditions of this licensing are
00023 ** not clear to you.
00024 **
00025 **********************************************************************/
00026 
00027 #ifndef TEREADERBASE_H
00028 #define TEREADERBASE_H
00029 
00030 #include <tebase.h>
00031 #include <qvaluelist.h>
00032 #include <qstring.h>
00033 #include "templexports.h"
00034 
00035 #define EVENT_READER_DATAARRIVED 1
00036 #define EVENT_READER_ERROR 100
00037 
00038 
00039 class LIB_EXPORT TEReaderBase : public TEBase
00040 {
00041     Q_OBJECT
00042     typedef TEBase superclass;
00043 
00044 public:
00045         // public interface
00046         TEReaderBase();
00047 
00048 public slots:
00049         virtual QString text( int iTrackNumber = 0 ) const;     // it returns first text data from queue.
00050                                                 // iTrackNumber = 0 - returns all tracks
00051                                                 // iTrackNumber = 1..max - returns iTrackNumber track text.
00052         int next();     // it advances to next barcode in queue, 0-there's no barcode available, 1-ok
00053                         // if there is barcode in buffer, then emit event EVENT_BARCODE.
00054         void setBuffering(int iBufEnabled); // params: iBufEnabled: 0 - buffering disabled, 1 - enabled
00055         int buffering() const;
00056 
00057         void setDropStopByte(bool bDSB) {m_bDropStopByte=bDSB;}
00058         bool dropStopByte() const {return m_bDropStopByte;}
00059 
00060         void setUseStopByte(bool bUSB) {m_bUseStopByte=bUSB;}
00061         bool useStopByte() const {return m_bUseStopByte;}
00062 
00063         void setMaxLength(int iML) {m_iMaxLength=iML;}
00064         int maxLength() const {return m_iMaxLength;}
00065 
00066         void setDropBegCnt(int iDBC) {m_iDropBegCnt=iDBC;}
00067         int dropBegCnt() const {return m_iDropBegCnt;}
00068 
00069         void setDropEndCnt(int iDEC) {m_iDropEndCnt=iDEC;}
00070         int dropEndCnt() const {return m_iDropEndCnt;}
00071 
00072         int clearBuffer(); // it clears queue of barcodes. Return value: 0 - there was no pending barcodes, 1 - there was pending barcodes
00073 
00074         void setStopByte(int); // sets 'stop byte' - byte value which marks the end of barcode
00075         int stopByte() const;
00076 
00077         void setMaxDelay(int); // sets maximum allowed wait time in ms for reading single barcode
00078         int maxDelay() const;
00079 
00080         void setStartSequence( const QString &seq );
00081         QString startSequence() const {return m_qsStartSequence;}
00082 
00083         void setStopSequence( const QString &seq );
00084         QString stopSequence() const {return m_qsStopSequence;}
00085 
00086         QString errorText() const;
00087 
00088         virtual bool startDriver(); // open port, then start polling it
00089         virtual bool stopDriver(); // stop polling, then closes port
00090 
00091         virtual bool setParameter(const QString &, const QString &); 
00092 
00093         int queueSize() const
00094         {
00095                 return m_qBuffer.size();
00096         }
00097 
00098   enum ReaderType
00099   {
00100     RT_BARCODE,
00101     RT_CARD
00102   };
00103 
00105   virtual int readerType() const=0; 
00106 
00107 protected:
00108 // Interface for descendant classes
00109 
00110         int pushText(const QString &);   // It pushes given barcode to the end of a queue,
00111                                         // emits event immediatly, or drops barcode.
00112                                         // Action depends on current driver settings.
00113 
00114         virtual int openPort()=0; // opens port
00115         virtual int closePort()=0; // closes port
00116         virtual int readBarcode()=0; // tries to read barcode. It is called by poll()
00117 
00118         virtual void emitSignal(); // emits EVENT_BARCODE_ARRIVED device event, can be replaced by miniport driver
00119         virtual void reportError(const QString &); // emits EVENT_ERROR device event
00120 
00121         void setErrorText(const QString & err);
00122 
00123         virtual void handleData( const QString &data );
00124 
00125 private:
00126         virtual int poll(); // this function gets called every nth millisecond
00127 
00128         QString m_qsReadBuffer;
00129 
00130         QValueList <QString> m_qBuffer;
00131         bool m_bClearToChangeBC; // it's clear to change value returned by barcode()
00132         bool m_bUseStopByte;
00133         bool m_bDropStopByte;
00134         int m_iStopByte; // stop byte value
00135         int m_iMaxDelay;
00136         int m_iBuffering; // 0-disable buffering, 1-enable buffering
00137         int m_iMaxLength; // maximal barcode length
00138         int m_iDropBegCnt; // number of starting characters to drop
00139         int m_iDropEndCnt; // number of ending characters to drop
00140         QString m_qsErrorText;
00141         QString m_qsStartSequence, m_qsStopSequence;
00142 };
00143 
00144 #endif

Документация по Общая библиотека для работы с торговым оборудованием.. Последние изменения: Sun Jul 2 23:38:24 2006. Создано системой  doxygen 1.4.7