FedmIscMyAxxessReader.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |                FedmIscMyAxxessReader.cpp              |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright  2009-2011    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.00.00 / 28.07.2011 / M. Hultsch
00020                                                 - keep-alive option for event connection
00021 
00022                                                 03.02.00 / 25.05.2010 / B. Tschunko, M. Hultsch
00023                                                 - GetTableItem returns 0 if end of table is reached
00024 
00025                                                 03.01.00 / 17.12.2009 / B. Tschunko, M. Hultsch
00026 
00027 Operation Systems       :       independent
00028 
00029 Function                        :       class for OBID i-scan and OBID classic-pro reader family with MyAxxess functionality
00030 
00031 OBID and OBID i-scan are registered Trademarks of FEIG ELECTRONIC GmbH
00032 Linux is a registered trademark of Linus Torvalds.
00033 Windows is a registered trademark of Microsoft Corporation in the United States and other countries.
00034 */
00035 
00036 
00037 
00038 #include <map>
00039 #include <assert.h>
00040 #ifdef _FEDM_LINUX
00041         #include <string.h>
00042 #endif
00043 #include "FedmIscMyAxxessReader.h"
00044 #include "FedmIscMyAxxess_XmlParser.h"
00045 #include "FedmIscMyAxxess_CsvParser.h"
00046 #include "feisc.h"      // declaration of constants, datatypes and DLL-functions
00047 
00048 
00050 // Construction/Destruction
00052 
00053 FedmIscMyAxxessReader::FedmIscMyAxxessReader(unsigned char ucIDDLength, unsigned char ucIDDFormat)
00054 {
00055         m_bInternalReaderModule = true;
00056         m_pReaderModule                 = new FEDM_ISCReaderModule;
00057         m_ucDateFormat                  = FEDM_MYAXXESS_DATE_FORMAT_ISO8601;
00058         m_uiTimeout                             = 0;
00059         m_uiPackageLen                  = 0;
00060         m_uiEventCallerType             = 0;    // 0 for C++
00061                                                                         // 1 for .NET
00062 
00063         m_cbEvent                               = NULL;
00064         m_cbKeepAlive                   = NULL;
00065 
00066 //TODO_M
00067 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00068         m_pXmlParser                    = NULL;//new FedmIscMyAxxess_XmlParser(this);
00069 #endif
00070         m_pCsvParser                    = new FedmIscMyAxxess_CsvParser(this);
00071 
00072         m_Metadata.Init();
00073         m_CrcList.Init();
00074 
00075 #ifdef _FEDM_WINDOWS
00076         VERIFY(m_pReaderModule);
00077         SetIDDFormat(ucIDDFormat);
00078         SetIDDLength(ucIDDLength);
00079 #endif
00080 #ifdef _FEDM_LINUX
00081         assert(m_pReaderModule);
00082         SetIDDFormat(ucIDDFormat);
00083         SetIDDLength(ucIDDLength);
00084 #endif
00085 }
00086 
00087 FedmIscMyAxxessReader::FedmIscMyAxxessReader(FEDM_ISCReaderModule* pReaderModule, unsigned char ucIDDLength, unsigned char ucIDDFormat)
00088 {
00089         m_bInternalReaderModule = false;
00090         m_pReaderModule                 = pReaderModule;
00091         m_ucDateFormat                  = FEDM_MYAXXESS_DATE_FORMAT_ISO8601;
00092         m_uiTimeout                             = 0;
00093         m_uiPackageLen                  = 0;
00094         m_uiEventCallerType             = 0;    // 0 for C++
00095                                                                         // 1 for .NET
00096 
00097         m_cbEvent                               = NULL;
00098         m_cbKeepAlive                   = NULL;
00099 
00100 //TODO_M
00101 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00102         m_pXmlParser                    = NULL;//new FedmIscMyAxxess_XmlParser(this);
00103 #endif
00104         m_pCsvParser                    = new FedmIscMyAxxess_CsvParser(this);
00105 
00106         m_Metadata.Init();
00107         m_CrcList.Init();
00108 
00109 #ifdef _FEDM_WINDOWS
00110         VERIFY(m_pReaderModule);
00111         SetIDDFormat(ucIDDFormat);
00112         SetIDDLength(ucIDDLength);
00113 #endif
00114 #ifdef _FEDM_LINUX
00115         assert(m_pReaderModule);
00116         SetIDDFormat(ucIDDFormat);
00117         SetIDDLength(ucIDDLength);
00118 #endif
00119 }
00120 
00121 
00122 FedmIscMyAxxessReader::~FedmIscMyAxxessReader()
00123 {
00124         ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00125         ClearTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
00126         ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00127         ClearTable(FEDM_MYAXXESS_EVENT_TABLE);
00128 
00129 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00130         if(m_pXmlParser != NULL)
00131                 delete m_pXmlParser;
00132 #endif
00133 
00134         if(m_pCsvParser != NULL)
00135                 delete m_pCsvParser;
00136 
00137         if(m_bInternalReaderModule && m_pReaderModule != NULL)
00138                 delete m_pReaderModule;
00139 }
00140 
00141 
00143 // public functions
00145 
00146 /***************************************************************************
00147   Begin         :       23.06.2009 / B. Tschunko
00148   Version       :       03.00.12 / 04.09.2009 / B. Tschunko, M. Hultsch
00149 
00150   Function              :       set IDD length
00151                                         NOTE: IDD-Format must be set before
00152 
00153   Parameters    :       unsigned char ucIDDLength       - IDD length to set
00154 
00155   Return value  :       FEDM_OK or error code (<0)
00156 ***************************************************************************/
00157 int FedmIscMyAxxessReader::SetIDDLength (unsigned char ucIDDLength)
00158 {
00159         switch(m_Metadata.ucIDDFormat)
00160         {
00161         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
00162         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
00163                 if ((ucIDDLength < 1) || (ucIDDLength > 64))
00164                         FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_LENGTH);
00165                 break;
00166 
00167         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
00168                 if ((ucIDDLength < 1) || (ucIDDLength > 8))
00169                         FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_LENGTH);
00170                 break;
00171 
00172         default:
00173                 FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_FORMAT);
00174         }
00175 
00176         m_Metadata.ucIDDLength = ucIDDLength;
00177         FEDM_RETURN(FEDM_OK);
00178 }
00179 
00180 /***************************************************************************
00181   Begin         :       25.06.2009 / B. Tschunko
00182   Version       :       03.00.08 / 26.07.2009 / B. Tschunko
00183 
00184   Function              :       set IDD format
00185 
00186   Parameters    :       unsigned char ucIDDFormat       - IDD format to set
00187 
00188   Return value  :       FEDM_OK or error code (<0)
00189 ***************************************************************************/
00190 int FedmIscMyAxxessReader::SetIDDFormat (unsigned char ucIDDFormat)
00191 {
00192         if ((ucIDDFormat < 1) || (ucIDDFormat > 3))
00193                 FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_FORMAT);
00194 
00195         m_Metadata.ucIDDFormat = ucIDDFormat;
00196         FEDM_RETURN(FEDM_OK);
00197 }
00198 
00199 /***************************************************************************
00200   Begin         :       10.02.2010 / M. Hultsch
00201   Version       :       03.01.00 / 10.02.2010 / M. Hultsch
00202 
00203   Function              :       check IDD settings
00204 
00205   Parameters    :       -
00206 
00207   Return value  :       FEDM_OK or error code (<0)
00208 ***************************************************************************/
00209 int FedmIscMyAxxessReader::ValidateIDDSettings()
00210 {
00211         switch(m_Metadata.ucIDDFormat)
00212         {
00213         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
00214         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
00215                 if ((m_Metadata.ucIDDLength < 1) || (m_Metadata.ucIDDLength > 64))
00216                         FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_LENGTH);
00217                 break;
00218 
00219         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
00220                 if ((m_Metadata.ucIDDLength < 1) || (m_Metadata.ucIDDLength > 8))
00221                         FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_LENGTH);
00222                 break;
00223 
00224         default:
00225                 FEDM_RETURN(FEDM_ERROR_UNVALID_IDD_FORMAT);
00226         }
00227 
00228         FEDM_RETURN(FEDM_OK);
00229 }
00230 
00231 /***************************************************************************
00232   Begin         :       01.07.2009 / B. Tschunko
00233   Version       :       03.00.08 / 01.07.2009 / B. Tschunko
00234 
00235   Function              :       set Date format
00236 
00237   Parameters    :       unsigned char ucIDDFormat       - IDD format to set
00238 
00239   Return value  :       FEDM_OK or error code (<0)
00240 ***************************************************************************/
00241 int FedmIscMyAxxessReader::SetDateFormat (unsigned char ucDateFormat)
00242 {
00243         if (ucDateFormat < 1 || ucDateFormat > 3)
00244                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00245 
00246         m_ucDateFormat = ucDateFormat;
00247         FEDM_RETURN(FEDM_OK);
00248 }
00249 
00250 
00251 // public API for table management
00252 /***************************************************************************
00253   Begin         :       01.07.2009 / B. Tschunko
00254   Version       :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00255 
00256   Function              :       clear specific table
00257 
00258   Parameters    :       unsigned int uiTableID  - table identifier
00259 
00260   Return value  :       FEDM_OK or error code (<0)
00261 ***************************************************************************/
00262 int FedmIscMyAxxessReader::ClearTable(unsigned int uiTableID)
00263 {
00264         int iError = ValidateIDDSettings();
00265         if(iError)
00266                 return iError;
00267 
00268         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator        itorTimezoneTable;
00269         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator         itorHolidayTable;
00270         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator          itorAccessTable;
00271         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pEventTableItem = NULL;
00272 
00273         switch (uiTableID)
00274         {
00275         case FEDM_MYAXXESS_TIMEZONE_TABLE:
00276 
00277                 for(itorTimezoneTable  = m_TimezoneTable.begin();
00278                         itorTimezoneTable != m_TimezoneTable.end();
00279                         itorTimezoneTable++)
00280                 {
00281                         if(*itorTimezoneTable != NULL)
00282                                 delete *itorTimezoneTable;
00283                 }
00284 
00285                 m_TimezoneTable.clear();
00286                 break;
00287 
00288         case FEDM_MYAXXESS_HOLIDAY_TABLE:
00289 
00290                 for(itorHolidayTable  = m_HolidayTable.begin();
00291                         itorHolidayTable != m_HolidayTable.end();
00292                         itorHolidayTable++)
00293                 {
00294                         if(*itorHolidayTable != NULL)
00295                                 delete *itorHolidayTable;
00296                 }
00297 
00298                 m_HolidayTable.clear();
00299                 break;
00300 
00301         case FEDM_MYAXXESS_ACCESS_TABLE:
00302 
00303                 for(itorAccessTable  = m_AccessTable.begin();
00304                         itorAccessTable != m_AccessTable.end();
00305                         itorAccessTable++)
00306                 {
00307                         if(*itorAccessTable != NULL)
00308                                 delete *itorAccessTable;
00309                 }
00310 
00311                 m_AccessTable.clear();
00312                 break;
00313 
00314         case FEDM_MYAXXESS_EVENT_TABLE:
00315 
00316                 while(! m_EventTable.empty())
00317                 {
00318                         pEventTableItem = m_EventTable.front();
00319                         if(pEventTableItem != NULL)
00320                         {
00321                                 m_EventTable.pop();
00322                         }
00323                 }
00324                 break;
00325 
00326         default:
00327                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
00328 
00329         }
00330 
00331         FEDM_RETURN(FEDM_OK);
00332 }
00333 
00334 
00335 /***************************************************************************
00336   Begin                 :       02.03.2009 / M. Hultsch
00337 
00338   Version               :       03.00.08 / 29.06.2009 / M. Hultsch
00339 
00340   Function                      :       Read table data from file
00341 
00342   Parameters            :       char* szFilename                - path and name of file
00343                                                 unsigned int uiFiletype - type of file (default: FEDM_MYAXXESS_FILETYPE_XML)
00344 
00345   Return value          :       FEDM_OK
00346                                                 or
00347                                                 < 0 in error case
00348 ***************************************************************************/
00349 int FedmIscMyAxxessReader::SerializeTableIn(    char* szFilename,
00350                                                                                                 unsigned int uiFileType )
00351 {
00352         switch (uiFileType)
00353         {
00354         case FEDM_MYAXXESS_FILETYPE_XML:
00355 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00356                 FEDM_CHK5(m_pXmlParser);
00357 
00358                 return m_pXmlParser->SerializeIn( szFilename, "Test", 4);
00359 #else
00360                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00361 #endif
00362                 break;
00363 
00364         case FEDM_MYAXXESS_FILETYPE_CSV:
00365                 FEDM_CHK5(m_pCsvParser)
00366 
00367                 return m_pCsvParser->SerializeIn( szFilename );
00368                 break;
00369 
00370         default:
00371 
00372                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00373         }
00374 
00375         FEDM_RETURN(FEDM_OK);
00376 }
00377 
00378 
00379 /***************************************************************************
00380   Begin                 :       02.03.2009 / M. Hultsch
00381 
00382   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00383 
00384   Function                      :       Write table data in file
00385 
00386   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
00387                                                 char* szFilename                - path and name of file
00388                                                 unsigned int uiFiletype - type of file (default: FEDM_MYAXXESS_FILETYPE_XML)
00389 
00390   Return value          :       FEDM_OK
00391                                                 or
00392                                                 < 0 in error case
00393 ***************************************************************************/
00394 int FedmIscMyAxxessReader::SerializeTableOut(   unsigned int uiTableID,
00395                                                                                                 char* szFilename,
00396                                                                                                 unsigned int uiFileType )
00397 {
00398         int iError = ValidateIDDSettings();
00399         if(iError)
00400                 return iError;
00401 
00402         switch (uiFileType)
00403         {
00404         case FEDM_MYAXXESS_FILETYPE_XML:
00405 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00406                 FEDM_CHK5(m_pXmlParser);
00407 
00408                 return m_pXmlParser->SerializeOut( uiTableID, szFilename, "Test", 4);
00409 #else
00410                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00411 #endif
00412 
00413                 break;
00414 
00415         case FEDM_MYAXXESS_FILETYPE_CSV:
00416                 FEDM_CHK5(m_pCsvParser)
00417 
00418                 return m_pCsvParser->SerializeOut( uiTableID, szFilename );
00419                 break;
00420 
00421         default:
00422                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00423         }
00424 
00425         FEDM_RETURN(FEDM_OK);
00426 }
00427 
00428 
00429 /***************************************************************************
00430   Begin                 :       06.07.2009 / B. Tschunko
00431 
00432   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00433 
00434   Function                      :       Add new Item to timezone table
00435 
00436   Parameters            :       FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem    - pointer if the new item
00437 
00438   Return value          :       FEDM_OK
00439                                                 or
00440                                                 < 0 in error case
00441 ***************************************************************************/
00442 int FedmIscMyAxxessReader::AddTableItem(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem)
00443 {
00444         int iError = ValidateIDDSettings();
00445         if(iError)
00446                 return iError;
00447 
00448         // check table size
00449         if (m_TimezoneTable.size() >= 15)
00450         {
00451                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00452         }
00453 
00454         // check new item
00455         if (pItem->ucStartDate_Year > 99)
00456         {
00457                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00458         }
00459 
00460         if ((pItem->ucStartDate_Month < 1) || (pItem->ucStartDate_Month > 12))
00461         {
00462                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00463         }
00464 
00465         if ((pItem->ucStartDate_Day < 1) || (pItem->ucStartDate_Day > 31))
00466         {
00467                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00468         }
00469 
00470         if (pItem->ucStartTime_Hour > 23)
00471         {
00472                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00473         }
00474 
00475         if (pItem->ucStartTime_Minute > 59)
00476         {
00477                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00478         }
00479 
00480         if (pItem->ucEndDate_Year > 99)
00481         {
00482                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00483         }
00484 
00485         if ((pItem->ucEndDate_Month < 1) || (pItem->ucEndDate_Month > 12))
00486         {
00487                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00488         }
00489 
00490         if ((pItem->ucEndDate_Day < 1) || (pItem->ucEndDate_Day > 31))
00491         {
00492                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00493         }
00494 
00495         if (pItem->ucEndTime_Hour > 23)
00496         {
00497                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00498         }
00499 
00500         if (pItem->ucEndTime_Minute > 59)
00501         {
00502                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00503         }
00504 
00505         // add new item
00506         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pTimezoneTableItem = new FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM;
00507         if (pTimezoneTableItem == NULL)
00508         {
00509                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
00510         }
00511         pTimezoneTableItem->Init();
00512         memcpy((unsigned char*)pTimezoneTableItem, (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM));
00513 
00514         // add item to vector
00515         m_TimezoneTable.push_back(pTimezoneTableItem);
00516 
00517         FEDM_RETURN(FEDM_OK);
00518 }
00519 
00520 
00521 /***************************************************************************
00522   Begin                 :       06.07.2009 / B. Tschunko
00523 
00524   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00525 
00526   Function                      :       Add new Item to hloiday table
00527 
00528   Parameters            :       FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem     - pointer if the new item
00529 
00530   Return value          :       FEDM_OK
00531                                                 or
00532                                                 < 0 in error case
00533 ***************************************************************************/
00534 int FedmIscMyAxxessReader::AddTableItem(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem)
00535 {
00536         int iError = ValidateIDDSettings();
00537         if(iError)
00538                 return iError;
00539 
00540         // check table size
00541         if (m_HolidayTable.size() >= 256)
00542         {
00543                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00544         }
00545 
00546         // check new item
00547         if (pItem->ucHoliday_Year > 99)
00548         {
00549                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00550         }
00551 
00552         if ((pItem->ucHoliday_Month < 1) || (pItem->ucHoliday_Month > 12))
00553         {
00554                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00555         }
00556 
00557         if ((pItem->ucHoliday_Day < 1) || (pItem->ucHoliday_Day > 31))
00558         {
00559                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00560         }
00561 
00562         // add new item
00563         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pHolidayTableItem = new FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM;
00564         if (pHolidayTableItem == NULL)
00565         {
00566                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
00567         }
00568         pHolidayTableItem->Init();
00569         memcpy((unsigned char*)pHolidayTableItem, (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM));
00570 
00571         // add item to vector
00572         m_HolidayTable.push_back(pHolidayTableItem);
00573 
00574         FEDM_RETURN(FEDM_OK);
00575 }
00576 
00577 
00578 /***************************************************************************
00579   Begin                 :       06.07.2009 / B. Tschunko
00580 
00581   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00582 
00583   Function                      :       Add new Item to access table
00584 
00585   Parameters            :       FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem      - pointer if the new item
00586 
00587   Return value          :       FEDM_OK
00588                                                 or
00589                                                 < 0 in error case
00590 ***************************************************************************/
00591 int FedmIscMyAxxessReader::AddTableItem(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem)
00592 {
00593         int iError = ValidateIDDSettings();
00594         if(iError)
00595                 return iError;
00596 
00597         // check table size
00598         if (m_AccessTable.size() >= 65535)
00599         {
00600                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00601         }
00602 
00603         // search Access Table
00604         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*    pAccessItem     = NULL;
00605         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator  itorAccess;
00606         for(itorAccess  = m_AccessTable.begin();
00607                 itorAccess != m_AccessTable.end();
00608                 itorAccess++)
00609         {
00610                 if ((*itorAccess) == NULL)
00611                         continue;
00612 
00613                 pAccessItem = *itorAccess;
00614 
00615                 // same IDD cannot be inserted
00616                 if (memcmp(pAccessItem->ucIDD, pItem->ucIDD, m_Metadata.ucIDDLength) == 0)
00617                 {
00618                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00619                 }
00620         }
00621 
00622         // add new item
00623         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pAccessTableItem = new FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM;
00624         if (pAccessTableItem == NULL)
00625         {
00626                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
00627         }
00628         pAccessTableItem->Init();
00629         memcpy((unsigned char*)pAccessTableItem, (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM));
00630 
00631         // add item to vector
00632         m_AccessTable.push_back(pAccessTableItem);
00633 
00634         FEDM_RETURN(FEDM_OK);
00635 }
00636 
00637 
00638 /***************************************************************************
00639   Begin                 :       02.03.2009 / M. Hultsch
00640 
00641   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00642 
00643   Function                      :       Add new Item to table
00644 
00645   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
00646                                                 char* sItem                             - string if the new item
00647                                                                                                   <element1_name=element1_value;element2_name=element2_value;...>
00648 
00649   Return value          :       FEDM_OK
00650                                                 or
00651                                                 < 0 in error case
00652 ***************************************************************************/
00653 int FedmIscMyAxxessReader::AddTableItem(unsigned int uiTableID, char* sItem)
00654 {
00655         int iBack = 0;  
00656         unsigned char ucCnt = 0;
00657         char* sPrt = NULL;
00658         vector<string> aName;
00659         vector<string> aValue;
00660 
00661         int iError = ValidateIDDSettings();
00662         if(iError)
00663                 return iError;
00664 
00665 
00666         // get name of first element
00667         if (strlen(sItem) > FEDM_MAX_TEXT_SIZE)
00668         {
00669                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00670         }
00671 
00672         sPrt = strtok(sItem, "=");
00673 
00674         while (sPrt != NULL && ucCnt < 16)
00675         {
00676                 aName.push_back("");
00677                 aName[ucCnt] = sPrt;
00678 
00679                 // get value of element
00680                 sPrt = strtok(NULL, ";");
00681                 if (sPrt != NULL)
00682                 {
00683                         aValue.push_back("");
00684                         aValue[ucCnt] = sPrt;
00685                 }
00686                 else
00687                 {
00688                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00689                 }
00690                 // get name of next element
00691                 sPrt = strtok(NULL, "=");
00692                 ucCnt++;
00693    }
00694 
00695         switch (uiTableID)
00696         {
00697         case FEDM_MYAXXESS_TIMEZONE_TABLE:
00698 
00699                 FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM pItemTimezone;
00700                 pItemTimezone.Init();
00701                 iBack = BuildTableItem(aName, aValue, &pItemTimezone);
00702                 if(iBack != 0)
00703                 {
00704                         return iBack;
00705                 }               
00706                 return AddTableItem(&pItemTimezone);
00707                 break;
00708 
00709         case FEDM_MYAXXESS_HOLIDAY_TABLE:
00710 
00711                 FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM pItemHoliday;
00712                 pItemHoliday.Init();
00713                 iBack = BuildTableItem(aName, aValue, &pItemHoliday);
00714                 if(iBack != 0)
00715                 {
00716                         return iBack;
00717                 }               
00718                 return AddTableItem(&pItemHoliday);
00719                 break;
00720 
00721         case FEDM_MYAXXESS_ACCESS_TABLE:
00722 
00723                 FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM pItemAccess;
00724                 pItemAccess.Init();
00725                 iBack = BuildTableItem(aName, aValue, &pItemAccess);
00726                 if(iBack != 0)
00727                 {
00728                         return iBack;
00729                 }               
00730                 return AddTableItem(&pItemAccess);
00731                 break;
00732 
00733         default:
00734                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
00735         }
00736 
00737         FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
00738 }
00739 
00740 
00741 /***************************************************************************
00742   Begin                 :       07.07.2009 / B. Tschunko
00743 
00744   Version               :       03.02.00 / 25.05.2010 / B. Tschunko, M. Hultsch
00745 
00746   Function                      :       get one table item from the timezone table
00747                                                 NOTE: method returns the next possible index and at end of table
00748                                                           a 1 is returned (index of first item)
00749 
00750   Parameters            :       unsigned int uiIndex                                                    - table index of item
00751                                                 FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem    - pointer if the new item
00752 
00753   Return value          :       > 0 - index of next table item to be read
00754                                                 or
00755                                                 0   - end of table
00756                                                 or
00757                                                 < 0 - in error case
00758 ***************************************************************************/
00759 int FedmIscMyAxxessReader::GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem)
00760 {
00761         unsigned int uiNextIndex = 1;
00762 
00763         int iError = ValidateIDDSettings();
00764         if(iError)
00765                 return iError;
00766 
00767 
00768         // check table size
00769         if ((uiIndex < 1) || (uiIndex > m_TimezoneTable.size()))
00770         {
00771                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00772         }
00773 
00774         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itorTimezone;
00775 
00776         // search Timezone Table
00777         for(itorTimezone  = m_TimezoneTable.begin();
00778                 itorTimezone != m_TimezoneTable.end();
00779                 itorTimezone++)
00780         {
00781                 if ((*itorTimezone) == NULL)
00782                         continue;
00783 
00784                 if (uiNextIndex++ != uiIndex)
00785                         continue;
00786 
00787                 // copy item
00788                 memcpy((unsigned char*)pItem, (unsigned char*)(*itorTimezone), sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM));
00789                 break;
00790         }
00791 
00792         if (uiNextIndex > m_TimezoneTable.size())
00793         {
00794                 uiNextIndex = 0;
00795         }
00796 
00797         return ((int)uiNextIndex);
00798 }
00799 
00800 
00801 /***************************************************************************
00802   Begin                 :       07.07.2009 / B. Tschunko
00803 
00804   Version               :       03.02.00 / 25.05.2010 / B. Tschunko, M. Hultsch
00805 
00806   Function                      :       get one table item from the holiday table
00807                                                 NOTE: method returns the next possible index and at end of table
00808                                                           a 1 is returned (index of first item)
00809 
00810   Parameters            :       unsigned int uiIndex                                                    - table index of item
00811                                                 FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem             - pointer if the new item
00812 
00813   Return value          :       > 0 - index of next table item to be read
00814                                                 or
00815                                                 0   - end of table
00816                                                 or
00817                                                 < 0 - in error case
00818 ***************************************************************************/
00819 int FedmIscMyAxxessReader::GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem)
00820 {
00821         unsigned int uiNextIndex = 1;
00822 
00823         int iError = ValidateIDDSettings();
00824         if(iError)
00825                 return iError;
00826 
00827 
00828         // check table size
00829         if ((uiIndex < 1) || (uiIndex > m_HolidayTable.size()))
00830         {
00831                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00832         }
00833 
00834         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itorHoliday;
00835 
00836         // search Holiday Table
00837         for(itorHoliday  = m_HolidayTable.begin();
00838                 itorHoliday != m_HolidayTable.end();
00839                 itorHoliday++)
00840         {
00841                 if ((*itorHoliday) == NULL)
00842                         continue;
00843 
00844                 if (uiNextIndex++ != uiIndex)
00845                         continue;
00846 
00847                 // copy item
00848                 memcpy((unsigned char*)pItem, (unsigned char*)(*itorHoliday), sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM));
00849                 break;
00850         }
00851 
00852         if (uiNextIndex > m_HolidayTable.size())
00853         {
00854                 uiNextIndex = 0;
00855         }
00856 
00857         return ((int)uiNextIndex);
00858 }
00859 
00860 
00861 /***************************************************************************
00862   Begin                 :       07.07.2009 / B. Tschunko
00863 
00864   Version               :       03.02.00 / 25.05.2010 / B. Tschunko, M. Hultsch
00865 
00866   Function                      :       get one table item from the access table
00867                                                 NOTE: method returns the next possible index and at end of table
00868                                                           a 1 is returned (index of first item)
00869 
00870   Parameters            :       unsigned int uiIndex                                                    - table index of item
00871                                                 FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem              - pointer if the new item
00872 
00873   Return value          :       > 0 - index of next table item to be read
00874                                                 or
00875                                                 0   - end of table
00876                                                 or
00877                                                 < 0 - in error case
00878 ***************************************************************************/
00879 int FedmIscMyAxxessReader::GetTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem)
00880 {
00881         unsigned int uiNextIndex = 1;
00882 
00883         int iError = ValidateIDDSettings();
00884         if(iError)
00885                 return iError;
00886 
00887 
00888         // check table size
00889         if ((uiIndex < 1) || (uiIndex > m_AccessTable.size()))
00890         {
00891                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00892         }
00893 
00894         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator itorAccess;
00895 
00896         // search Access Table
00897         for(itorAccess  = m_AccessTable.begin();
00898                 itorAccess != m_AccessTable.end();
00899                 itorAccess++)
00900         {
00901                 if ((*itorAccess) == NULL)
00902                         continue;
00903 
00904                 if (uiNextIndex++ != uiIndex)
00905                         continue;
00906 
00907                 // copy item
00908                 memcpy((unsigned char*)pItem, (unsigned char*)(*itorAccess), sizeof(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM));
00909                 break;
00910         }
00911 
00912         if (uiNextIndex > m_AccessTable.size())
00913         {
00914                 uiNextIndex = 0;
00915         }
00916 
00917         return ((int)uiNextIndex);
00918 }
00919 
00920 
00921 /***************************************************************************
00922   Begin                 :       07.07.2009 / B. Tschunko
00923 
00924   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00925 
00926   Function                      :       get the last table item from the event table
00927 
00928   Parameters            :       FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pItem               - pointer if the new item
00929 
00930   Return value          :       FEDM_OK
00931                                                 or
00932                                                 < 0 in error case
00933 ***************************************************************************/
00934 int FedmIscMyAxxessReader::GetTableItem(FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pItem)
00935 {
00936         int iError = ValidateIDDSettings();
00937         if(iError)
00938                 return iError;
00939 
00940         // search Event Table
00941         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*     pEventItem      = NULL;
00942         
00943         if(m_EventTable.empty())
00944         {
00945                 FEDM_RETURN(FEDM_ERROR_NO_TABLE_DATA);
00946         }
00947 
00948         pEventItem = m_EventTable.front();
00949 
00950         if(&pEventItem == NULL)
00951         {
00952                 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
00953         }
00954 
00955         // copy item
00956         memcpy((unsigned char*)pItem, (unsigned char*)pEventItem, sizeof(FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM));
00957         
00958         // item must be deleted, because item is no longer controlled by the queue
00959         m_EventTable.pop();
00960 
00961         FEDM_RETURN(FEDM_OK);
00962 }
00963 
00964 
00965 /***************************************************************************
00966   Begin                 :       24.06.2009 / M. Hultsch
00967 
00968   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
00969 
00970   Function                      :       get one table item from a specified internal table
00971                                                 NOTE: method returns the next possible index and at end of table
00972                                                           a 1 is returned (index of first item)
00973 
00974   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
00975                                                 unsigned int uiIndex    - table index of item
00976                                                 char* sItem                             - string if the new item
00977                                                                                                   <element1_name=element1_value;element2_name=element2_value;...>
00978 
00979   Return value          :       > 0 - index of next table item to be read
00980                                                 or
00981                                                 < 0 in error case
00982 ***************************************************************************/
00983 int FedmIscMyAxxessReader::GetTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem)
00984 {
00985         int iError = ValidateIDDSettings();
00986         if(iError)
00987                 return iError;
00988 
00989         switch (uiTableID)
00990         {
00991         case FEDM_MYAXXESS_TIMEZONE_TABLE:
00992 
00993                 return GetTableItem_Timezone(uiIndex, sItem);
00994                 break;
00995 
00996         case FEDM_MYAXXESS_HOLIDAY_TABLE:
00997 
00998                 return GetTableItem_Holiday(uiIndex, sItem);
00999                 break;
01000 
01001         case FEDM_MYAXXESS_ACCESS_TABLE:
01002 
01003                 return GetTableItem_Access(uiIndex, sItem);
01004                 break;
01005 
01006         case FEDM_MYAXXESS_EVENT_TABLE:
01007 
01008                 return GetTableItem_Event(sItem);
01009                 break;
01010 
01011         default:
01012                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01013         }
01014 
01015         FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01016 }
01017 
01018 
01019 /***************************************************************************
01020   Begin                 :       07.07.2009 / B. Tschunko
01021 
01022   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01023 
01024   Function                      :       remove one table item from a specified internal table
01025 
01026   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
01027                                                 unsigned int uiIndex    - table index of item
01028 
01029   Return value          :       FEDM_OK
01030                                                 or
01031                                                 < 0 in error case
01032 ***************************************************************************/
01033 int FedmIscMyAxxessReader::RemoveTableItem(unsigned int uiTableID, unsigned int uiIndex)
01034 {
01035         int iError = ValidateIDDSettings();
01036         if(iError)
01037                 return iError;
01038 
01039         switch (uiTableID)
01040         {
01041         case FEDM_MYAXXESS_HOLIDAY_TABLE:
01042 
01043                 // check table size
01044                 if ((uiIndex < 1) || (uiIndex > m_HolidayTable.size()))
01045                 {
01046                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01047                 }
01048 
01049                 // remove item
01050                 m_HolidayTable.erase(m_HolidayTable.begin()+uiIndex-1);
01051                 break;
01052 
01053         case FEDM_MYAXXESS_ACCESS_TABLE:
01054 
01055                 // check table size
01056                 if ((uiIndex < 1) || (uiIndex > m_AccessTable.size()))
01057                 {
01058                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01059                 }
01060 
01061                 // remove item
01062                 m_AccessTable.erase(m_AccessTable.begin()+uiIndex-1);
01063                 break;
01064 
01065         default:
01066                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01067         }
01068 
01069         FEDM_RETURN(FEDM_OK);
01070 }
01071 
01072 
01073 /***************************************************************************
01074   Begin                 :       07.07.2009 / B. Tschunko
01075 
01076   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01077 
01078   Function                      :       modify one table item of the timezone table
01079 
01080   Parameters            :       unsigned int uiIndex    - table index of item
01081                                                 FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem    - pointer if the item to modify
01082 
01083   Return value          :       FEDM_OK
01084                                                 or
01085                                                 < 0 in error case
01086 ***************************************************************************/
01087 int FedmIscMyAxxessReader::ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem)
01088 {
01089         unsigned int uiNextIndex = 1;
01090 
01091         int iError = ValidateIDDSettings();
01092         if(iError)
01093                 return iError;
01094 
01095         // check table size
01096         if ((uiIndex < 1) || (uiIndex > m_TimezoneTable.size()))
01097         {
01098                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01099         }
01100 
01101         // check new item
01102         if (pItem->ucStartDate_Year > 99)
01103         {
01104                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01105         }
01106 
01107         if ((pItem->ucStartDate_Month < 1) || (pItem->ucStartDate_Month > 12))
01108         {
01109                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01110         }
01111 
01112         if ((pItem->ucStartDate_Day < 1) || (pItem->ucStartDate_Day > 31))
01113         {
01114                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01115         }
01116 
01117         if (pItem->ucStartTime_Hour > 23)
01118         {
01119                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01120         }
01121 
01122         if (pItem->ucStartTime_Minute > 59)
01123         {
01124                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01125         }
01126 
01127         if (pItem->ucEndDate_Year > 99)
01128         {
01129                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01130         }
01131 
01132         if ((pItem->ucEndDate_Month < 1) || (pItem->ucEndDate_Month > 12))
01133         {
01134                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01135         }
01136 
01137         if ((pItem->ucEndDate_Day < 1) || (pItem->ucEndDate_Day > 31))
01138         {
01139                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01140         }
01141 
01142         if (pItem->ucEndTime_Hour > 23)
01143         {
01144                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01145         }
01146 
01147         if (pItem->ucEndTime_Minute > 59)
01148         {
01149                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01150         }
01151 
01152         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itorTimezone;
01153 
01154         // search Timezone Table
01155         for(itorTimezone  = m_TimezoneTable.begin();
01156                 itorTimezone != m_TimezoneTable.end();
01157                 itorTimezone++)
01158         {
01159                 if ((*itorTimezone) == NULL)
01160                         continue;
01161 
01162                 if (uiNextIndex++ != uiIndex)
01163                         continue;
01164 
01165                 // copy item
01166                 memcpy((unsigned char*)(*itorTimezone), (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM));
01167                 break;
01168         }
01169 
01170         FEDM_RETURN(FEDM_OK);
01171 }
01172 
01173 
01174 /***************************************************************************
01175   Begin                 :       07.07.2009 / B. Tschunko
01176 
01177   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01178 
01179   Function                      :       modify one table item of the holiday table
01180 
01181   Parameters            :       unsigned int uiIndex    - table index of item
01182                                                 FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem     - pointer if the item to modify
01183 
01184   Return value          :       FEDM_OK
01185                                                 or
01186                                                 < 0 in error case
01187 ***************************************************************************/
01188 int FedmIscMyAxxessReader::ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem)
01189 {
01190         unsigned int uiNextIndex = 1;
01191 
01192         int iError = ValidateIDDSettings();
01193         if(iError)
01194                 return iError;
01195 
01196         // check table size
01197         if ((uiIndex < 1) || (uiIndex > m_HolidayTable.size()))
01198         {
01199                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01200         }
01201 
01202         // check new item
01203         if (pItem->ucHoliday_Year > 99)
01204         {
01205                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01206         }
01207 
01208         if ((pItem->ucHoliday_Month < 1) || (pItem->ucHoliday_Month > 12))
01209         {
01210                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01211         }
01212 
01213         if ((pItem->ucHoliday_Day < 1) || (pItem->ucHoliday_Day > 31))
01214         {
01215                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01216         }
01217 
01218         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itorHoliday;
01219 
01220         // search Holiday Table
01221         for(itorHoliday  = m_HolidayTable.begin();
01222                 itorHoliday != m_HolidayTable.end();
01223                 itorHoliday++)
01224         {
01225                 if ((*itorHoliday) == NULL)
01226                         continue;
01227 
01228                 if (uiNextIndex++ != uiIndex)
01229                         continue;
01230 
01231                 // modify item
01232                 memcpy((unsigned char*)(*itorHoliday), (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM));
01233                 break;
01234         }
01235 
01236         FEDM_RETURN(FEDM_OK);
01237 }
01238 
01239 
01240 /***************************************************************************
01241   Begin                 :       07.07.2009 / B. Tschunko
01242 
01243   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01244 
01245   Function                      :       modify one table item of the access table
01246 
01247   Parameters            :       unsigned int uiIndex    - table index of item
01248                                                 FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem      - pointer if the item to modify
01249 
01250   Return value          :       FEDM_OK
01251                                                 or
01252                                                 < 0 in error case
01253 ***************************************************************************/
01254 int FedmIscMyAxxessReader::ModifyTableItem(unsigned int uiIndex, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem)
01255 {
01256         unsigned int uiNextIndex = 1;
01257 
01258         int iError = ValidateIDDSettings();
01259         if(iError)
01260                 return iError;
01261 
01262         // check table size
01263         if ((uiIndex < 1) || (uiIndex > m_AccessTable.size()))
01264         {
01265                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01266         }
01267 
01268         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator itorAccess;
01269 
01270         // search Access Table
01271         for(itorAccess  = m_AccessTable.begin();
01272                 itorAccess != m_AccessTable.end();
01273                 itorAccess++)
01274         {
01275                 if ((*itorAccess) == NULL)
01276                         continue;
01277 
01278                 if (uiNextIndex++ != uiIndex)
01279                         continue;
01280 
01281                 // copy item
01282                 memcpy((unsigned char*)(*itorAccess), (unsigned char*)pItem, sizeof(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM));
01283                 break;
01284         }
01285 
01286         FEDM_RETURN(FEDM_OK);
01287 }
01288 
01289 
01290 /***************************************************************************
01291   Begin                 :       07.07.2009 / B. Tschunko
01292 
01293   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01294 
01295   Function                      :       modify one table item of a specified internal table
01296 
01297   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
01298                                                 unsigned int uiIndex    - table index of item
01299                                                 char* sItem                             - string if the new item
01300                                                                                                   <element1_name=element1_value;element2_name=element2_value;...>
01301 
01302   Return value          :       FEDM_OK
01303                                                 or
01304                                                 < 0 in error case
01305 ***************************************************************************/
01306 int FedmIscMyAxxessReader::ModifyTableItem(unsigned int uiTableID, unsigned int uiIndex, char* sItem)
01307 {
01308         int iBack = 0;
01309         unsigned char ucCnt = 0;
01310         char* sPrt = NULL;
01311         vector<string> aName;
01312         vector<string> aValue;
01313 
01314         int iError = ValidateIDDSettings();
01315         if(iError)
01316                 return iError;
01317 
01318         // get name of first element
01319         if (strlen(sItem) > FEDM_MAX_TEXT_SIZE)
01320         {
01321                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
01322         }
01323 
01324         sPrt = strtok(sItem, "=");
01325 
01326         while (sPrt != NULL && ucCnt < 16)
01327         {
01328                 aName.push_back("");
01329                 aName[ucCnt] = sPrt;
01330 
01331                 // get value of element
01332                 sPrt = strtok(NULL, ";");
01333                 if (sPrt != NULL)
01334                 {
01335                         aValue.push_back("");
01336                         aValue[ucCnt] = sPrt;
01337                 }
01338                 else
01339                 {
01340                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01341                 }
01342                 // get name of next element
01343                 sPrt = strtok(NULL, "=");
01344                 ucCnt++;
01345    }
01346 
01347         switch (uiTableID)
01348         {
01349         case FEDM_MYAXXESS_TIMEZONE_TABLE:
01350 
01351                 FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM pItemTimezone;
01352                 pItemTimezone.Init();
01353                 iBack = BuildTableItem(aName, aValue, &pItemTimezone);
01354                 if(iBack != 0)
01355                 {
01356                         return iBack;
01357                 }               
01358                 return ModifyTableItem(uiIndex, &pItemTimezone);
01359                 break;
01360 
01361         case FEDM_MYAXXESS_HOLIDAY_TABLE:
01362 
01363                 FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM pItemHoliday;
01364                 pItemHoliday.Init();
01365                 iBack = BuildTableItem(aName, aValue, &pItemHoliday);
01366                 if(iBack != 0)
01367                 {
01368                         return iBack;
01369                 }               
01370                 return ModifyTableItem(uiIndex, &pItemHoliday);
01371                 break;
01372 
01373         case FEDM_MYAXXESS_ACCESS_TABLE:
01374 
01375                 FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM pItemAccess;
01376                 pItemAccess.Init();
01377                 iBack = BuildTableItem(aName, aValue, &pItemAccess);
01378                 if(iBack != 0)
01379                 {
01380                         return iBack;
01381                 }               
01382                 return ModifyTableItem(uiIndex, &pItemAccess);
01383                 break;
01384 
01385         default:
01386                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01387         }
01388 
01389         FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01390 }
01391 
01392 
01393 // public API for table update
01394 
01395 /***************************************************************************
01396   Begin                 :       02.03.2009 / M. Hultsch
01397 
01398   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01399 
01400   Function                      :       Write tables into reader
01401 
01402   Parameters            :       -
01403 
01404   Return value          :       FEDM_OK
01405                                                 or
01406                                                 < 0 in error case
01407 ***************************************************************************/
01408 int FedmIscMyAxxessReader::WriteTables()
01409 {
01410         int iBack = 0;
01411         int iOldTimeout = 0;
01412 
01413         int iError = ValidateIDDSettings();
01414         if(iError)
01415                 return iError;
01416 
01417         m_CrcList.Init();
01418 
01419         // 1. step:     Send Start Update with Metadata
01420         iBack = WriteTables_Metadata();
01421         if(iBack != 0)
01422         {
01423                 return iBack;
01424         }
01425 
01426         if(m_uiPackageLen > FEDM_MYAXXESS_MAX_BLOCKSIZE)
01427         {
01428                 FEDM_RETURN(FEDM_ERROR_BLOCK_SIZE);
01429         }
01430 /*
01431         if(FEDM_IS_COMPORT(m_iReaderHnd) && uiPackageLen > FEDM_FW_EXC_SERIAL_BLOCKSIZE)
01432         {
01433                 // limitation for serial port
01434                 uiPackageLen = FEDM_FW_EXC_SERIAL_BLOCKSIZE;
01435         }
01436 */
01437         // get old timeout of PC
01438         m_pReaderModule->GetPortPara("Timeout", &iOldTimeout);
01439         // set the timeout for PC
01440         m_pReaderModule->SetPortPara("Timeout", m_uiTimeout);
01441 
01442         // 2. step: Upload Timezone Table
01443         iBack = WriteTables_Timezone();
01444         if(iBack != 0)
01445         {
01446                 return iBack;
01447         }
01448 
01449         // 3. step: Upload Holiday Table
01450         iBack = WriteTables_Holiday();
01451         if(iBack != 0)
01452         {
01453                 return iBack;
01454         }
01455 
01456         // 4. step: Upload AccessData Table
01457         iBack = WriteTables_Access();
01458         if(iBack != 0)
01459         {
01460                 return iBack;
01461         }
01462 
01463         // 5. step:     Send Update End with CrcList
01464         iBack = WriteTables_CrcList();
01465         if(iBack != 0)
01466         {
01467                 return iBack;
01468         }
01469 
01470         // restore old timeout for PC
01471         m_pReaderModule->SetPortPara("Timeout", iOldTimeout);
01472 
01473         FEDM_RETURN(FEDM_OK);
01474 }
01475 
01476 /***************************************************************************
01477   Begin                 :       02.03.2009 / M. Hultsch
01478 
01479   Version               :       03.01.00 / 10.02.2010 / B. Tschunko, M. Hultsch
01480 
01481   Function                      :       Read table from reader
01482 
01483   Parameters            :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
01484 
01485   Return value          :       FEDM_OK
01486                                                 or
01487                                                 < 0 in error case
01488 ***************************************************************************/
01489 int FedmIscMyAxxessReader::ReadTable(unsigned int uiTableID)
01490 {
01491         int iBack = 0;
01492 
01493         int iError = ValidateIDDSettings();
01494         if(iError)
01495                 return iError;
01496 
01497 
01498         switch (uiTableID)
01499         {
01500         case FEDM_MYAXXESS_CRC_LIST:
01501 
01502                 return ReadTable_CrcList();
01503                 break;
01504 
01505         case FEDM_MYAXXESS_METADATA:
01506 
01507                 return ReadTable_Metadata();
01508                 break;
01509 
01510         case FEDM_MYAXXESS_TIMEZONE_TABLE:
01511 
01512                 return ReadTable_Timezone();
01513                 break;
01514 
01515         case FEDM_MYAXXESS_HOLIDAY_TABLE:
01516 
01517                 return ReadTable_Holiday();
01518                 break;
01519 
01520         case FEDM_MYAXXESS_ACCESS_TABLE:
01521 
01522                 iBack = ReadTable_Metadata();
01523                 if (iBack != 0)
01524                         return iBack;
01525                 else
01526                         return ReadTable_Access();
01527                 break;
01528 
01529         case FEDM_MYAXXESS_EVENT_TABLE:
01530 
01531                 iBack = ReadTable_Metadata();
01532                 if (iBack != 0)
01533                         return iBack;
01534                 else
01535                         return ReadTable_Event();
01536                 break;
01537 
01538         default:
01539                 FEDM_RETURN(FEDM_ERROR_UNKNOWN_TABLE_ID);
01540         }
01541 
01542         FEDM_RETURN(FEDM_OK);
01543 }
01544 
01545 
01546 /***************************************************************************
01547   Begin                 :       24.09.2009 / M. Hultsch
01548 
01549   Version               :       03.01.00 / 10.02.2010 / M. Hultsch
01550 
01551   Function                      :       Start of receive thread for MAX events
01552 
01553   Parameters            :       unsigned int uiPortNr   - TCP/IP-Port
01554                                                 void* pAny                              - pointer to anything, which is reflected as the first parameter 
01555                                                                                                   in the callback function (e.g. can be used to pass the object pointer)
01556                                                 LPFN_FEDM_MYAXXESS_EVENT_CB cbEvent                     - callback function for access events
01557                                                 LPFN_FEDM_MYAXXESS_KEEPALIVE_CB cbKeepAlive     - callback function for keep alive notifications
01558                                                 int iAuthentType                - authentication type
01559                                                                                                   0 : AES 128
01560                                                                                                   1 : AES 192
01561                                                                                                   2 : AES 256
01562                                                 char* sAuthentKey               - authentication key in hex format (e.g. "0134A0F3...")
01563                                                                                                   key length must correspond to authent type
01564 
01565   Return value          :       FEDM_OK
01566                                                 or
01567                                                 < 0 in error case
01568 ***************************************************************************/
01569 int FedmIscMyAxxessReader::StartEventHandler(   unsigned int uiPortNr,
01570                                                                                                 void* pAny,
01571                                                                                                 LPFN_FEDM_MYAXXESS_EVENT_CB cbEvent,
01572                                                                                                 LPFN_FEDM_MYAXXESS_KEEPALIVE_CB cbKeepAlive,
01573                                                                                                 int iAuthentType,
01574                                                                                                 char* sAuthentKey )
01575 {
01576         int iBack = 0;
01577         FEISC_TASK_INIT TI;
01578 
01579         int iError = ValidateIDDSettings();
01580         if(iError)
01581                 return iError;
01582 
01583         if(m_pReaderModule->m_bActiveAsyncTask)
01584                 FEDM_RETURN(FEDM_ERROR_TASK_STILL_RUNNING);
01585 
01586         if(uiPortNr > 65535)
01587                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01588 
01589         switch(iAuthentType)
01590         {
01591         case 0:
01592         case 1:
01593         case 2:
01594                 FEDM_CHK5(sAuthentKey);
01595                 break;
01596         }
01597 
01598         // initialize task structure for this class
01599         memset(&m_pReaderModule->m_TaskInit, 0, sizeof(FEDM_TASK_INIT));
01600         m_pReaderModule->m_TaskInit.uiFlag              = FEDM_TASKCB3;
01601         m_pReaderModule->m_TaskInit.uiUse               = FEDM_TASKID_MAX_EVENT;
01602         m_pReaderModule->m_TaskInit.pAny                = pAny;
01603         m_pReaderModule->m_TaskInit.uiTimeout   = 30;   // in seconds
01604         m_cbEvent                               = cbEvent;
01605         m_cbKeepAlive                   = cbKeepAlive;
01606 
01607         m_uiEventCallerType     = 0;    // 0 for C++
01608                                                                 // 1 for .NET
01609 
01610         // initialize task structure for FEISC which handles the task
01611         memset(&TI, 0, sizeof(FEISC_TASK_INIT));
01612         TI.uiFlag                               = FEISC_TASKCB_3;
01613         TI.cbFct3                               = cbsTaskRsp3;          // static member function
01614         TI.uiChannelType                = FEISC_TASK_CHANNEL_TYPE_NEW_TCP;
01615         TI.ucBusAdr                             = m_pReaderModule->GetBusAddress();
01616         TI.iPortNr                              = uiPortNr;
01617         TI.pAny                                 = (void*)this;          // backpointer to caller object
01618         TI.uiTimeout                    = m_pReaderModule->m_TaskInit.uiTimeout;
01619 
01620         switch(iAuthentType)
01621         {
01622         case 0:
01623                 TI.bCryptoMode = true;
01624                 TI.uiAuthentKeyLength = 16;
01625                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 32, TI.ucAuthentKey, 16));
01626                 break;
01627         case 1:
01628                 TI.bCryptoMode = true;
01629                 TI.uiAuthentKeyLength = 24;
01630                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 48, TI.ucAuthentKey, 24));
01631                 break;
01632         case 2:
01633                 TI.bCryptoMode = true;
01634                 TI.uiAuthentKeyLength = 32;
01635                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 64, TI.ucAuthentKey, 32));
01636                 break;
01637         }
01638 
01639         TI.bKeepAlive = true;
01640         TI.uiKeepAliveIdleTime = 500;
01641         TI.uiKeepAliveProbeCount = 5;
01642         TI.uiKeepAliveIntervalTime = 500;
01643 
01644         FEDM_CHK2(iBack, FEISC_StartAsyncTask(m_pReaderModule->GetReaderHnd(), FEISC_TASKID_MAX_EVENT, &TI, NULL));
01645 
01646         m_pReaderModule->m_bActiveAsyncTask = true; // asynchronous task is started successfully
01647 
01648         FEDM_RETURN(FEDM_OK);
01649 }
01650 
01651 
01652 /***************************************************************************
01653   Begin                 :       24.09.2009 / M. Hultsch
01654 
01655   Version               :       04.00.00 / 28.07.2011 / M. Hultsch
01656                                                 - keep-alive option
01657 
01658                                                 03.01.00 / 10.02.2010 / M. Hultsch
01659 
01660   Function                      :       Start of receive thread for MAX events
01661                                                 NOTE: only for .NET-Wrapper
01662 
01663   Parameters            :       unsigned int uiPortNr   - TCP/IP-Port
01664                                                 void* pAny                              - pointer to anything, which is reflected as the first parameter 
01665                                                                                                   in the callback function (e.g. can be used to pass the object pointer)
01666                                                 LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB cbEvent                      - callback function for access events
01667                                                 LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB cbKeepAlive      - callback function for keep alive notifications
01668                                                 int iAuthentType                - authentication type
01669                                                                                                   0 : AES 128
01670                                                                                                   1 : AES 192
01671                                                                                                   2 : AES 256
01672                                                 char* sAuthentKey               - authentication key in hex format (e.g. "0134A0F3...")
01673                                                                                                   key length must correspond to authent type
01674 
01675   Return value          :       FEDM_OK
01676                                                 or
01677                                                 < 0 in error case
01678 ***************************************************************************/
01679 int FedmIscMyAxxessReader::StartEventHandler4DotNet(    unsigned int uiPortNr,
01680                                                                                                                 void* pAny,
01681                                                                                                                 LPFN_FEDM_MYAXXESS_EVENT_DOTNET_CB cbEvent,
01682                                                                                                                 LPFN_FEDM_MYAXXESS_KEEPALIVE_DOTNET_CB cbKeepAlive,
01683                                                                                                                 int iAuthentType,
01684                                                                                                                 char* sAuthentKey )
01685 {
01686         int iBack = 0;
01687         FEISC_TASK_INIT TI;
01688 
01689         int iError = ValidateIDDSettings();
01690         if(iError)
01691                 return iError;
01692 
01693         if(m_pReaderModule->m_bActiveAsyncTask)
01694                 FEDM_RETURN(FEDM_ERROR_TASK_STILL_RUNNING);
01695 
01696         if(uiPortNr > 65535)
01697                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01698 
01699         switch(iAuthentType)
01700         {
01701         case 0:
01702         case 1:
01703         case 2:
01704                 FEDM_CHK5(sAuthentKey);
01705                 break;
01706         }
01707 
01708         // initialize task structure for this class
01709         memset(&m_pReaderModule->m_TaskInit, 0, sizeof(FEDM_TASK_INIT));
01710         m_pReaderModule->m_TaskInit.uiFlag              = FEDM_TASKCB3;
01711         m_pReaderModule->m_TaskInit.uiUse               = FEDM_TASKID_MAX_EVENT;
01712         m_pReaderModule->m_TaskInit.pAny                = pAny;
01713         m_pReaderModule->m_TaskInit.uiTimeout   = 30;   // in seconds
01714         m_cbStdCallEvent                = cbEvent;
01715         m_cbStdCallKeepAlive    = cbKeepAlive;
01716 
01717         m_uiEventCallerType     =       1;      // 0 for C++
01718                                                                 // 1 for .NET
01719 
01720         // initialize task structure for FEISC which handles the task
01721         memset(&TI, 0, sizeof(FEISC_TASK_INIT));
01722         TI.uiFlag                               = FEISC_TASKCB_3;
01723         TI.cbFct3                               = cbsTaskRsp3;          // static member function
01724         TI.uiChannelType                = FEISC_TASK_CHANNEL_TYPE_NEW_TCP;
01725         TI.ucBusAdr                             = m_pReaderModule->GetBusAddress();
01726         TI.iPortNr                              = uiPortNr;
01727         TI.pAny                                 = (void*)this;          // backpointer to caller object
01728         TI.uiTimeout                    = m_pReaderModule->m_TaskInit.uiTimeout;
01729 
01730         switch(iAuthentType)
01731         {
01732         case 0:
01733                 TI.bCryptoMode = true;
01734                 TI.uiAuthentKeyLength = 16;
01735                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 32, TI.ucAuthentKey, 16));
01736                 break;
01737         case 1:
01738                 TI.bCryptoMode = true;
01739                 TI.uiAuthentKeyLength = 24;
01740                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 48, TI.ucAuthentKey, 24));
01741                 break;
01742         case 2:
01743                 TI.bCryptoMode = true;
01744                 TI.uiAuthentKeyLength = 32;
01745                 FEDM_CHK2(iBack, FEDM_ConvHexCharToHexUChar(sAuthentKey, 64, TI.ucAuthentKey, 32));
01746                 break;
01747         }
01748 
01749         TI.bKeepAlive = true;
01750         TI.uiKeepAliveIdleTime = 500;
01751         TI.uiKeepAliveProbeCount = 5;
01752         TI.uiKeepAliveIntervalTime = 500;
01753 
01754         FEDM_CHK2(iBack, FEISC_StartAsyncTask(m_pReaderModule->GetReaderHnd(), FEISC_TASKID_MAX_EVENT, &TI, NULL));
01755 
01756         m_pReaderModule->m_bActiveAsyncTask = true; // asynchronous task is started successfully
01757 
01758         FEDM_RETURN(FEDM_OK);
01759 }
01760 
01761 
01762 int FedmIscMyAxxessReader::StopEventHandler()
01763 {
01764         int iBack = m_pReaderModule->CancelAsyncTask();
01765 
01766         if(iBack == FEDM_OK)
01767         {
01768                 memset(&m_pReaderModule->m_TaskInit, 0, sizeof(FEDM_TASK_INIT));
01769                 m_cbEvent                       = NULL;
01770                 m_cbKeepAlive           = NULL;
01771         }
01772 
01773         return iBack;
01774 }
01775 
01776 
01778 // protected functions
01780 /***************************************************************************
01781   Begin         :       18.06.2009 / B. Tschunko
01782   Version       :       03.00.08 / 18.06.2009 / B. Tschunko
01783 
01784   Function              :       calculate checksum 
01785 
01786   Parameters    :       -
01787 
01788   Return value  :       unsigned int uiCrc      - checksum
01789 ***************************************************************************/
01790 unsigned int FedmIscMyAxxessReader::CalcCRC16CheckSum(unsigned short int uiCrcStart, 
01791                                                                                                           unsigned short int uiCrcPoly, 
01792                                                                                                           unsigned char* ucBuffer, 
01793                                                                                                           unsigned int uiBufLen)
01794 {
01795         unsigned short int uiCrc = uiCrcStart;
01796         unsigned int i, j;
01797 
01798         for(i=0;i<uiBufLen;i++)
01799         {
01800                 uiCrc ^= ucBuffer[i];
01801 
01802                 for(j=0; j<8; j++)
01803                 {
01804                         if(uiCrc & 0x0001)
01805                         {
01806                                 uiCrc = (unsigned short int)((uiCrc >> 1) ^ uiCrcPoly);
01807                         }
01808                         else
01809                         {
01810                                 uiCrc = (unsigned short int)(uiCrc >> 1);
01811                         }
01812                 }
01813         }
01814         return uiCrc;
01815 }
01816 
01817 int FedmIscMyAxxessReader::BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem)
01818 {
01819         unsigned char ucCnt = 0;
01820         char* sValue = NULL;
01821         unsigned int uiValue = 0;
01822 
01823         if (aName.size() != 5)
01824         {
01825                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01826         }
01827 
01828         pItem->Init();
01829 
01830         for (ucCnt = 0; ucCnt < aName.size(); ucCnt++)
01831         {
01832                 FEDM_STRUPR((char *)(aName[ucCnt].c_str()), aName[ucCnt].length()+1);
01833                 if (aName[ucCnt] == "DAYS")
01834                 {
01835                         // if no weekday is listed, then this item contains special time conditions for holidays
01836                         // thus, this is not a bug!
01837                         if(aValue[ucCnt].empty())
01838                         {
01839                                 continue;
01840                         }
01841 
01842                         FEDM_STRUPR((char *)(aValue[ucCnt].c_str()), aValue[ucCnt].length()+1);
01843                         sValue = strtok((char *)(aValue[ucCnt].c_str()), "+");
01844                         if (sValue != NULL)
01845                         {
01846                                 for (int iCnt = 0; iCnt < 7; iCnt++)
01847                                 {       
01848                                         if(!strcmp(sValue, "MO"))
01849                                                 pItem->ucDays |= 0x02;
01850                                         else if(!strcmp(sValue, "TU"))
01851                                                 pItem->ucDays |= 0x04;
01852                                         else if(!strcmp(sValue, "WE"))
01853                                                 pItem->ucDays |= 0x08;
01854                                         else if(!strcmp(sValue, "TH"))
01855                                                 pItem->ucDays |= 0x10;
01856                                         else if(!strcmp(sValue, "FR"))
01857                                                 pItem->ucDays |= 0x20;
01858                                         else if(!strcmp(sValue, "SA"))
01859                                                 pItem->ucDays |= 0x40;
01860                                         else if (!strcmp(sValue, "SU"))
01861                                                 pItem->ucDays |= 0x01;
01862                                         else
01863                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01864 
01865                                         sValue = strtok(NULL, "+");
01866                                         if (sValue == NULL)
01867                                         {
01868                                                 break;
01869                                         }
01870                                 }
01871                                 // too may days
01872                                 if (sValue != NULL)
01873                                 {
01874                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01875                                 }
01876                         }
01877                         else
01878                         {
01879                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01880                         }
01881                         continue;
01882                 }
01883                 else if (aName[ucCnt] == "DATEFROM")
01884                 {
01885                         sValue = strtok((char *)(aValue[ucCnt].c_str()), ".");
01886                         if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
01887                         {
01888                                 sscanf(sValue, "%d", &uiValue);
01889                                 if ((uiValue < 1) || (uiValue > 31))
01890                                 {
01891                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01892                                 }
01893                                 else
01894                                 {
01895                                         pItem->ucStartDate_Day = (unsigned char)(uiValue);
01896                                 }
01897 
01898                                 sValue = strtok(NULL, ".");
01899                                 if(sValue != NULL)
01900                                 {
01901                                         sscanf(sValue, "%d", &uiValue);
01902                                         if ((uiValue < 1) || (uiValue > 12))
01903                                         {
01904                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01905                                         }
01906                                         else
01907                                         {
01908                                                 pItem->ucStartDate_Month = (unsigned char)(uiValue);
01909                                         }
01910 
01911                                         sValue = strtok(NULL, ".");
01912                                         if(sValue != NULL)
01913                                         {
01914                                                 sscanf(sValue, "%d", &uiValue);
01915                                                 if (uiValue > 99)
01916                                                 {
01917                                                         if ((uiValue < 2000) || (uiValue > 2099))
01918                                                         {
01919                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01920                                                         }
01921                                                         else
01922                                                         {
01923                                                                 pItem->ucStartDate_Year = (unsigned char)(uiValue - 2000);
01924                                                                 continue;
01925                                                         }
01926                                                 }
01927                                                 else
01928                                                 {
01929                                                         pItem->ucStartDate_Year = (unsigned char)(uiValue);
01930                                                         continue;
01931                                                 }
01932                                         }
01933                                         else
01934                                         {
01935                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01936                                         }
01937                                 }
01938                                 else
01939                                 {
01940                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01941                                 }
01942                         }
01943                         else
01944                         {
01945                                 sValue = strtok((char *)(aValue[ucCnt].c_str()), "-");
01946                                 if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
01947                                 {
01948                                         sscanf(sValue, "%d", &uiValue);
01949                                         if (uiValue > 99)
01950                                         {
01951                                                 if ((uiValue < 2000) || (uiValue > 2099))
01952                                                 {
01953                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01954                                                 }
01955                                                 else
01956                                                 {
01957                                                         pItem->ucStartDate_Year = (unsigned char)(uiValue - 2000);
01958                                                 }
01959                                         }
01960                                         else
01961                                         {
01962                                                 pItem->ucStartDate_Year = (unsigned char)(uiValue);
01963                                         }
01964 
01965                                         sValue = strtok(NULL, "-");
01966                                         if(sValue != NULL)
01967                                         {
01968                                                 sscanf(sValue, "%d", &uiValue);
01969                                                 if ((uiValue < 1) || (uiValue > 12))
01970                                                 {
01971                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01972                                                 }
01973                                                 else
01974                                                 {
01975                                                         pItem->ucStartDate_Month = (unsigned char)(uiValue);
01976                                                 }
01977 
01978                                                 sValue = strtok(NULL, "-");
01979                                                 if(sValue != NULL)
01980                                                 {
01981                                                         sscanf(sValue, "%d", &uiValue);
01982                                                         if ((uiValue < 1) || (uiValue > 31))
01983                                                         {
01984                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01985                                                         }
01986                                                         else
01987                                                         {
01988                                                                 pItem->ucStartDate_Day = (unsigned char)(uiValue);
01989                                                                 continue;
01990                                                         }
01991                                                 }
01992                                                 else
01993                                                 {
01994                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
01995                                                 }
01996                                         }
01997                                         else
01998                                         {
01999                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02000                                         }
02001                                 }
02002                                 else
02003                                 {
02004                                         sValue = strtok((char *)(aValue[ucCnt].c_str()), "/");
02005                                         if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02006                                         {
02007                                                 sscanf(sValue, "%d", &uiValue);
02008                                                 if ((uiValue < 1) || (uiValue > 12))
02009                                                 {
02010                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02011                                                 }
02012                                                 else
02013                                                 {
02014                                                         pItem->ucStartDate_Month = (unsigned char)(uiValue);
02015                                                 }
02016 
02017                                                 sValue = strtok(NULL, "/");
02018                                                 if(sValue != NULL)
02019                                                 {
02020                                                         sscanf(sValue, "%d", &uiValue);
02021                                                         if ((uiValue < 1) || (uiValue > 31))
02022                                                         {
02023                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02024                                                         }
02025                                                         else
02026                                                         {
02027                                                                 pItem->ucStartDate_Day = (unsigned char)(uiValue);
02028                                                         }
02029 
02030                                                         sValue = strtok(NULL, "/");
02031                                                         if(sValue != NULL)
02032                                                         {
02033                                                                 sscanf(sValue, "%d", &uiValue);
02034                                                                 if (uiValue > 99)
02035                                                                 {
02036                                                                         if ((uiValue < 2000) || (uiValue > 2099))
02037                                                                         {
02038                                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02039                                                                         }
02040                                                                         else
02041                                                                         {
02042                                                                                 pItem->ucStartDate_Year = (unsigned char)(uiValue - 2000);
02043                                                                                 continue;
02044                                                                         }
02045                                                                 }
02046                                                                 else
02047                                                                 {
02048                                                                         pItem->ucStartDate_Year = (unsigned char)(uiValue);
02049                                                                         continue;
02050                                                                 }
02051                                                         }
02052                                                         else
02053                                                         {
02054                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02055                                                         }
02056                                                 }
02057                                                 else
02058                                                 {
02059                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02060                                                 }
02061                                         }
02062                                         else
02063                                         {
02064                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02065                                         }
02066                                 }
02067                         }
02068                 }
02069                 else if (aName[ucCnt] == "TIMEFROM")
02070                 {
02071                         sValue = strtok((char *)(aValue[ucCnt].c_str()), ":");
02072                         if(sValue != NULL)
02073                         {
02074                                 sscanf(sValue, "%d", &uiValue);
02075                                 if (uiValue > 23)
02076                                 {
02077                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02078                                 }
02079                                 else
02080                                 {
02081                                         pItem->ucStartTime_Hour = (unsigned char)(uiValue);
02082                                 }
02083 
02084                                 sValue = strtok(NULL, ":");
02085                                 if(sValue != NULL)
02086                                 {
02087                                         sscanf(sValue, "%d", &uiValue);
02088                                         if (uiValue > 59)
02089                                         {
02090                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02091                                         }
02092                                         else
02093                                         {
02094                                                 pItem->ucStartTime_Minute = (unsigned char)(uiValue);
02095                                                 continue;
02096                                         }
02097                                 }
02098                                 else
02099                                 {
02100                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02101                                 }
02102                         }
02103                         else
02104                         {
02105                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02106                         }
02107                 }
02108                 else if (aName[ucCnt] == "DATETO")
02109                 {
02110                         sValue = strtok((char *)(aValue[ucCnt].c_str()), ".");
02111                         if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02112                         {
02113                                 sscanf(sValue, "%d", &uiValue);
02114                                 if ((uiValue < 1) || (uiValue > 31))
02115                                 {
02116                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02117                                 }
02118                                 else
02119                                 {
02120                                         pItem->ucEndDate_Day = (unsigned char)(uiValue);
02121                                 }
02122 
02123                                 sValue = strtok(NULL, ".");
02124                                 if(sValue != NULL)
02125                                 {
02126                                         sscanf(sValue, "%d", &uiValue);
02127                                         if ((uiValue < 1) || (uiValue > 12))
02128                                         {
02129                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02130                                         }
02131                                         else
02132                                         {
02133                                                 pItem->ucEndDate_Month = (unsigned char)(uiValue);
02134                                         }
02135 
02136                                         sValue = strtok(NULL, ".");
02137                                         if(sValue != NULL)
02138                                         {
02139                                                 sscanf(sValue, "%d", &uiValue);
02140                                                 if (uiValue > 99)
02141                                                 {
02142                                                         if ((uiValue < 2000) || (uiValue > 2099))
02143                                                         {
02144                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02145                                                         }
02146                                                         else
02147                                                         {
02148                                                                 pItem->ucEndDate_Year = (unsigned char)(uiValue - 2000);
02149                                                                 continue;
02150                                                         }
02151                                                 }
02152                                                 else
02153                                                 {
02154                                                         pItem->ucEndDate_Year = (unsigned char)(uiValue);
02155                                                         continue;
02156                                                 }
02157                                         }
02158                                         else
02159                                         {
02160                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02161                                         }
02162                                 }
02163                                 else
02164                                 {
02165                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02166                                 }
02167                         }
02168                         else
02169                         {
02170                                 sValue = strtok((char *)(aValue[ucCnt].c_str()), "-");
02171                                 if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02172                                 {
02173                                         sscanf(sValue, "%d", &uiValue);
02174                                         if (uiValue > 99)
02175                                         {
02176                                                 if ((uiValue < 2000) || (uiValue > 2099))
02177                                                 {
02178                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02179                                                 }
02180                                                 else
02181                                                 {
02182                                                         pItem->ucEndDate_Year = (unsigned char)(uiValue - 2000);
02183                                                 }
02184                                         }
02185                                         else
02186                                         {
02187                                                 pItem->ucEndDate_Year = (unsigned char)(uiValue);
02188                                         }
02189 
02190                                         sValue = strtok(NULL, "-");
02191                                         if(sValue != NULL)
02192                                         {
02193                                                 sscanf(sValue, "%d", &uiValue);
02194                                                 if ((uiValue < 1) || (uiValue > 12))
02195                                                 {
02196                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02197                                                 }
02198                                                 else
02199                                                 {
02200                                                         pItem->ucEndDate_Month = (unsigned char)(uiValue);
02201                                                 }
02202 
02203                                                 sValue = strtok(NULL, "-");
02204                                                 if(sValue != NULL)
02205                                                 {
02206                                                         sscanf(sValue, "%d", &uiValue);
02207                                                         if ((uiValue < 1) || (uiValue > 31))
02208                                                         {
02209                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02210                                                         }
02211                                                         else
02212                                                         {
02213                                                                 pItem->ucEndDate_Day = (unsigned char)(uiValue);
02214                                                                 continue;
02215                                                         }
02216                                                 }
02217                                                 else
02218                                                 {
02219                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02220                                                 }
02221                                         }
02222                                         else
02223                                         {
02224                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02225                                         }
02226                                 }
02227                                 else
02228                                 {
02229                                         sValue = strtok((char *)(aValue[ucCnt].c_str()), "/");
02230                                         if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02231                                         {
02232                                                 sscanf(sValue, "%d", &uiValue);
02233                                                 if ((uiValue < 1) || (uiValue > 12))
02234                                                 {
02235                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02236                                                 }
02237                                                 else
02238                                                 {
02239                                                         pItem->ucEndDate_Month = (unsigned char)(uiValue);
02240                                                 }
02241 
02242                                                 sValue = strtok(NULL, "/");
02243                                                 if(sValue != NULL)
02244                                                 {
02245                                                         sscanf(sValue, "%d", &uiValue);
02246                                                         if ((uiValue < 1) || (uiValue > 31))
02247                                                         {
02248                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02249                                                         }
02250                                                         else
02251                                                         {
02252                                                                 pItem->ucEndDate_Day = (unsigned char)(uiValue);
02253                                                         }
02254 
02255                                                         sValue = strtok(NULL, "/");
02256                                                         if(sValue != NULL)
02257                                                         {
02258                                                                 sscanf(sValue, "%d", &uiValue);
02259                                                                 if (uiValue > 99)
02260                                                                 {
02261                                                                         if ((uiValue < 2000) || (uiValue > 2099))
02262                                                                         {
02263                                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02264                                                                         }
02265                                                                         else
02266                                                                         {
02267                                                                                 pItem->ucEndDate_Year = (unsigned char)(uiValue - 2000);
02268                                                                                 continue;
02269                                                                         }
02270                                                                 }
02271                                                                 else
02272                                                                 {
02273                                                                         pItem->ucEndDate_Year = (unsigned char)(uiValue);
02274                                                                         continue;
02275                                                                 }
02276                                                         }
02277                                                         else
02278                                                         {
02279                                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02280                                                         }
02281                                                 }
02282                                                 else
02283                                                 {
02284                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02285                                                 }
02286                                         }
02287                                         else
02288                                         {
02289                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02290                                         }
02291                                 }
02292                         }
02293                 }
02294                 else if (aName[ucCnt] =="TIMETO")
02295                 {
02296                         sValue = strtok((char *)(aValue[ucCnt].c_str()), ":");
02297                         if(sValue != NULL)
02298                         {
02299                                 sscanf(sValue, "%d", &uiValue);
02300                                 if (uiValue > 23)
02301                                 {
02302                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02303                                 }
02304                                 else
02305                                 {
02306                                         pItem->ucEndTime_Hour = (unsigned char)(uiValue);
02307                                 }
02308 
02309                                 sValue = strtok(NULL, ":");
02310                                 if(sValue != NULL)
02311                                 {
02312                                         sscanf(sValue, "%d", &uiValue);
02313                                         if (uiValue > 59)
02314                                         {
02315                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02316                                         }
02317                                         else
02318                                         {
02319                                                 pItem->ucEndTime_Minute = (unsigned char)(uiValue);
02320                                                 continue;
02321                                         }
02322                                 }
02323                                 else
02324                                 {
02325                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02326                                 }
02327                         }
02328                         else
02329                         {
02330                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02331                         }
02332                 }
02333                 else
02334                 {
02335                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02336                 }
02337         }
02338 
02339         FEDM_RETURN(FEDM_OK);
02340 }
02341 
02342 int FedmIscMyAxxessReader::BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem)
02343 {
02344         unsigned char ucCnt = 0;
02345         char* sValue = NULL;
02346         unsigned int uiValue = 0;
02347 
02348         if (aName.size() != 1)
02349         {
02350                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02351         }
02352 
02353         pItem->Init();
02354 
02355         FEDM_STRUPR((char *)(aName[ucCnt].c_str()), aName[ucCnt].length()+1);
02356         if (aName[ucCnt] == "HOLIDAY")
02357         {
02358                 sValue = strtok((char *)(aValue[ucCnt].c_str()), ".");
02359                 if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02360                 {
02361                         sscanf(sValue, "%d", &uiValue);
02362                         if ((uiValue < 1) || (uiValue > 31))
02363                         {
02364                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02365                         }
02366                         else
02367                         {
02368                                 pItem->ucHoliday_Day = (unsigned char)(uiValue);
02369                         }
02370 
02371                         sValue = strtok(NULL, ".");
02372                         if(sValue != NULL)
02373                         {
02374                                 sscanf(sValue, "%d", &uiValue);
02375                                 if ((uiValue < 1) || (uiValue > 12))
02376                                 {
02377                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02378                                 }
02379                                 else
02380                                 {
02381                                         pItem->ucHoliday_Month = (unsigned char)(uiValue);
02382                                 }
02383 
02384                                 sValue = strtok(NULL, ".");
02385                                 if(sValue != NULL)
02386                                 {
02387                                         sscanf(sValue, "%d", &uiValue);
02388                                         if (uiValue > 99)
02389                                         {
02390                                                 if ((uiValue < 2000) || (uiValue > 2099))
02391                                                 {
02392                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02393                                                 }
02394                                                 else
02395                                                 {
02396                                                         pItem->ucHoliday_Year = (unsigned char)(uiValue - 2000);
02397                                                         //continue;
02398                                                 }
02399                                         }
02400                                         else
02401                                         {
02402                                                 pItem->ucHoliday_Year = (unsigned char)(uiValue);
02403                                                 //continue;
02404                                         }
02405                                 }
02406                                 else
02407                                 {
02408                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02409                                 }
02410                         }
02411                         else
02412                         {
02413                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02414                         }
02415                 }
02416                 else
02417                 {
02418                         sValue = strtok((char *)(aValue[ucCnt].c_str()), "-");
02419                         if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02420                         {
02421                                 sscanf(sValue, "%d", &uiValue);
02422                                 if (uiValue > 99)
02423                                 {
02424                                         if ((uiValue < 2000) || (uiValue > 2099))
02425                                         {
02426                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02427                                         }
02428                                         else
02429                                         {
02430                                                 pItem->ucHoliday_Year = (unsigned char)(uiValue - 2000);
02431                                                 //continue;
02432                                         }
02433                                 }
02434                                 else
02435                                 {
02436                                         pItem->ucHoliday_Year = (unsigned char)(uiValue);
02437                                 }
02438 
02439                                 sValue = strtok(NULL, "-");
02440                                 if(sValue != NULL)
02441                                 {
02442                                         sscanf(sValue, "%d", &uiValue);
02443                                         if ((uiValue < 1) || (uiValue > 12))
02444                                         {
02445                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02446                                         }
02447                                         else
02448                                         {
02449                                                 pItem->ucHoliday_Month = (unsigned char)(uiValue);
02450                                         }
02451 
02452                                         sValue = strtok(NULL, "-");
02453                                         if(sValue != NULL)
02454                                         {
02455                                                 sscanf(sValue, "%d", &uiValue);
02456                                                 if ((uiValue < 1) || (uiValue > 31))
02457                                                 {
02458                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02459                                                 }
02460                                                 else
02461                                                 {
02462                                                         pItem->ucHoliday_Day = (unsigned char)(uiValue);
02463                                                         //continue;
02464                                                 }
02465                                         }
02466                                         else
02467                                         {
02468                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02469                                         }
02470                                 }
02471                                 else
02472                                 {
02473                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02474                                 }
02475                         }
02476                         else
02477                         {
02478                                 sValue = strtok((char *)(aValue[ucCnt].c_str()), "/");
02479                                 if((sValue != NULL) && ((strlen(sValue)) != (aValue[ucCnt].length())))
02480                                 {
02481                                         sscanf(sValue, "%d", &uiValue);
02482                                         if ((uiValue < 1) || (uiValue > 12))
02483                                         {
02484                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02485                                         }
02486                                         else
02487                                         {
02488                                                 pItem->ucHoliday_Month = (unsigned char)(uiValue);
02489                                         }
02490 
02491                                         sValue = strtok(NULL, "/");
02492                                         if(sValue != NULL)
02493                                         {
02494                                                 sscanf(sValue, "%d", &uiValue);
02495                                                 if ((uiValue < 1) || (uiValue > 31))
02496                                                 {
02497                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02498                                                 }
02499                                                 else
02500                                                 {
02501                                                         pItem->ucHoliday_Day = (unsigned char)(uiValue);
02502                                                 }
02503 
02504                                                 sValue = strtok(NULL, "/");
02505                                                 if(sValue != NULL)
02506                                                 {
02507                                                         sscanf(sValue, "%d", &uiValue);
02508                                                         if (uiValue > 99)
02509                                                         {
02510                                                                 if ((uiValue < 2000) || (uiValue > 2099))
02511                                                                 {
02512                                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02513                                                                 }
02514                                                                 else
02515                                                                 {
02516                                                                         pItem->ucHoliday_Year = (unsigned char)(uiValue - 2000);
02517                                                                         //continue;
02518                                                                 }
02519                                                         }
02520                                                         else
02521                                                         {
02522                                                                 pItem->ucHoliday_Year = (unsigned char)(uiValue);
02523                                                                 //continue;
02524                                                         }
02525                                                 }
02526                                                 else
02527                                                 {
02528                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02529                                                 }
02530                                         }
02531                                         else
02532                                         {
02533                                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02534                                         }
02535                                 }
02536                                 else
02537                                 {
02538                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02539                                 }
02540                         }
02541                 }
02542         }
02543         else
02544         {
02545                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02546         }
02547 
02548         FEDM_RETURN(FEDM_OK);
02549 }
02550 
02551 int FedmIscMyAxxessReader::BuildTableItem(vector<string> aName, vector<string> aValue, FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem)
02552 {
02553         unsigned char ucCnt = 0;
02554         char* sValue = NULL;
02555         unsigned int uiValue = 0;
02556 
02557         unsigned char ucByte = 0;
02558         unsigned __int64 ui64Value = 0;
02559 
02560         bool bOptReserved = false;
02561 
02562         string sIDD;
02563 
02564         if ((aName.size() == 2))
02565         {
02566                 bOptReserved = false;
02567         }
02568         else if ((aName.size() == 3))
02569         {
02570                 bOptReserved = true;
02571         }
02572         else
02573         {
02574                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02575         }
02576 
02577         pItem ->Init();
02578 
02579         for (ucCnt = 0; ucCnt < aName.size(); ucCnt++)
02580         {
02581                 FEDM_STRUPR((char *)(aName[ucCnt].c_str()), aName[ucCnt].length()+1);
02582                 if (aName[ucCnt] == "IDD")
02583                 {
02584                         switch(m_Metadata.ucIDDFormat)
02585                         {
02586                         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
02587                                 if(aValue[ucCnt].length() != m_Metadata.ucIDDLength)
02588                                 {
02589                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
02590                                 }
02591 
02592                                 memcpy (pItem->ucIDD, aValue[ucCnt].c_str(), m_Metadata.ucIDDLength);
02593                                 break;
02594 
02595                         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
02596                                 if(aValue[ucCnt].length() > 20)
02597                                 {
02598                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
02599                                 }
02600 
02601                                 sscanf(aValue[ucCnt].c_str(), "%lld", &ui64Value);
02602                                 for (ucByte = 0; ucByte < m_Metadata.ucIDDLength; ucByte++)
02603                                 {
02604                                         // change intel in motorola format
02605                                         pItem->ucIDD[m_Metadata.ucIDDLength-ucByte-1] = *( ((unsigned char*)&ui64Value) + ucByte );
02606                                 }
02607                                 if ((ucByte < 8) && (*( ((unsigned char*)&ui64Value) + ucByte ) != 0))
02608                                 {
02609                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
02610                                 }
02611 
02612                                 // set all not used byte to zero
02613                                 memset(&pItem->ucIDD[m_Metadata.ucIDDLength], 0, 128-m_Metadata.ucIDDLength);
02614                                 break;
02615 
02616                         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
02617                                 if( (aValue[ucCnt].length()%2) ||               // IDD not even
02618                                         (aValue[ucCnt].length() == 0) ||        // no IDD string
02619                                         (aValue[ucCnt].length() > (size_t)(m_Metadata.ucIDDLength<<1)) ) // IDD too long
02620                                 {
02621                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
02622                                 }
02623                                 else if(aValue[ucCnt].length() == (size_t)(m_Metadata.ucIDDLength<<1))
02624                                 {
02625                                         for(size_t i=aValue[ucCnt].length(); i<(size_t)(m_Metadata.ucIDDLength<<1); i+=2)
02626                                                 sIDD += "00";
02627 
02628                                         sIDD += aValue[ucCnt];
02629                                 }
02630                                 else
02631                                 {
02632                                         sIDD = aValue[ucCnt];
02633                                 }
02634 
02635                                 FEDM_ConvHexCharToHexUChar((char *)sIDD.c_str(), (m_Metadata.ucIDDLength<<1), pItem->ucIDD, 128);
02636                                 break;
02637 
02638                         default:
02639                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02640 
02641                         }
02642                         continue;
02643                 }
02644                 else if (aName[ucCnt] == "TIMEZONES")
02645                 {
02646                         sValue = strtok((char *)(aValue[ucCnt].c_str()), "+");
02647                         if (sValue != NULL)
02648                         {
02649                                 for (int iCnt = 0; iCnt < 16; iCnt++)
02650                                 {
02651                                         sscanf(sValue, "%d", &uiValue);
02652                                         if ((uiValue > 0) && (uiValue < 17))
02653                                         {
02654                                                 // set bit for timezone
02655                                                 pItem->uiTimezones |= (0x01<<(uiValue-1));
02656                                         }
02657                                         else
02658                                         {
02659                                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02660                                         }
02661 
02662                                         sValue = strtok(NULL, "+");
02663                                         if (sValue == NULL)
02664                                         {
02665                                                 break;
02666                                         }
02667                                 }
02668                                 // too may days
02669                                 if (sValue != NULL)
02670                                 {
02671                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02672                                 }
02673                         }
02674                         else
02675                         {
02676                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02677                         }
02678                         continue;
02679 
02680                 }
02681                 else if (aName[ucCnt] =="RESERVED")
02682                 {
02683                         if (!bOptReserved)
02684                         {
02685                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02686                         }
02687 
02688                         sscanf(aValue[ucCnt].c_str(), "%d", &uiValue);
02689                         pItem->ucReserved = (unsigned char)(uiValue);
02690                         continue;
02691                 }
02692                 else
02693                 {
02694                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02695                 }
02696         }
02697 
02698         FEDM_RETURN(FEDM_OK);
02699 }
02700 
02701 
02702 int FedmIscMyAxxessReader::GetTableItem_Timezone(unsigned int uiIndex, char* sItem)
02703 {
02704         unsigned int uiNextIndex = 1;
02705         bool bAddPlus = false;
02706         string szDays;
02707 
02708         if ((uiIndex < 1) || (uiIndex > m_TimezoneTable.size()))
02709         {
02710                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02711         }
02712 
02713         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*  pTimezoneItem   = NULL;
02714         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itorTimezone;
02715 
02716         // search Timezone Table
02717         for(itorTimezone  = m_TimezoneTable.begin();
02718                 itorTimezone != m_TimezoneTable.end();
02719                 itorTimezone++)
02720         {
02721                 if ((*itorTimezone) == NULL)
02722                         continue;
02723 
02724                 if (uiNextIndex++ != uiIndex)
02725                         continue;
02726 
02727                 pTimezoneItem = *itorTimezone;
02728 
02729                 // built item
02730                 for (unsigned char ucDay = 0; ucDay < 7; ucDay++)
02731                 {
02732                         if ((pTimezoneItem->ucDays >> ucDay) && 0x01)
02733                         {
02734                                 if (bAddPlus)
02735                                         szDays += "+";
02736 
02737                                 switch (ucDay)
02738                                 {
02739                                 case 0:
02740                                         szDays += "Mo";
02741                                         break;
02742 
02743                                 case 1:
02744                                         szDays += "Tu";
02745                                         break;
02746 
02747                                 case 2:
02748                                         szDays += "We";
02749                                         break;
02750 
02751                                 case 3:
02752                                         szDays += "Th";
02753                                         break;
02754 
02755                                 case 4:
02756                                         szDays += "Fr";
02757                                         break;
02758 
02759                                 case 5:
02760                                         szDays += "Sa";
02761                                         break;
02762 
02763                                 case 6:
02764                                         szDays += "Su";
02765                                         break;
02766 
02767 
02768                                 }
02769                                 bAddPlus = true;
02770                         }
02771                 }
02772 
02773                 switch (m_ucDateFormat)
02774                 {
02775                 case FEDM_MYAXXESS_DATE_FORMAT_ISO8601:
02776                         sprintf(sItem, 
02777                                         "Days=%s;DateFrom=20%02d-%02d-%02d;TimeFrom=%02d:%02d;DateTo=20%02d-%02d-%02d;TimeTo=%02d:%02d",        
02778                                         szDays.c_str(),
02779                                         pTimezoneItem->ucStartDate_Year, 
02780                                         pTimezoneItem->ucStartDate_Month,
02781                                         pTimezoneItem->ucStartDate_Day,
02782                                         pTimezoneItem->ucStartTime_Hour,
02783                                         pTimezoneItem->ucStartTime_Minute, 
02784                                         pTimezoneItem->ucEndDate_Year, 
02785                                         pTimezoneItem->ucEndDate_Month,
02786                                         pTimezoneItem->ucEndDate_Day,
02787                                         pTimezoneItem->ucEndTime_Hour,
02788                                         pTimezoneItem->ucEndTime_Minute);
02789                         break;
02790 
02791                 case FEDM_MYAXXESS_DATE_FORMAT_GER:
02792                         sprintf(sItem, 
02793                                         "Days=%s;DateFrom=%02d.%02d.20%02d;TimeFrom=%02d:%02d;DateTo=%02d.%02d.20%02d;TimeTo=%02d:%02d",        
02794                                         szDays.c_str(),
02795                                         pTimezoneItem->ucStartDate_Day,
02796                                         pTimezoneItem->ucStartDate_Month,
02797                                         pTimezoneItem->ucStartDate_Year, 
02798                                         pTimezoneItem->ucStartTime_Hour,
02799                                         pTimezoneItem->ucStartTime_Minute, 
02800                                         pTimezoneItem->ucEndDate_Day,
02801                                         pTimezoneItem->ucEndDate_Month,
02802                                         pTimezoneItem->ucEndDate_Year, 
02803                                         pTimezoneItem->ucEndTime_Hour,
02804                                         pTimezoneItem->ucEndTime_Minute);
02805                         break;
02806 
02807                 case FEDM_MYAXXESS_DATE_FORMAT_US:
02808                         sprintf(sItem, 
02809                                         "Days=%s;DateFrom=%02d/%02d/20%02d;TimeFrom=%02d:%02d;DateTo=%02d/%02d/20%02d;TimeTo=%02d:%02d",        
02810                                         szDays.c_str(),
02811                                         pTimezoneItem->ucStartDate_Month,
02812                                         pTimezoneItem->ucStartDate_Day,
02813                                         pTimezoneItem->ucStartDate_Year, 
02814                                         pTimezoneItem->ucStartTime_Hour,
02815                                         pTimezoneItem->ucStartTime_Minute, 
02816                                         pTimezoneItem->ucEndDate_Month,
02817                                         pTimezoneItem->ucEndDate_Day,
02818                                         pTimezoneItem->ucEndDate_Year, 
02819                                         pTimezoneItem->ucEndTime_Hour,
02820                                         pTimezoneItem->ucEndTime_Minute);
02821                         break;
02822 
02823                 default:
02824                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02825                 }
02826 
02827                 break;
02828         }
02829 
02830         if (uiNextIndex > m_TimezoneTable.size())
02831         {
02832                 uiNextIndex = 0;
02833         }
02834 
02835         return ((int)uiNextIndex);
02836 }
02837 
02838 
02839 int FedmIscMyAxxessReader::GetTableItem_Holiday(unsigned int uiIndex, char* sItem)
02840 {
02841         unsigned int uiNextIndex = 1;
02842 
02843         if ((uiIndex < 1) || (uiIndex > m_HolidayTable.size()))
02844         {
02845                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02846         }
02847 
02848         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*   pHolidayItem    = NULL;
02849         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itorHoliday;
02850 
02851         // search Holiday Table
02852         for(itorHoliday  = m_HolidayTable.begin();
02853                 itorHoliday != m_HolidayTable.end();
02854                 itorHoliday++)
02855         {
02856                 if ((*itorHoliday) == NULL)
02857                         continue;
02858 
02859                 if (uiNextIndex++ != uiIndex)
02860                         continue;
02861 
02862                 pHolidayItem = *itorHoliday;
02863 
02864                 // built item
02865                 switch (m_ucDateFormat)
02866                 {
02867                 case FEDM_MYAXXESS_DATE_FORMAT_ISO8601:
02868                         sprintf(sItem, 
02869                                         "Holiday=20%02d-%02d-%02d",     
02870                                         pHolidayItem->ucHoliday_Year,           
02871                                         pHolidayItem->ucHoliday_Month,          
02872                                         pHolidayItem->ucHoliday_Day);
02873                         break;
02874 
02875                 case FEDM_MYAXXESS_DATE_FORMAT_GER:
02876                         sprintf(sItem,
02877                                         "Holiday=%02d.%02d.20%02d",
02878                                         pHolidayItem->ucHoliday_Day,
02879                                         pHolidayItem->ucHoliday_Month,
02880                                         pHolidayItem->ucHoliday_Year);
02881                         break;
02882 
02883                 case FEDM_MYAXXESS_DATE_FORMAT_US:
02884                         sprintf(sItem, 
02885                                         "Holiday=%02d/%02d/20%02d",
02886                                         pHolidayItem->ucHoliday_Month,
02887                                         pHolidayItem->ucHoliday_Day,
02888                                         pHolidayItem->ucHoliday_Year);
02889                         break;
02890 
02891                 default:
02892                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02893 
02894                 }
02895                 break;
02896         }
02897 
02898         if (uiNextIndex > m_HolidayTable.size())
02899         {
02900                 uiNextIndex = 0;
02901         }
02902 
02903         return ((int)uiNextIndex);
02904 }
02905 
02906 
02907 int FedmIscMyAxxessReader::GetTableItem_Access(unsigned int uiIndex, char* sItem)
02908 {
02909         unsigned int uiNextIndex = 1;
02910         char szIDD[256];
02911         unsigned __int64 ui64IDD = 0;
02912         bool bAddPlus = false;
02913         char szTimezones[32];
02914 
02915         if ((uiIndex < 1) || (uiIndex > m_AccessTable.size()))
02916         {
02917                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
02918         }
02919 
02920         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*    pAccessItem     = NULL;
02921         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator itorAccess;
02922 
02923         // search Access Table
02924         for(itorAccess  = m_AccessTable.begin();
02925                 itorAccess != m_AccessTable.end();
02926                 itorAccess++)
02927         {
02928                 if ((*itorAccess) == NULL)
02929                         continue;
02930 
02931                 if (uiNextIndex++ != uiIndex)
02932                         continue;
02933 
02934                 pAccessItem = *itorAccess;
02935 
02936                 // built item
02937                 switch(m_Metadata.ucIDDFormat)
02938                 {
02939                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
02940                         memcpy(szIDD, pAccessItem->ucIDD, m_Metadata.ucIDDLength);
02941                         szIDD[m_Metadata.ucIDDLength] = '\0';
02942                         break;
02943 
02944                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
02945                         if(strlen((char*)pAccessItem->ucIDD) > 20)
02946                         {
02947                                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
02948                         }
02949                         ui64IDD = 0;
02950                         for (unsigned char ucByte = 0; ucByte < m_Metadata.ucIDDLength; ucByte++)
02951                         {
02952                                 // change Motorola format to Intel format
02953                                 ui64IDD += ( (unsigned __int64)pAccessItem->ucIDD[m_Metadata.ucIDDLength-ucByte-1] << (8*ucByte) );
02954                         }
02955                         sprintf(szIDD,"%lld",ui64IDD);
02956                         break;
02957 
02958                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
02959                         FEDM_ConvHexUCharToHexChar(pAccessItem->ucIDD, m_Metadata.ucIDDLength, szIDD, 256);
02960                         break;
02961 
02962                 default:
02963                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
02964                 }
02965 
02966 
02967                 for (unsigned char ucCnt = 0; ucCnt < 16; ucCnt++)
02968                 {
02969                         if (pAccessItem->uiTimezones & (0x01 << ucCnt))
02970                         {
02971                                 if (bAddPlus)
02972                                         sprintf(szTimezones, "%s+%d", szTimezones, ucCnt+1);
02973                                 else
02974                                         sprintf(szTimezones, "%d", ucCnt+1);
02975                                 bAddPlus = true;
02976                         }
02977                 }
02978 
02979                 sprintf(sItem, 
02980                                 "IDD=%s;Timezones=%s;Reserved=%d",      
02981                                 szIDD,
02982                                 szTimezones,
02983                                 pAccessItem->ucReserved);
02984                 break;
02985         }
02986 
02987         if (uiNextIndex > m_AccessTable.size())
02988         {
02989                 uiNextIndex = 0;
02990         }
02991 
02992         return ((int)uiNextIndex);
02993 }
02994 
02995 
02996 int FedmIscMyAxxessReader::GetTableItem_Event(char* sItem)
02997 {
02998         char    szIDD[256];
02999         char    szTimestamp[64];
03000         char    szStatus[32];
03001         char    szInput[32];
03002         char    szAnt[32];
03003         unsigned __int64 ui64IDD = 0;
03004 
03005         // search Event Table
03006         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*     pEventItem      = NULL;
03007 
03008         if(m_EventTable.empty())
03009         {
03010                 FEDM_RETURN(FEDM_ERROR_NO_TABLE_DATA);
03011         }
03012 
03013         pEventItem = m_EventTable.front();
03014 
03015         if(pEventItem == NULL)
03016         {
03017                 FEDM_RETURN(FEDM_ERROR_NULL_POINTER);
03018         }
03019 
03020         memset(szIDD, 0, 32);
03021         memset(szTimestamp, 0, 64);
03022         memset(szStatus, 0, 32);
03023         memset(szInput, 0, 32);
03024         memset(szAnt, 0, 32);
03025 
03026         sprintf(sItem,
03027                         "EventID=%d;",  
03028                         pEventItem->ucEventID);
03029 
03030         if(pEventItem->ucDataLayout & 0x01)
03031         {
03032                 switch(m_Metadata.ucIDDFormat)
03033                 {
03034                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
03035                         memcpy(szIDD, pEventItem->ucIDD, pEventItem->ucIDDLength);
03036                         szIDD[pEventItem->ucIDDLength] = '\0';
03037                         break;
03038 
03039                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
03040                         if(strlen((char*)pEventItem->ucIDD) > 20)
03041                         {
03042                                 m_EventTable.pop();
03043                                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
03044                         }       
03045                         ui64IDD = 0;
03046                         for(unsigned char ucByte=0; ucByte<pEventItem->ucIDDLength; ucByte++ )
03047                         {
03048                                 // change Motorola format to Intel format
03049                                 ui64IDD += ( (unsigned __int64)pEventItem->ucIDD[pEventItem->ucIDDLength-ucByte-1] << (8*ucByte) );
03050                         }
03051                         sprintf(szIDD,"%lld",ui64IDD);
03052                         break;
03053 
03054                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
03055                         FEDM_ConvHexUCharToHexChar(pEventItem->ucIDD, pEventItem->ucIDDLength, szIDD, 256);
03056                         break;
03057 
03058                 default:
03059                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03060                 }
03061 
03062                 strcat(sItem, "IDD=");
03063                 strcat(sItem, szIDD);
03064                 strcat(sItem, ";");
03065         }
03066 
03067         if(pEventItem->ucDataLayout & 0x02)
03068         {
03069                 switch (m_ucDateFormat)
03070                 {
03071                 case FEDM_MYAXXESS_DATE_FORMAT_ISO8601:
03072                         sprintf(szTimestamp, 
03073                                         "Date=20%02d-%02d-%02d;Time=%02d:%02d;",        
03074                                         pEventItem->ucYear, 
03075                                         pEventItem->ucMonth, 
03076                                         pEventItem->ucDay, 
03077                                         pEventItem->ucHour, 
03078                                         pEventItem->ucMinute);
03079                         break;
03080 
03081                 case FEDM_MYAXXESS_DATE_FORMAT_GER:
03082                         sprintf(szTimestamp, 
03083                                         "Date=%02d.%02d.20%02d;Time=%02d:%02d;",
03084                                         pEventItem->ucDay, 
03085                                         pEventItem->ucMonth, 
03086                                         pEventItem->ucYear,
03087                                         pEventItem->ucHour, 
03088                                         pEventItem->ucMinute);
03089                         break;
03090 
03091                 case FEDM_MYAXXESS_DATE_FORMAT_US:
03092                         sprintf(szTimestamp,
03093                                         "Date=%02d/%02d/20%02d;Time=%02d:%02d;",
03094                                         pEventItem->ucMonth,
03095                                         pEventItem->ucDay, 
03096                                         pEventItem->ucYear,
03097                                         pEventItem->ucHour, 
03098                                         pEventItem->ucMinute);
03099                         break;
03100 
03101                 default:
03102                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03103                 }
03104 
03105                 strcat(sItem, szTimestamp);
03106         }
03107 
03108         if(pEventItem->ucDataLayout & 0x08)
03109         {
03110                 sprintf(szInput,
03111                                 "Input=%d;",
03112                                 pEventItem->ucInput);
03113 
03114                 strcat(sItem, szInput);
03115         }
03116 
03117         if(pEventItem->ucDataLayout & 0x10)
03118         {
03119                 sprintf(szAnt,
03120                                 "Ant=%d;",
03121                                 pEventItem->ucAnt);
03122 
03123                 strcat(sItem, szAnt);
03124         }
03125 
03126         if(pEventItem->ucDataLayout & 0x04)
03127         {
03128                 sprintf(szStatus,
03129                                 "Action=%d;Error=%i;",  
03130                                 pEventItem->ucAction,
03131                                 pEventItem->uiError);
03132 
03133                 strcat(sItem, szStatus);
03134         }
03135 
03136         strcat(sItem, "Source=");
03137         strcat(sItem, pEventItem->sSourceIP.c_str());
03138 
03139         // item must be deleted, because item is no longer controlled by the queue
03140         m_EventTable.pop();
03141 
03142         FEDM_RETURN(FEDM_OK);
03143 }
03144 
03145 
03146 int FedmIscMyAxxessReader::WriteTables_CrcList()
03147 {
03148         int iOutLen = 0;
03149         int iInLen = 0;
03150 
03151         int iBack = 0;
03152 
03153         m_ucOut[iOutLen++] = (unsigned char)((m_CrcList.uiCrcMetadata & 0xFF00) >> 8);  // CRC of Metadata
03154         m_ucOut[iOutLen++] = (unsigned char)(m_CrcList.uiCrcMetadata & 0x00FF);
03155         m_ucOut[iOutLen++] = (unsigned char)((m_CrcList.uiCrcTimezone & 0xFF00) >> 8);  // CRC of Timzone Table
03156         m_ucOut[iOutLen++] = (unsigned char)(m_CrcList.uiCrcTimezone & 0x00FF);
03157         m_ucOut[iOutLen++] = (unsigned char)((m_CrcList.uiCrcHoliday & 0xFF00) >> 8);   // CRC of Holiday Table
03158         m_ucOut[iOutLen++] = (unsigned char)(m_CrcList.uiCrcHoliday & 0x00FF);
03159         m_ucOut[iOutLen++] = (unsigned char)((m_CrcList.uiCrcAccess & 0xFF00) >> 8);    // CRC of Access Table
03160         m_ucOut[iOutLen++] = (unsigned char)(m_CrcList.uiCrcAccess & 0x00FF);
03161 
03162         // send end update protocol
03163         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03164                                                                                 m_pReaderModule->m_ucBusAdr, 
03165                                                                                 FEDM_MYAXXESS_UPDATE_END, 
03166                                                                                 0x00, 
03167                                                                                 FEDM_MYAXXESS_CRC_LIST, 
03168                                                                                 m_ucOut, 
03169                                                                                 iOutLen, 
03170                                                                                 m_ucIn, 
03171                                                                                 &iInLen, 
03172                                                                                 0x00 );
03173         if(iBack != 0)
03174         {
03175                 return iBack;
03176         }
03177 
03178         FEDM_RETURN(FEDM_OK);
03179 }
03180 
03181 int FedmIscMyAxxessReader::WriteTables_Metadata()
03182 {
03183         int iOutLen = 0;
03184         int iInLen = 0;
03185 
03186         int iBack = 0;
03187 
03188         // calculate Metadata
03189         m_Metadata.uiTableVersion = FEDM_MYAXXESS_TABLE_VERSION;
03190         m_Metadata.ucTimezoneEntries = (unsigned char)m_TimezoneTable.size();
03191         m_Metadata.ucHolidayEntries = (unsigned char)m_HolidayTable.size();
03192         m_Metadata.uiAccessEntries = (unsigned short int)m_AccessTable.size();
03193 
03194         if (m_Metadata.ucTimezoneEntries > 15)
03195                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03196 
03197         if (m_Metadata.ucHolidayEntries > 256)
03198                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03199 
03200         if (m_Metadata.uiAccessEntries > 65535)
03201                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03202 
03203         if ((m_Metadata.ucIDDLength < 1) || (m_Metadata.ucIDDLength > 64))
03204                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03205 
03206         if ((m_Metadata.ucIDDFormat < 1) || (m_Metadata.ucIDDFormat > 3))
03207                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03208 
03209         m_CrcList.uiCrcMetadata = 0xFFFF;       // set startvaule for crc
03210 
03211         // load Metadata
03212         m_ucOut[iOutLen++] = (unsigned char)((m_Metadata.uiTableVersion & 0xFF00) >> 8);
03213         m_ucOut[iOutLen++] = (unsigned char)(m_Metadata.uiTableVersion & 0x00FF);
03214         m_ucOut[iOutLen++] = m_Metadata.ucTimezoneEntries;
03215         m_ucOut[iOutLen++] = m_Metadata.ucHolidayEntries;
03216         m_ucOut[iOutLen++] = (unsigned char)((m_Metadata.uiAccessEntries & 0xFF00) >> 8);
03217         m_ucOut[iOutLen++] = (unsigned char)(m_Metadata.uiAccessEntries & 0x00FF);
03218         m_ucOut[iOutLen++] = m_Metadata.ucIDDLength;
03219         m_ucOut[iOutLen++] = m_Metadata.ucIDDFormat;
03220         m_ucOut[iOutLen++] = m_Metadata.ucReserved[0];
03221         m_ucOut[iOutLen++] = m_Metadata.ucReserved[1];
03222         m_ucOut[iOutLen++] = m_Metadata.ucReserved[2];
03223         m_ucOut[iOutLen++] = m_Metadata.ucReserved[3];
03224         m_ucOut[iOutLen++] = m_Metadata.ucReserved[4];
03225         m_ucOut[iOutLen++] = m_Metadata.ucReserved[5];
03226         m_ucOut[iOutLen++] = m_Metadata.ucReserved[6];
03227         m_ucOut[iOutLen++] = m_Metadata.ucReserved[7];
03228 
03229         m_CrcList.uiCrcMetadata = CalcCRC16CheckSum(m_CrcList.uiCrcMetadata, 0x1021, &m_ucOut[0], iOutLen);
03230 
03231         // send start update protocol
03232         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd,
03233                                                                                 m_pReaderModule->m_ucBusAdr, 
03234                                                                                 FEDM_MYAXXESS_UPDATE_START, 
03235                                                                                 0x00, 
03236                                                                                 FEDM_MYAXXESS_METADATA, 
03237                                                                                 m_ucOut, 
03238                                                                                 iOutLen, 
03239                                                                                 m_ucIn, 
03240                                                                                 &iInLen, 
03241                                                                                 0x00 );
03242         if(iBack != 0)
03243         {
03244                 FEDM_RETURN(iBack);
03245         }
03246 
03247         if(iInLen < 4)
03248         {
03249                 FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03250         }
03251 
03252         // 2 byte package length, 2 byte timeout
03253         m_uiPackageLen  = (m_ucIn[0] << 8) + m_ucIn[1];
03254         m_uiTimeout             = (m_ucIn[2] << 8) + m_ucIn[3];
03255 
03256         FEDM_RETURN(FEDM_OK);
03257 }
03258 
03259 
03260 int FedmIscMyAxxessReader::WriteTables_Timezone()
03261 {
03262         int iOutLen = 0;
03263         int iInLen = 0;
03264 
03265         int iBack = 0;
03266 
03267         unsigned int uiDataSets = 0;
03268         unsigned char ucLen = 0;
03269 
03270         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*  pTimezoneItem   = NULL;
03271         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itorTimezone;
03272 
03273         m_CrcList.uiCrcTimezone = 0xFFFF;       // set startvaule for crc
03274         iOutLen = 3;
03275         uiDataSets = 0;
03276 
03277         // load Timezone Table
03278         for(itorTimezone  = m_TimezoneTable.begin();
03279                 itorTimezone != m_TimezoneTable.end();
03280                 itorTimezone++)
03281         {
03282                 if ((*itorTimezone) == NULL)
03283                         continue;
03284 
03285                 pTimezoneItem = *itorTimezone;
03286 
03287 /*              m_ucOut[iOutLen++] = pTimezoneItem->ucStartDate_Day;
03288                 m_ucOut[iOutLen++] = pTimezoneItem->ucStartDate_Month;
03289                 m_ucOut[iOutLen++] = (pTimezoneItem->ucStartDate_Year;
03290                 m_ucOut[iOutLen++] = pTimezoneItem->ucEndDate_Day;
03291                 m_ucOut[iOutLen++] = pTimezoneItem->ucEndDate_Month;
03292                 m_ucOut[iOutLen++] = pTimezoneItem->ucEndDate_Year;
03293                 m_ucOut[iOutLen++] = pTimezoneItem->ucWeekdays;
03294                 m_ucOut[iOutLen++] = pTimezoneItem->ucStartTime_Hour;
03295                 m_ucOut[iOutLen++] = pTimezoneItem->ucStartTime_Minute;
03296                 m_ucOut[iOutLen++] = pTimezoneItem->ucEndTime_Hour;
03297                 m_ucOut[iOutLen++] = pTimezoneItem->ucEndTime_Minute;
03298 */
03299                 memcpy(&m_ucOut[iOutLen], (unsigned char*)pTimezoneItem, sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM));
03300                 iOutLen += sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM);
03301                 uiDataSets++;
03302 
03303                 if ( (iOutLen + sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM) + 15) > m_uiPackageLen )
03304                 {
03305                         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03306                         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03307                         m_ucOut[2] = sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM);     // length of each dataset
03308 
03309                         m_CrcList.uiCrcTimezone = CalcCRC16CheckSum(m_CrcList.uiCrcTimezone, 0x1021, &m_ucOut[3], (iOutLen-3));
03310 
03311                         // send Timezone Table with MORE Flag
03312                         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd,
03313                                                                                                 m_pReaderModule->m_ucBusAdr,
03314                                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03315                                                                                                 0x80, 
03316                                                                                                 FEDM_MYAXXESS_TIMEZONE_TABLE, 
03317                                                                                                 m_ucOut, 
03318                                                                                                 iOutLen, 
03319                                                                                                 m_ucIn, 
03320                                                                                                 &iInLen, 
03321                                                                                                 0x00 );
03322                         if(iBack != 0)
03323                         {
03324                                 FEDM_RETURN(iBack);
03325                         }
03326                         iOutLen = 3;
03327                         uiDataSets = 0;
03328                 }               
03329         }
03330 
03331         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03332         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03333         m_ucOut[2] = sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM);     // length of each dataset
03334 
03335         m_CrcList.uiCrcTimezone = CalcCRC16CheckSum(m_CrcList.uiCrcTimezone, 0x1021, &m_ucOut[3], (iOutLen-3));
03336 
03337         // send Timezone Table
03338         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03339                                                                                 m_pReaderModule->m_ucBusAdr, 
03340                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03341                                                                                 0x00, 
03342                                                                                 FEDM_MYAXXESS_TIMEZONE_TABLE, 
03343                                                                                 m_ucOut, 
03344                                                                                 iOutLen, 
03345                                                                                 m_ucIn, 
03346                                                                                 &iInLen, 
03347                                                                                 0x00 );
03348         if(iBack != 0)
03349         {
03350                 return iBack;
03351         }
03352 
03353         FEDM_RETURN(FEDM_OK);
03354 }
03355 
03356 
03357 int FedmIscMyAxxessReader::WriteTables_Holiday()
03358 {
03359         int iOutLen = 0;
03360         int iInLen = 0;
03361 
03362         int iBack = 0;
03363 
03364         unsigned int uiDataSets = 0;
03365         unsigned char ucLen = 0;
03366 
03367         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*   pHolidayItem    = NULL;
03368         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itorHoliday;
03369 
03370         m_CrcList.uiCrcHoliday = 0xFFFF;        // set startvaule for crc
03371         iOutLen = 3;
03372         uiDataSets = 0;
03373 
03374         // load Holiday Table
03375         for(itorHoliday  = m_HolidayTable.begin();
03376                 itorHoliday != m_HolidayTable.end();
03377                 itorHoliday++)
03378         {
03379                 if ((*itorHoliday) == NULL)
03380                         continue;
03381 
03382                 pHolidayItem = *itorHoliday;
03383 
03384 /*              m_ucOut[iOutLen++] = pHolidayItem->ucHoliday_Day;
03385                 m_ucOut[iOutLen++] = pHolidayItem->ucHoliday_Month;
03386                 m_ucOut[iOutLen++] = pHolidayItem->ucHoliday_Year;
03387 */
03388                 memcpy(&m_ucOut[iOutLen], (unsigned char*)pHolidayItem, sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM));
03389                 iOutLen += sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM);
03390                 uiDataSets++;
03391                 if ( (iOutLen + sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM) + 15) > m_uiPackageLen )
03392                 {
03393                         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03394                         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03395                         m_ucOut[2] = sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM);      // length of each dataset
03396 
03397                         m_CrcList.uiCrcHoliday = CalcCRC16CheckSum(m_CrcList.uiCrcHoliday, 0x1021, &m_ucOut[3], (iOutLen-3));
03398 
03399                         // send Holiday Table with MORE Flag
03400                         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03401                                                                                                 m_pReaderModule->m_ucBusAdr, 
03402                                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03403                                                                                                 0x80, 
03404                                                                                                 FEDM_MYAXXESS_HOLIDAY_TABLE, 
03405                                                                                                 m_ucOut, 
03406                                                                                                 iOutLen, 
03407                                                                                                 m_ucIn, 
03408                                                                                                 &iInLen, 
03409                                                                                                 0x00 );
03410                         if(iBack != 0)
03411                         {
03412                                 return iBack;
03413                         }
03414                         iOutLen = 3;
03415                         uiDataSets = 0;
03416                 }       
03417         }
03418         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03419         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03420         m_ucOut[2] = sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM);      // length of each dataset
03421 
03422         m_CrcList.uiCrcHoliday = CalcCRC16CheckSum(m_CrcList.uiCrcHoliday, 0x1021, &m_ucOut[3], (iOutLen-3));
03423 
03424         // send Holiday Table
03425         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03426                                                                                 m_pReaderModule->m_ucBusAdr, 
03427                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03428                                                                                 0x00, 
03429                                                                                 FEDM_MYAXXESS_HOLIDAY_TABLE, 
03430                                                                                 m_ucOut, 
03431                                                                                 iOutLen, 
03432                                                                                 m_ucIn, 
03433                                                                                 &iInLen, 
03434                                                                                 0x00 );
03435         if(iBack != 0)
03436         {
03437                 return iBack;
03438         }
03439 
03440         FEDM_RETURN(FEDM_OK);
03441 }
03442 
03443 
03444 int FedmIscMyAxxessReader::WriteTables_Access()
03445 {
03446         int iOutLen = 0;
03447         int iInLen = 0;
03448 
03449         int iBack = 0;
03450 
03451         unsigned int uiDataSets = 0;
03452         unsigned char ucLen = 0;
03453 
03454         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*    pAccessItem             = NULL;
03455         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator  itorAccess;
03456         // sort Access Table on numeric IDDs
03457         map<string, vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator> mapAccess;
03458         map<string, vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator>::iterator itorAccessMap;
03459         string sIDD;
03460 
03461         for(itorAccess  = m_AccessTable.begin();
03462                 itorAccess != m_AccessTable.end();
03463                 itorAccess++ )
03464         {
03465                 pAccessItem = *itorAccess;
03466                 if(pAccessItem == NULL)
03467                         continue;
03468                 FEDM_ConvHexUCharToHexStr(pAccessItem->ucIDD, m_Metadata.ucIDDLength, sIDD);
03469                 mapAccess.insert(make_pair(sIDD, itorAccess));
03470         }
03471 
03472         m_CrcList.uiCrcAccess = 0xFFFF; // set startvalue for crc
03473         iOutLen = 3;
03474         uiDataSets = 0;
03475 
03476         pAccessItem             = NULL;
03477         // load AccessData Table
03478         for(itorAccessMap = mapAccess.begin();
03479                 itorAccessMap != mapAccess.end();
03480                 itorAccessMap++)
03481         {
03482                 if (*itorAccessMap->second == NULL)
03483                         continue;
03484 
03485                 pAccessItem = *itorAccessMap->second;
03486 
03487                 if ((iOutLen > 3) && ((iOutLen + (m_Metadata.ucIDDLength + 3) + 15) > (int)(m_uiPackageLen)))
03488                 {
03489                         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03490                         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03491                         m_ucOut[2] = m_Metadata.ucIDDLength + 3;                                        // length of each dataset
03492 
03493                         m_CrcList.uiCrcAccess = CalcCRC16CheckSum(m_CrcList.uiCrcAccess, 0x1021, &m_ucOut[3], (iOutLen-3));
03494 
03495                         // send Holiday Table with MORE Flag
03496                         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03497                                                                                                 m_pReaderModule->m_ucBusAdr, 
03498                                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03499                                                                                                 0x80, 
03500                                                                                                 FEDM_MYAXXESS_ACCESS_TABLE, 
03501                                                                                                 m_ucOut, 
03502                                                                                                 iOutLen, 
03503                                                                                                 m_ucIn, 
03504                                                                                                 &iInLen, 
03505                                                                                                 0x00 );
03506                         if(iBack != 0)
03507                         {
03508                                 return iBack;
03509                         }
03510                         iOutLen = 3;
03511                         uiDataSets = 0;
03512                 }
03513 
03514                 // add data
03515                 for (ucLen = 0; ucLen < m_Metadata.ucIDDLength; ucLen++)
03516                         m_ucOut[iOutLen++] = pAccessItem->ucIDD[ucLen];
03517 
03518                 m_ucOut[iOutLen++] = (unsigned char)((pAccessItem->uiTimezones & 0xFF00) >> 8);
03519                 m_ucOut[iOutLen++] = (unsigned char)(pAccessItem->uiTimezones & 0x00FF);
03520                 m_ucOut[iOutLen++] = pAccessItem->ucReserved;
03521 
03522                 uiDataSets++;
03523         }
03524 
03525         m_ucOut[0] = (unsigned char)((uiDataSets & 0xFF00) >> 8);       // number of dataset
03526         m_ucOut[1] = (unsigned char)(uiDataSets & 0x00FF);
03527         m_ucOut[2] = m_Metadata.ucIDDLength + 3;                                        // length of each dataset
03528 
03529         m_CrcList.uiCrcAccess = CalcCRC16CheckSum(m_CrcList.uiCrcAccess, 0x1021, &m_ucOut[3], (iOutLen-3));
03530 
03531         // send Access Table
03532         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03533                                                                                 m_pReaderModule->m_ucBusAdr, 
03534                                                                                 FEDM_MYAXXESS_WRITE_TABLE, 
03535                                                                                 0x00, 
03536                                                                                 FEDM_MYAXXESS_ACCESS_TABLE, 
03537                                                                                 m_ucOut, 
03538                                                                                 iOutLen, 
03539                                                                                 m_ucIn, 
03540                                                                                 &iInLen, 
03541                                                                                 0x00 );
03542         if(iBack != 0)
03543         {
03544                 return iBack;
03545         }
03546 
03547         FEDM_RETURN(FEDM_OK);
03548 }
03549 
03550 int FedmIscMyAxxessReader::ReadTable_CrcList()
03551 {
03552         int iOutLen = 0;
03553         int iInLen = 0;
03554 
03555         int iBack = 0;
03556 
03557         unsigned int uiDataSets = 0;
03558         unsigned char ucLen = 0;
03559 
03560         m_ucOut[0] = 0;         // first Req-Info
03561         m_ucOut[1] = 0;
03562         iOutLen = 2;
03563 
03564         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03565                                                                                 m_pReaderModule->m_ucBusAdr, 
03566                                                                                 FEDM_MYAXXESS_READ_TABLE, 
03567                                                                                 0x00, 
03568                                                                                 FEDM_MYAXXESS_CRC_LIST, 
03569                                                                                 m_ucOut, 
03570                                                                                 iOutLen, 
03571                                                                                 m_ucIn, 
03572                                                                                 &iInLen, 
03573                                                                                 0x00 );
03574         if((iBack != 0))
03575         {
03576                 return iBack;
03577         }
03578 
03579         uiDataSets = ((unsigned int)m_ucIn[0] << 8) | (unsigned int)m_ucIn[1];
03580         ucLen = m_ucIn[2];
03581 
03582         if (uiDataSets != 1)
03583         {
03584                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03585         }
03586 
03587         if (ucLen != sizeof(FEDM_ISC_MYAXXESS_CRCLIST))
03588         {
03589                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03590         }
03591         
03592         if (((uiDataSets * ucLen) + 3) != iInLen)
03593         {
03594                 FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03595         }
03596 
03597         m_CrcList.Init();
03598         // copy collected data to item
03599         m_CrcList.uiCrcMetadata = ((unsigned short int)m_ucIn[3] << 8) | (unsigned short int)m_ucIn[4];
03600         m_CrcList.uiCrcTimezone = ((unsigned short int)m_ucIn[5] << 8) | (unsigned short int)m_ucIn[6];
03601         m_CrcList.uiCrcHoliday = ((unsigned short int)m_ucIn[7] << 8) | (unsigned short int)m_ucIn[8];
03602         m_CrcList.uiCrcAccess = ((unsigned short int)m_ucIn[9] << 8) | (unsigned short int)m_ucIn[10];
03603 
03604         FEDM_RETURN(FEDM_OK);
03605 }
03606 
03607 int FedmIscMyAxxessReader::ReadTable_Metadata()
03608 {
03609 
03610         int iOutLen = 0;
03611         int iInLen = 0;
03612 
03613         int iBack = 0;
03614 
03615         unsigned int uiDataSets = 0;
03616         unsigned char ucLen = 0;
03617 
03618         m_ucOut[0] = 0;         // first Req-Info
03619         m_ucOut[1] = 0;
03620         iOutLen = 2;
03621 
03622         iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03623                                                                                 m_pReaderModule->m_ucBusAdr, 
03624                                                                                 FEDM_MYAXXESS_READ_TABLE, 
03625                                                                                 0x00, 
03626                                                                                 FEDM_MYAXXESS_METADATA, 
03627                                                                                 m_ucOut, 
03628                                                                                 iOutLen, 
03629                                                                                 m_ucIn, 
03630                                                                                 &iInLen, 
03631                                                                                 0x00 );
03632         if((iBack != 0))
03633         {
03634                 return iBack;
03635         }
03636 
03637         uiDataSets = ((unsigned int)m_ucIn[0] << 8) | (unsigned int)m_ucIn[1];
03638         ucLen = m_ucIn[2];
03639 
03640         if (uiDataSets != 1)
03641         {
03642                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03643         }
03644 
03645         if (ucLen != sizeof(FEDM_ISC_MYAXXESS_METADATA))
03646         {
03647                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
03648         }
03649         
03650         if (((uiDataSets * ucLen) + 3) != iInLen)
03651         {
03652                 FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03653         }
03654 
03655         m_Metadata.Init();
03656 
03657         // copy collected data to item
03658         m_Metadata.uiTableVersion = ((unsigned short int)m_ucIn[3] << 8) | (unsigned short int)m_ucIn[4];
03659         m_Metadata.ucTimezoneEntries = m_ucIn[5];
03660         m_Metadata.ucHolidayEntries = m_ucIn[6];
03661         m_Metadata.uiAccessEntries = ((unsigned short int)m_ucIn[7] << 8) | (unsigned short int)m_ucIn[8];
03662         m_Metadata.ucIDDLength = m_ucIn[9];
03663         m_Metadata.ucIDDFormat = m_ucIn[10];
03664         m_Metadata.ucReserved[0] = m_ucIn[11];
03665         m_Metadata.ucReserved[1] = m_ucIn[12];
03666         m_Metadata.ucReserved[2] = m_ucIn[13];
03667         m_Metadata.ucReserved[3] = m_ucIn[14];
03668         m_Metadata.ucReserved[4] = m_ucIn[15];
03669         m_Metadata.ucReserved[5] = m_ucIn[16];
03670         m_Metadata.ucReserved[6] = m_ucIn[17];
03671         m_Metadata.ucReserved[7] = m_ucIn[18];
03672 
03673         FEDM_RETURN(FEDM_OK);
03674 }
03675 
03676 
03677 int FedmIscMyAxxessReader::ReadTable_Timezone()
03678 {
03679         int iOutLen = 0;
03680         int iInLen = 0;
03681 
03682         int iBack = 0;
03683 
03684         unsigned int uiDataSets = 0;
03685         unsigned char ucLen = 0;
03686         int iInCnt = 0;
03687 
03688         unsigned int uiDataIndex = 0;           // first Req-Info
03689 
03690         ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
03691 
03692         do
03693         {
03694                 m_ucOut[0] = (unsigned char)(uiDataIndex >> 8); // Req-Info
03695                 m_ucOut[1] = (unsigned char)(uiDataIndex);
03696                 iOutLen = 2;
03697 
03698                 iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03699                                                                                         m_pReaderModule->m_ucBusAdr, 
03700                                                                                         FEDM_MYAXXESS_READ_TABLE, 
03701                                                                                         0x00, 
03702                                                                                         FEDM_MYAXXESS_TIMEZONE_TABLE, 
03703                                                                                         m_ucOut, 
03704                                                                                         iOutLen, 
03705                                                                                         m_ucIn, 
03706                                                                                         &iInLen, 
03707                                                                                         0x00 );
03708                 if((iBack != 0) && (iBack != 0x94))
03709                 {
03710                         return iBack;
03711                 }
03712 
03713                 uiDataSets = ((unsigned int)m_ucIn[0] << 8) | (unsigned int)m_ucIn[1];
03714                 ucLen = m_ucIn[2];
03715                 uiDataIndex += uiDataSets;
03716 
03717                 iInCnt = 3;
03718 
03719                 if (ucLen != sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM))
03720                 {
03721                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03722                 }
03723                 
03724                 if (((uiDataSets * ucLen) + 3) != iInLen)
03725                 {
03726                         FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03727                 }
03728 
03729                 while (uiDataSets-- != 0)
03730                 {
03731                         // copy collected data to new item
03732                         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pTimezoneTableItem = new FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM;
03733                         if (pTimezoneTableItem == NULL)
03734                         {
03735                                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
03736                         }
03737 
03738                         pTimezoneTableItem->Init();
03739                         // copy data
03740                         memcpy((unsigned char*)pTimezoneTableItem, &m_ucIn[iInCnt], ucLen);
03741                         iInCnt += ucLen;
03742 
03743                         // add item to vector
03744                         m_TimezoneTable.push_back(pTimezoneTableItem);
03745                 }
03746 
03747         } while (iBack == 0x94);        // more table data
03748 
03749         FEDM_RETURN(FEDM_OK);
03750 }
03751 
03752 int FedmIscMyAxxessReader::ReadTable_Holiday()
03753 {
03754         int iOutLen = 0;
03755         int iInLen = 0;
03756 
03757         int iBack = 0;
03758 
03759         unsigned int uiDataSets = 0;
03760         unsigned char ucLen = 0;
03761         int iInCnt = 0;
03762 
03763         unsigned int uiDataIndex = 0;           // first Req-Info
03764 
03765         ClearTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
03766 
03767         do
03768         {
03769                 m_ucOut[0] = (unsigned char)(uiDataIndex >> 8); // Req-Info
03770                 m_ucOut[1] = (unsigned char)(uiDataIndex);
03771                 iOutLen = 2;
03772 
03773                 iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03774                                                                                         m_pReaderModule->m_ucBusAdr, 
03775                                                                                         FEDM_MYAXXESS_READ_TABLE, 
03776                                                                                         0x00, 
03777                                                                                         FEDM_MYAXXESS_HOLIDAY_TABLE, 
03778                                                                                         m_ucOut, 
03779                                                                                         iOutLen, 
03780                                                                                         m_ucIn, 
03781                                                                                         &iInLen, 
03782                                                                                         0x00 );
03783                 if((iBack != 0) && (iBack != 0x94))
03784                 {
03785                         return iBack;
03786                 }
03787 
03788                 uiDataSets = ((unsigned int)m_ucIn[0] << 8) | (unsigned int)m_ucIn[1];
03789                 ucLen = m_ucIn[2];
03790                 uiDataIndex += uiDataSets;
03791 
03792                 iInCnt = 3;
03793 
03794                 if (ucLen != sizeof(FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM))
03795                 {
03796                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03797                 }
03798                 
03799                 if (((uiDataSets * ucLen) + 3) != iInLen)
03800                 {
03801                         FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03802                 }
03803 
03804                 while (uiDataSets-- != 0)
03805                 {
03806                         // copy collected data to new item
03807                         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pHolidayTableItem = new FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM;
03808                         if (pHolidayTableItem == NULL)
03809                         {
03810                                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
03811                         }
03812 
03813                         pHolidayTableItem->Init();
03814                         // copy data
03815                         memcpy((unsigned char*)pHolidayTableItem, &m_ucIn[iInCnt], ucLen);
03816                         iInCnt += ucLen;
03817 
03818                         // add item to vector
03819                         m_HolidayTable.push_back(pHolidayTableItem);
03820                 }
03821 
03822         } while (iBack == 0x94);        // more table data
03823 
03824         FEDM_RETURN(FEDM_OK);
03825 }
03826 
03827 int FedmIscMyAxxessReader::ReadTable_Access()
03828 {
03829         int iOutLen = 0;
03830         int iInLen = 0;
03831 
03832         int iBack = 0;
03833 
03834         unsigned int uiDataSets = 0;
03835         unsigned char ucLen = 0;
03836         int iInCnt = 0;
03837 
03838         unsigned int uiDataIndex = 0;           // first Req-Info
03839 
03840         ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
03841 
03842         do
03843         {
03844                 m_ucOut[0] = (unsigned char)(uiDataIndex >> 8); // Req-Info
03845                 m_ucOut[1] = (unsigned char)(uiDataIndex);
03846                 iOutLen = 2;
03847 
03848                 iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03849                                                                                         m_pReaderModule->m_ucBusAdr, 
03850                                                                                         FEDM_MYAXXESS_READ_TABLE, 
03851                                                                                         0x00, 
03852                                                                                         FEDM_MYAXXESS_ACCESS_TABLE, 
03853                                                                                         m_ucOut, 
03854                                                                                         iOutLen, 
03855                                                                                         m_ucIn, 
03856                                                                                         &iInLen, 
03857                                                                                         0x00 );
03858                 if((iBack != 0) && (iBack != 0x94))
03859                 {
03860                         return iBack;
03861                 }
03862 
03863                 uiDataSets = ((unsigned int)m_ucIn[0] << 8) | (unsigned int)m_ucIn[1];
03864                 ucLen = m_ucIn[2];
03865                 uiDataIndex += uiDataSets;
03866 
03867                 iInCnt = 3;
03868 
03869                 if ((ucLen > sizeof(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM)) || (ucLen != (m_Metadata.ucIDDLength + 3)))
03870                 {
03871                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03872                 }
03873                 
03874                 if (((uiDataSets * ucLen) + 3) != iInLen)
03875                 {
03876                         FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03877                 }
03878 
03879                 while (uiDataSets-- != 0)
03880                 {
03881                         // copy collected data to new item
03882                         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pAccessTableItem = new FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM;
03883                         if (pAccessTableItem == NULL)
03884                         {
03885                                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
03886                         }
03887 
03888                         pAccessTableItem->Init();
03889 
03890                         // copy data
03891                         memcpy((unsigned char*)pAccessTableItem, &m_ucIn[iInCnt], ucLen-3);
03892                         pAccessTableItem->uiTimezones = ((unsigned short int)m_ucIn[iInCnt+ucLen-3] << 8) | (unsigned short int)m_ucIn[iInCnt+ucLen-2];
03893                         pAccessTableItem->ucReserved = m_ucIn[iInCnt+ucLen-1];
03894                         iInCnt += ucLen;
03895 
03896                         // add item to vector
03897                         m_AccessTable.push_back(pAccessTableItem);
03898                 }
03899 
03900         } while (iBack == 0x94);        // more table data
03901 
03902         FEDM_RETURN(FEDM_OK);
03903 }
03904 
03905 
03906 int FedmIscMyAxxessReader::ReadTable_Event()
03907 {
03908         int iOutLen = 0;
03909         int iInLen = 0;
03910 
03911         int iBack = 0;
03912 
03913         unsigned int uiDataSets = 0;
03914         unsigned char ucDataLayout = 0;
03915         int iInCnt = 0;
03916         unsigned int uiRecLen = 0;
03917 
03918         unsigned int uiReqInfo = 0;
03919 
03920         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM EventTableItem;
03921 
03922 
03923         uiReqInfo = FEDM_MYAXXESS_MAX_BLOCKSIZE / sizeof(FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM);
03924         m_ucOut[0] = (unsigned char)((uiReqInfo & 0xFF00) >> 8);        // Req-Info
03925         m_ucOut[1] = (unsigned char)(uiReqInfo & 0x00FF);
03926         iOutLen = 2;
03927 
03928         do
03929         {
03930                 iBack = FEISC_0x1F_MAXDataExchange(     m_pReaderModule->m_iReaderHnd, 
03931                                                                                         m_pReaderModule->m_ucBusAdr, 
03932                                                                                         FEDM_MYAXXESS_READ_TABLE, 
03933                                                                                         0x00, 
03934                                                                                         FEDM_MYAXXESS_EVENT_TABLE, 
03935                                                                                         m_ucOut, 
03936                                                                                         iOutLen, 
03937                                                                                         m_ucIn, 
03938                                                                                         &iInLen, 
03939                                                                                         0x00 );
03940                 if((iBack != 0) && (iBack != 0x93) && (iBack != 0x94))
03941                 {
03942                         return iBack;
03943                 }
03944 
03945                 ucDataLayout = m_ucIn[0];
03946                 uiDataSets = ((unsigned int)m_ucIn[1] << 8) | (unsigned int)m_ucIn[2];
03947 
03948                 iInCnt = 3;
03949 
03950 /*              
03951                 if (((uiDataSets * ucLen) + 3) != iInLen)
03952                 {
03953                         FEDM_RETURN(FEDM_ERROR_BUFFER_LENGTH);
03954                 }
03955 */
03956                 while (uiDataSets-- != 0)
03957                 {
03958                         // copy collected data to new item
03959                         EventTableItem.Init();
03960                         EventTableItem.ucDataLayout = ucDataLayout;
03961                         uiRecLen = (unsigned int)m_ucIn[iInCnt++] << 8;
03962                         uiRecLen |= (unsigned int)m_ucIn[iInCnt++];
03963                         EventTableItem.ucEventID = m_ucIn[iInCnt++];
03964 
03965                         if (ucDataLayout & 0x01)        // IDD Set
03966                         {
03967                                 EventTableItem.ucIDDLength = m_ucIn[iInCnt++];
03968 
03969                                 if (EventTableItem.ucIDDLength > 64)
03970                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
03971 
03972                                 memcpy((unsigned char*)EventTableItem.ucIDD, &m_ucIn[iInCnt], EventTableItem.ucIDDLength);
03973                                 iInCnt += EventTableItem.ucIDDLength;
03974                         }
03975 
03976                         if (ucDataLayout & 0x02)        // Timestamp
03977                         {
03978                                 EventTableItem.ucDay = m_ucIn[iInCnt++];
03979                                 EventTableItem.ucMonth = m_ucIn[iInCnt++];
03980                                 EventTableItem.ucYear = m_ucIn[iInCnt++];
03981                                 EventTableItem.ucHour = m_ucIn[iInCnt++];
03982                                 EventTableItem.ucMinute = m_ucIn[iInCnt++];
03983                                 EventTableItem.ucSecond = m_ucIn[iInCnt++];
03984                         }
03985 
03986                         if (ucDataLayout & 0x04)        // Event Status
03987                         {
03988                                 EventTableItem.ucAction = m_ucIn[iInCnt++];
03989                                 EventTableItem.uiError = (unsigned short int)m_ucIn[iInCnt++] << 8;
03990                                 EventTableItem.uiError |= (unsigned short int)m_ucIn[iInCnt++];
03991                         }
03992 
03993                         if (ucDataLayout & 0x08)        // Input Data
03994                         {
03995                                 EventTableItem.ucInput = m_ucIn[iInCnt++];
03996                         }
03997 
03998                         if (ucDataLayout & 0x10)        // Antenne No
03999                         {
04000                                 EventTableItem.ucAnt = m_ucIn[iInCnt++];
04001                         }
04002 
04003                         if (FEDM_IS_TCPPORT(m_pReaderModule->GetPortHnd()))
04004                         {
04005                                 char cTmp[32];
04006                                 m_pReaderModule->GetPortPara("HostAdr", cTmp);
04007                                 EventTableItem.sSourceIP = cTmp;
04008                         }
04009                         else
04010                         {
04011                                 EventTableItem.sSourceIP = "0.0.0.0";
04012                         }
04013 
04014                         // copy collected data to new item
04015                         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pEventTableItem = new FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM;
04016                         if (pEventTableItem == NULL)
04017                         {
04018                                 FEDM_RETURN(FEDM_ERROR_NO_MORE_MEM);
04019                         }
04020                         pEventTableItem->Init();
04021                         memcpy((unsigned char*)pEventTableItem, (unsigned char*)&EventTableItem, sizeof(FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM));
04022 
04023                         // add item to vector
04024                         m_EventTable.push(pEventTableItem);
04025                 }
04026 
04027                 m_ucOut[0] = (unsigned char)((uiReqInfo & 0xFF00) >> 8);        // Req-Info if more table data
04028                 m_ucOut[1] = (unsigned char)(uiReqInfo & 0x00FF);
04029                 iOutLen = 2;
04030 
04031         } while ((iBack == 0x94) || (iBack == 0x93));   // more table data or overflow
04032 
04033         FEDM_RETURN(FEDM_OK);
04034 }
04035 
04036 
04037 /***************************************************************************
04038   Begin                 :       24.09.2009 / M. Hultsch
04039 
04040   Version               :       03.00.13 / 28.09.2009 / M. Hultsch
04041 
04042   Function                      :       static callback function for invoke from DLL
04043 
04044   Parameters            :       void* pAny                                      - [in] pointer to caller object
04045                                                 int iReaderHnd                          - [in] reader handle (FEISC.DLL)
04046                                                 int iTaskID                                     - [in] task identifier from FEISC_StartAsyncTask(..)
04047                                                 int iError                                      - [in] error code
04048                                                 unsigned char ucCmd                     - [in] reader command
04049                                                 unsigned char* ucRspData        - [in] pointer to response data
04050                                                 int iRspLen                                     - [in] length of response data
04051                                                 char* cIPAdr                            - [in] pointer to ip address of reader
04052                                                 int iPortNr                                     - [in] local or remote port number 
04053                                                 unsigned char& ucAction         - [out] reference to action value
04054 
04055   Return value          :       -
04056 ***************************************************************************/
04057 int FedmIscMyAxxessReader::cbsTaskRsp3( void* pAny, 
04058                                                                                 int iReaderHnd, 
04059                                                                                 int iTaskID, 
04060                                                                                 int iError, 
04061                                                                                 unsigned char ucCmd,
04062                                                                                 unsigned char* ucRspData, 
04063                                                                                 int iRspLen,
04064                                                                                 char* cIPAdr,
04065                                                                                 int iPortNr,
04066                                                                                 unsigned char& ucAction )
04067 {
04068         if((FedmIscMyAxxessReader*)pAny == NULL)
04069                 return FEDM_ERROR_NULL_POINTER;
04070 
04071         switch(iTaskID)
04072         {
04073         case FEISC_TASKID_MAX_EVENT:
04074                 switch(ucCmd)
04075                 {
04076                 case 0x1F:
04077                         return ((FedmIscMyAxxessReader*)pAny)->cbNewMaxEvent(   iReaderHnd, 
04078                                                                                                                                         FEDM_TASKID_MAX_EVENT, 
04079                                                                                                                                         iError, 
04080                                                                                                                                         ucRspData, 
04081                                                                                                                                         iRspLen, 
04082                                                                                                                                         cIPAdr, 
04083                                                                                                                                         iPortNr, 
04084                                                                                                                                         ucAction );
04085                         break;
04086 
04087                 case 0x6E:
04088                         ((FedmIscMyAxxessReader*)pAny)->cbNewReaderDiagnostic(  iReaderHnd,
04089                                                                                                                                         FEDM_TASKID_MAX_EVENT,
04090                                                                                                                                         iError,
04091                                                                                                                                         ucRspData, 
04092                                                                                                                                         iRspLen, 
04093                                                                                                                                         cIPAdr, 
04094                                                                                                                                         iPortNr );
04095                         break;
04096 
04097                 default:
04098                         return FEDM_ERROR_UNKNOWN_COMMAND;
04099                 }
04100 
04101         default:
04102                 return FEDM_ERROR_PARAMETER;
04103         }
04104 
04105         return FEDM_ERROR_UNSUPPORTED;
04106 }
04107 
04108 
04109 
04110 /***************************************************************************
04111   Begin                 :       24.09.2009 / M. Hultsch
04112 
04113   Version               :       03.00.13 / 30.09.2009 / M. Hultsch
04114 
04115   Function                      :       non-static callback function for invoke from DLL
04116                                                 - every callback contains only one access event
04117 
04118   Parameters            :       int iReaderHnd                          - [in] reader handle (FEISC.DLL)
04119                                                 int iTaskID                                     - [in] task identifier from FEISC_StartAsyncTask(..)
04120                                                 int iError                                      - [in] error code
04121                                                 unsigned char* ucRspData        - [in] pointer to response data
04122                                                 int iRspLen                                     - [in] length of response data
04123                                                 char* cIPAdr                            - [in] pointer to ip address of reader
04124                                                 int iPortNr                                     - [in] local or remote port number 
04125                                                 unsigned char& ucAction         - [out] reference to action value
04126 
04127   Return value          :       -
04128 ***************************************************************************/
04129 int FedmIscMyAxxessReader::cbNewMaxEvent(       int iReaderHnd, 
04130                                                                                         int iTaskID, 
04131                                                                                         int iError, 
04132                                                                                         unsigned char* ucRspData, 
04133                                                                                         int iRspLen,
04134                                                                                         char* cIPAdr,
04135                                                                                         int iPortNr,
04136                                                                                         unsigned char& ucAction )
04137 {
04138         int iBack = 0;
04139         unsigned char ucDataLayout      = 0;
04140         unsigned int  uiDataSets        = 0;
04141         unsigned int  uiDataSize        = 0;
04142         unsigned int uiCnt = 0;
04143         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pEventItem = NULL;
04144         vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*> aEvent;
04145         vector<FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM*>::iterator itor;
04146 
04147         if(iReaderHnd != m_pReaderModule->GetReaderHnd())
04148                 return FEDM_ERROR_NO_READER_HANDLE;
04149 
04150         if(iTaskID != FEDM_TASKID_MAX_EVENT)
04151                 return FEDM_ERROR_UNSUPPORTED;
04152 
04153         switch(m_uiEventCallerType)
04154         {
04155         case 0: // for C++
04156                 if(m_cbEvent == NULL)
04157                         return FEDM_ERROR_NULL_POINTER;
04158                 break;
04159 
04160         case 1: // for .NET
04161                 if(m_cbStdCallEvent == NULL)
04162                         return FEDM_ERROR_NULL_POINTER;
04163                 break;
04164         }
04165 
04166         // notify error cases
04167         if(iError != 0x00 && iError != 0x93)
04168                 return m_cbEvent(m_pReaderModule->m_TaskInit.pAny, iError, aEvent, ucAction, cIPAdr, iPortNr);
04169 
04170         if(iRspLen <= 3)
04171                 return m_cbEvent(m_pReaderModule->m_TaskInit.pAny, FEDM_ERROR_NO_DATA, aEvent, ucAction, cIPAdr, iPortNr);
04172 
04173 
04174 
04175         // extract event data
04176         ucDataLayout = ucRspData[uiCnt++];
04177         uiDataSets  = ((unsigned int)ucRspData[uiCnt++] << 8);
04178         uiDataSets |=  (unsigned int)ucRspData[uiCnt++];
04179 
04180         if(uiDataSets == 0)
04181                 return m_cbEvent(m_pReaderModule->m_TaskInit.pAny, FEDM_ERROR_NO_DATA, aEvent, ucAction, cIPAdr, iPortNr);
04182 
04183         for(unsigned int uiRecCount = 0; uiRecCount < uiDataSets; uiRecCount++)
04184         {
04185                 uiDataSize  = ((unsigned int)ucRspData[uiCnt++] << 8);
04186                 uiDataSize |=  (unsigned int)ucRspData[uiCnt++];
04187 
04188                 if( (unsigned int)iRspLen < (3 + uiDataSize) )
04189                 {
04190                         return m_cbEvent(m_pReaderModule->m_TaskInit.pAny, FEDM_ERROR_NO_DATA, aEvent, ucAction, cIPAdr, iPortNr);
04191                 }
04192         
04193                 pEventItem = new FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM;
04194                 pEventItem->Init();
04195 
04196                 pEventItem->ucDataLayout = ucDataLayout;
04197                 pEventItem->ucEventID = ucRspData[uiCnt++];
04198 
04199                 if (ucDataLayout & 0x01)        // IDD Set
04200                 {
04201                         pEventItem->ucIDDLength = ucRspData[uiCnt++];
04202 
04203                         if (pEventItem->ucIDDLength > 64)
04204                         {
04205                                 // send notofocation with collected events and with error code
04206                                 iBack = m_cbEvent(m_pReaderModule->m_TaskInit.pAny, FEDM_ERROR_BUFFER_LENGTH, aEvent, ucAction, cIPAdr, iPortNr);
04207                                 
04208                                 delete pEventItem;
04209                                 // delete temporary vector
04210                                 for(itor = aEvent.begin(); itor != aEvent.end(); itor++)
04211                                 {
04212                                         delete (*itor);
04213                                 }
04214                                 return iBack;
04215                         }
04216 
04217                         memcpy(pEventItem->ucIDD, &ucRspData[uiCnt], pEventItem->ucIDDLength);
04218                         uiCnt += pEventItem->ucIDDLength;
04219                 }
04220 
04221                 if (ucDataLayout & 0x02)        // Timestamp
04222                 {
04223                         pEventItem->ucDay = ucRspData[uiCnt++];
04224                         pEventItem->ucMonth = ucRspData[uiCnt++];
04225                         pEventItem->ucYear = ucRspData[uiCnt++];
04226                         pEventItem->ucHour = ucRspData[uiCnt++];
04227                         pEventItem->ucMinute = ucRspData[uiCnt++];
04228                         pEventItem->ucSecond = ucRspData[uiCnt++];
04229                 }
04230 
04231                 if (ucDataLayout & 0x04)        // Event Status
04232                 {
04233                         pEventItem->ucAction = ucRspData[uiCnt++];
04234                         pEventItem->uiError  = ((unsigned short int)ucRspData[uiCnt++] << 8);
04235                         pEventItem->uiError |=  (unsigned short int)ucRspData[uiCnt++];
04236                 }
04237 
04238                 if (ucDataLayout & 0x08)        // Input Data
04239                 {
04240                         pEventItem->ucInput = ucRspData[uiCnt++];
04241                 }
04242 
04243                 if (ucDataLayout & 0x10)        // Antenna No
04244                 {
04245                         pEventItem->ucAnt = ucRspData[uiCnt++];
04246                 }
04247 
04248                 pEventItem->sSourceIP = cIPAdr;
04249 
04250                 aEvent.push_back(pEventItem);
04251         }
04252 
04253         switch(m_uiEventCallerType)
04254         {
04255         case 0: // for C++
04256                 iBack = m_cbEvent(m_pReaderModule->m_TaskInit.pAny, FEDM_OK, aEvent, ucAction, cIPAdr, iPortNr);
04257                 break;
04258 
04259         case 1: // for .NET
04260                 iBack = m_cbStdCallEvent(FEDM_OK, aEvent, ucAction, cIPAdr, iPortNr);
04261                 break;
04262         }
04263 
04264         // delete temporary vector
04265         for(itor = aEvent.begin(); itor != aEvent.end(); itor++)
04266         {
04267                 delete (*itor);
04268         }
04269 
04270         return iBack;
04271 }
04272 
04273 
04274 /***************************************************************************
04275   Begin                 :       28.09.2009 / M. Hultsch
04276 
04277   Version               :       03.00.13 / 28.09.2009 / M. Hultsch
04278 
04279   Function                      :       non-static callback function for invoke from DLL
04280 
04281   Parameters            :       int iReaderHnd                          - reader handle (FEISC.DLL)
04282                                                 int iTaskID                                     - task identifier from FEISC_StartAsyncTask(..)
04283                                                 int iError                                      - error code
04284                                                 unsigned char* ucRspData        - pointer to response data
04285                                                 int iRspLen                                     - length of response data
04286                                                 char* cIPAdr                            - pointer to ip address of reader
04287                                                 int iPortNr                                     - local or remote port number 
04288 
04289   Return value          :       -
04290 ***************************************************************************/
04291 void FedmIscMyAxxessReader::cbNewReaderDiagnostic(      int iReaderHnd, 
04292                                                                                                         int iTaskID, 
04293                                                                                                         int iError, 
04294                                                                                                         unsigned char* ucRspData, 
04295                                                                                                         int iRspLen,
04296                                                                                                         char* cIPAdr,
04297                                                                                                         int iPortNr )
04298 {
04299         unsigned char ucData[13];
04300         int iErr = 0;
04301 //      unsigned int uiIP[4];
04302 //      unsigned char ucIP[4];
04303         unsigned int uiErrorFlags = 0;
04304         unsigned int uiTableSize = 0;
04305         unsigned int uiTableLength = 0;
04306 
04307 //      memset(uiIP, 0, 4*sizeof(unsigned int));
04308 //      memset (ucIP, 0, 4*sizeof(unsigned char));
04309 
04310 
04311         if(iReaderHnd != m_pReaderModule->GetReaderHnd())
04312                 return;
04313 
04314         if(iTaskID != FEDM_TASKID_MAX_EVENT)
04315                 return;
04316 
04317         switch(m_uiEventCallerType)
04318         {
04319         case 0: // for C++
04320                 if(m_cbKeepAlive == NULL)
04321                         return;
04322                 break;
04323 
04324         case 1: // for .NET
04325                 if(m_cbStdCallKeepAlive == NULL)
04326                         return;
04327                 break;
04328         }
04329 
04330         SetLastError(iError);
04331 
04332         
04333         // first step: extract reader diagnostic data
04334         if( iError == 0x00 || 
04335                 iError == 0x84 )
04336         {       
04337                 if(iRspLen != 6)
04338                 {
04339                         m_cbKeepAlive(m_pReaderModule->m_TaskInit.pAny, FEDM_ERROR_NO_DATA, 0, 0, 0, cIPAdr, iPortNr);
04340                         return;
04341                 }
04342 
04343                 memset(ucData, 0, 13);
04344 
04345                 // with mode 0x06, we receive 6 bytes
04346                 memcpy(ucData, ucRspData, iRspLen);
04347 
04348                 // set reader diagnostic mode 0x01
04349                 FEDM_CHK6(iErr, m_pReaderModule->SetData(FEDM_ISC_TMP_DIAG_MODE, (unsigned char)0x06));
04350 
04351                 // FEDM_ISC_TMP_DIAG_DATA addresses always 13 bytes
04352                 FEDM_CHK6(iErr, m_pReaderModule->SetData(FEDM_ISC_TMP_DIAG_DATA, ucData, 13));
04353 
04354                 uiErrorFlags    = (((unsigned int)ucRspData[0]) << 8) + ucRspData[1];
04355                 uiTableSize             = (((unsigned int)ucRspData[2]) << 8) + ucRspData[3];
04356                 uiTableLength   = (((unsigned int)ucRspData[4]) << 8) + ucRspData[5];
04357         }
04358 
04359 /*      sscanf(cIPAdr, "%u.%u.%u.%u", &uiIP[0], &uiIP[1], &uiIP[2], &uiIP[3]);
04360         ucIP[0] = (uiIP[0] & 0x000000FF);
04361         ucIP[1] = (uiIP[1] & 0x000000FF);
04362         ucIP[2] = (uiIP[2] & 0x000000FF);
04363         ucIP[3] = (uiIP[3] & 0x000000FF);
04364         SetData(FEDM_ISC_TMP_NTF_REMOTE_IP_ADR, ucIP, 4);
04365         SetData(FEDM_ISC_TMP_NTF_IP_PORT_NR, (unsigned int)iPortNr);
04366 */
04367         // second step: invoke callback function of application
04368         switch(m_uiEventCallerType)
04369         {
04370         case 0: // for C++
04371                 m_cbKeepAlive(m_pReaderModule->m_TaskInit.pAny, iError, uiErrorFlags, uiTableSize, uiTableLength, cIPAdr, iPortNr);
04372                 break;
04373 
04374         case 1: // for .NET
04375                 m_cbStdCallKeepAlive(iError, uiErrorFlags, uiTableSize, uiTableLength, cIPAdr, iPortNr);
04376                 break;
04377         }
04378 }
04379 
04380 void FedmIscMyAxxessReader::SetLastError(int iError)
04381 {
04382         m_pReaderModule->SetLastError(iError);
04383 }
04384 
04385 int FedmIscMyAxxessReader::GetLastError()
04386 {
04387         return m_pReaderModule->GetLastError();
04388 }
04389 
04390 char* FedmIscMyAxxessReader::GetErrorText(int iErrorCode)
04391 {
04392         return m_pReaderModule->GetErrorText(iErrorCode);
04393 }


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