FedmIscMyAxxessReader.h
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |                  FedmIscMyAxxessReader.h              |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009-2012   FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Markus Hultsch
00017 Begin                   :       02.03.2009
00018 
00019 Version                 :       04.03.01 / 27.08.2012 / M. Hultsch
00020                                                 - declaration of event callbacks modified for multiple records per event
00021                                                 - support for alarm event and request event
00022 
00023                                                 04.00.02 / 29.08.2011 / B. Tschunko, M. Hultsch
00024 
00025 Operation Systems       :       independent
00026 
00027 Function                        :       class for OBID i-scan and OBID classic-pro reader family with myAxxess functionality
00028 
00029 OBID and OBID i-scan are registered Trademarks of FEIG ELECTRONIC GmbH
00030 Linux is a registered trademark of Linus Torvalds.
00031 Windows is a registered trademark of Microsoft Corporation in the United States and other countries.
00032 */
00033 
00034 #if !defined(_FEDM_ISC_MYAXXESS_READER_H_INCLUDED_)
00035 #define _FEDM_ISC_MYAXXESS_READER_H_INCLUDED_
00036 
00037 
00038 
00039 #include <vector>
00040 #include <queue>
00041 #include "FedmIscCore.h"
00042 #include "FedmIscMyAxxessTables.h"
00043 
00044 
00045 // STL - Standard Template Library
00046 using namespace std;
00047 
00048 
00049 #ifdef _MSC_VER
00050         #ifdef _FEDM_MYAXXESS_DLL
00051                 #define _FEDM_MYAXXESS_EXT_CLASS __declspec(dllexport)
00052         #else
00053                 #if !defined(_FEDM_DLL)
00054                         #define _FEDM_MYAXXESS_EXT_CLASS
00055                 #else
00056                         #define _FEDM_MYAXXESS_EXT_CLASS __declspec(dllimport)
00057                 #endif
00058         #endif
00059 
00060 //      #define _FEDM_ISC_CORE_EXT_CLASS //__declspec(dllimport)
00061 //      #define _FEDM_ISC_CORE_EXT_FUNCT
00062 #else
00063         #define _FEDM_MYAXXESS_EXT_CLASS
00064 #endif
00065 
00066 
00067 //#####################################################################################
00068 // constants
00069 //#####################################################################################
00070 // table version
00071 #define FEDM_MYAXXESS_TABLE_VERSION                     0x00
00072 
00073 // command types
00074 #define FEDM_MYAXXESS_UPDATE_START                      0x01
00075 #define FEDM_MYAXXESS_UPDATE_END                        0x02
00076 #define FEDM_MYAXXESS_WRITE_TABLE                       0x03
00077 //#define FEDM_MYAXXESS_RESET_TABLE                     0x04
00078 #define FEDM_MYAXXESS_READ_TABLE                        0x05
00079 #define FEDM_MYAXXESS_NOTIFY                            0x06
00080 
00081 // table types
00082 #define FEDM_MYAXXESS_CRC_LIST                          0x00
00083 #define FEDM_MYAXXESS_METADATA                          0x01
00084 #define FEDM_MYAXXESS_TIMEZONE_TABLE            0x02
00085 #define FEDM_MYAXXESS_HOLIDAY_TABLE                     0x03
00086 #define FEDM_MYAXXESS_ACCESS_TABLE                      0x04
00087 #define FEDM_MYAXXESS_EVENT_TABLE                       0x05
00088 
00089 // event types
00090 #define FEDM_MYAXXESS_EVENT_ACCESS                      0x01
00091 #define FEDM_MYAXXESS_EVENT_IO                          0x02
00092 #define FEDM_MYAXXESS_EVENT_ALARM                       0x03
00093 #define FEDM_MYAXXESS_EVENT_REQUEST                     0x04
00094 
00095 // idd format types
00096 #define FEDM_MYAXXESS_IDD_FORMAT_ASCII          0x01
00097 #define FEDM_MYAXXESS_IDD_FORMAT_NUM            0x02
00098 #define FEDM_MYAXXESS_IDD_FORMAT_HEX            0x03
00099 
00100 // date type types
00101 #define FEDM_MYAXXESS_DATE_FORMAT_ISO8601       0x01    // separated by -
00102 #define FEDM_MYAXXESS_DATE_FORMAT_GER           0x02    // separated by .
00103 #define FEDM_MYAXXESS_DATE_FORMAT_US            0x03    // separated by /
00104 
00105 // file types
00106 #define FEDM_MYAXXESS_FILETYPE_XML                      1
00107 #define FEDM_MYAXXESS_FILETYPE_CSV                      2
00108 
00109 #define FEDM_MYAXXESS_MAX_BLOCKSIZE                     32000
00110 #define FEDM_MYAXXESS_SERIAL_BLOCKSIZE           1024
00111 
00112 
00113 //#####################################################################################
00114 // types
00115 //#####################################################################################
00116 
00117 // callback functions for C++
00118 typedef int             (FEDM_CALL*
00119                                  LPFN_FEDM_MYAXXESS_EVENT_CB)(                          void*,                          // pAny
00120                                                                                                                         int,                            // error value
00121                                                                                                                         vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>, // event record
00122                                                                                                                         unsigned char&,         // reference to action
00123                                                                                                                         char*,                          // IP-Address
00124                                                                                                                         int );                          // IP-Port
00125 
00126 typedef void    (FEDM_CALL*
00127                  LPFN_FEDM_MYAXXESS_KEEPALIVE_CB)(                      void*,                          // pAny
00128                                                                                                                         int,                            // error value
00129                                                                                                                         unsigned int,           // error flags from my axxess Reader
00130                                                                                                                         unsigned int,           // event table size
00131                                                                                                                         unsigned int,           // event table length
00132                                                                                                                         char*,                          // IP-Address
00133                                                                                                                         int );                          // IP-Port
00134 
00135 // callback functions for .NET-Wrapper
00136 typedef int             (CALLBACK* 
00137                                  LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB)(           int,                            // error value
00138                                                                                                                         vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>, // event record
00139                                                                                                                         unsigned char&,         // reference to action
00140                                                                                                                         char*,                          // IP-Address
00141                                                                                                                         int );                          // IP-Port
00142 
00143 typedef void    (CALLBACK* 
00144                                  LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB)(       int,                            // error value
00145                                                                                                                         unsigned int,           // error flags from my axxess Reader
00146                                                                                                                         unsigned int,           // event table size
00147                                                                                                                         unsigned int,           // event table length
00148                                                                                                                         char*,                          // IP-Address
00149                                                                                                                         int );                          // IP-Port
00150 
00151 
00152 class FedmIscMyAxxess_XmlParser;
00153 class FedmIscMyAxxess_CsvParser;
00154 
00155 
00156 //#####################################################################################
00157 // class FedmIscMyAxxessReader
00158 //#####################################################################################
00159 
00160 class FedmIscMyAxxessReader
00161 {
00162 
00163 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00164         friend class FedmIscMyAxxess_XmlParser;
00165 #endif
00166         friend class FedmIscMyAxxess_CsvParser;
00167 
00168 public:
00169         // main constructor
00170         _FEDM_MYAXXESS_EXT_CLASS FedmIscMyAxxessReader( unsigned char ucIDDLength, 
00171                                                         unsigned char ucIDDFormat = FEDM_MYAXXESS_IDD_FORMAT_NUM);
00172         
00173         // constructor for wrapper projects (.NET, JNI)
00174         _FEDM_MYAXXESS_EXT_CLASS FedmIscMyAxxessReader( FEDM_ISCReaderModule* pReaderModule, 
00175                                                         unsigned char ucIDDLength, 
00176                                                         unsigned char ucIDDFormat = FEDM_MYAXXESS_IDD_FORMAT_NUM);
00177 
00178         _FEDM_MYAXXESS_EXT_CLASS ~FedmIscMyAxxessReader();
00179 
00180         _FEDM_MYAXXESS_EXT_CLASS FEDM_ISCReaderModule* GetReaderObject()        { return m_pReaderModule; }
00181 
00182         _FEDM_MYAXXESS_EXT_CLASS unsigned char GetIDDLength(void)                       { return m_Metadata.ucIDDLength; }
00183         _FEDM_MYAXXESS_EXT_CLASS unsigned char GetIDDFormat(void)                       { return m_Metadata.ucIDDFormat; }
00184 
00185         _FEDM_MYAXXESS_EXT_CLASS int SetDateFormat (unsigned char ucDateType);
00186         _FEDM_MYAXXESS_EXT_CLASS unsigned char GetDateFormat(void)                      { return m_ucDateFormat; }
00187 
00188         _FEDM_MYAXXESS_EXT_CLASS int   GetLastError();
00189         _FEDM_MYAXXESS_EXT_CLASS char* GetErrorText(int iErrorCode);
00190 
00191         // TODO_M - GetTableInfo: definieren, was Methode zurückgeben könnte
00192         //const char* GetTableInfo();
00193 
00194         // public API for table management
00195         _FEDM_MYAXXESS_EXT_CLASS int ClearTable(unsigned int uiTableID);
00196         
00197         _FEDM_MYAXXESS_EXT_CLASS int SerializeTableIn(  char* szFilename,
00198                                                         unsigned int uiFileType=FEDM_MYAXXESS_FILETYPE_XML );
00199         
00200         _FEDM_MYAXXESS_EXT_CLASS int SerializeTableOut( unsigned int uiTableID,
00201                                                         char* szFilename,
00202                                                         unsigned int uiFileType=FEDM_MYAXXESS_FILETYPE_XML );
00203 
00204         // for native C/C++ interface
00205         _FEDM_MYAXXESS_EXT_CLASS int AddTableItem(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem);
00206         _FEDM_MYAXXESS_EXT_CLASS int AddTableItem(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem);
00207         _FEDM_MYAXXESS_EXT_CLASS int AddTableItem(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem);
00208         // for 'naturally speaking' interface; ready for VB, Delphi, and other stupid languages
00209         _FEDM_MYAXXESS_EXT_CLASS int AddTableItem(unsigned int uiTableID, char* sItem);
00210 
00211         // for native C/C++ interface and
00212         _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem);
00213         _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem);
00214         _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem);
00215         _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pItem);
00216         // for 'naturally speaking' interface; ready for VB, Delphi, and other stupid languages
00217         _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem);
00218 
00219         // for native C/C++ interface and for 'naturally speaking' interface; ready for VB, Delphi, and other stupid languages
00220         _FEDM_MYAXXESS_EXT_CLASS int RemoveTableItem(unsigned int uiTableID, unsigned int uiIndex);
00221 
00222         // for native C/C++ interface and
00223         _FEDM_MYAXXESS_EXT_CLASS int ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem);
00224         _FEDM_MYAXXESS_EXT_CLASS int ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem);
00225         _FEDM_MYAXXESS_EXT_CLASS int ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem);
00226         // for 'naturally speaking' interface; ready for VB, Delphi, and other stupid languages
00227         _FEDM_MYAXXESS_EXT_CLASS int ModifyTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem);
00228 
00229         // public API for tabel update
00230         _FEDM_MYAXXESS_EXT_CLASS int WriteTables();
00231         _FEDM_MYAXXESS_EXT_CLASS int ReadTable(unsigned int uiTableID);
00232 
00233         _FEDM_MYAXXESS_EXT_CLASS int StartEventHandler( unsigned int uiPortNr,
00234                                                                                                         void* pAny,
00235                                                                                                         LPFN_FEDM_MYAXXESS_EVENT_CB cbEvent,
00236                                                                                                         LPFN_FEDM_MYAXXESS_KEEPALIVE_CB cbKeepAlive,
00237                                                                                                         int iAuthentType=-1,
00238                                                                                                         char* sAuthentKey=NULL );
00239 
00240         // only for .NET wrapper library OBIDISC4NETnative
00241         _FEDM_MYAXXESS_EXT_CLASS int StartEventHandler4DotNet(  unsigned int uiPortNr,
00242                                                                                                                         void* pAny,
00243                                                                                                                         LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB cbEvent,
00244                                                                                                                         LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB cbKeepAlive,
00245                                                                                                                         int iAuthentType=-1,
00246                                                                                                                         char* sAuthentKey=NULL );
00247         
00248         _FEDM_MYAXXESS_EXT_CLASS int StopEventHandler();
00249 
00250         // callback function, invoked by asynchronous task
00251         _FEDM_MYAXXESS_EXT_CLASS static int     cbsTaskRsp3(void* pAny, 
00252                                                                                                         int iReaderHnd, 
00253                                                                                                         int iTaskID, 
00254                                                                                                         int iError, 
00255                                                                                                         unsigned char ucCmd,
00256                                                                                                         unsigned char* ucRspData, 
00257                                                                                                         int iRspLen,
00258                                                                                                         char* cIPAdr,
00259                                                                                                         int iPortNr,
00260                                                                                                         unsigned char& ucAction );
00261 
00262 // protected methods
00263 protected:
00264         int SetIDDLength (unsigned char ucIDDLength);
00265         int SetIDDFormat (unsigned char ucIDDFormat);
00266 
00267         int ValidateIDDSettings();
00268 
00269         void SetLastError(int iError);
00270 
00271         unsigned int CalcCRC16CheckSum(unsigned short int uiCrcStart, unsigned short int uiCrcPoly, unsigned char* ucBuffer, unsigned int uiBufLen);
00272 
00273         int BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem);
00274         int BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem);
00275         int BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem);
00276 
00277         int GetTableItem_Timezone(unsigned int uiIndex, char* sItem);
00278         int GetTableItem_Holiday(unsigned int uiIndex, char* sItem);
00279         int GetTableItem_Access(unsigned int uiIndex, char* sItem);
00280         int GetTableItem_Event(char* sItem);
00281 
00282         int WriteTables_CrcList();
00283         int WriteTables_Metadata();
00284         int WriteTables_Timezone();
00285         int WriteTables_Holiday();
00286         int WriteTables_Access();
00287 
00288         int ReadTable_CrcList();
00289         int ReadTable_Metadata();
00290         int ReadTable_Timezone();
00291         int ReadTable_Holiday();
00292         int ReadTable_Access();
00293         int ReadTable_Event();
00294 
00295 
00296         // callback function for notifications from a my axxess reader, invoked by static callback member
00297         int  cbNewMaxEvent(     int iReaderHnd, 
00298                                                 int iTaskID, 
00299                                                 int iError, 
00300                                                 unsigned char* ucRspData, 
00301                                                 int iRspLen,
00302                                                 char* cIPAdr,
00303                                                 int iPortNr,
00304                                                 unsigned char& ucAction );
00305 
00306         // callback function for keep alive message with protocol [0x6E] from a reader, invoked by static callback member
00307         void cbNewReaderDiagnostic(     int iReaderHnd, 
00308                                                                 int iTaskID, 
00309                                                                 int iError, 
00310                                                                 unsigned char* ucRspData, 
00311                                                                 int iRspLen,
00312                                                                 char* cIPAdr,
00313                                                                 int iPortNr );
00314 
00315 // public member
00316 public:
00317 
00318 // protected member
00319 protected:
00320         // is set by main constructor to control the delete of m_pReaderModule
00321         bool    m_bInternalReaderModule;
00322 
00323         FEDM_ISCReaderModule*                                                   m_pReaderModule;
00324         FEDM_ISC_MYAXXESS_CRCLIST                                               m_CrcList;
00325         FEDM_ISC_MYAXXESS_METADATA                                              m_Metadata;
00326         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>  m_TimezoneTable;
00327         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>   m_HolidayTable;
00328         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>    m_AccessTable;
00329         queue<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>              m_EventTable;
00330 
00331         // parser modules for XML and CSV file types
00332 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00333         FedmIscMyAxxess_XmlParser*      m_pXmlParser;
00334 #endif
00335         FedmIscMyAxxess_CsvParser*      m_pCsvParser;
00336 
00337         unsigned char   m_ucDateFormat;                 // date format
00338         unsigned int    m_uiTimeout;                    // communication timeout
00339         unsigned int    m_uiPackageLen;                 // length of a package to transfer
00340         unsigned int    m_uiEventCallerType;    // 0 for C++
00341                                                                                         // 1 for .NET
00342 
00343         // buffer for I/O exchange with Reader
00344         unsigned char m_ucOut[FEDM_MYAXXESS_MAX_BLOCKSIZE + 20];
00345         unsigned char m_ucIn[FEDM_MYAXXESS_MAX_BLOCKSIZE + 20];
00346 
00347         LPFN_FEDM_MYAXXESS_EVENT_CB                             m_cbEvent;
00348         LPFN_FEDM_MYAXXESS_KEEPALIVE_CB                 m_cbKeepAlive;
00349         LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB              m_cbStdCallEvent;
00350         LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB  m_cbStdCallKeepAlive;
00351 };
00352 
00353 #endif // !defined(_FEDM_ISC_MYAXXESS_READER_H_INCLUDED_)


rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 2 2015 03:06:13