Trade equipment common library.  1.0.0
teglobal.h
1 /****************************************************************************
2 ** $Id: teglobal.h,v 1.15 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 #ifndef TEGLOBAL_H
27 #define TEGLOBAL_H
28 #include <qglobal.h>
29 #include <qgplugin.h>
30 #include <qstringlist.h>
31 #include <math.h>
32 
33 #define round(x) floor(x+0.55555555)
34 
35 #define DEBUG
36 //#define DEMOVERSION
37 
38 #ifdef Q_OS_WIN32
39 # include <windows.h>
40 # define _TTY_WIN_
41 #endif
42 #ifdef Q_OS_UNIX
43 # include <unistd.h>
44 # define Sleep(a) usleep((a)*1000)
45 # ifndef _TTY_POSIX_
46 # define _TTY_POSIX_
47 # endif
48 #endif
49 
50 #if defined(Q_OS_WIN32) && !defined(LIB_NO_DLL)
51 # define LIB_DLLIMPORT __declspec(dllimport)
52 # define LIB_DLLEXPORT __declspec(dllexport)
53 #else
54 # define LIB_DLLIMPORT
55 # define LIB_DLLEXPORT
56 #endif
57 
58 #if defined (Q_CC_MSVC)
59 #define TEMPLATE_EXTERN extern
60 #else
61 #define TEMPLATE_EXTERN
62 #endif
63 
64 #ifdef TRADEEQUIP_EXPORT
65 # define LIB_EXPORT LIB_DLLEXPORT
66 #else
67 # define LIB_EXPORT LIB_DLLIMPORT
68 #endif
69 
70 #ifdef TRADEEQUIP_EXPORT
71 # define LIB_TEMPLATE_EXTERN
72 #else
73 # define LIB_TEMPLATE_EXTERN TEMPLATE_EXTERN
74 #endif
75 
76 #if defined(Q_CC_MSVC)
77 # define vsnprintf _vsnprintf
78 #endif
79 
80 #undef min
81 #undef max
82 /*
83 template <class T>
84 T & min(T & a, T & b)
85 {
86  if (a<b) return a; else return b;
87 }
88 
89 template <class T>
90 const T & min(const T & a, const T & b)
91 {
92  if (a<b) return a; else return b;
93 }
94 */
95 template <class U, class V>
96 U min(const U & a, const V & b)
97 {
98  if (a<=(const U&)b) return a; else return (const U&)b;
99 }
100 
101 template <class U, class V>
102 U max(const U & a, const V & b)
103 {
104  if (a>=(const U&)b) return a; else return (const U&)b;
105 }
106 //#define min(a,b) (((a)<(b))?(a):(b))
107 //#endif
108 
109 // -- error codes for new check-related functions
110 #define CRERROR_OK 0
111 #define CRERROR_NOTSUPPORTED 1
112 #define CRERROR_DEVICEERROR 2
113 #define CRERROR_INVALIDCALL 3
114 #define CRERROR_FATALDEVICEERROR 4
115 #define CRERROR_COMMERROR 5
116 
128 class TE
129 {
130 public:
131 
135  {
136  CM_Exclusive=0,
137  CM_NonExclusive=1
138  };
139 
144  ECT_NOCONNECTION =0x0,
145  ECT_SERIAL =0x1,
146  ECT_KEYBOARD =0x2,
147  ECT_TCP =0x3,
148  ECT_TESERVER =0x4
149  };
154  CRO_SELL = 0x0,
155  CRO_BUY = 0x1,
156  CRO_SELLRET = 0x2,
157  CRO_BUYRET = 0x3,
158  CRO_SELLSTORNO = 0x4,
159  CRO_BUYSTORNO = 0x5,
160  CRO_CASHIN = 0x6,
161  CRO_CASHOUT = 0x7,
162  CRO_DISCOUNT = 0x8,
163  CRO_DISCOUNTPERCENT = 0x9,
164  CRO_OPMASK = 0xF
165  //CRO_SIMPLEMODE=0x8,
166  //CRO_MODEMASK=0x8,
167  //CRO_CASHLESS=0x10,
168  //CRO_PAYMENTMASK=0x10
169  };
170 };
171 
172 class TEBase;
173 
174 Q_EXTERN_C LIB_EXPORT QStringList te_drivers( const QString &baseClass = QString::null );
175 Q_EXTERN_C LIB_EXPORT bool te_driverExists( const QString &className, const QString &baseClass = QString::null );
176 Q_EXTERN_C LIB_EXPORT TEBase *te_createDriverObject( const QString &className );
177 
178 LIB_EXPORT QString te_MD5( const QByteArray &data );
179 LIB_EXPORT QString te_MD5( const QString &data );
180 LIB_EXPORT int te_MD5_selftest();
181 
182 // Encoding for msgfmt should be UTF-8
183 extern void cr_message(QString logFile, int msgtype, const char *msgfmt,...);
184 // Encoding for msgfmt should be UTF-8
185 extern void cfg_message(int msgtype, const char *msgfmt,...);
186 
187 #endif
The TE class is a namespace for miscellaneous identifiers that need to be global-like in trade equipm...
Definition: teglobal.h:128
EquipmentConnectionType
Definition: teglobal.h:143
CaptureMode
Define connection capture mode for setCaptureMode()
Definition: teglobal.h:134
CashRegisterOperations
Definition: teglobal.h:153
The TEBase is base class for all trade equipment classes.
Definition: tebase.h:148