00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
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
00061
00062 #else
00063 #define _FEDM_MYAXXESS_EXT_CLASS
00064 #endif
00065
00066
00067
00068
00069
00070
00071 #define FEDM_MYAXXESS_TABLE_VERSION 0x00
00072
00073
00074 #define FEDM_MYAXXESS_UPDATE_START 0x01
00075 #define FEDM_MYAXXESS_UPDATE_END 0x02
00076 #define FEDM_MYAXXESS_WRITE_TABLE 0x03
00077
00078 #define FEDM_MYAXXESS_READ_TABLE 0x05
00079 #define FEDM_MYAXXESS_NOTIFY 0x06
00080
00081
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
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
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
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
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
00115
00116
00117
00118 typedef int (FEDM_CALL*
00119 LPFN_FEDM_MYAXXESS_EVENT_CB)( void*,
00120 int,
00121 vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>,
00122 unsigned char&,
00123 char*,
00124 int );
00125
00126 typedef void (FEDM_CALL*
00127 LPFN_FEDM_MYAXXESS_KEEPALIVE_CB)( void*,
00128 int,
00129 unsigned int,
00130 unsigned int,
00131 unsigned int,
00132 char*,
00133 int );
00134
00135
00136 typedef int (CALLBACK*
00137 LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB)( int,
00138 vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>,
00139 unsigned char&,
00140 char*,
00141 int );
00142
00143 typedef void (CALLBACK*
00144 LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB)( int,
00145 unsigned int,
00146 unsigned int,
00147 unsigned int,
00148 char*,
00149 int );
00150
00151
00152 class FedmIscMyAxxess_XmlParser;
00153 class FedmIscMyAxxess_CsvParser;
00154
00155
00156
00157
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
00170 _FEDM_MYAXXESS_EXT_CLASS FedmIscMyAxxessReader( unsigned char ucIDDLength,
00171 unsigned char ucIDDFormat = FEDM_MYAXXESS_IDD_FORMAT_NUM);
00172
00173
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
00192
00193
00194
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
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
00209 _FEDM_MYAXXESS_EXT_CLASS int AddTableItem(unsigned int uiTableID, char* sItem);
00210
00211
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
00217 _FEDM_MYAXXESS_EXT_CLASS int GetTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem);
00218
00219
00220 _FEDM_MYAXXESS_EXT_CLASS int RemoveTableItem(unsigned int uiTableID, unsigned int uiIndex);
00221
00222
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
00227 _FEDM_MYAXXESS_EXT_CLASS int ModifyTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem);
00228
00229
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
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
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
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
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
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
00316 public:
00317
00318
00319 protected:
00320
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
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;
00338 unsigned int m_uiTimeout;
00339 unsigned int m_uiPackageLen;
00340 unsigned int m_uiEventCallerType;
00341
00342
00343
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_)