Общая библиотека для работы с торговым оборудованием. 1.0.0
tebase.h
1/****************************************************************************
2** $Id: tebase.h,v 1.18 2009/01/31 14:14:15 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 interface object
27*/
28#ifndef TEBASE_H
29#define TEBASE_H
30
31#include <teglobal.h>
32#include <templexports.h>
33#include <qdict.h>
34#include <qintdict.h>
35#include <tserialport.h>
36#include <cmdparser.h>
37#include <qstring.h>
38
39
42{
43public:
45
55
57
66
68
69 virtual int numberOfParameters()=0;
70
72
75 virtual int parameterDomain(int num)=0;
76
78
81 virtual int preferredUIControl(int num)=0;
82
84
87 virtual QString parameterDescription(int num)=0;
88
90
93 virtual int parameterItemsCount(int num)=0;
94
96
100 virtual QString parameterItemDescription(int num, int item)=0;
101
103
109 virtual int getItemRange(int num, int item, int & low, int & hi)=0;
110
112
117 virtual int getItemValue(int num, int item, int & val)=0;
118
120
124 virtual int setParameter(int num, int val)=0;
125 virtual int setParameter(int num, const QString & val)=0;
126 virtual int setParameter(int num, double val)=0;
127 virtual int setParameter(int num, bool val)=0;
128
130
134 virtual int getParameter(int num, int & val)=0;
135 virtual int getParameter(int num, QString & val)=0;
136 virtual int getParameter(int num, double & val)=0;
137 virtual int getParameter(int num, bool &val)=0;
138
140
142 virtual QString errorText()=0;
144
145};
146
147//---------------------------------------------------------------------------
148class LIB_EXPORT TEBase : public QObject, public TE
149{
150 Q_OBJECT
151 Q_PROPERTY( QString ActivationKey READ activationKey WRITE setActivationKey )
152 Q_PROPERTY( int PortNumber READ portNumber WRITE setPortNumber )
153 Q_PROPERTY( int PortBaudRate READ portBaudRate WRITE setPortBaudRate )
154
155public:
156
157 TEBase( int pn );
158 ~TEBase();
159
160 // Interface functions
161 virtual void setActivationKey( const QString &key );
162 virtual QString activationKey() const;
163
164 int connectionType();
165 virtual int setConnectionType( int ct );
166
167 virtual int setPortNumber( int pn );
168 int portNumber() const;
169
170 void setPollInterval( int pint );
171 int pollInterval();
172
173 virtual int isOpen();
174
175 int timeout();
176 void setTimeout( int timeout );
177 bool isTimeout();
178
179 int debugLevel();
180 void setDebugLevel( int level );
181
182 virtual QCString utf8ToDevice( const QString &text );
183 virtual QString deviceToUtf8( const QCString &text );
184
185 virtual int isActivationKeyValid();
186
187 int errorCode() const { return iErrorCode; }
188 void setErrorCode( const int &code ) { iErrorCode = code; }
189
190 virtual QString errorText() const;// {return m_sError;}
191 virtual void setErrorText(const QString & err){m_sError=err;}
192
193 QString productSuffix() const
194 {
195 return m_sProductSuffix;
196 }
197 void setProductSuffix(const QString & sProductSuffix)
198 {
199 m_sProductSuffix=sProductSuffix;
200 }
201
202 void setPortBaudRate(int);
203 int portBaudRate() const {return m_iPBaudRate;}
204
205 void setPortFlowControl(FlowType);
206 FlowType portFlowControl() const {return m_PFlow;}
207
208 void setPortParity(ParityType);
209 ParityType portParity() const {return m_PParity;}
210
211 void setPortDataBits(DataBitsType);
212 DataBitsType portDataBits() const {return m_PDataBits;}
213
214 void setPortStopBits(StopBitsType);
215 StopBitsType portStopBits() const {return m_PStopBits;}
216
217
218 virtual QValueList<int> supportedBaudRates(); // Non const, just in case.
219 virtual QValueList<int> supportedConnectionTypes(); // Non const, just in case.
220
221
222 virtual int open();
223 virtual int close();
224
225public slots:
226 virtual int startDriver();
227 virtual int stopDriver();
228 virtual int setCaptureMode(int iMode); // port capture mode (one of CaptureMode enum), returns error code
229 virtual int captureMode() {return m_iCaptureMode;};
230 virtual void processEvent( int Code );
231 virtual QStringList execCommand( const QString &cmd );
232 virtual bool isDriverRunning() {return m_bDriverStarted;}
233
234
235signals:
236 void deviceEvent( int Code );
237
238protected:
239
240 void abstract();
241// Polling control functions
242 void startPoll( int PollInterval = 500, bool defaultProc = true );
243 void startPoll( bool defaultProc = true );
244 void stopPoll();
245 void startIOTransaction();
246 void stopIOTransaction();
247 virtual int poll();
248
249// serial port control functions
250 TSerialPort *port();
251 virtual int putch( int b );
252 virtual int getch();
253 virtual Q_ULONG writeBlock( const char *data, Q_ULONG len );
254 virtual Q_ULONG readBlock( char *data, Q_ULONG maxlen = 1 );
255 virtual Q_ULONG readCount();
256 void clearPPP(); // clears persistent port parameters
257
258 void timerEvent( QTimerEvent * );
259 ExecEngine m_ee;
260 int m_iCaptureMode; //
261 bool m_bDriverStarted;
262
263private:
264 int vPortNumber, vDebugLevel, vTimeout, vPollInterval;
265 bool vTimeoutFlag;
266 int m_eConnectionType;
267 TSerialPort *Port;
268 QString vActivationKey;
269 QString m_sProductSuffix; // product suffix such as 'drv','1cdrv','srv', etc.
270
271 int m_iPBaudRate;
272 FlowType m_PFlow;
273 ParityType m_PParity;
274 DataBitsType m_PDataBits;
275 StopBitsType m_PStopBits;
276
277 int iErrorCode; // error code. 0 - if no error.
278 QString m_sError; // error description
279};
280//---------------------------------------------------------------------------
281
282#endif
Command interpreter for TEBase classes.
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ cmdparser.h:46
TEBase(int pn)
The TEBase is base class for all trade equipment classes.
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:90
virtual int putch(int b)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:320
void abstract()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:664
TSerialPort * port()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:476
virtual QStringList execCommand(const QString &cmd)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:490
virtual Q_ULONG writeBlock(const char *data, Q_ULONG len)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:366
void stopPoll()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:439
virtual int stopDriver()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:641
virtual QValueList< int > supportedBaudRates()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:596
void timerEvent(QTimerEvent *)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:466
virtual int startDriver()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:627
virtual int setCaptureMode(int iMode)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:651
virtual int getch()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:337
void startPoll(int PollInterval=500, bool defaultProc=true)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:415
virtual Q_ULONG readBlock(char *data, Q_ULONG maxlen=1)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:383
virtual int setConnectionType(int ct)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:171
virtual int isOpen()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:260
virtual QValueList< int > supportedConnectionTypes()
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:608
virtual QString errorText() const
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.cpp:144
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:42
ParameterDomain
Перечисление (типы допустимых значений параметра)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:47
@ PT_Invalid
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:48
@ PT_Double
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:52
@ PT_Bool
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:53
@ PT_IntRangeList
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:49
@ PT_IntList
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:50
@ PT_String
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:51
virtual int preferredUIControl(int num)=0
Предпочитаемый тип представления значения
virtual int numberOfParameters()=0
Количество настраиваемых параметров
virtual int parameterDomain(int num)=0
Тип допустимых значений
virtual QString parameterItemDescription(int num, int item)=0
Описание элемента item из списка допустимых значений/диапазонов параметра num
virtual int getParameter(int num, int &val)=0
Получить параметр номер num
virtual QString errorText()=0
Описание последней ошибки
virtual int setParameter(int num, int val)=0
Установить параметр номер num
virtual QString parameterDescription(int num)=0
Описание назначения параметра
virtual int getItemRange(int num, int item, int &low, int &hi)=0
Получить допустимый интервал номер item
virtual int parameterItemsCount(int num)=0
Количество элементов в списке допустимых значений/диапазонов
virtual int getItemValue(int num, int item, int &val)=0
Получить допустимое значение номер item
PreferredUIControl
Перечисление (предпочтительный тип представления значения)
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:59
@ PUC_CheckBox
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:63
@ PUC_DropDown
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:62
@ PUC_RadioButtons
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:64
@ PUC_LineEdit
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:60
@ PUC_Slider
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tebase.h:61
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ teglobal.h:129
The TSerialPort class for work with serial ports from TEBase classes.
п·п©я─п╣п╢п╣п╩п╣п╫п╦я▐ tserialport.h:57