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
00028 #ifndef TEBASE_H
00029 #define TEBASE_H
00030
00031 #include <teglobal.h>
00032 #include <templexports.h>
00033
00034
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
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();
00113
00114 virtual QValueList<int> supportedBaudRates();
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;
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;
00142
00143 };
00144
00145
00146 #endif