FedmIscMyAxxess_XmlParser.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |       FedmIscMyAxxess_XmlParser.cpp                               |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright © 2009                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                   :       25.06.2009
00018 Version                 :       03.00.08 / 29.06.2009 / M. Hultsch
00019 Operation Systems       :       independent
00020 Function                        :       parser for myAxxess Data Files
00021 
00022 OBID® and OBID i-scan® are registered Trademarks of FEIG ELECTRONIC GmbH.
00023 Linux® is a registered trademark of Linus Torvalds.
00024 Microsoft® and Windows® are registered trademarks of Microsoft Corporation.
00025 */
00026 
00027 #if defined(_FEDM_MYAXXESS_XML_SUPPORT)
00028 
00029 //#############################
00030 //      I N C L U D E S
00031 //#############################
00032 #include "FedmIscMyAxxess_XmlParser.h"          // public include file of library
00033 #include "FEDM_XmlParser_IWriter.h"                     // public include file of library
00034 #include "FEDM_XmlParser_Types.h"
00035 #include "FedmIscCore.h"
00036 #include "FedmIscMyAxxess_Xml.h"
00037 
00038 
00039 //#######################################################################################
00040 //      class FedmIscMyAxxess_XmlParser
00041 //#######################################################################################
00042 FedmIscMyAxxess_XmlParser::FedmIscMyAxxess_XmlParser(FedmIscMyAxxessReader* pAxxessReader)
00043 : FEDM_XmlParser_Base(FEDM_XML_PARSER_TYPE_FEDM, FEDM_XML_PARSER_TYPE_FEDM)
00044 {
00045         m_pAxxessReader = pAxxessReader;
00046 
00047         SetComment();
00048 }
00049 
00050 
00051 FedmIscMyAxxess_XmlParser::~FedmIscMyAxxess_XmlParser(void)
00052 {
00053 }
00054 
00055 //#####################################################################################
00056 // serialization functions
00057 //#####################################################################################
00058 
00059 /***************************************************************************
00060   Begin         :       25.06.2009 / M. Hultsch
00061   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
00062 
00063   Function              :       read xml document and save content in data map
00064 
00065   Parameters    :       char* szXmlFileName     - pointer to buffer with filename
00066                                         char* szAccessCode      - pointer to password
00067                                         unsigned int uiAccessCodeLen    - length of password
00068 
00069   Return value  :       FEDM_OK or error code (<0)
00070 ***************************************************************************/
00071 int FedmIscMyAxxess_XmlParser::SerializeIn(     char* szXmlFileName, 
00072                                                                                         char* szAccessCode, 
00073                                                                                         unsigned int uiAccessCodeLen)
00074 {
00075         if(strlen(szXmlFileName) == 0)
00076                 return FEDM_ERROR_STRING_LENGTH;
00077 
00078         int     iBack = 0;
00079         unsigned int uiCrc = 0;
00080         FEDM_XML_TREEITEM* root                 = NULL;
00081 
00082 
00083         m_XmlHeader.Init();
00084 
00085 
00086         iBack = OpenDoc(szXmlFileName, "r");
00087         if(iBack)
00088                 FEDM_RETURN(iBack);
00089         
00090         // read complete xml document into string
00091         iBack = LoadDoc();
00092         if(iBack)
00093                 FEDM_RETURN(iBack);
00094 
00095 
00096         // parser in read mode
00097         m_bWriteMode = false;
00098         m_bIsParsed = false;
00099 
00100 
00101         // #####################################################
00102         // root tag
00103         root = FindTag(FEDM_XML_TAG_OBID_UC, (unsigned int)0);
00104         if(root == NULL)
00105         {
00106                 return m_iLastError;
00107         }
00108         AddTagItem(NULL, root);
00109 
00110         // #####################################################
00111         // header tag
00112         FEDM_CHK2(iBack, SerializeHeaderIn(root));
00113 
00114         if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00115         {
00116                 iBack = SerializeIn_AccessTable(root);
00117         }
00118         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00119         {
00120                 iBack = SerializeIn_TimezoneTable(root);
00121         }
00122         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00123         {
00124                 iBack = SerializeIn_HolidayTable(root);
00125         }
00126         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00127         {
00128                 iBack = SerializeIn_EventTable(root);
00129         }
00130         else
00131         {
00132                 DeleteXmlTree(); // clean up
00133                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00134         }
00135 
00136         if(iBack)
00137         {
00138                 DeleteXmlTree(); // clean up
00139                 FEDM_RETURN(iBack);
00140         }
00141 
00142 
00143         // clean up
00144         DeleteXmlTree();
00145 
00146         
00147         // calculate checksum
00148         if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00149         {
00150                 uiCrc = CalcChecksum_AccessTable();
00151         }
00152         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00153         {
00154                 uiCrc = CalcChecksum_TimezoneTable();
00155         }
00156         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00157         {
00158                 uiCrc = CalcChecksum_HolidayTable();
00159         }
00160         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00161         {
00162                 FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00163         }
00164 
00165         if(uiAccessCodeLen > 0)
00166         {
00167                 uiCrc = CalcCRC16CheckSum(      uiCrc, 
00168                                                                         (unsigned char*)szAccessCode, 
00169                                                                         uiAccessCodeLen );
00170         }
00171 
00172         // verify checksum
00173         if(uiCrc != m_XmlHeader.uiCrc)
00174         {
00175                 if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00176                 {
00177                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00178                 }
00179                 else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00180                 {
00181                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00182                 }
00183                 else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00184                 {
00185                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
00186                 }
00187                 else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00188                 {
00189                         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00190                 }
00191 
00192                 FEDM_RETURN(FEDM_ERROR_CRC);
00193         }
00194         
00195         m_bIsParsed = true;
00196 
00197         FEDM_RETURN(FEDM_OK);
00198 }
00199 
00200 
00201 /***************************************************************************
00202   Begin         :       25.06.2009 / M. Hultsch
00203   Version       :       03.00.08 / 26.06.2009 / M. Hultsch
00204 
00205   Function              :       write content of data map into xml document
00206 
00207   Parameters    :       unsigned int uiTableID  - table identifier from FedmIscMyAxxessReader.h
00208                                         char* szXmlFileName     - pointer to buffer with filename
00209                                         char* szAccessCode      - pointer to password
00210                                         unsigned int uiAccessCodeLen    - length of password
00211 
00212   Return value  :       FEDM_OK or error code (<0)
00213 ***************************************************************************/
00214 int FedmIscMyAxxess_XmlParser::SerializeOut(unsigned int uiTableID,
00215                                                                                         char* szXmlFileName,
00216                                                                                         char* szAccessCode, 
00217                                                                                         unsigned int uiAccessCodeLen)
00218 {
00219         if(strlen(szXmlFileName) == 0)
00220                 return FEDM_ERROR_STRING_LENGTH;
00221 
00222         wchar_t wcTmp[128];
00223         int     iBack = 0;
00224         int     iTmp[2];
00225         unsigned int uiCrc = FEDM_CRC16_PRESET;
00226         FEDM_XML_TREEITEM* root = NULL;
00227 
00228 
00229         // parser in write mode
00230         m_bWriteMode = true;
00231 
00232         //TODO_M
00233         // header settings
00234         if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00235         {
00236                 strcpy(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE);
00237         }
00238         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00239         {
00240                 strcpy(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE);
00241         }
00242         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00243         {
00244                 strcpy(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE);
00245         }
00246         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00247         {
00248                 strcpy(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE);
00249         }
00250         else
00251         {
00252                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00253         }
00254 
00255 
00256         sscanf(FEDM_XML_STRING_MAX_DOC_VERSION, "%d.%d", &iTmp[1], &iTmp[0]);
00257         m_XmlHeader.uiDocVersion = (((unsigned char)iTmp[1]) << 8) + (unsigned char)iTmp[0];
00258 
00259 
00260         // root tag
00261         root = BuildTag(FEDM_XML_TAG_OBID_UC);
00262         if(root == NULL)
00263         {
00264                 return m_iLastError;
00265         }
00266         AddTagItem(NULL, root);
00267 
00268 
00269         // #####################################################
00270         // header tag
00271         FEDM_CHK2(iBack, SerializeHeaderOut(root));
00272 
00273 
00274         if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00275         {
00276                 iBack = SerializeOut_AccessTable(root);
00277         }
00278         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00279         {
00280                 iBack = SerializeOut_TimezoneTable(root);
00281         }
00282         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00283         {
00284                 iBack = SerializeOut_HolidayTable(root);
00285         }
00286         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00287         {
00288                 iBack = SerializeOut_EventTable(root, uiCrc);
00289         }
00290         else
00291         {
00292                 DeleteXmlTree(); // clean up
00293                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00294         }
00295 
00296         if(iBack)
00297         {
00298                 DeleteXmlTree(); // clean up
00299                 FEDM_RETURN(iBack);
00300         }
00301 
00302 
00303         // calculate checksum
00304         if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_AT_DOC_TYPE) == 0)
00305         {
00306                 m_XmlHeader.uiCrc = CalcChecksum_AccessTable();
00307         }
00308         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_TT_DOC_TYPE) == 0)
00309         {
00310                 m_XmlHeader.uiCrc = CalcChecksum_TimezoneTable();
00311         }
00312         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_HT_DOC_TYPE) == 0)
00313         {
00314                 m_XmlHeader.uiCrc = CalcChecksum_HolidayTable();
00315         }
00316         else if(strcmp(m_XmlHeader.szDocType, FEDM_XML_STRING_MAX_ET_DOC_TYPE) == 0)
00317         {
00318                 // EventTable is a queue. Thus, crc is calculated together with serialization process
00319                 m_XmlHeader.uiCrc = uiCrc;
00320         }
00321 
00322         if(uiAccessCodeLen > 0)
00323         {
00324                 m_XmlHeader.uiCrc = CalcCRC16CheckSum(  m_XmlHeader.uiCrc, 
00325                                                                                                 (unsigned char*)szAccessCode, 
00326                                                                                                 uiAccessCodeLen );
00327         }
00328 #if defined(__BORLANDC__) || defined(_MSC_VER)
00329         #if _MSC_VER <= 1200
00330         swprintf(wcTmp, L"%d", m_XmlHeader.uiCrc);
00331         #else
00332         swprintf(wcTmp, 128, L"%d", m_XmlHeader.uiCrc);
00333         #endif
00334 #else
00335         swprintf(wcTmp, 128, L"%d", m_XmlHeader.uiCrc);
00336 #endif
00337         root->aChildList[0]->aChildList[7]->sValue = wcTmp;
00338 
00339 
00340         // #####################################################
00341 
00342         iBack = OpenDoc(szXmlFileName, "w");
00343         if(iBack)
00344         {
00345                 DeleteXmlTree(); // clean up
00346                 return iBack;
00347         }
00348         else
00349         {
00350                 WriteDoc();
00351         }
00352 
00353 
00354         CloseDoc();
00355 
00356         DeleteXmlTree(); // clean up
00357 
00358         FEDM_RETURN(FEDM_OK);
00359 }
00360 
00361 /***************************************************************************
00362   Begin         :       25.06.2009 / M. Hultsch
00363   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
00364 
00365   Function              :       read xml document for doc type access table
00366 
00367   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
00368 
00369   Return value  :       FEDM_OK or error code (<0)
00370 ***************************************************************************/
00371 int FedmIscMyAxxess_XmlParser::SerializeIn_AccessTable(FEDM_XML_TREEITEM* root)
00372 {
00373         char cValue[256];
00374         unsigned char ucCnt = 0;
00375         unsigned int uiBit = 0;
00376         unsigned int uiValue = 0;
00377         unsigned __int64 ui64Value = 0;
00378         FEDM_XML_TREEITEM* access_table = NULL;
00379         FEDM_XML_TREEITEM* access_data  = NULL;
00380         FEDM_XML_TREEITEM* timezones    = NULL;
00381         FEDM_XML_TREEITEM* child                = NULL;
00382 
00383         FEDM_ISC_MYAXXESS_METADATA                              metadata;
00384         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM             item;
00385 
00386         metadata.Init();
00387         item.Init();
00388 
00389 
00390         // delete content of access table
00391         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00392 
00393 
00394         // #####################################################
00395         //      <access-table>
00396         //              ...
00397         //      </access-table>
00398         
00399         // <access-table>
00400         child = FindTag(FEDM_XML_TAG_ACCESS_TABLE_UC, (unsigned int)1, true);
00401         if(child == NULL)
00402         {
00403                 DeleteXmlTree(); // clean up
00404                 return m_iLastError;
00405         }
00406         AddTagItem(root, child);
00407         access_table = child;
00408 
00409         // <idd-format>
00410         child = FindTag(FEDM_XML_TAG_IDD_FORMAT_UC, (unsigned int)2, true);
00411         if(child != NULL)
00412         {
00413                 AddTagItem(access_table, child);
00414                 FEDM_SWSCANF(child->sValue, cValue);
00415                 sscanf(cValue, "%u", &metadata.ucIDDFormat);
00416                 switch(metadata.ucIDDFormat)
00417                 {
00418                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
00419                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
00420                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
00421                         break;
00422                 default:
00423                         DeleteXmlTree(); // clean up
00424                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00425                 }
00426         }
00427         else
00428         {
00429                 DeleteXmlTree(); // clean up
00430                 return m_iLastError;
00431         }
00432 
00433         // <idd-length>
00434         child = FindTag(FEDM_XML_TAG_IDD_LENGTH_UC, (unsigned int)2, true);
00435         if(child != NULL)
00436         {
00437                 AddTagItem(access_table, child);
00438                 FEDM_SWSCANF(child->sValue, cValue);
00439                 sscanf(cValue, "%u", &metadata.ucIDDLength);
00440                 switch(metadata.ucIDDFormat)
00441                 {
00442                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
00443                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
00444                         if(metadata.ucIDDLength < 1 || metadata.ucIDDLength > 64)
00445                         {
00446                                 DeleteXmlTree(); // clean up
00447                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00448                         }
00449                         break;
00450 
00451                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
00452                         if(metadata.ucIDDLength < 1 || metadata.ucIDDLength > 8)
00453                         {
00454                                 DeleteXmlTree(); // clean up
00455                                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
00456                         }
00457                         break;
00458                 }
00459         }
00460         else
00461         {
00462                 DeleteXmlTree(); // clean up
00463                 return m_iLastError;
00464         }
00465 
00466 
00467         // <access-data>
00468         child = FindTag(FEDM_XML_TAG_ACCESS_DATA_UC, (unsigned int)2, true);
00469         while(child)
00470         {
00471                 item.Init();
00472 
00473                 AddTagItem(access_table, child);
00474                 access_data = child;
00475 
00476                 // <idd>
00477                 child = FindTag(FEDM_XML_TAG_IDD_UC, (unsigned int)3, true);
00478                 if(child != NULL)
00479                 {
00480                         AddTagItem(access_data, child);
00481                         FEDM_SWSCANF(child->sValue, cValue);
00482                         switch(metadata.ucIDDFormat)
00483                         {
00484                         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
00485                                 if(strlen(cValue) != metadata.ucIDDLength)
00486                                 {
00487                                         DeleteXmlTree(); // clean up
00488                                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00489                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00490                                 }
00491 
00492                                 memcpy(item.ucIDD, cValue, metadata.ucIDDLength);
00493                                 break;
00494 
00495                         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
00496                                 if(strlen(cValue) > 20)
00497                                 {
00498                                         DeleteXmlTree(); // clean up
00499                                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00500                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00501                                 }
00502 
00503                                 sscanf(cValue, "%lld", &ui64Value);
00504                                 for(ucCnt=0; ucCnt<metadata.ucIDDLength; ucCnt++)
00505                                 {
00506                                         // change intel in motorola format
00507                                         item.ucIDD[metadata.ucIDDLength-ucCnt-1] = *( ((unsigned char*)&ui64Value) + ucCnt );
00508                                 }
00509                                 if ((ucCnt < 8) && (*( ((unsigned char*)&ui64Value) + ucCnt ) != 0))
00510                                 {
00511                                         DeleteXmlTree(); // clean up
00512                                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00513                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00514                                 }
00515 
00516                                 // set all not used byte to zero
00517                                 memset(&item.ucIDD[metadata.ucIDDLength], 0, 128-metadata.ucIDDLength);
00518                                 break;
00519 
00520                         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
00521                                 if(strlen(cValue) != (metadata.ucIDDLength<<1))
00522                                 {
00523                                         DeleteXmlTree(); // clean up
00524                                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00525                                         FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
00526                                 }
00527 
00528                                 FEDM_ConvHexCharToHexUChar(cValue, (metadata.ucIDDLength<<1), item.ucIDD, 128);
00529                                 break;
00530                         }
00531                 }
00532 
00533                 // <timezones>
00534                 child = FindTag(FEDM_XML_TAG_TIMEZONES_UC, (unsigned int)3, true);
00535                 if(child != NULL)
00536                 {
00537                         AddTagItem(access_data, child);
00538                         timezones = child;
00539 
00540                         // <timezone>
00541                         child = FindTag(FEDM_XML_TAG_TIMEZONE_UC, (unsigned int)4, true);
00542                         while(child)
00543                         {
00544                                 AddTagItem(timezones, child);
00545                                 AddTagItem(access_data, child);
00546                                 FEDM_SWSCANF(child->sValue, cValue);
00547                                 sscanf(cValue, "%u", &uiValue);
00548                                 if(uiValue >= 1 && uiValue <= 16)
00549                                 {
00550                                         uiBit = 1;
00551                                         uiBit <<= (uiValue-1);
00552                                         item.uiTimezones |= uiBit;
00553                                 }
00554                                 else
00555                                 {
00556                                         DeleteXmlTree(); // clean up
00557                                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00558                                 }
00559 
00560                                 child = FindTag(FEDM_XML_TAG_TIMEZONE_UC, (unsigned int)4, true);
00561                         }
00562                 }
00563 
00564                 // <reserved> - ignored
00565 
00566                 // save new record in table
00567                 FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem = new FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM;
00568                 memcpy(pItem, &item, sizeof(FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM));
00569                 m_pAxxessReader->m_AccessTable.push_back(pItem);
00570 
00571                 child = FindTag(FEDM_XML_TAG_ACCESS_DATA_UC, (unsigned int)2, true);
00572         }
00573 
00574         // at least: update metadata
00575         m_pAxxessReader->SetIDDFormat(metadata.ucIDDFormat);
00576         m_pAxxessReader->SetIDDLength(metadata.ucIDDLength);
00577 
00578         // #####################################################
00579 
00580         FEDM_RETURN(FEDM_OK);
00581 }
00582 
00583 /***************************************************************************
00584   Begin         :       25.06.2009 / M. Hultsch
00585   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
00586 
00587   Function              :       read xml document for doc type holiday table
00588 
00589   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
00590 
00591   Return value  :       FEDM_OK or error code (<0)
00592 ***************************************************************************/
00593 int FedmIscMyAxxess_XmlParser::SerializeIn_HolidayTable(FEDM_XML_TREEITEM* root)
00594 {
00595         char cValue[128];
00596         unsigned int uiYear = 0;
00597         unsigned int uiMonth = 0;
00598         unsigned int uiDay = 0;
00599         FEDM_XML_TREEITEM* table        = NULL;
00600         FEDM_XML_TREEITEM* child        = NULL;
00601 
00602         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*   pItem = NULL;
00603 
00604 
00605         // delete content of holiday table
00606         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
00607 
00608 
00609         // #####################################################
00610         //      <holiday-table>
00611         //              ...
00612         //      </holiday-table>
00613         
00614         // <holiday-table>
00615         child = FindTag(FEDM_XML_TAG_HOLIDAY_TABLE_UC, (unsigned int)1, true);
00616         if(child == NULL)
00617         {
00618                 DeleteXmlTree(); // clean up
00619                 return m_iLastError;
00620         }
00621         AddTagItem(root, child);
00622         table = child;
00623 
00624         // <holiday>
00625         child = FindTag(FEDM_XML_TAG_HOLIDAY_UC, (unsigned int)2, true);
00626         while(child != NULL)
00627         {
00628                 AddTagItem(table, child);
00629 
00630                 // date format is according to XML-Schema-Definition
00631                 // The w3C xs:date data type is specified in the following form "YYYY-MM-DD" where:
00632                 // YYYY indicates the year
00633                 // MM indicates the month
00634                 // DD indicates the day
00635 
00636                 FEDM_SWSCANF(child->sValue, cValue);
00637                 sscanf(cValue, "%u-%u-%u", &uiYear, &uiMonth, &uiDay);
00638                 if(uiYear < 2000 || uiYear > 2099 || uiMonth < 1 || uiMonth > 12 || uiDay < 1 || uiDay > 31)
00639                 {
00640                         DeleteXmlTree(); // clean up
00641                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
00642                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00643                 }
00644 
00645                 // save new record in table
00646                 pItem = new FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM;
00647                 pItem->Init();
00648                 pItem->ucHoliday_Year = (unsigned char)(uiYear - 2000);
00649                 pItem->ucHoliday_Month = (unsigned char)uiMonth;
00650                 pItem->ucHoliday_Day = (unsigned char)uiDay;
00651                 m_pAxxessReader->m_HolidayTable.push_back(pItem);
00652 
00653                 child = FindTag(FEDM_XML_TAG_HOLIDAY_UC, (unsigned int)2, true);
00654         }
00655 
00656         // #####################################################
00657 
00658         FEDM_RETURN(FEDM_OK);
00659 }
00660 
00661 /***************************************************************************
00662   Begin         :       25.06.2009 / M. Hultsch
00663   Version       :       03.00.08 / 26.06.2009 / M. Hultsch
00664 
00665   Function              :       read xml document for doc type timezone table
00666 
00667   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
00668 
00669   Return value  :       FEDM_OK or error code (<0)
00670 ***************************************************************************/
00671 int FedmIscMyAxxess_XmlParser::SerializeIn_TimezoneTable(FEDM_XML_TREEITEM* root)
00672 {
00673         char cValue[128];
00674         unsigned int uiYear = 0;
00675         unsigned int uiMonth = 0;
00676         unsigned int uiDay = 0;
00677         unsigned int uiHour = 0;
00678         unsigned int uiMinute = 0;
00679         unsigned int uiSecond = 0;
00680         FEDM_XML_TREEITEM* table        = NULL;
00681         FEDM_XML_TREEITEM* zone         = NULL;
00682         FEDM_XML_TREEITEM* days         = NULL;
00683         FEDM_XML_TREEITEM* child        = NULL;
00684 
00685         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*  pItem = NULL;
00686         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM   item;
00687 
00688         item.Init();
00689 
00690         // delete content of timezone table
00691         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00692 
00693 
00694         // #####################################################
00695         //      <timezone-table>
00696         //              ...
00697         //      </timezone-table>
00698         
00699         // <timezone-table>
00700         child = FindTag(FEDM_XML_TAG_TIMEZONE_TABLE_UC, (unsigned int)1, true);
00701         if(child == NULL)
00702         {
00703                 DeleteXmlTree(); // clean up
00704                 return m_iLastError;
00705         }
00706         AddTagItem(root, child);
00707         table = child;
00708 
00709         // <timezone>
00710         child = FindTag(FEDM_XML_TAG_TIMEZONE_UC, (unsigned int)2, true);
00711         while(child != NULL)
00712         {
00713                 item.Init();
00714 
00715                 AddTagItem(table, child);
00716                 zone = child;
00717 
00718                 // <days>
00719                 child = FindTag(FEDM_XML_TAG_DAYS_UC, (unsigned int)3, true);
00720                 if(child == NULL)
00721                 {
00722                         DeleteXmlTree(); // clean up
00723                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00724                         return m_iLastError;
00725                 }
00726                 AddTagItem(zone, child);
00727                 days = child;
00728 
00729                 // <monday>
00730                 child = FindTag(FEDM_XML_TAG_MONDAY_UC, (unsigned int)4, true);
00731                 if(child == NULL)
00732                 {
00733                         DeleteXmlTree(); // clean up
00734                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00735                         return m_iLastError;
00736                 }
00737                 AddTagItem(days, child);
00738                 FEDM_SWSCANF(child->sValue, cValue);
00739                 sscanf(cValue, "%u", &uiDay);
00740                 if(uiDay > 0)
00741                         item.ucDays |= 0x02;
00742 
00743                 // <tuesday>
00744                 child = FindTag(FEDM_XML_TAG_TUESDAY_UC, (unsigned int)4, true);
00745                 if(child == NULL)
00746                 {
00747                         DeleteXmlTree(); // clean up
00748                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00749                         return m_iLastError;
00750                 }
00751                 AddTagItem(days, child);
00752                 FEDM_SWSCANF(child->sValue, cValue);
00753                 sscanf(cValue, "%u", &uiDay);
00754                 if(uiDay > 0)
00755                         item.ucDays |= 0x04;
00756 
00757                 // <wednesday>
00758                 child = FindTag(FEDM_XML_TAG_WEDNESDAY_UC, (unsigned int)4, true);
00759                 if(child == NULL)
00760                 {
00761                         DeleteXmlTree(); // clean up
00762                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00763                         return m_iLastError;
00764                 }
00765                 AddTagItem(days, child);
00766                 FEDM_SWSCANF(child->sValue, cValue);
00767                 sscanf(cValue, "%u", &uiDay);
00768                 if(uiDay > 0)
00769                         item.ucDays |= 0x08;
00770 
00771                 // <thursday>
00772                 child = FindTag(FEDM_XML_TAG_THURSDAY_UC, (unsigned int)4, true);
00773                 if(child == NULL)
00774                 {
00775                         DeleteXmlTree(); // clean up
00776                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00777                         return m_iLastError;
00778                 }
00779                 AddTagItem(days, child);
00780                 FEDM_SWSCANF(child->sValue, cValue);
00781                 sscanf(cValue, "%u", &uiDay);
00782                 if(uiDay > 0)
00783                         item.ucDays |= 0x10;
00784 
00785                 // <friday>
00786                 child = FindTag(FEDM_XML_TAG_FRIDAY_UC, (unsigned int)4, true);
00787                 if(child == NULL)
00788                 {
00789                         DeleteXmlTree(); // clean up
00790                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00791                         return m_iLastError;
00792                 }
00793                 AddTagItem(days, child);
00794                 FEDM_SWSCANF(child->sValue, cValue);
00795                 sscanf(cValue, "%u", &uiDay);
00796                 if(uiDay > 0)
00797                         item.ucDays |= 0x20;
00798 
00799                 // <saturday>
00800                 child = FindTag(FEDM_XML_TAG_SATURDAY_UC, (unsigned int)4, true);
00801                 if(child == NULL)
00802                 {
00803                         DeleteXmlTree(); // clean up
00804                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00805                         return m_iLastError;
00806                 }
00807                 AddTagItem(days, child);
00808                 FEDM_SWSCANF(child->sValue, cValue);
00809                 sscanf(cValue, "%u", &uiDay);
00810                 if(uiDay > 0)
00811                         item.ucDays |= 0x40;
00812 
00813                 // <sunday>
00814                 child = FindTag(FEDM_XML_TAG_SUNDAY_UC, (unsigned int)4, true);
00815                 if(child == NULL)
00816                 {
00817                         DeleteXmlTree(); // clean up
00818                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00819                         return m_iLastError;
00820                 }
00821                 AddTagItem(days, child);
00822                 FEDM_SWSCANF(child->sValue, cValue);
00823                 sscanf(cValue, "%u", &uiDay);
00824                 if(uiDay > 0)
00825                         item.ucDays |= 0x01;
00826 
00827                 // <date-from>
00828                 child = FindTag(FEDM_XML_TAG_DATE_FROM_UC, (unsigned int)3, true);
00829                 if(child == NULL)
00830                 {
00831                         DeleteXmlTree(); // clean up
00832                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00833                         return m_iLastError;
00834                 }
00835                 AddTagItem(days, child);
00836 
00837                 // date format is according to XML-Schema-Definition
00838                 // The w3C xs:date data type is specified in the following form "YYYY-MM-DD" where:
00839                 // YYYY indicates the year
00840                 // MM indicates the month
00841                 // DD indicates the day
00842 
00843                 FEDM_SWSCANF(child->sValue, cValue);
00844                 sscanf(cValue, "%u-%u-%u", &uiYear, &uiMonth, &uiDay);
00845                 if(uiYear < 2000 || uiYear > 2099 || uiMonth < 1 || uiMonth > 12 || uiDay < 1 || uiDay > 31)
00846                 {
00847                         DeleteXmlTree(); // clean up
00848                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00849                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00850                 }
00851                 item.ucStartDate_Year   = (unsigned char)(uiYear - 2000);
00852                 item.ucStartDate_Month  = (unsigned char)uiMonth;
00853                 item.ucStartDate_Day    = (unsigned char)uiDay;
00854 
00855                 // <date-to>
00856                 child = FindTag(FEDM_XML_TAG_DATE_TO_UC, (unsigned int)3, true);
00857                 if(child == NULL)
00858                 {
00859                         DeleteXmlTree(); // clean up
00860                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00861                         return m_iLastError;
00862                 }
00863                 AddTagItem(days, child);
00864 
00865                 // date format is according to XML-Schema-Definition
00866                 // The w3C xs:date data type is specified in the following form "YYYY-MM-DD" where:
00867                 // YYYY indicates the year
00868                 // MM indicates the month
00869                 // DD indicates the day
00870 
00871                 FEDM_SWSCANF(child->sValue, cValue);
00872                 sscanf(cValue, "%u-%u-%u", &uiYear, &uiMonth, &uiDay);
00873                 if(uiYear < 2000 || uiYear > 2099 || uiMonth < 1 || uiMonth > 12 || uiDay < 1 || uiDay > 31)
00874                 {
00875                         DeleteXmlTree(); // clean up
00876                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00877                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00878                 }
00879                 item.ucEndDate_Year             = (unsigned char)(uiYear - 2000);
00880                 item.ucEndDate_Month    = (unsigned char)uiMonth;
00881                 item.ucEndDate_Day              = (unsigned char)uiDay;
00882 
00883                 // <time-from>
00884                 child = FindTag(FEDM_XML_TAG_TIME_FROM_UC, (unsigned int)3, true);
00885                 if(child == NULL)
00886                 {
00887                         DeleteXmlTree(); // clean up
00888                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00889                         return m_iLastError;
00890                 }
00891                 AddTagItem(days, child);
00892 
00893                 // time format is according to XML-Schema-Definition
00894                 // The w3C xs:time data type is specified in the following form "hh:mm:ss" where:
00895                 // hh indicates the hour        {0..23}
00896                 // mm indicates the minute      {0..59}
00897                 // ss indicates the second (are ignored in myAxxess)
00898 
00899                 FEDM_SWSCANF(child->sValue, cValue);
00900                 sscanf(cValue, "%u:%u:%u", &uiHour, &uiMinute, &uiSecond);
00901                 if(uiHour > 23 || uiMinute > 59)
00902                 {
00903                         DeleteXmlTree(); // clean up
00904                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00905                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00906                 }
00907                 item.ucStartTime_Hour   = (unsigned char)uiHour;
00908                 item.ucStartTime_Minute = (unsigned char)uiMinute;
00909 
00910                 // <time-to>
00911                 child = FindTag(FEDM_XML_TAG_TIME_TO_UC, (unsigned int)3, true);
00912                 if(child == NULL)
00913                 {
00914                         DeleteXmlTree(); // clean up
00915                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00916                         return m_iLastError;
00917                 }
00918                 AddTagItem(days, child);
00919 
00920                 // time format is according to XML-Schema-Definition
00921                 // The w3C xs:time data type is specified in the following form "hh:mm:ss" where:
00922                 // hh indicates the hour        {0..23}
00923                 // mm indicates the minute      {0..59}
00924                 // ss indicates the second (are ignored in myAxxess)
00925 
00926                 FEDM_SWSCANF(child->sValue, cValue);
00927                 sscanf(cValue, "%u:%u:%u", &uiHour, &uiMinute, &uiSecond);
00928                 if(uiHour > 23 || uiMinute > 59)
00929                 {
00930                         DeleteXmlTree(); // clean up
00931                         m_pAxxessReader->ClearTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00932                         FEDM_RETURN(FEDM_ERROR_PARAMETER);
00933                 }
00934                 item.ucEndTime_Hour             = (unsigned char)uiHour;
00935                 item.ucEndTime_Minute   = (unsigned char)uiMinute;
00936 
00937 
00938                 // save new record in table
00939                 pItem = new FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM;
00940                 memcpy(pItem, &item, sizeof(FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM));
00941                 m_pAxxessReader->m_TimezoneTable.push_back(pItem);
00942 
00943                 child = FindTag(FEDM_XML_TAG_TIMEZONE_UC, (unsigned int)2, true);
00944         }
00945 
00946         // #####################################################
00947 
00948         FEDM_RETURN(FEDM_OK);
00949 }
00950 
00951 /***************************************************************************
00952   Begin         :       25.06.2009 / M. Hultsch
00953   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
00954 
00955   Function              :       read xml document for doc type event table
00956 
00957   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
00958 
00959   Return value  :       FEDM_OK or error code (<0)
00960 ***************************************************************************/
00961 int FedmIscMyAxxess_XmlParser::SerializeIn_EventTable(FEDM_XML_TREEITEM* root)
00962 {
00963         FEDM_RETURN(FEDM_ERROR_UNSUPPORTED);
00964 }
00965 
00966 
00967 /***************************************************************************
00968   Begin         :       25.06.2009 / M. Hultsch
00969   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
00970 
00971   Function              :       write xml document for doc type access table
00972 
00973   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
00974 
00975   Return value  :       FEDM_OK or error code (<0)
00976 ***************************************************************************/
00977 int FedmIscMyAxxess_XmlParser::SerializeOut_AccessTable(FEDM_XML_TREEITEM* root)
00978 {
00979         char szValue[256];
00980         int     iBack = 0;
00981         unsigned int uiBit = 0;
00982         unsigned __int64 ui64Value = 0;
00983         wchar_t wcTmp[256];
00984         FEDM_XML_TREEITEM* table                = NULL;
00985         FEDM_XML_TREEITEM* access_data  = NULL;
00986         FEDM_XML_TREEITEM* timezones    = NULL;
00987         FEDM_XML_TREEITEM* child                = NULL;
00988         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem = NULL;
00989         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator itor;
00990 
00991         // #####################################################
00992         //      <access-table>
00993         //              ...
00994         //      </access-table>
00995 
00996         // #####################################################
00997         // add <access-table> tag
00998         child = BuildTag(FEDM_XML_TAG_ACCESS_TABLE_UC);
00999         if(child == NULL)
01000         {
01001                 DeleteXmlTree(); // clean up
01002                 return m_iLastError;
01003         }
01004         AddTagItem(root, child);
01005         table = child;
01006 
01007         // add <idd-format> tag
01008         child = BuildTag(FEDM_XML_TAG_IDD_FORMAT_UC, false);
01009         if(child == NULL)
01010         {
01011                 DeleteXmlTree(); // clean up
01012                 return GetLastError();
01013         }
01014         AddTagItem(table, child);
01015 
01016         switch(m_pAxxessReader->m_Metadata.ucIDDFormat)
01017         {
01018         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
01019         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
01020         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
01021                 break;
01022         default:
01023                 DeleteXmlTree(); // clean up
01024                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01025         }
01026 #if defined(__BORLANDC__) || defined(_MSC_VER)
01027         #if _MSC_VER <= 1200
01028         swprintf(wcTmp, L"%d", m_pAxxessReader->m_Metadata.ucIDDFormat);
01029         #else
01030         swprintf(wcTmp, 256, L"%d", m_pAxxessReader->m_Metadata.ucIDDFormat);
01031         #endif
01032 #else
01033         swprintf(wcTmp, 256, L"%d", m_pAxxessReader->m_Metadata.ucIDDFormat);
01034 #endif
01035         AddTagValue(child, wcTmp);
01036 
01037         // add <idd-length> tag
01038         child = BuildTag(FEDM_XML_TAG_IDD_LENGTH_UC, false);
01039         if(child == NULL)
01040         {
01041                 DeleteXmlTree(); // clean up
01042                 return GetLastError();
01043         }
01044 #if defined(__BORLANDC__) || defined(_MSC_VER)
01045         #if _MSC_VER <= 1200
01046         swprintf(wcTmp, L"%d", m_pAxxessReader->m_Metadata.ucIDDLength);
01047         #else
01048         swprintf(wcTmp, 256, L"%d", m_pAxxessReader->m_Metadata.ucIDDLength);
01049         #endif
01050 #else
01051         swprintf(wcTmp, 256, L"%d", m_pAxxessReader->m_Metadata.ucIDDLength);
01052 #endif
01053         AddTagValue(child, wcTmp);
01054         AddTagItem(table, child);
01055 
01056         // add <access-data> tag
01057         child = BuildTag(FEDM_XML_TAG_ACCESS_DATA_UC, false);
01058         if(child == NULL)
01059         {
01060                 DeleteXmlTree(); // clean up
01061                 return GetLastError();
01062         }
01063         AddTagItem(table, child);
01064         access_data = child;
01065 
01066         // add all records
01067         for(itor  = m_pAxxessReader->m_AccessTable.begin();
01068                 itor != m_pAxxessReader->m_AccessTable.end();
01069                 itor++)
01070         {
01071                 pItem = *itor;
01072                 if(pItem == NULL)
01073                         continue;
01074 
01075                 // add <idd> tag
01076                 child = BuildTag(FEDM_XML_TAG_IDD_UC, false);
01077                 if(child == NULL)
01078                 {
01079                         DeleteXmlTree(); // clean up
01080                         return GetLastError();
01081                 }
01082 
01083                 switch(m_pAxxessReader->m_Metadata.ucIDDFormat)
01084                 {
01085                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
01086                         memcpy(szValue, pItem->ucIDD, m_pAxxessReader->m_Metadata.ucIDDLength);
01087                         szValue[m_pAxxessReader->m_Metadata.ucIDDLength] = '\0';
01088                         break;
01089 
01090                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
01091                         if(strlen((char*)pItem->ucIDD) > 20)
01092                         {
01093                                 DeleteXmlTree(); // clean up
01094                                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
01095                         }       
01096                         ui64Value = 0;
01097                         for(unsigned char ucCnt=0; ucCnt<m_pAxxessReader->m_Metadata.ucIDDLength; ucCnt++ )
01098                         {
01099                                 // change Motorola format to Intel format
01100                                 ui64Value += ( (unsigned __int64)pItem->ucIDD[m_pAxxessReader->m_Metadata.ucIDDLength-ucCnt-1] << (8*ucCnt) );
01101                         }
01102                         break;
01103 
01104                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
01105                         FEDM_ConvHexUCharToHexChar(pItem->ucIDD, m_pAxxessReader->m_Metadata.ucIDDLength, szValue, 256);
01106                         break;
01107                 }
01108 
01109 #if defined(__BORLANDC__) || defined(_MSC_VER)
01110         #if _MSC_VER <= 1200
01111                 swprintf(wcTmp, L"%S", szValue);
01112         #else
01113                 swprintf(wcTmp, 256, L"%S", szValue);
01114         #endif
01115 #else
01116                 swprintf(wcTmp, 256, L"%S", szValue);
01117 #endif
01118                 AddTagValue(child, wcTmp);
01119                 AddTagItem(access_data, child);
01120 
01121                 // add <timezones> tag
01122                 child = BuildTag(FEDM_XML_TAG_TIMEZONES_UC, false);
01123                 if(child == NULL)
01124                 {
01125                         DeleteXmlTree(); // clean up
01126                         return GetLastError();
01127                 }
01128                 AddTagItem(access_data, child);
01129                 timezones = child;
01130 
01131                 uiBit = 1;
01132                 for(int iCnt=1; iCnt<=16; iCnt++)
01133                 {
01134                         if(pItem->uiTimezones & uiBit)
01135                         {
01136                                 // add <timezone> tag
01137                                 child = BuildTag(FEDM_XML_TAG_TIMEZONE_UC, false);
01138                                 if(child == NULL)
01139                                 {
01140                                         DeleteXmlTree(); // clean up
01141                                         return GetLastError();
01142                                 }
01143 #if defined(__BORLANDC__) || defined(_MSC_VER)
01144         #if _MSC_VER <= 1200
01145                                 swprintf(wcTmp, L"%d", iCnt);
01146         #else
01147                                 swprintf(wcTmp, 256, L"%d", iCnt);
01148         #endif
01149 #else
01150                                 swprintf(wcTmp, 256, L"%d", iCnt);
01151 #endif
01152                                 AddTagValue(child, wcTmp);
01153                                 AddTagItem(timezones, child);
01154 
01155                                 uiBit <<= 1;
01156                         }
01157                 }
01158 
01159                 // add <reserved> tag - ignored
01160         }
01161 
01162 
01163         FEDM_RETURN(FEDM_OK);
01164 }
01165 
01166 /***************************************************************************
01167   Begin         :       25.06.2009 / M. Hultsch
01168   Version       :       03.00.08 / 26.06.2009 / M. Hultsch
01169 
01170   Function              :       write xml document for doc type holiday table
01171 
01172   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
01173 
01174   Return value  :       FEDM_OK or error code (<0)
01175 ***************************************************************************/
01176 int FedmIscMyAxxess_XmlParser::SerializeOut_HolidayTable(FEDM_XML_TREEITEM* root)
01177 {
01178         int     iBack = 0;
01179         wchar_t wcTmp[128];
01180         FEDM_XML_TREEITEM* table                = NULL;
01181         FEDM_XML_TREEITEM* child                = NULL;
01182         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem = NULL;
01183         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itor;
01184 
01185         // #####################################################
01186         //      <holiday-table>
01187         //              ...
01188         //      </holiday-table>
01189 
01190         // #####################################################
01191         // add <holiday-table> tag
01192         child = BuildTag(FEDM_XML_TAG_HOLIDAY_TABLE_UC);
01193         if(child == NULL)
01194         {
01195                 DeleteXmlTree(); // clean up
01196                 return m_iLastError;
01197         }
01198         AddTagItem(root, child);
01199         table = child;
01200 
01201         // add all records
01202         for(itor  = m_pAxxessReader->m_HolidayTable.begin();
01203                 itor != m_pAxxessReader->m_HolidayTable.end();
01204                 itor++ )
01205         {
01206                 pItem = *itor;
01207                 if(pItem == NULL)
01208                         continue;
01209 
01210                 // add <holiday> tag
01211                 child = BuildTag(FEDM_XML_TAG_HOLIDAY_UC, false);
01212                 if(child == NULL)
01213                 {
01214                         DeleteXmlTree(); // clean up
01215                         return GetLastError();
01216                 }
01217 
01218 #if defined(__BORLANDC__) || defined(_MSC_VER)
01219         #if _MSC_VER <= 1200
01220                 swprintf(wcTmp, L"%d-%02d-%02d", ((int)(pItem->ucHoliday_Year)+2000), pItem->ucHoliday_Month, pItem->ucHoliday_Day);
01221         #else
01222                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucHoliday_Year)+2000), pItem->ucHoliday_Month, pItem->ucHoliday_Day);
01223         #endif
01224 #else
01225                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucHoliday_Year)+2000), pItem->ucHoliday_Month, pItem->ucHoliday_Day);
01226 #endif
01227                 AddTagValue(child, wcTmp);
01228                 AddTagItem(table, child);
01229         }
01230 
01231 
01232         FEDM_RETURN(FEDM_OK);
01233 }
01234 
01235 /***************************************************************************
01236   Begin         :       25.06.2009 / M. Hultsch
01237   Version       :       03.00.08 / 26.06.2009 / M. Hultsch
01238 
01239   Function              :       write xml document for doc type timezone table
01240 
01241   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
01242 
01243   Return value  :       FEDM_OK or error code (<0)
01244 ***************************************************************************/
01245 int FedmIscMyAxxess_XmlParser::SerializeOut_TimezoneTable(FEDM_XML_TREEITEM* root)
01246 {
01247         int     iBack = 0;
01248         wchar_t wcTmp[128];
01249         FEDM_XML_TREEITEM* table        = NULL;
01250         FEDM_XML_TREEITEM* zone         = NULL;
01251         FEDM_XML_TREEITEM* days         = NULL;
01252         FEDM_XML_TREEITEM* child        = NULL;
01253         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem = NULL;
01254         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itor;
01255 
01256         // #####################################################
01257         //      <timezone-table>
01258         //              ...
01259         //      </timezone-table>
01260 
01261         // #####################################################
01262         // add <timezone-table> tag
01263         child = BuildTag(FEDM_XML_TAG_TIMEZONE_TABLE_UC);
01264         if(child == NULL)
01265         {
01266                 DeleteXmlTree(); // clean up
01267                 return m_iLastError;
01268         }
01269         AddTagItem(root, child);
01270         table = child;
01271 
01272         // add all records
01273         for(itor  = m_pAxxessReader->m_TimezoneTable.begin();
01274                 itor != m_pAxxessReader->m_TimezoneTable.end();
01275                 itor++ )
01276         {
01277                 pItem = *itor;
01278                 if(pItem == NULL)
01279                         continue;
01280 
01281                 // add <timezone> tag
01282                 child = BuildTag(FEDM_XML_TAG_TIMEZONE_UC, false);
01283                 if(child == NULL)
01284                 {
01285                         DeleteXmlTree(); // clean up
01286                         return GetLastError();
01287                 }
01288                 AddTagItem(table, child);
01289                 zone = child;
01290 
01291                 // add <days> tag
01292                 child = BuildTag(FEDM_XML_TAG_DAYS_UC, false);
01293                 if(child == NULL)
01294                 {
01295                         DeleteXmlTree(); // clean up
01296                         return GetLastError();
01297                 }
01298                 AddTagItem(zone, child);
01299                 days = child;
01300 
01301                 // add <monday> tag
01302                 child = BuildTag(FEDM_XML_TAG_MONDAY_UC, false);
01303                 if(child == NULL)
01304                 {
01305                         DeleteXmlTree(); // clean up
01306                         return GetLastError();
01307                 }
01308                 if(pItem->ucDays & 0x02)        AddTagValue(child, L"1");
01309                 else                                            AddTagValue(child, L"0");
01310                 AddTagItem(days, child);
01311 
01312                 // add <tuesday> tag
01313                 child = BuildTag(FEDM_XML_TAG_TUESDAY_UC, false);
01314                 if(child == NULL)
01315                 {
01316                         DeleteXmlTree(); // clean up
01317                         return GetLastError();
01318                 }
01319                 if(pItem->ucDays & 0x04)        AddTagValue(child, L"1");
01320                 else                                            AddTagValue(child, L"0");
01321                 AddTagItem(days, child);
01322 
01323                 // add <wednesday> tag
01324                 child = BuildTag(FEDM_XML_TAG_WEDNESDAY_UC, false);
01325                 if(child == NULL)
01326                 {
01327                         DeleteXmlTree(); // clean up
01328                         return GetLastError();
01329                 }
01330                 if(pItem->ucDays & 0x08)        AddTagValue(child, L"1");
01331                 else                                            AddTagValue(child, L"0");
01332                 AddTagItem(days, child);
01333 
01334                 // add <thursday> tag
01335                 child = BuildTag(FEDM_XML_TAG_THURSDAY_UC, false);
01336                 if(child == NULL)
01337                 {
01338                         DeleteXmlTree(); // clean up
01339                         return GetLastError();
01340                 }
01341                 if(pItem->ucDays & 0x10)        AddTagValue(child, L"1");
01342                 else                                            AddTagValue(child, L"0");
01343                 AddTagItem(days, child);
01344 
01345                 // add <friday> tag
01346                 child = BuildTag(FEDM_XML_TAG_FRIDAY_UC, false);
01347                 if(child == NULL)
01348                 {
01349                         DeleteXmlTree(); // clean up
01350                         return GetLastError();
01351                 }
01352                 if(pItem->ucDays & 0x20)        AddTagValue(child, L"1");
01353                 else                                            AddTagValue(child, L"0");
01354                 AddTagItem(days, child);
01355 
01356                 // add <saturday> tag
01357                 child = BuildTag(FEDM_XML_TAG_SATURDAY_UC, false);
01358                 if(child == NULL)
01359                 {
01360                         DeleteXmlTree(); // clean up
01361                         return GetLastError();
01362                 }
01363                 if(pItem->ucDays & 0x40)        AddTagValue(child, L"1");
01364                 else                                            AddTagValue(child, L"0");
01365                 AddTagItem(days, child);
01366 
01367                 // add <sunday> tag
01368                 child = BuildTag(FEDM_XML_TAG_SUNDAY_UC, false);
01369                 if(child == NULL)
01370                 {
01371                         DeleteXmlTree(); // clean up
01372                         return GetLastError();
01373                 }
01374                 if(pItem->ucDays & 0x01)        AddTagValue(child, L"1");
01375                 else                                            AddTagValue(child, L"0");
01376                 AddTagItem(days, child);
01377 
01378                 // add <date-from> tag
01379                 child = BuildTag(FEDM_XML_TAG_DATE_FROM_UC, false);
01380                 if(child == NULL)
01381                 {
01382                         DeleteXmlTree(); // clean up
01383                         return GetLastError();
01384                 }
01385 #if defined(__BORLANDC__) || defined(_MSC_VER)
01386         #if _MSC_VER <= 1200
01387                 swprintf(wcTmp, L"%d-%02d-%02d", ((int)(pItem->ucStartDate_Year)+2000), pItem->ucStartDate_Month, pItem->ucStartDate_Day);
01388         #else
01389                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucStartDate_Year)+2000), pItem->ucStartDate_Month, pItem->ucStartDate_Day);
01390         #endif
01391 #else
01392                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucStartDate_Year)+2000), pItem->ucStartDate_Month, pItem->ucStartDate_Day);
01393 #endif
01394                 AddTagValue(child, wcTmp);
01395                 AddTagItem(zone, child);
01396 
01397                 // add <date-to> tag
01398                 child = BuildTag(FEDM_XML_TAG_DATE_TO_UC, false);
01399                 if(child == NULL)
01400                 {
01401                         DeleteXmlTree(); // clean up
01402                         return GetLastError();
01403                 }
01404 #if defined(__BORLANDC__) || defined(_MSC_VER)
01405         #if _MSC_VER <= 1200
01406                 swprintf(wcTmp, L"%d-%02d-%02d", ((int)(pItem->ucEndDate_Year)+2000), pItem->ucEndDate_Month, pItem->ucEndDate_Day);
01407         #else
01408                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucEndDate_Year)+2000), pItem->ucEndDate_Month, pItem->ucEndDate_Day);
01409         #endif
01410 #else
01411                 swprintf(wcTmp, 128, L"%d-%02d-%02d", ((int)(pItem->ucEndDate_Year)+2000), pItem->ucEndDate_Month, pItem->ucEndDate_Day);
01412 #endif
01413                 AddTagValue(child, wcTmp);
01414                 AddTagItem(zone, child);
01415 
01416                 // add <time-from> tag
01417                 child = BuildTag(FEDM_XML_TAG_TIME_FROM_UC, false);
01418                 if(child == NULL)
01419                 {
01420                         DeleteXmlTree(); // clean up
01421                         return GetLastError();
01422                 }
01423 #if defined(__BORLANDC__) || defined(_MSC_VER)
01424         #if _MSC_VER <= 1200
01425                 swprintf(wcTmp, L"%02d:%02d:00", pItem->ucStartTime_Hour, pItem->ucStartTime_Minute);
01426         #else
01427                 swprintf(wcTmp, 128, L"%02d:%02d:00", pItem->ucStartTime_Hour, pItem->ucStartTime_Minute);
01428         #endif
01429 #else
01430                 swprintf(wcTmp, 128, L"%02d:%02d:00", pItem->ucStartTime_Hour, pItem->ucStartTime_Minute);
01431 #endif
01432                 AddTagValue(child, wcTmp);
01433                 AddTagItem(zone, child);
01434 
01435                 // add <time-to> tag
01436                 child = BuildTag(FEDM_XML_TAG_TIME_TO_UC, false);
01437                 if(child == NULL)
01438                 {
01439                         DeleteXmlTree(); // clean up
01440                         return GetLastError();
01441                 }
01442 #if defined(__BORLANDC__) || defined(_MSC_VER)
01443         #if _MSC_VER <= 1200
01444                 swprintf(wcTmp, L"%02d:%02d:00", pItem->ucEndTime_Hour, pItem->ucEndTime_Minute);
01445         #else
01446                 swprintf(wcTmp, 128, L"%02d:%02d:00", pItem->ucEndTime_Hour, pItem->ucEndTime_Minute);
01447         #endif
01448 #else
01449                 swprintf(wcTmp, 128, L"%02d:%02d:00", pItem->ucEndTime_Hour, pItem->ucEndTime_Minute);
01450 #endif
01451                 AddTagValue(child, wcTmp);
01452                 AddTagItem(zone, child);
01453         }
01454 
01455 
01456         FEDM_RETURN(FEDM_OK);
01457 }
01458 
01459 /***************************************************************************
01460   Begin         :       25.06.2009 / M. Hultsch
01461   Version       :       03.00.08 / 29.06.2009 / M. Hultsch
01462 
01463   Function              :       write xml document for doc type event table
01464 
01465   Parameters    :       FEDM_XML_TREEITEM* root - pointer to parent xml element
01466                                         unsigned int& uiCrc             - reference to crc
01467 
01468   Return value  :       FEDM_OK or error code (<0)
01469 ***************************************************************************/
01470 int FedmIscMyAxxess_XmlParser::SerializeOut_EventTable(FEDM_XML_TREEITEM* root, unsigned int& uiCrc)
01471 {
01472         char szValue[256];
01473         int     iBack = 0;
01474         wchar_t wcTmp[256];
01475         unsigned __int64 ui64Value = 0;
01476         FEDM_XML_TREEITEM* table        = NULL;
01477         FEDM_XML_TREEITEM* ev           = NULL;
01478         FEDM_XML_TREEITEM* child        = NULL;
01479         FEDM_ISC_MYAXXESS_EVENT_TABLE_ITEM* pItem = NULL;
01480 
01481 
01482         // verify correct metadata info
01483         switch(m_pAxxessReader->m_Metadata.ucIDDFormat)
01484         {
01485         case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
01486         case FEDM_MYAXXESS_IDD_FORMAT_HEX:
01487         case FEDM_MYAXXESS_IDD_FORMAT_NUM:
01488                 break;
01489         default:
01490                 FEDM_RETURN(FEDM_ERROR_PARAMETER);
01491         }
01492 
01493 
01494         // calculate crc over some header data
01495         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)m_XmlHeader.szDocType, (unsigned int)strlen(m_XmlHeader.szDocType));
01496         uiCrc = CalcCRC16CheckSum(uiCrc, m_XmlHeader.uiDocVersion);
01497 
01498         // #####################################################
01499         //      <event-table>
01500         //              ...
01501         //      </event-table>
01502 
01503         // #####################################################
01504         // add <event-table> tag
01505         child = BuildTag(FEDM_XML_TAG_EVENT_TABLE_UC);
01506         if(child == NULL)
01507         {
01508                 DeleteXmlTree(); // clean up
01509                 return m_iLastError;
01510         }
01511         AddTagItem(root, child);
01512         table = child;
01513 
01514         while(! m_pAxxessReader->m_EventTable.empty())
01515         {
01516                 pItem = m_pAxxessReader->m_EventTable.front();
01517                 if(pItem == NULL)
01518                         continue;
01519 
01520                 // add <event> tag
01521                 child = BuildTag(FEDM_XML_TAG_EVENT_UC, false);
01522                 if(child == NULL)
01523                 {
01524                         DeleteXmlTree(); // clean up
01525                         return GetLastError();
01526                 }
01527                 AddTagItem(table, child);
01528                 ev = child;
01529 
01530                 // calculate crc over data
01531                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEventID);
01532                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)pItem->ucIDD, (unsigned int)m_pAxxessReader->m_Metadata.ucIDDLength);
01533                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucYear);
01534                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucMonth);
01535                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucDay);
01536                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucHour);
01537                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucMinute);
01538                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucSecond);
01539                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucInput);
01540                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucAction);
01541                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->uiError);
01542                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)pItem->sSourceIP.c_str(), (unsigned int)pItem->sSourceIP.length());
01543 
01544                 // add <event-id> tag
01545                 child = BuildTag(FEDM_XML_TAG_EVENT_ID_UC, false);
01546                 if(child == NULL)
01547                 {
01548                         delete pItem;
01549                         DeleteXmlTree(); // clean up
01550                         return GetLastError();
01551                 }
01552 #if defined(__BORLANDC__) || defined(_MSC_VER)
01553         #if _MSC_VER <= 1200
01554                 swprintf(wcTmp, L"%d", pItem->ucEventID);
01555         #else
01556                 swprintf(wcTmp, 256, L"%d", pItem->ucEventID);
01557         #endif
01558 #else
01559                 swprintf(wcTmp, 256, L"%d", pItem->ucEventID);
01560 #endif
01561                 AddTagValue(child, wcTmp);
01562                 AddTagItem(ev, child);
01563 
01564                 // add <idd> tag
01565                 child = BuildTag(FEDM_XML_TAG_IDD_UC, false);
01566                 if(child == NULL)
01567                 {
01568                         delete pItem;
01569                         DeleteXmlTree(); // clean up
01570                         return GetLastError();
01571                 }
01572 
01573                 switch(m_pAxxessReader->m_Metadata.ucIDDFormat)
01574                 {
01575                 case FEDM_MYAXXESS_IDD_FORMAT_ASCII:
01576                         memcpy(szValue, pItem->ucIDD, pItem->ucIDDLength);
01577                         szValue[pItem->ucIDDLength] = '\0';
01578                         break;
01579 
01580                 case FEDM_MYAXXESS_IDD_FORMAT_NUM:
01581                         if(strlen((char*)pItem->ucIDD) > 20)
01582                         {
01583                                 delete pItem;
01584                                 DeleteXmlTree(); // clean up
01585                                 FEDM_RETURN(FEDM_ERROR_STRING_LENGTH);
01586                         }       
01587                         ui64Value = 0;
01588                         for(unsigned char ucCnt=0; ucCnt<pItem->ucIDDLength; ucCnt++ )
01589                         {
01590                                 // change Motorola format to Intel format
01591                                 ui64Value += ( (unsigned __int64)pItem->ucIDD[pItem->ucIDDLength-ucCnt-1] << (8*ucCnt) );
01592                         }
01593                         break;
01594 
01595                 case FEDM_MYAXXESS_IDD_FORMAT_HEX:
01596                         FEDM_ConvHexUCharToHexChar(pItem->ucIDD, pItem->ucIDDLength, szValue, 256);
01597                         break;
01598                 }
01599 
01600 #if defined(__BORLANDC__) || defined(_MSC_VER)
01601         #if _MSC_VER <= 1200
01602                 swprintf(wcTmp, L"%S", szValue);
01603         #else
01604                 swprintf(wcTmp, 256, L"%S", szValue);
01605         #endif
01606 #else
01607                 swprintf(wcTmp, 256, L"%S", szValue);
01608 #endif
01609                 AddTagValue(child, wcTmp);
01610                 AddTagItem(ev, child);
01611 
01612                 // add <date> tag
01613                 child = BuildTag(FEDM_XML_TAG_DATE_UC, false);
01614                 if(child == NULL)
01615                 {
01616                         delete pItem;
01617                         DeleteXmlTree(); // clean up
01618                         return GetLastError();
01619                 }
01620 #if defined(__BORLANDC__) || defined(_MSC_VER)
01621         #if _MSC_VER <= 1200
01622                 swprintf(wcTmp, L"%d-%02d-%02d", ((int)(pItem->ucYear)+2000), pItem->ucMonth, pItem->ucDay);
01623         #else
01624                 swprintf(wcTmp, 256, L"%d-%02d-%02d", ((int)(pItem->ucYear)+2000), pItem->ucMonth, pItem->ucDay);
01625         #endif
01626 #else
01627                 swprintf(wcTmp, 256, L"%d-%02d-%02d", ((int)(pItem->ucYear)+2000), pItem->ucMonth, pItem->ucDay);
01628 #endif
01629                 AddTagValue(child, wcTmp);
01630                 AddTagItem(ev, child);
01631 
01632                 // add <time> tag
01633                 child = BuildTag(FEDM_XML_TAG_TIME_UC, false);
01634                 if(child == NULL)
01635                 {
01636                         delete pItem;
01637                         DeleteXmlTree(); // clean up
01638                         return GetLastError();
01639                 }
01640 #if defined(__BORLANDC__) || defined(_MSC_VER)
01641         #if _MSC_VER <= 1200
01642                 swprintf(wcTmp, L"%02d:%02d:%02d", pItem->ucHour, pItem->ucMinute, pItem->ucSecond);
01643         #else
01644                 swprintf(wcTmp, 256, L"%02d:%02d:%02d", pItem->ucHour, pItem->ucMinute, pItem->ucSecond);
01645         #endif
01646 #else
01647                 swprintf(wcTmp, 256, L"%02d:%02d:%02d", pItem->ucHour, pItem->ucMinute, pItem->ucSecond);
01648 #endif
01649                 AddTagValue(child, wcTmp);
01650                 AddTagItem(ev, child);
01651 
01652                 // add <input> tag
01653                 child = BuildTag(FEDM_XML_TAG_INPUT_UC, false);
01654                 if(child == NULL)
01655                 {
01656                         delete pItem;
01657                         DeleteXmlTree(); // clean up
01658                         return GetLastError();
01659                 }
01660 #if defined(__BORLANDC__) || defined(_MSC_VER)
01661         #if _MSC_VER <= 1200
01662                 swprintf(wcTmp, L"%d", pItem->ucInput);
01663         #else
01664                 swprintf(wcTmp, 256, L"%d", pItem->ucInput);
01665         #endif
01666 #else
01667                 swprintf(wcTmp, 256, L"%d", pItem->ucInput);
01668 #endif
01669                 AddTagValue(child, wcTmp);
01670                 AddTagItem(ev, child);
01671 
01672                 // add <action> tag
01673                 child = BuildTag(FEDM_XML_TAG_ACTION_UC, false);
01674                 if(child == NULL)
01675                 {
01676                         delete pItem;
01677                         DeleteXmlTree(); // clean up
01678                         return GetLastError();
01679                 }
01680 #if defined(__BORLANDC__) || defined(_MSC_VER)
01681         #if _MSC_VER <= 1200
01682                 swprintf(wcTmp, L"%d", pItem->ucAction);
01683         #else
01684                 swprintf(wcTmp, 256, L"%d", pItem->ucAction);
01685         #endif
01686 #else
01687                 swprintf(wcTmp, 256, L"%d", pItem->ucAction);
01688 #endif
01689                 AddTagValue(child, wcTmp);
01690                 AddTagItem(ev, child);
01691 
01692                 // add <error> tag
01693                 child = BuildTag(FEDM_XML_TAG_ERROR_UC, false);
01694                 if(child == NULL)
01695                 {
01696                         delete pItem;
01697                         DeleteXmlTree(); // clean up
01698                         return GetLastError();
01699                 }
01700 #if defined(__BORLANDC__) || defined(_MSC_VER)
01701         #if _MSC_VER <= 1200
01702                 swprintf(wcTmp, L"%d", pItem->uiError);
01703         #else
01704                 swprintf(wcTmp, 256, L"%i", pItem->uiError);
01705         #endif
01706 #else
01707                 swprintf(wcTmp, 256, L"%i", pItem->uiError);
01708 #endif
01709                 AddTagValue(child, wcTmp);
01710                 AddTagItem(ev, child);
01711 
01712                 // add <source> tag
01713                 child = BuildTag(FEDM_XML_TAG_SOURCE_UC, false);
01714                 if(child == NULL)
01715                 {
01716                         delete pItem;
01717                         DeleteXmlTree(); // clean up
01718                         return GetLastError();
01719                 }
01720 #if defined(__BORLANDC__) || defined(_MSC_VER)
01721         #if _MSC_VER <= 1200
01722                 swprintf(wcTmp, L"%S", pItem->sSourceIP.c_str());
01723         #else
01724                 swprintf(wcTmp, 256, L"%S", pItem->sSourceIP.c_str());
01725         #endif
01726 #else
01727                 swprintf(wcTmp, 256, L"%S", pItem->sSourceIP.c_str());
01728 #endif
01729                 AddTagValue(child, wcTmp);
01730                 AddTagItem(ev, child);
01731         
01732                 // item must be deleted, because item is no longer controlled by the queue
01733                 delete pItem;
01734                 m_pAxxessReader->m_EventTable.pop();
01735 
01736         } // while(! m_pAxxessReader->m_EventTable.empty())
01737 
01738         FEDM_RETURN(FEDM_OK);
01739 }
01740 
01741 
01742 /***************************************************************************
01743   Begin         :       25.06.2009 / M. Hultsch
01744   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
01745 
01746   Function              :       calculate CRC16 checksum over access table
01747 
01748   Parameters    :       -
01749 
01750   Return value  :       unsigned int uiCrc      - checksum
01751 ***************************************************************************/
01752 unsigned int FedmIscMyAxxess_XmlParser::CalcChecksum_AccessTable()
01753 {
01754         unsigned int uiCrc = FEDM_CRC16_PRESET;
01755         FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM* pItem = NULL;
01756         vector<FEDM_ISC_MYAXXESS_ACCESS_TABLE_ITEM*>::iterator itor;
01757 
01758         // calculate crc over some header data
01759         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)m_XmlHeader.szDocType, (unsigned int)strlen(m_XmlHeader.szDocType));
01760         uiCrc = CalcCRC16CheckSum(uiCrc, m_XmlHeader.uiDocVersion);
01761 
01762         // calculate crc over data
01763         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)m_pAxxessReader->m_Metadata.ucIDDFormat);
01764         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)m_pAxxessReader->m_Metadata.ucIDDLength);
01765 
01766         for(itor  = m_pAxxessReader->m_AccessTable.begin();
01767                 itor != m_pAxxessReader->m_AccessTable.end();
01768                 itor++ )
01769         {
01770                 pItem = *itor;
01771                 if(pItem == NULL)
01772                         continue;
01773 
01774                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)pItem->ucIDD, (unsigned int)m_pAxxessReader->m_Metadata.ucIDDLength);
01775                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->uiTimezones);
01776                 //uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucReserved); // ignored
01777         }
01778 
01779         return uiCrc;
01780 }
01781 
01782 
01783 /***************************************************************************
01784   Begin         :       25.06.2009 / M. Hultsch
01785   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
01786 
01787   Function              :       calculate CRC16 checksum over holiday table
01788 
01789   Parameters    :       -
01790 
01791   Return value  :       unsigned int uiCrc      - checksum
01792 ***************************************************************************/
01793 unsigned int FedmIscMyAxxess_XmlParser::CalcChecksum_HolidayTable()
01794 {
01795         unsigned int uiCrc = FEDM_CRC16_PRESET;
01796         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM* pItem = NULL;
01797         vector<FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM*>::iterator itor;
01798 
01799         // calculate crc over some header data
01800         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)m_XmlHeader.szDocType, (unsigned int)strlen(m_XmlHeader.szDocType));
01801         uiCrc = CalcCRC16CheckSum(uiCrc, m_XmlHeader.uiDocVersion);
01802 
01803         // calculate crc over data
01804         for(itor  = m_pAxxessReader->m_HolidayTable.begin();
01805                 itor != m_pAxxessReader->m_HolidayTable.end();
01806                 itor++ )
01807         {
01808                 pItem = *itor;
01809                 if(pItem == NULL)
01810                         continue;
01811 
01812                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucHoliday_Year);
01813                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucHoliday_Month);
01814                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucHoliday_Day);
01815         }
01816 
01817         return uiCrc;
01818 }
01819 
01820 
01821 /***************************************************************************
01822   Begin         :       25.06.2009 / M. Hultsch
01823   Version       :       03.00.08 / 25.06.2009 / M. Hultsch
01824 
01825   Function              :       calculate CRC16 checksum over timezone table
01826 
01827   Parameters    :       -
01828 
01829   Return value  :       unsigned int uiCrc      - checksum
01830 ***************************************************************************/
01831 unsigned int FedmIscMyAxxess_XmlParser::CalcChecksum_TimezoneTable()
01832 {
01833         unsigned int uiCrc = FEDM_CRC16_PRESET;
01834         FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM* pItem = NULL;
01835         vector<FEDM_ISC_MYAXXESS_TIMEZONE_TABLE_ITEM*>::iterator itor;
01836 
01837         // calculate crc over some header data
01838         uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned char*)m_XmlHeader.szDocType, (unsigned int)strlen(m_XmlHeader.szDocType));
01839         uiCrc = CalcCRC16CheckSum(uiCrc, m_XmlHeader.uiDocVersion);
01840 
01841         // calculate crc over data
01842         for(itor  = m_pAxxessReader->m_TimezoneTable.begin();
01843                 itor != m_pAxxessReader->m_TimezoneTable.end();
01844                 itor++ )
01845         {
01846                 pItem = *itor;
01847                 if(pItem == NULL)
01848                         continue;
01849 
01850                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucDays);
01851                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucStartDate_Year);
01852                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucStartDate_Month);
01853                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucStartDate_Day);
01854                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEndDate_Year);
01855                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEndDate_Month);
01856                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEndDate_Day);
01857                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucStartTime_Hour);
01858                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucStartTime_Minute);
01859                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEndTime_Hour);
01860                 uiCrc = CalcCRC16CheckSum(uiCrc, (unsigned int)pItem->ucEndTime_Minute);
01861         }
01862 
01863         return uiCrc;
01864 }
01865 
01866 
01867 void FedmIscMyAxxess_XmlParser::SetComment()
01868 {
01869         wstring sXmlComment;
01870 
01871         sXmlComment  = L"\n\n";
01872         sXmlComment += L"<!-- Copyright © 2009 -->\n";
01873         sXmlComment += L"<!-- FEIG ELECTRONIC GmbH, All Rights Reserved. -->\n";
01874         sXmlComment += L"<!-- Lange Strasse 4 -->\n";
01875         sXmlComment += L"<!-- D-35781 Weilburg -->\n";
01876         sXmlComment += L"<!-- Federal Republic of Germany -->\n";
01877         sXmlComment += L"<!-- phone    : +49 6471 31090 -->\n";
01878         sXmlComment += L"<!-- fax      : +49 6471 310999 -->\n";
01879         sXmlComment += L"<!-- e-mail   : obid-support@feig.de -->\n";
01880         sXmlComment += L"<!-- Internet : http://www.feig.de -->\n";
01881         sXmlComment += L"<!-- OBID® and OBID i-scan® are registered Trademarks of FEIG ELECTRONIC GmbH -->\n";
01882         sXmlComment += L"\n";
01883         sXmlComment += L"<!-- This file contains a myAxxess-Reader file for one OBID i-scan® or OBID® classic-pro reader -->\n";
01884         sXmlComment += L"\n\n";
01885 
01886         FEDM_XmlParser_Base::SetComment(sXmlComment);
01887 }
01888 
01889 #endif // #if defined(_FEDM_MYAXXESS_XML_SUPPORT)


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