tebase.h

00001 /****************************************************************************
00002 ** $Id: tebase.h,v 1.8 2006/07/02 12:06:47 leader Exp $
00003 **
00004 ** Trade equipment common portable library project
00005 **
00006 ** Copyright (C) 1999-2006 Leader InfoTech.  All rights reserved.
00007 **
00008 ** This file is part of the Library of the Ananas
00009 ** automation accounting system.
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 as published by the Free Software
00013 ** Foundation and appearing in the file LICENSE.GPL included in the
00014 ** packaging of this file.
00015 **
00016 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00017 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00018 **
00019 ** See http://www.leaderit.ru/ or email sales@leaderit.ru
00020 **
00021 ** Contact org@leaderit.ru if any conditions of this licensing are
00022 ** not clear to you.
00023 **
00024 **********************************************************************/
00025 /*
00026    Abstract trade equipment interface object
00027 */
00028 #ifndef TEBASE_H
00029 #define TEBASE_H
00030 
00031 #include <teglobal.h>
00032 #include <templexports.h>
00033 
00034 //#include <qobject.h>
00035 #include <qdict.h>
00036 #include <tserialport.h>
00037 #include <cmdparser.h>
00038 
00039 //---------------------------------------------------------------------------
00040 class LIB_EXPORT TEBase : public QObject, public TE
00041 {
00042     Q_OBJECT
00043     Q_PROPERTY( QString ActivationKey READ activationKey WRITE setActivationKey )
00044     Q_PROPERTY( int PortNumber READ portNumber WRITE setPortNumber )
00045     Q_PROPERTY( int PortBaudRate READ portBaudRate WRITE setPortBaudRate )
00046 
00047 public:
00048 
00049     TEBase( int pn );
00050     ~TEBase();
00051 
00052     // Interface functions
00053     virtual void setActivationKey( const QString &key );
00054     virtual QString activationKey() const;
00055 
00056     virtual int setConnectionType( int ct );
00057     int connectionType();
00058 
00059     virtual int setPortNumber( int pn );
00060     int portNumber() const;
00061     void setPollInterval( int pint );
00062     int pollInterval();
00063     virtual int open();
00064     virtual int close();
00065     virtual int isOpen();
00066     int timeout();
00067     void setTimeout( int timeout );
00068     bool isTimeout();
00069     int debugLevel();
00070     void setDebugLevel( int level );
00071 
00072     void startPoll(  int PollInterval = 500, bool defaultProc = true );
00073     void startPoll(  bool defaultProc = true );
00074     void stopPoll();
00075     void startIOTransaction();
00076     void stopIOTransaction();
00077 
00078     TSerialPort *port();
00079     virtual int putch( int b );
00080     virtual int getch();
00081     virtual Q_ULONG writeBlock( const char *data, Q_ULONG len );
00082     virtual Q_ULONG readBlock( char *data, Q_ULONG maxlen = 1 );
00083     virtual Q_ULONG readCount();
00084     virtual int poll();
00085     virtual QCString utf8ToDevice( const QString &text );
00086     virtual QString deviceToUtf8( const QCString &text );
00087     virtual int isActivationKeyValid();
00088     QString productSuffix() const
00089     {
00090       return m_sProductSuffix;
00091     }
00092     void setProductSuffix(const QString & sProductSuffix)
00093     {
00094       m_sProductSuffix=sProductSuffix;
00095     }
00096 
00097     void setPortBaudRate(int);
00098     int portBaudRate() const {return m_iPBaudRate;}
00099 
00100     void setPortFlowControl(FlowType);
00101     FlowType portFlowControl() const {return m_PFlow;}
00102 
00103     void setPortParity(ParityType);
00104     ParityType portParity() const {return m_PParity;}
00105 
00106     void setPortDataBits(DataBitsType);
00107     DataBitsType portDataBits() const {return m_PDataBits;}
00108 
00109     void setPortStopBits(StopBitsType);
00110     StopBitsType portStopBits() const {return m_PStopBits;}
00111 
00112     void clearPPP(); // clears persistent port parameters
00113 
00114     virtual QValueList<int> supportedBaudRates(); // Non const, just in case.
00115 
00116 public slots:
00117         virtual void processEvent( int Code );
00118         virtual QStringList execCommand( const QString &cmd );
00119         virtual QString errorText() const {return m_sError;}
00120 
00121 signals:
00122         void deviceEvent( int Code );
00123 
00124 protected:
00125         virtual void setErrorText(const QString & err){m_sError=err;}
00126         void timerEvent( QTimerEvent * );
00127         ExecEngine m_ee;
00128 private:
00129     int vPortNumber, vDebugLevel, vTimeout, vPollInterval;
00130     bool vTimeoutFlag;
00131     int m_eConnectionType;
00132     TSerialPort *Port;
00133     QString vActivationKey;
00134     QString m_sProductSuffix; // product suffix such as 'drv','1cdrv','srv', etc.
00135 
00136     int m_iPBaudRate;
00137     FlowType m_PFlow;
00138     ParityType m_PParity;
00139     DataBitsType m_PDataBits;
00140     StopBitsType m_PStopBits;
00141     QString m_sError; // error description
00142 //    static QDict <TSerialPort> PortsList;
00143 };
00144 //---------------------------------------------------------------------------
00145 
00146 #endif

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