Общая библиотека для работы с торговым оборудованием.  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 {
43 public:
45 
47  {
53  PT_Bool
54  };
55 
57 
59  {
64  PUC_RadioButtons
65  };
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;
143  virtual ~TEConnectionSettingsInterface(){};
144 
145 };
146 
147 //---------------------------------------------------------------------------
148 class 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 
155 public:
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 
225 public 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 
235 signals:
236  void deviceEvent( int Code );
237 
238 protected:
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 
263 private:
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
PreferredUIControl
Перечисление (предпочтительный тип представления значения)
Definition: tebase.h:58
Definition: tebase.h:41
Definition: teglobal.h:128
ParameterDomain
Перечисление (типы допустимых значений параметра)
Definition: tebase.h:46
Command interpreter for TEBase classes.
Definition: cmdparser.h:45
The TEBase is base class for all trade equipment classes.
Definition: tebase.h:148
The TSerialPort class for work with serial ports from TEBase classes.
Definition: tserialport.h:56