Trade equipment common library. 1.0.0
teconnect.h
1/****************************************************************************
2** $Id: teconnect.h,v 1.1 2006/07/12 09:12:32 leader Exp $
3**
4** Trade equipment common portable library project
5**
6** Copyright (C) 1999-2006 Leader InfoTech. All rights reserved.
7**
8** This file is part of the Library of the Ananas
9** automation accounting system.
10**
11** This file may be distributed and/or modified under the terms of the
12** GNU General Public License version 2 as published by the Free Software
13** Foundation and appearing in the file LICENSE.GPL included in the
14** packaging of this file.
15**
16** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18**
19** See http://www.leaderit.ru/ or email sales@leaderit.ru
20**
21** Contact org@leaderit.ru if any conditions of this licensing are
22** not clear to you.
23**
24**********************************************************************/
25/*
26 Abstract trade equipment data provider object
27*/
28#ifndef TECONNECT_H
29#define TECONNECT_H
30
31#include <teglobal.h>
32#include <templexports.h>
33
34//#include <qobject.h>
35#include <qdict.h>
36#include <tserialport.h>
37#include <cmdparser.h>
38
39//---------------------------------------------------------------------------
40class LIB_EXPORT TEConnect : public QObject, public TE
41{
42 Q_OBJECT
43 Q_PROPERTY( QString ActivationKey READ activationKey WRITE setActivationKey )
44 Q_PROPERTY( int PortNumber READ portNumber WRITE setPortNumber )
45 Q_PROPERTY( int PortBaudRate READ portBaudRate WRITE setPortBaudRate )
46
47public:
48
49 TEConnect( int pn );
50 ~TEConnect();
51
52 // Interface functions
53 virtual void setActivationKey( const QString &key );
54 virtual QString activationKey() const;
55
56 int connectionType();
57
58 virtual int setPortNumber( int pn );
59 int portNumber() const;
60 void setPollInterval( int pint );
61 int pollInterval();
62
63 virtual int isOpen();
64 int timeout();
65 bool isTimeout();
66 int debugLevel();
67 void setDebugLevel( int level );
68
69 virtual QCString utf8ToDevice( const QString &text );
70 virtual QString deviceToUtf8( const QCString &text );
71 virtual int isActivationKeyValid();
72 QString productSuffix() const
73 {
74 return m_sProductSuffix;
75 }
76 void setProductSuffix(const QString & sProductSuffix)
77 {
78 m_sProductSuffix=sProductSuffix;
79 }
80
81 void setPortBaudRate(int);
82 int portBaudRate() const {return m_iPBaudRate;}
83
84 void setPortFlowControl(FlowType);
85 FlowType portFlowControl() const {return m_PFlow;}
86
87 void setPortParity(ParityType);
88 ParityType portParity() const {return m_PParity;}
89
90 void setPortDataBits(DataBitsType);
91 DataBitsType portDataBits() const {return m_PDataBits;}
92
93 void setPortStopBits(StopBitsType);
94 StopBitsType portStopBits() const {return m_PStopBits;}
95
96
97 virtual QValueList<int> supportedBaudRates(); // Non const, just in case.
98
99 virtual int setConnectionType( int ct );
100
101 virtual int open();
102 virtual int close();
103public slots:
104 virtual void processEvent( int Code );
105 virtual QStringList execCommand( const QString &cmd );
106 virtual QString errorText() const {return m_sError;}
107
108signals:
109 void deviceEvent( int Code );
110
111protected:
112// Polling control functions
113 void startPoll( int PollInterval = 500, bool defaultProc = true );
114 void startPoll( bool defaultProc = true );
115 void stopPoll();
116 void startIOTransaction();
117 void stopIOTransaction();
118 virtual int poll();
119
120// serial port control functions
121 TSerialPort *port();
122 virtual int putch( int b );
123 virtual int getch();
124 virtual Q_ULONG writeBlock( const char *data, Q_ULONG len );
125 virtual Q_ULONG readBlock( char *data, Q_ULONG maxlen = 1 );
126 virtual Q_ULONG readCount();
127 void setTimeout( int timeout );
128 void clearPPP(); // clears persistent port parameters
129
130 virtual void setErrorText(const QString & err){m_sError=err;}
131 void timerEvent( QTimerEvent * );
132 ExecEngine m_ee;
133private:
134 int vPortNumber, vDebugLevel, vTimeout, vPollInterval;
135 bool vTimeoutFlag;
136 int m_eConnectionType;
137 TSerialPort *Port;
138 QString vActivationKey;
139 QString m_sProductSuffix; // product suffix such as 'drv','1cdrv','srv', etc.
140
141 int m_iPBaudRate;
142 FlowType m_PFlow;
143 ParityType m_PParity;
144 DataBitsType m_PDataBits;
145 StopBitsType m_PStopBits;
146 QString m_sError; // error description
147// static QDict <TSerialPort> PortsList;
148};
149//---------------------------------------------------------------------------
150
151#endif
Command interpreter for TEBase classes.
Definition cmdparser.h:46
virtual Q_ULONG readBlock(char *data, Q_ULONG maxlen=1)
Definition teconnect.cpp:313
virtual Q_ULONG writeBlock(const char *data, Q_ULONG len)
Definition teconnect.cpp:296
virtual int putch(int b)
Definition teconnect.cpp:250
TSerialPort * port()
Definition teconnect.cpp:406
void timerEvent(QTimerEvent *)
Definition teconnect.cpp:396
void startPoll(int PollInterval=500, bool defaultProc=true)
Definition teconnect.cpp:345
TEConnect(int pn)
Definition teconnect.cpp:55
virtual QStringList execCommand(const QString &cmd)
Definition teconnect.cpp:420
virtual int isOpen()
Definition teconnect.cpp:190
virtual int getch()
Definition teconnect.cpp:267
void stopPoll()
Definition teconnect.cpp:369
The TE class is a namespace for miscellaneous identifiers that need to be global-like in trade equipm...
Definition teglobal.h:129
The TSerialPort class for work with serial ports from TEBase classes.
Definition tserialport.h:57