00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00046 TEReaderBase();
00047
00048 public slots:
00049 virtual QString text( int iTrackNumber = 0 ) const;
00050
00051
00052 int next();
00053
00054 void setBuffering(int iBufEnabled);
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();
00073
00074 void setStopByte(int);
00075 int stopByte() const;
00076
00077 void setMaxDelay(int);
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();
00089 virtual bool stopDriver();
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
00109
00110 int pushText(const QString &);
00111
00112
00113
00114 virtual int openPort()=0;
00115 virtual int closePort()=0;
00116 virtual int readBarcode()=0;
00117
00118 virtual void emitSignal();
00119 virtual void reportError(const QString &);
00120
00121 void setErrorText(const QString & err);
00122
00123 virtual void handleData( const QString &data );
00124
00125 private:
00126 virtual int poll();
00127
00128 QString m_qsReadBuffer;
00129
00130 QValueList <QString> m_qBuffer;
00131 bool m_bClearToChangeBC;
00132 bool m_bUseStopByte;
00133 bool m_bDropStopByte;
00134 int m_iStopByte;
00135 int m_iMaxDelay;
00136 int m_iBuffering;
00137 int m_iMaxLength;
00138 int m_iDropBegCnt;
00139 int m_iDropEndCnt;
00140 QString m_qsErrorText;
00141 QString m_qsStartSequence, m_qsStopSequence;
00142 };
00143
00144 #endif