FEDM_XmlReaderCfgDataModul.cpp
Go to the documentation of this file.
00001 /*-------------------------------------------------------
00002 |                                                       |
00003 |              FEDM_XmlReaderCfgDataModul.cpp           |
00004 |                                                       |
00005 ---------------------------------------------------------
00006 
00007 Copyright  2000-2012    FEIG ELECTRONIC GmbH, All Rights Reserved.
00008                                                 Lange Strasse 4
00009                                                 D-35781 Weilburg
00010                                                 Federal Republic of Germany
00011                                                 phone    : +49 6471 31090
00012                                                 fax      : +49 6471 310999
00013                                                 e-mail   : obid-support@feig.de
00014                                                 Internet : http://www.feig.de
00015                                         
00016 Author                  :       Markus Hultsch
00017 Begin                   :       23.04.2003
00018 Version                 :       04.00.09 / 01.02.2012 / M. Hultsch
00019                                                 - AddReaderInfo: mode 0x04 >> modification for CPR-Reader 
00020 
00021                                                 03.03.00 / 01.02.2011 / M. Hultsch
00022 
00023 Operation Systems       :       independent
00024 
00025 Function                        :       main class for XML document handler
00026                                                 
00027 Note                            :       this XML document handler is designed only for use
00028                                                 inside the class library FEDM !!
00029 
00030 
00031 Trademarks:
00032 -----------
00033 OBID®, OBID i-scan® and OBID myAXXESS® are registered Trademarks of FEIG ELECTRONIC GmbH
00034 Other Trademarks: see FEDM.h
00035 */
00036 
00037 
00038 #ifdef _FEDM_XML_SUPPORT
00039 
00040 
00041 #include "FEDM_XmlReaderCfgDataModul.h"
00042 #include "FEDM_DataBase.h"
00043 #include "i_scan/FEDM_ISC.h"
00044 #include <time.h>
00045 
00046 #if _MSC_VER >= 1400
00047         #pragma warning(disable : 4996)
00048 #endif
00049 
00050 
00051 
00052 
00053 //#####################################################################################
00054 // Construction/Destruction
00055 //#####################################################################################
00056 
00057 /***************************************************************************
00058   Begin         :       23.04.2003 / M. Hultsch
00059   Version       :       03.00.00 / 16.04.2008 / M. Hultsch
00060 
00061   Function              :       constructor
00062 
00063   Parameters    :       -
00064 
00065   Return value  :       -
00066 
00067 ***************************************************************************/
00068 FEDM_XMLReaderCfgDataModul::FEDM_XMLReaderCfgDataModul()
00069 {
00070         m_pReaderInfo           = NULL;
00071 
00072         m_wsDocType                     = L"";
00073         m_wsDocVer                      = L"";
00074         m_wsComment                     = L"";
00075         m_wsPrgName                     = L"";
00076         m_wsPrgVer                      = L"";
00077         m_wsFedmVer                     = L"";
00078         m_wsHost                        = L"";  // for TCP/IP
00079         m_wsPort                        = L"";  // for TCP/IP
00080         m_wsDate                        = L"";
00081         m_wsTime                        = L"";
00082         m_wsCommMode            = L"";  // last communication mode
00083 }
00084 
00085 /***************************************************************************
00086   Begin         :       23.04.2003 / M. Hultsch
00087   Version       :       01.08.00 / 23.04.2003 / M. Hultsch
00088 
00089   Function              :       destructor
00090 
00091   Parameters    :       -
00092 
00093   Return value  :       -
00094 
00095 ***************************************************************************/
00096 FEDM_XMLReaderCfgDataModul::~FEDM_XMLReaderCfgDataModul()
00097 {
00098 }
00099 
00100 
00101 //#####################################################################################
00102 // serialization functions
00103 //#####################################################################################
00104 
00105 /***************************************************************************
00106   Begin         :       23.04.2003 / M. Hultsch
00107   Version       :       03.00.00 / 16.04.2008 / M. Hultsch
00108 
00109   Function              :       read xml document and save content in reader class
00110 
00111   Parameters    :       FEDM_DataBase* pReader
00112                                         char* sFileName -       file name
00113 
00114   Return value  :       FEDM_OK or error code (<0)
00115 
00116 ***************************************************************************/
00117 int FEDM_XMLReaderCfgDataModul::SerializeIn(FEDM_DataBase* pReader, char* sFileName)
00118 {
00119         FEDM_CHK5(pReader);
00120         FEDM_CHK5(sFileName);
00121 
00122         char    cValue[32];
00123         char*   cFamCode = NULL;
00124         wchar_t wcFamCode[5];
00125         unsigned int uiTmp;
00126         int             iBack = 0;
00127         wstring wsFamCode;
00128         FEDM_XML_TREEITEM* root = NULL;
00129         FEDM_XML_TREEITEM* parent = NULL;
00130         FEDM_XML_TREEITEM* child = NULL;
00131 
00132         
00133         iBack = OpenDoc(sFileName, "r");
00134         if(iBack)
00135                 return iBack;
00136         
00137         // is it a xml document?
00138         if(IsXmlDoc())
00139         {
00140                 CloseDoc();
00141                 return m_iLastError;
00142         }
00143 
00144         // has the xml document an OBID tag?
00145         if(HasOBIDTag())
00146         {
00147                 CloseDoc();
00148                 return m_iLastError;
00149         }
00150         
00151         // read complete xml document into string
00152         if(ReadDoc())
00153         {
00154                 CloseDoc();
00155                 return m_iLastError;
00156         }
00157 
00158         CloseDoc();
00159 
00160 
00161         // root tag
00162         root = FindTag(FEDM_XML_TAG_OBID_UC);
00163         if(root == NULL)
00164                 return m_iLastError;
00165         AddTagItem(NULL, root);
00166 
00167         // header tag
00168         child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
00169         if(child == NULL)
00170         {
00171                 DeleteXmlTree(); // clean up
00172                 return m_iLastError;
00173         }
00174         AddTagItem(root, child);
00175         parent = child;
00176 
00177         // header tag document type
00178         child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
00179         if(child == NULL)
00180         {
00181                 DeleteXmlTree(); // clean up
00182                 return m_iLastError;
00183         }
00184         if(child->sValue != FEDM_XML_STRING_DOC_TYPE_1_UC)
00185         {
00186                 delete child;
00187                 DeleteXmlTree(); // clean up
00188                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_TYPE);
00189         }
00190         m_wsDocType = child->sValue;
00191         AddTagItem(parent, child);
00192 
00193         // header tag document version
00194         child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
00195         if(child == NULL)
00196         {
00197                 DeleteXmlTree(); // clean up
00198                 return m_iLastError;
00199         }
00200         if(child->sValue != FEDM_XML_STRING_DOC_VERSION_UC)
00201         {
00202                 delete child;
00203                 DeleteXmlTree(); // clean up
00204                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_VERSION);
00205         }
00206         m_wsDocVer = child->sValue;
00207         AddTagItem(parent, child);
00208 
00209         // header tag reader family name
00210         child = FindTag(FEDM_XML_TAG_READER_FAM_UC);
00211         if(child == NULL)
00212         {
00213                 DeleteXmlTree(); // clean up
00214                 return m_iLastError;
00215         }
00216 
00217         // check the family code
00218         if(child->sValue.size() > 4)
00219         {
00220                 delete child;
00221                 DeleteXmlTree(); // clean up
00222                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_FAMILY);
00223         }
00224         cFamCode = pReader->GetFamilyCode();
00225 #if defined(__BORLANDC__) || defined(_MSC_VER)
00226         swprintf(wcFamCode, L"%S", cFamCode);
00227 #else
00228         swprintf(wcFamCode, 5, L"%s", cFamCode);
00229 #endif
00230         wsFamCode = wcFamCode;
00231         if(child->sValue != wsFamCode)
00232         {
00233                 delete child;
00234                 DeleteXmlTree(); // clean up
00235                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_FAMILY);
00236         }
00237         AddTagItem(parent, child);
00238 
00239         // header tag reader type
00240         child = FindTag(FEDM_XML_TAG_READER_TYPE_UC);
00241         if(child != NULL)
00242         {
00243                 AddTagItem(parent, child);
00244 #if defined(__BORLANDC__) || defined(_MSC_VER)
00245                 swscanf(child->sValue.c_str(), L"%S", cValue);
00246 #elif defined(_FEDM_SUPPORT_UCLINUX)
00247                 FEDM_SWSCANF(child->sValue.c_str(), cValue);
00248 #else
00249                 swscanf(child->sValue.c_str(), L"%s", cValue);
00250 #endif
00251                 sscanf(cValue, "%u", &uiTmp);
00252                 pReader->SetReaderType(uiTmp);
00253         }
00254         else
00255         {
00256                 pReader->SetReaderType(0);
00257         }
00258 
00259         // header tag  bus address
00260         child = FindTag(FEDM_XML_TAG_BUSADR_UC);
00261         if(child != NULL)
00262         {
00263                 AddTagItem(parent, child);
00264 #if defined(__BORLANDC__) || defined(_MSC_VER)
00265                 swscanf(child->sValue.c_str(), L"%S", cValue);
00266 #elif defined(_FEDM_SUPPORT_UCLINUX)
00267                 FEDM_SWSCANF(child->sValue.c_str(), cValue);
00268 #else
00269                 swscanf(child->sValue.c_str(), L"%s", cValue);
00270 #endif
00271                 sscanf(cValue, "%d", &uiTmp);
00272                 pReader->SetBusAddress((unsigned char)uiTmp);
00273         }
00274 
00275         // header tag host-address
00276         child = FindTag(FEDM_XML_TAG_HOSTADR_UC);
00277         if(child != NULL)
00278         {
00279                 AddTagItem(parent, child);
00280                 m_wsHost = child->sValue;
00281         }
00282 
00283         // header tag port-number
00284         child = FindTag(FEDM_XML_TAG_PORTNR_UC);
00285         if(child != NULL)
00286         {
00287                 AddTagItem(parent, child);
00288                 m_wsPort = child->sValue;
00289         }
00290 
00291         // header tag communication mode
00292         child = FindTag(FEDM_XML_TAG_COMM_MODE_UC);
00293         if(child != NULL)
00294         {
00295                 AddTagItem(parent, child);
00296                 m_wsCommMode = child->sValue;
00297         }
00298 
00299         // header tag protocol-frame-support
00300         child = FindTag(FEDM_XML_TAG_FRAME_SUPPORT);
00301         if(child != NULL)
00302         {
00303                 AddTagItem(parent, child);
00304                 if(wcscmp(child->sValue.c_str(), L"advanced") == 0)
00305                 {
00306                         pReader->SetProtocolFrameSupport(FEDM_PRT_FRAME_ADVANCED);
00307                 }
00308                 else
00309                 {
00310                         pReader->SetProtocolFrameSupport(FEDM_PRT_FRAME_STANDARD);
00311                 }
00312         }
00313 
00314         // header tag comment
00315         child = FindTag(FEDM_XML_TAG_COMMENT_UC);
00316         if(child != NULL)
00317         {
00318                 AddTagItem(parent, child);
00319                 m_wsComment = child->sValue;
00320         }
00321 
00322         // optional: tag <reader>
00323 //      if(m_pReaderInfo)
00324 //              GetReaderInfo(pReader, root);
00325 
00326         // ... transfer content of tag items to byte arrays
00327         iBack = pReader->SerializeIn(this, root);
00328         if(iBack)
00329         {
00330                 DeleteXmlTree(); // clean up
00331                 return iBack;
00332         }
00333 
00334         // clean up
00335         DeleteXmlTree();
00336 
00337         FEDM_RETURN(FEDM_OK);
00338 }
00339 
00340 
00341 /***************************************************************************
00342   Begin         :       23.04.2003 / M. Hultsch
00343   Version       :       03.02.05 / 03.09.2010 / M. Hultsch
00344 
00345   Function              :       write content of reader class into xml document
00346 
00347   Parameters    :       FEDM_DataBase* pReader
00348                                         char* sFileName -       file name
00349 
00350   Return value  :       FEDM_OK or error code (<0)
00351 
00352 ***************************************************************************/
00353 int FEDM_XMLReaderCfgDataModul::SerializeOut(FEDM_DataBase* pReader, char* sFileName)
00354 {
00355         FEDM_CHK5(pReader);
00356         FEDM_CHK5(sFileName);
00357 
00358         int             iBack = 0;
00359         char    cValue[32];
00360         wchar_t wcTmp[128];
00361 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00362         time_t  ltime;
00363         struct  tm *tmtime;
00364 #endif
00365         FEDM_XML_TREEITEM* root = NULL;
00366         FEDM_XML_TREEITEM* parent = NULL;
00367         FEDM_XML_TREEITEM* child = NULL;
00368 
00369         int iPortHnd = pReader->GetPortHnd();
00370 
00371 
00372         // root tag
00373         root = BuildTag(FEDM_XML_TAG_OBID_UC);
00374         if(root == NULL)
00375         {
00376                 return m_iLastError;
00377         }
00378         AddTagItem(NULL, root);
00379 
00380         // header tag
00381         child = BuildTag(FEDM_XML_TAG_FILE_HDR_UC);
00382         if(child == NULL)
00383         {
00384                 DeleteXmlTree(); // clean up
00385                 return m_iLastError;
00386         }
00387         AddTagItem(root, child);
00388         parent = child;
00389 
00390         // header tag document type
00391         child = BuildTag(FEDM_XML_TAG_DOC_TYPE_UC, false);
00392         if(child == NULL)
00393         {
00394                 DeleteXmlTree(); // clean up
00395                 return m_iLastError;
00396         }
00397         AddTagValue(child, FEDM_XML_STRING_DOC_TYPE_1_UC);
00398         AddTagItem(parent, child);
00399 
00400         // header tag document version
00401         child = BuildTag(FEDM_XML_TAG_DOC_VERSION_UC, false);
00402         if(child == NULL)
00403         {
00404                 DeleteXmlTree(); // clean up
00405                 return m_iLastError;
00406         }
00407         AddTagValue(child, FEDM_XML_STRING_DOC_VERSION_UC);
00408         AddTagItem(parent, child);
00409 
00410         // header tag reader family name
00411         child = BuildTag(FEDM_XML_TAG_READER_FAM_UC, false);
00412         if(child == NULL)
00413         {
00414                 DeleteXmlTree(); // clean up
00415                 return m_iLastError;
00416         }
00417 #if defined(__BORLANDC__) || defined(_MSC_VER)
00418         swprintf(wcTmp, L"%S", pReader->GetFamilyCode());
00419 #else
00420         swprintf(wcTmp, 128, L"%s", pReader->GetFamilyCode());
00421 #endif
00422         AddTagValue(child, wcTmp);
00423         AddTagItem(parent, child);
00424 
00425         // header tag reader name
00426         child = BuildTag(FEDM_XML_TAG_READER_NAME_UC, false);
00427         if(child == NULL)
00428         {
00429                 DeleteXmlTree(); // clean up
00430                 return m_iLastError;
00431         }
00432 #if defined(__BORLANDC__) || defined(_MSC_VER)
00433         swprintf(wcTmp, L"%S", pReader->GetReaderName());
00434 #else
00435         swprintf(wcTmp, 128, L"%s", pReader->GetReaderName());
00436 #endif
00437         AddTagValue(child, wcTmp);
00438         AddTagItem(parent, child);
00439 
00440         // header tag reader type
00441         child = BuildTag(FEDM_XML_TAG_READER_TYPE_UC, false);
00442         if(child == NULL)
00443         {
00444                 DeleteXmlTree(); // clean up
00445                 return m_iLastError;
00446         }
00447 #if defined(__BORLANDC__) || defined(_MSC_VER)
00448         swprintf(wcTmp, L"%u", pReader->GetReaderType());
00449 #else
00450         swprintf(wcTmp, 128, L"%u", pReader->GetReaderType());
00451 #endif
00452         AddTagValue(child, wcTmp);
00453         AddTagItem(parent, child);
00454 
00455 
00456         if(FEDM_IS_USBPORT(iPortHnd))
00457         {
00458 #ifdef _FEDM_USB_SUPPORT
00459                 // header tag usb device-id
00460                 child = BuildTag(FEDM_XML_TAG_DEVICE_ID_UC, false);
00461                 if(child == NULL)
00462                 {
00463                         DeleteXmlTree(); // clean up
00464                         return m_iLastError;
00465                 }
00466 #if !defined(_FEDM_SUPPORT_SLINK)
00467                 LPFN_FEUSB_GET_DEVICE_PARA lpfn = (LPFN_FEUSB_GET_DEVICE_PARA)pReader->GetFeUsbFunction(FEUSB_GET_DEVICE_PARA);
00468                 if(lpfn == NULL)
00469                         return FEDM_ERROR_NULL_POINTER;
00470 
00471                 if(0 == lpfn(iPortHnd, "Device-ID", cValue))
00472 #else
00473                 if(0 == FEUSB_GetDevicePara(iPortHnd, "Device-ID", cValue))
00474 #endif
00475                 {
00476 #if defined(__BORLANDC__) || defined(_MSC_VER)
00477                         swprintf(wcTmp, L"%S", cValue);
00478 #else
00479                         swprintf(wcTmp, 128, L"%s", cValue);
00480 #endif
00481                         AddTagValue(child, wcTmp);
00482                         AddTagItem(parent, child);
00483 
00484                         // header tag communication mode
00485                         child = BuildTag(FEDM_XML_TAG_COMM_MODE_UC, false);
00486                         if(child == NULL)
00487                         {
00488                                 DeleteXmlTree(); // clean up
00489                                 return m_iLastError;
00490                         }
00491                         AddTagValue(child, FEDM_XML_STRING_COMM_MODE_USB_UC);
00492                         AddTagItem(parent, child);
00493                 }
00494                 else
00495                 {
00496                         delete child;
00497                 }
00498 #endif
00499         }
00500         else if(FEDM_IS_TCPPORT(iPortHnd))
00501         {
00502 #ifdef _FEDM_TCP_SUPPORT
00503                 LPFN_FETCP_GET_SOCKET_PARA lpfn = (LPFN_FETCP_GET_SOCKET_PARA)pReader->GetFeTcpFunction(FETCP_GET_SOCKET_PARA);
00504                 if(lpfn != NULL)
00505                 {
00506                         // header tag host-address
00507                         child = BuildTag(FEDM_XML_TAG_HOSTADR_UC, false);
00508                         if(child == NULL)
00509                         {
00510                                 DeleteXmlTree(); // clean up
00511                                 return m_iLastError;
00512                         }
00513                         if(0 == lpfn(iPortHnd, "HostAdr", cValue))
00514                         {
00515 #if defined(__BORLANDC__) || defined(_MSC_VER)
00516                                 swprintf(wcTmp, L"%S", cValue);
00517 #else
00518                                 swprintf(wcTmp, 128, L"%s", cValue);
00519 #endif
00520                                 AddTagValue(child, wcTmp);
00521                                 AddTagItem(parent, child);
00522                         }
00523                         else
00524                         {
00525                                 delete child;
00526                         }
00527 
00528                         // header tag port-number
00529                         child = BuildTag(FEDM_XML_TAG_PORTNR_UC, false);
00530                         if(child == NULL)
00531                         {
00532                                 DeleteXmlTree(); // clean up
00533                                 return m_iLastError;
00534                         }
00535 
00536                         if(0 == lpfn(iPortHnd, "PortNr", cValue))
00537                         {
00538 #if defined(__BORLANDC__) || defined(_MSC_VER)
00539                                 swprintf(wcTmp, L"%S", cValue);
00540 #else
00541                                 swprintf(wcTmp, 128, L"%s", cValue);
00542 #endif
00543                                 AddTagValue(child, wcTmp);
00544                                 AddTagItem(parent, child);
00545                         }
00546                         else
00547                         {
00548                                 delete child;
00549                         }
00550 
00551                         // header tag communication mode
00552                         child = BuildTag(FEDM_XML_TAG_COMM_MODE_UC, false);
00553                         if(child == NULL)
00554                         {
00555                                 DeleteXmlTree(); // clean up
00556                                 return m_iLastError;
00557                         }
00558                         AddTagValue(child, FEDM_XML_STRING_COMM_MODE_TCP_UC);
00559                         AddTagItem(parent, child);
00560                 }
00561 #endif
00562         }
00563         else
00564         {
00565 #ifdef _FEDM_COM_SUPPORT
00566 #if !defined(_FEDM_SUPPORT_SLINK)
00567                 LPFN_FECOM_GET_PORT_PARA lpfn = (LPFN_FECOM_GET_PORT_PARA)pReader->GetFeComFunction(FECOM_GET_PORT_PARA);
00568                 if(lpfn == NULL)
00569                         return FEDM_ERROR_NULL_POINTER;
00570 #endif
00571                 // header tag bus address
00572                 child = BuildTag(FEDM_XML_TAG_BUSADR_UC, false);
00573                 if(child == NULL)
00574                 {
00575                         DeleteXmlTree(); // clean up
00576                         return m_iLastError;
00577                 }
00578 #if defined(__BORLANDC__) || defined(_MSC_VER)
00579                 swprintf(wcTmp, L"%d", pReader->GetBusAddress());
00580 #else
00581                 swprintf(wcTmp, 128, L"%d", pReader->GetBusAddress());
00582 #endif
00583                 AddTagValue(child, wcTmp);
00584                 AddTagItem(parent, child);
00585 
00586                 // header tag serial com port
00587                 child = BuildTag(FEDM_XML_TAG_COMPORT_UC, false);
00588                 if(child == NULL)
00589                 {
00590                         DeleteXmlTree(); // clean up
00591                         return m_iLastError;
00592                 }
00593 
00594 #if !defined(_FEDM_SUPPORT_SLINK)
00595                 if(0 == lpfn(iPortHnd, "PortNr", cValue))
00596 #else
00597                 if(0 == FECOM_GetPortPara(iPortHnd, "PortNr", cValue))
00598 #endif
00599                 {
00600 #if defined(__BORLANDC__) || defined(_MSC_VER)
00601                         swprintf(wcTmp, L"%S", cValue);
00602 #else
00603                         swprintf(wcTmp, 128, L"%s", cValue);
00604 #endif
00605                         AddTagValue(child, wcTmp);
00606                         AddTagItem(parent, child);
00607 
00608                         // header tag communication mode
00609                         child = BuildTag(FEDM_XML_TAG_COMM_MODE_UC, false);
00610                         if(child == NULL)
00611                         {
00612                                 DeleteXmlTree(); // clean up
00613                                 return m_iLastError;
00614                         }
00615                         AddTagValue(child, FEDM_XML_STRING_COMM_MODE_SERIAL_UC);
00616                         AddTagItem(parent, child);
00617                 }
00618                 else
00619                 {
00620                         delete child;
00621                 }
00622 #endif
00623         }
00624 
00625         // header tag protocol-frame-support
00626         if(! FEDM_IS_USBPORT(iPortHnd))
00627         {
00628                 child = BuildTag(FEDM_XML_TAG_FRAME_SUPPORT, false);
00629                 if(child == NULL)
00630                 {
00631                         DeleteXmlTree(); // clean up
00632                         return m_iLastError;
00633                 }
00634                 if(pReader->GetProtocolFrameSupport() == FEDM_PRT_FRAME_ADVANCED)
00635                 {
00636 #if defined(__BORLANDC__) || defined(_MSC_VER)
00637                         swprintf(wcTmp, L"%S", "advanced");
00638 #else
00639                         swprintf(wcTmp, 128, L"%s", "advanced");
00640 #endif
00641                 }
00642                 else
00643                 {
00644 #if defined(__BORLANDC__) || defined(_MSC_VER)
00645                         swprintf(wcTmp, L"%S", "standard");
00646 #else
00647                         swprintf(wcTmp, 128, L"%s", "standard");
00648 #endif
00649                 }
00650                 AddTagValue(child, wcTmp);
00651                 AddTagItem(parent, child);
00652         }
00653         
00654 
00655         // header tag comment
00656         if(m_wsComment.size() > 0)
00657         {
00658                 child = BuildTag(FEDM_XML_TAG_COMMENT_UC, false);
00659                 if(child == NULL)
00660                 {
00661                         DeleteXmlTree(); // clean up
00662                         return m_iLastError;
00663                 }
00664                 AddTagValue(child, m_wsComment);
00665                 AddTagItem(parent, child);
00666         }
00667 
00668         // header tag program name
00669         child = BuildTag(FEDM_XML_TAG_PRG_NAME_UC, false);
00670         if(child == NULL)
00671         {
00672                 DeleteXmlTree(); // clean up
00673                 return m_iLastError;
00674         }
00675         AddTagValue(child, m_wsPrgName);
00676         AddTagItem(parent, child);
00677 
00678         // header tag program version number
00679         child = BuildTag(FEDM_XML_TAG_PRG_VERSION_UC, false);
00680         if(child == NULL)
00681         {
00682                 DeleteXmlTree(); // clean up
00683                 return m_iLastError;
00684         }
00685         AddTagValue(child, m_wsPrgVer);
00686         AddTagItem(parent, child);
00687 
00688         // header tag fedm library version number
00689         child = BuildTag(FEDM_XML_TAG_FEDM_VERSION_UC, false);
00690         if(child == NULL)
00691         {
00692                 DeleteXmlTree(); // clean up
00693                 return m_iLastError;
00694         }
00695         AddTagValue(child, FEDM_VERSION_UC);
00696         AddTagItem(parent, child);
00697 
00698         // header tag date
00699 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00700         child = BuildTag(FEDM_XML_TAG_DATE_UC, false);
00701         if(child == NULL)
00702         {
00703                 DeleteXmlTree(); // clean up
00704                 return m_iLastError;
00705         }
00706         time(&ltime);
00707         tmtime = localtime(&ltime);
00708         wcsftime(wcTmp, 128, L"%x", tmtime);
00709         AddTagValue(child, wcTmp);
00710         AddTagItem(parent, child);
00711 #endif
00712 
00713         // header tag time
00714 #if !defined(_FEDM_SUPPORT_UCLINUX) && !defined(_WIN32_WCE)
00715         child = BuildTag(FEDM_XML_TAG_TIME_UC, false);
00716         if(child == NULL)
00717         {
00718                 DeleteXmlTree(); // clean up
00719                 return m_iLastError;
00720         }
00721         wcsftime(wcTmp, 128, L"%X", tmtime);
00722         AddTagValue(child, wcTmp);
00723         AddTagItem(parent, child);
00724 #endif
00725 
00726         // header tag <reader-info>
00727         if(m_pReaderInfo)
00728         {
00729                 iBack = AddReaderInfo(pReader, root);
00730                 if(iBack)
00731                 {
00732                         DeleteXmlTree(); // clean up
00733                         return iBack;
00734                 }
00735         }
00736 
00737         // add data array tags
00738         iBack = pReader->SerializeOut(this, root);
00739         if(iBack)
00740         {
00741                 DeleteXmlTree(); // clean up
00742                 return iBack;
00743         }
00744 
00745         iBack = OpenDoc(sFileName, "w");
00746         if(iBack)
00747         {
00748                 DeleteXmlTree(); // clean up
00749                 return iBack;
00750         }
00751         else
00752         {
00753                 WriteDoc();
00754         }
00755 
00756 
00757         CloseDoc();
00758 
00759         FEDM_RETURN(FEDM_OK);
00760 }
00761 
00762 
00763 /***************************************************************************
00764   Begin         :       16.04.2008 / M. Hultsch
00765   Version       :       03.00.00 / 16.01.2009 / M. Hultsch
00766 
00767   Function              :       get reader information from xml file in tag <reader>
00768                                         >> these tags are all optional <<
00769 
00770   Parameters    :       FEDM_DataBase* pReader  - pointer to reader object
00771                                         FEDM_XML_TREEITEM* root - pointer to root element
00772 
00773   Return value  :       FEDM_OK or error code (<0)
00774 ***************************************************************************/
00775 int FEDM_XMLReaderCfgDataModul::GetReaderInfo(FEDM_DataBase* pReader, FEDM_XML_TREEITEM* root)
00776 {
00777         char cValue[128];
00778         int iTmp = 0;
00779         unsigned int uiReaderType = 0;
00780         FEDM_XML_TREEITEM* reader = NULL;
00781         FEDM_XML_TREEITEM* child = NULL;
00782         FEDM_XML_TREEITEM* sub = NULL;
00783         FEDM_XML_ATTRIBUTE_LIST_ITOR AttrItor;
00784 
00785         // tag <reader-info>
00786         child = FindTag(FEDM_XML_TAG_READER_INFO_UC, false, true);
00787         if(child == NULL)
00788                 return FEDM_OK;
00789 
00790         AddTagItem(root, child);
00791         reader = child;
00792 
00793         // header tags <controller>
00794         child = FindTag(FEDM_XML_TAG_CONTROLLER_UC, true);
00795         while(child)
00796         {
00797                 AddTagItem(reader, child);
00798                 sub = child;
00799                 for(AttrItor = sub->aAttribList.begin(); AttrItor != sub->aAttribList.end(); AttrItor++)
00800                 {
00801                         if((*AttrItor)->sAttribute != FEDM_XML_ATTRIB_TYPE_UC)
00802                                 continue;
00803 
00804                         if((*AttrItor)->sValue == L"RFC")
00805                         {
00806                                 // header tag <reader-type>
00807                                 child = FindTag(FEDM_XML_TAG_READER_TYPE_UC, true);
00808                                 if(child == NULL)
00809                                         return FEDM_OK;
00810                                 AddTagItem(sub, child);
00811                                 FEDM_SWSCANF(child->sValue, cValue);
00812                                 sscanf( cValue, 
00813                                                 "%u", 
00814                                                 (unsigned int*)&uiReaderType );
00815 
00816                                 if(uiReaderType & 0x00000080)
00817                                 {
00818                                         m_pReaderInfo->ucReaderClass            = (unsigned char)( uiReaderType & 0x000000FF);
00819                                         m_pReaderInfo->ucReaderClassGen         = (unsigned char)((uiReaderType & 0x0000FF00) >>  8);
00820                                         m_pReaderInfo->ucReaderTypeOfClass      = (unsigned char)((uiReaderType & 0x00FF0000) >> 16);
00821                                         m_pReaderInfo->ucReserved3                      = (unsigned char)((uiReaderType & 0xFF000000) >> 24);
00822                                 }
00823                                 else
00824                                 {
00825                                         m_pReaderInfo->ucReaderType                     = (unsigned char)(uiReaderType & 0x000000FF);
00826                                 }
00827 
00828                                 // tag <firmware-version>
00829                                 child = FindTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
00830                                 if(child == NULL)
00831                                         return FEDM_OK;
00832                                 AddTagItem(sub, child);
00833                                 FEDM_SWSCANF(child->sValue, cValue);
00834                                 sscanf( cValue, 
00835                                                 "%d.%d.%d", 
00836                                                 (unsigned int*)&m_pReaderInfo->ucRfcSwVer[0], 
00837                                                 (unsigned int*)&m_pReaderInfo->ucRfcSwVer[1], 
00838                                                 (unsigned int*)&m_pReaderInfo->ucRfcDevVer );
00839 
00840 
00841                                 // tag <hardware-type>
00842                                 child = FindTag(FEDM_XML_TAG_HARDWARE_TYPE_UC);
00843                                 if(child == NULL)
00844                                         return FEDM_OK;
00845                                 AddTagItem(sub, child);
00846                                 FEDM_SWSCANF(child->sValue, cValue);
00847                                 sscanf(cValue, "0x%02X", &iTmp);
00848                                 m_pReaderInfo->ucRfcHwType = (unsigned char)iTmp;
00849 
00850                                 m_pReaderInfo->bIsMode0x00Read = true;
00851                         }
00852                         else if((*AttrItor)->sValue == L"ACC")
00853                         {
00854                                 m_pReaderInfo->bIsMode0x01Read = true;
00855                         }
00856                         else if((*AttrItor)->sValue == L"USBC")
00857                         {
00858                                 m_pReaderInfo->bIsMode0x02Read = true;
00859                         }
00860                         else if((*AttrItor)->sValue == L"RFD")
00861                         {
00862                                 m_pReaderInfo->bIsMode0x03Read = true;
00863                         }
00864                         else if((*AttrItor)->sValue == L"FPGA")
00865                         {
00866                                 m_pReaderInfo->bIsMode0x03Read = true;
00867                         }
00868                         else if((*AttrItor)->sValue == L"BOOT")
00869                         {
00870                                 m_pReaderInfo->bIsMode0x05Read = true;
00871                         }
00872                 }
00873 
00874                 child = FindTag(FEDM_XML_TAG_CONTROLLER_UC, false, true, true);
00875         }
00876 
00877         m_pReaderInfo->bIsInfoRead = true;
00878         return FEDM_OK;
00879 }
00880 
00881 
00882 /***************************************************************************
00883   Begin         :       16.04.2008 / M. Hultsch
00884   Version       :       04.00.09 / 01.02.2012 / M. Hultsch
00885                                         - mode 0x04: modification for CPR-Reader
00886 
00887                                         03.00.00 / 28.08.2008 / M. Hultsch
00888 
00889   Function              :       add reader information to xml file in tag <reader>
00890 
00891   Parameters    :       FEDM_DataBase* pReader  - pointer to reader object
00892                                         FEDM_XML_TREEITEM* root - pointer to root element
00893 
00894   Return value  :       FEDM_OK or error code (<0)
00895 ***************************************************************************/
00896 int FEDM_XMLReaderCfgDataModul::AddReaderInfo(FEDM_DataBase* pReader, FEDM_XML_TREEITEM* root)
00897 {
00898         unsigned int uiTmp = 0;
00899         wchar_t wcTmp[128];
00900         FEDM_XML_TREEITEM* reader = NULL;
00901         FEDM_XML_TREEITEM* child = NULL;
00902         FEDM_XML_TREEITEM* sub = NULL;
00903 
00904         child = BuildTag(FEDM_XML_TAG_READER_INFO_UC);
00905         if(child == NULL)
00906         {
00907                 DeleteXmlTree(); // clean up
00908                 return m_iLastError;
00909         }
00910 
00911         AddTagItem(root, child);
00912         reader = child;
00913 
00914         // header tag <reader-name>
00915         child = BuildTag(FEDM_XML_TAG_READER_NAME_UC, false);
00916         if(child == NULL)
00917         {
00918                 return m_iLastError;
00919         }
00920 #if defined(__BORLANDC__) || defined(_MSC_VER)
00921         swprintf(wcTmp, L"%S", pReader->GetReaderName());
00922 #else
00923         swprintf(wcTmp, 128, L"%s", pReader->GetReaderName());
00924 #endif
00925         AddTagValue(child, wcTmp);
00926         AddTagItem(reader, child);
00927 
00928         // header tag <reader-type>
00929         child = BuildTag(FEDM_XML_TAG_READER_TYPE_UC, false);
00930         if(child == NULL)
00931         {
00932                 return m_iLastError;
00933         }
00934 #if defined(__BORLANDC__) || defined(_MSC_VER)
00935         swprintf(wcTmp, L"%u", pReader->GetReaderType());
00936 #else
00937         swprintf(wcTmp, 128, L"%u", pReader->GetReaderType());
00938 #endif
00939         AddTagValue(child, wcTmp);
00940         AddTagItem(reader, child);
00941 
00942         // ####################################################################################
00943         // new standard protocol - must have all newer readers implemented
00944         // mode: 0x00
00945         // ####################################################################################
00946         if(m_pReaderInfo->bIsMode0x00Read)
00947         {
00948                 // tag <controller>
00949                 child = BuildTag(FEDM_XML_TAG_CONTROLLER_UC);
00950                 if(child == NULL)
00951                 {
00952                         return m_iLastError;
00953                 }
00954                 AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"RFC");
00955                 AddTagItem(reader, child);
00956                 sub = child;
00957 
00958                 // tag <firmware-version>
00959                 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
00960                 if(child == NULL)
00961                 {
00962                         return m_iLastError;
00963                 }
00964 #if defined(__BORLANDC__) || defined(_MSC_VER)
00965                 swprintf(wcTmp, L"%d.%d.%d", m_pReaderInfo->ucRfcSwVer[0], m_pReaderInfo->ucRfcSwVer[1], m_pReaderInfo->ucRfcDevVer);
00966 #else
00967                 swprintf(wcTmp, 128, L"%d.%d.%d", m_pReaderInfo->ucRfcSwVer[0], m_pReaderInfo->ucRfcSwVer[1], m_pReaderInfo->ucRfcDevVer);
00968 #endif
00969                 AddTagValue(child, wcTmp);
00970                 AddTagItem(sub, child);
00971 
00972                 // tag <hardware-type>
00973                 child = BuildTag(FEDM_XML_TAG_HARDWARE_TYPE_UC);
00974                 if(child == NULL)
00975                 {
00976                         return m_iLastError;
00977                 }
00978 #if defined(__BORLANDC__) || defined(_MSC_VER)
00979                 swprintf(wcTmp, L"0x%02X", m_pReaderInfo->ucRfcHwType);
00980 #else
00981                 swprintf(wcTmp, 128, L"0x%02X", m_pReaderInfo->ucRfcHwType);
00982 #endif
00983                 AddTagValue(child, wcTmp);
00984                 AddTagItem(sub, child);
00985 
00986                 if(pReader->GetReaderType() == FEDM_ISC_TYPE_ISCPRHD102)
00987                 {
00988                         // tag <hf-transponder-driver>
00989                         child = BuildTag(FEDM_XML_TAG_HF_TRANSPONDER_DRIVER_UC);
00990                         if(child == NULL)
00991                         {
00992                                 return m_iLastError;
00993                         }
00994 #if defined(__BORLANDC__) || defined(_MSC_VER)
00995                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcTrType[0], m_pReaderInfo->ucRfcTrType[1]);
00996 #else
00997                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcTrType[0], m_pReaderInfo->ucRfcTrType[1]);
00998 #endif
00999                         AddTagValue(child, wcTmp);
01000                         AddTagItem(sub, child);
01001 
01002                         // tag <uhf-transponder-driver>
01003                         child = BuildTag(FEDM_XML_TAG_UHF_TRANSPONDER_DRIVER_UC);
01004                         if(child == NULL)
01005                         {
01006                                 return m_iLastError;
01007                         }
01008 #if defined(__BORLANDC__) || defined(_MSC_VER)
01009                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcUhfTrType[0], m_pReaderInfo->ucRfcUhfTrType[1]);
01010 #else
01011                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcUhfTrType[0], m_pReaderInfo->ucRfcUhfTrType[1]);
01012 #endif
01013                         AddTagValue(child, wcTmp);
01014                         AddTagItem(sub, child);
01015                 }
01016                 else
01017                 {
01018                         // tag <transponder-driver>
01019                         child = BuildTag(FEDM_XML_TAG_TRANSPONDER_DRIVER_UC);
01020                         if(child == NULL)
01021                         {
01022                                 return m_iLastError;
01023                         }
01024 #if defined(__BORLANDC__) || defined(_MSC_VER)
01025                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcTrType[0], m_pReaderInfo->ucRfcTrType[1]);
01026 #else
01027                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcTrType[0], m_pReaderInfo->ucRfcTrType[1]);
01028 #endif
01029                         AddTagValue(child, wcTmp);
01030                         AddTagItem(sub, child);
01031                 }
01032 
01033                 // tag <rx-buffer-size>
01034                 child = BuildTag(FEDM_XML_TAG_RX_BUFFER_SIZE_UC);
01035                 if(child == NULL)
01036                 {
01037                         return m_iLastError;
01038                 }
01039                 uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcRxBufferSize[0]<<8);
01040                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcRxBufferSize[1]);
01041 #if defined(__BORLANDC__) || defined(_MSC_VER)
01042                 swprintf(wcTmp, L"%d", uiTmp);
01043 #else
01044                 swprintf(wcTmp, 128, L"%d", uiTmp);
01045 #endif
01046                 AddTagValue(child, wcTmp);
01047                 AddTagItem(sub, child);
01048 
01049                 // tag <tx-buffer-size>
01050                 child = BuildTag(FEDM_XML_TAG_TX_BUFFER_SIZE_UC);
01051                 if(child == NULL)
01052                 {
01053                         return m_iLastError;
01054                 }
01055                 uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcTxBufferSize[0]<<8);
01056                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcTxBufferSize[1]);
01057 #if defined(__BORLANDC__) || defined(_MSC_VER)
01058                 swprintf(wcTmp, L"%d", uiTmp);
01059 #else
01060                 swprintf(wcTmp, 128, L"%d", uiTmp);
01061 #endif
01062                 AddTagValue(child, wcTmp);
01063                 AddTagItem(sub, child);
01064 
01065         } //  if(m_pReaderInfo->bIsMode0x00Read)
01066 
01067         // ####################################################################################
01068         // mode: 0x01 - ACC firmware version
01069         // ####################################################################################
01070         if(m_pReaderInfo->bIsMode0x01Read)
01071         {
01072                 // tag <controller>
01073                 child = BuildTag(FEDM_XML_TAG_CONTROLLER_UC);
01074                 if(child == NULL)
01075                 {
01076                         return m_iLastError;
01077                 }
01078                 AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"ACC");
01079                 AddTagItem(reader, child);
01080                 sub = child;
01081 
01082                 // tag <firmware-version>
01083                 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
01084                 if(child == NULL)
01085                 {
01086                         return m_iLastError;
01087                 }
01088 #if defined(__BORLANDC__) || defined(_MSC_VER)
01089                 swprintf(wcTmp, L"%d.%d.%d", m_pReaderInfo->ucAccSwVer[0], m_pReaderInfo->ucAccSwVer[1], m_pReaderInfo->ucAccDevVer);
01090 #else
01091                 swprintf(wcTmp, 128, L"%d.%d.%d", m_pReaderInfo->ucAccSwVer[0], m_pReaderInfo->ucAccSwVer[1], m_pReaderInfo->ucAccDevVer);
01092 #endif
01093                 AddTagValue(child, wcTmp);
01094                 AddTagItem(sub, child);
01095 
01096         } //  if(m_pReaderInfo->bIsMode0x01Read)
01097 
01098         // ####################################################################################
01099         // mode: 0x02 - USB-Controller firmware version
01100         // ####################################################################################
01101         if(m_pReaderInfo->bIsMode0x02Read)
01102         {
01103                 // tag <controller>
01104                 child = BuildTag(FEDM_XML_TAG_CONTROLLER_UC);
01105                 if(child == NULL)
01106                 {
01107                         return m_iLastError;
01108                 }
01109                 AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"USBC");
01110                 AddTagItem(reader, child);
01111                 sub = child;
01112 
01113                 // tag <firmware-version>
01114                 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
01115                 if(child == NULL)
01116                 {
01117                         return m_iLastError;
01118                 }
01119 #if defined(__BORLANDC__) || defined(_MSC_VER)
01120                 swprintf(wcTmp, L"%d.%d.%d", m_pReaderInfo->ucUsbSwVer[0], m_pReaderInfo->ucUsbSwVer[1], m_pReaderInfo->ucUsbDevVer);
01121 #else
01122                 swprintf(wcTmp, 128, L"%d.%d.%d", m_pReaderInfo->ucUsbSwVer[0], m_pReaderInfo->ucUsbSwVer[1], m_pReaderInfo->ucUsbDevVer);
01123 #endif
01124                 AddTagValue(child, wcTmp);
01125                 AddTagItem(sub, child);
01126 
01127         } //  if(m_pReaderInfo->bIsMode0x02Read)
01128 
01129         // ####################################################################################
01130         // mode: 0x03 - FPGA firmware version
01131         //                        - CPR decoder info
01132         // ####################################################################################
01133         if(m_pReaderInfo->bIsMode0x03Read)
01134         {
01135                 // tag <controller>
01136                 child = BuildTag(FEDM_XML_TAG_CONTROLLER_UC);
01137                 if(child == NULL)
01138                 {
01139                         return m_iLastError;
01140                 }
01141 
01142                 switch(m_pReaderInfo->ucReaderType)
01143                 {
01144                 // classic-pro
01145                 case FEDM_ISC_TYPE_CPR40_XX_U:
01146                 case FEDM_ISC_TYPE_CPR40_XX:
01147                         AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"RFD");
01148                         AddTagItem(reader, child);
01149                         sub = child;
01150                         // tag <decoder-info>
01151                         child = BuildTag(FEDM_XML_TAG_DECODER_INFO_UC);
01152                         if(child == NULL)
01153                         {
01154                                 return m_iLastError;
01155                         }
01156 #if defined(__BORLANDC__) || defined(_MSC_VER)
01157                         swprintf(       wcTmp, 
01158                                                 L"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X", 
01159                                                 m_pReaderInfo->ucDecoderType[0], 
01160                                                 m_pReaderInfo->ucDecoderType[1], 
01161                                                 m_pReaderInfo->ucDecoderType[2],
01162                                                 m_pReaderInfo->ucDecoderType[3],
01163                                                 m_pReaderInfo->ucDecoderType[4] );
01164 #else
01165                         swprintf(       wcTmp, 
01166                                                 128,
01167                                                 L"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X", 
01168                                                 m_pReaderInfo->ucDecoderType[0], 
01169                                                 m_pReaderInfo->ucDecoderType[1], 
01170                                                 m_pReaderInfo->ucDecoderType[2],
01171                                                 m_pReaderInfo->ucDecoderType[3],
01172                                                 m_pReaderInfo->ucDecoderType[4] );
01173 #endif
01174                         AddTagValue(child, wcTmp);
01175                         AddTagItem(sub, child);
01176 
01177                         // tag <self-test>
01178                         child = BuildTag(FEDM_XML_TAG_SELF_TEST_UC);
01179                         if(child == NULL)
01180                         {
01181                                 return m_iLastError;
01182                         }
01183 #if defined(__BORLANDC__) || defined(_MSC_VER)
01184                         swprintf(wcTmp, L"0x%02X", m_pReaderInfo->ucSelfTest);
01185 #else
01186                         swprintf(wcTmp, 128, L"0x%02X", m_pReaderInfo->ucSelfTest);
01187 #endif
01188                         AddTagValue(child, wcTmp);
01189                         AddTagItem(sub, child);
01190                         break;
01191 
01192                 // HF-Reader
01193                 case FEDM_ISC_TYPE_ISCLR2000:
01194                 case FEDM_ISC_TYPE_ISCLR2500_A:
01195                 case FEDM_ISC_TYPE_ISCLR2500_B:
01196                 // UHF-Reader
01197                 case FEDM_ISC_TYPE_ISCMRU200:
01198                 case FEDM_ISC_TYPE_ISCLRU2000:
01199                 case FEDM_ISC_TYPE_ISCLRU3000:
01200                         AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"FPGA");
01201                         AddTagItem(reader, child);
01202                         sub = child;
01203 
01204                         // tag <firmware-version>
01205                         child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
01206                         if(child == NULL)
01207                         {
01208                                 return m_iLastError;
01209                         }
01210 #if defined(__BORLANDC__) || defined(_MSC_VER)
01211                         swprintf(wcTmp, L"%d.%d.%d", m_pReaderInfo->ucFpgaSwVer[0], m_pReaderInfo->ucFpgaSwVer[1], m_pReaderInfo->ucFpgaDevVer);
01212 #else
01213                         swprintf(wcTmp, 128, L"%d.%d.%d", m_pReaderInfo->ucFpgaSwVer[0], m_pReaderInfo->ucFpgaSwVer[1], m_pReaderInfo->ucFpgaDevVer);
01214 #endif
01215                         AddTagValue(child, wcTmp);
01216                         AddTagItem(sub, child);
01217                         break;
01218                 }
01219 
01220         } //  if(m_pReaderInfo->bIsMode0x03Read)
01221 
01222         // ####################################################################################
01223         // mode: 0x05 - Bootloader firmware version
01224         // ####################################################################################
01225         if(m_pReaderInfo->bIsMode0x05Read)
01226         {
01227                 // tag <controller>
01228                 child = BuildTag(FEDM_XML_TAG_CONTROLLER_UC);
01229                 if(child == NULL)
01230                 {
01231                         return m_iLastError;
01232                 }
01233                 AddTagAttrib(child, FEDM_XML_ATTRIB_TYPE_UC, L"BOOT");
01234                 AddTagItem(reader, child);
01235                 sub = child;
01236 
01237                 // tag <firmware-version>
01238                 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
01239                 if(child == NULL)
01240                 {
01241                         return m_iLastError;
01242                 }
01243 #if defined(__BORLANDC__) || defined(_MSC_VER)
01244                 swprintf(wcTmp, L"%d.%d", m_pReaderInfo->ucBootSwVer[0], m_pReaderInfo->ucBootSwVer[1]);
01245 #else
01246                 swprintf(wcTmp, 128, L"%d.%d", m_pReaderInfo->ucBootSwVer[0], m_pReaderInfo->ucBootSwVer[1]);
01247 #endif
01248                 AddTagValue(child, wcTmp);
01249                 AddTagItem(sub, child);
01250 
01251         } //  if(m_pReaderInfo->bIsMode0x05Read)
01252 
01253         // ####################################################################################
01254         // mode: 0x04 - special firmware information
01255         // ####################################################################################
01256         if(m_pReaderInfo->bIsMode0x04Read)
01257         {
01258                 // tag <additional-firmware-info>
01259                 child = BuildTag(FEDM_XML_TAG_ADD_FIRMWARE_INFO_UC);
01260                 if(child == NULL)
01261                 {
01262                         return m_iLastError;
01263                 }
01264                 AddTagItem(reader, child);
01265                 sub = child;
01266 
01267                 switch(m_pReaderInfo->ucReaderType)     // reader type
01268                 {
01269                 // classic-pro
01270                 case FEDM_ISC_TYPE_CPRM02:
01271                 case FEDM_ISC_TYPE_CPR02:
01272                 case FEDM_ISC_TYPE_CPR04_U:
01273                         // tag <template>
01274                         child = BuildTag(FEDM_XML_TAG_TEMPLATE_UC);
01275                         if(child == NULL)
01276                         {
01277                                 return m_iLastError;
01278                         }
01279 #if defined(__BORLANDC__) || defined(_MSC_VER)
01280                         swprintf(wcTmp, L"0x%02X", m_pReaderInfo->ucCprFctTemplate);
01281 #else
01282                         swprintf(wcTmp, 128, L"0x%02X", m_pReaderInfo->ucCprFctTemplate);
01283 #endif
01284                         AddTagValue(child, wcTmp);
01285                         AddTagItem(sub, child);
01286 
01287                         // tag <function-list>
01288                         child = BuildTag(FEDM_XML_TAG_FUNCTION_LIST_UC);
01289                         if(child == NULL)
01290                         {
01291                                 return m_iLastError;
01292                         }
01293 #if defined(__BORLANDC__) || defined(_MSC_VER)
01294                         swprintf(wcTmp, L"0x%02X", m_pReaderInfo->ucCprFctList);
01295 #else
01296                         swprintf(wcTmp, 128, L"0x%02X", m_pReaderInfo->ucCprFctList);
01297 #endif
01298                         AddTagValue(child, wcTmp);
01299                         AddTagItem(sub, child);
01300                         break;
01301 
01302                 case FEDM_ISC_TYPE_CPR20_XX:
01303                 case FEDM_ISC_TYPE_CPR30_XX:
01304                 case FEDM_ISC_TYPE_CPR40_XX_U:
01305                 case FEDM_ISC_TYPE_CPR40_XX:
01306                 case FEDM_ISC_TYPE_CPR44_XX:
01307                 case FEDM_ISC_TYPE_CPR46_XX:
01308                 case FEDM_ISC_TYPE_CPR47_XX:
01309                 case FEDM_ISC_TYPE_CPR50_XX:
01310                 case FEDM_ISC_TYPE_CPR52_XX:
01311                 case FEDM_ISC_TYPE_CPR60_XX:
01312                 case FEDM_ISC_TYPE_MAX50_XX:
01313                 // myAXXESS
01314                 case FEDM_ISC_TYPE_MAX_STANDARD:
01315                 case FEDM_ISC_TYPE_MAX_COMFORT:
01316                 case FEDM_ISC_TYPE_MAX_ONTOP:
01317                         // tag <template>
01318                         child = BuildTag(FEDM_XML_TAG_TEMPLATE_UC);
01319                         if(child == NULL)
01320                         {
01321                                 return m_iLastError;
01322                         }
01323 #if defined(__BORLANDC__) || defined(_MSC_VER)
01324                         swprintf(wcTmp, L"0x%02X", m_pReaderInfo->ucCprFctTemplate);
01325 #else
01326                         swprintf(wcTmp, 128, L"0x%02X", m_pReaderInfo->ucCprFctTemplate);
01327 #endif
01328                         AddTagValue(child, wcTmp);
01329                         AddTagItem(sub, child);
01330 
01331                         // tag <function-list>
01332                         child = BuildTag(FEDM_XML_TAG_FUNCTION_LIST_UC);
01333                         if(child == NULL)
01334                         {
01335                                 return m_iLastError;
01336                         }
01337 #if defined(__BORLANDC__) || defined(_MSC_VER)
01338                         swprintf(wcTmp, L"0x%02X 0x%02X 0x%02X", m_pReaderInfo->ucCprFctList0, m_pReaderInfo->ucCprFctList1, m_pReaderInfo->ucCprFctList2);
01339 #else
01340                         swprintf(wcTmp, 128, L"0x%02X 0x%02X 0x%02X", m_pReaderInfo->ucCprFctList0, m_pReaderInfo->ucCprFctList1, m_pReaderInfo->ucCprFctList2);
01341 #endif
01342                         AddTagValue(child, wcTmp);
01343                         AddTagItem(sub, child);
01344 
01345                         // tag <identifier>
01346                         child = BuildTag(FEDM_XML_TAG_IDENTIFIER_UC);
01347                         if(child == NULL)
01348                         {
01349                                 return m_iLastError;
01350                         }
01351 #if defined(__BORLANDC__) || defined(_MSC_VER)
01352                         swprintf(       wcTmp, 
01353                                                 L"0x%02X 0x%02X", 
01354                                                 m_pReaderInfo->ucFwIdentifierC[0], 
01355                                                 m_pReaderInfo->ucFwIdentifierC[1] );
01356 #else
01357                         swprintf(       wcTmp, 
01358                                                 128,
01359                                                 L"0x%02X 0x%02X", 
01360                                                 m_pReaderInfo->ucFwIdentifierC[0], 
01361                                                 m_pReaderInfo->ucFwIdentifierC[1] );
01362 #endif
01363                         AddTagValue(child, wcTmp);
01364                         AddTagItem(sub, child);
01365 
01366                 case FEDM_ISC_TYPE_ISCMU02:
01367                 case FEDM_ISC_TYPE_ISCLR2000:
01368                 case FEDM_ISC_TYPE_ISCLR2500_A:
01369                 case FEDM_ISC_TYPE_ISCLR2500_B:
01370                 case FEDM_ISC_TYPE_ISCLRU2000:
01371                 case FEDM_ISC_TYPE_ISCLRU3000:
01372                         // tag <identifier>
01373                         child = BuildTag(FEDM_XML_TAG_IDENTIFIER_UC);
01374                         if(child == NULL)
01375                         {
01376                                 return m_iLastError;
01377                         }
01378 #if defined(__BORLANDC__) || defined(_MSC_VER)
01379                         swprintf(       wcTmp, 
01380                                                 L"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X", 
01381                                                 m_pReaderInfo->ucFwIdentifierB[0], 
01382                                                 m_pReaderInfo->ucFwIdentifierB[1], 
01383                                                 m_pReaderInfo->ucFwIdentifierB[2],
01384                                                 m_pReaderInfo->ucFwIdentifierB[3],
01385                                                 m_pReaderInfo->ucFwIdentifierB[4],
01386                                                 m_pReaderInfo->ucFwIdentifierB[5],
01387                                                 m_pReaderInfo->ucFwIdentifierB[6],
01388                                                 m_pReaderInfo->ucFwIdentifierB[7],
01389                                                 m_pReaderInfo->ucFwIdentifierB[8],
01390                                                 m_pReaderInfo->ucFwIdentifierB[9],
01391                                                 m_pReaderInfo->ucFwIdentifierB[10]      );
01392 #else
01393                         swprintf(       wcTmp, 
01394                                                 128,
01395                                                 L"0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X", 
01396                                                 m_pReaderInfo->ucFwIdentifierB[0], 
01397                                                 m_pReaderInfo->ucFwIdentifierB[1], 
01398                                                 m_pReaderInfo->ucFwIdentifierB[2],
01399                                                 m_pReaderInfo->ucFwIdentifierB[3],
01400                                                 m_pReaderInfo->ucFwIdentifierB[4],
01401                                                 m_pReaderInfo->ucFwIdentifierB[5],
01402                                                 m_pReaderInfo->ucFwIdentifierB[6],
01403                                                 m_pReaderInfo->ucFwIdentifierB[7],
01404                                                 m_pReaderInfo->ucFwIdentifierB[8],
01405                                                 m_pReaderInfo->ucFwIdentifierB[9],
01406                                                 m_pReaderInfo->ucFwIdentifierB[10]      );
01407 #endif
01408                         AddTagValue(child, wcTmp);
01409                         AddTagItem(sub, child);
01410                         break;
01411                 }
01412 
01413         } //  if(m_pReaderInfo->bIsMode0x04Read)
01414 
01415         // ####################################################################################
01416         // mode: 0x10 - additional hardware information
01417         // ####################################################################################
01418         if(m_pReaderInfo->bIsMode0x10Read)
01419         {
01420                 // tag <additional-hardware-info>
01421                 child = BuildTag(FEDM_XML_TAG_ADD_HARDWARE_INFO_UC);
01422                 if(child == NULL)
01423                 {
01424                         return m_iLastError;
01425                 }
01426                 AddTagItem(reader, child);
01427                 sub = child;
01428 
01429                 switch(m_pReaderInfo->ucReaderType)     // reader type
01430                 {
01431                 // HF-Reader
01432                 case FEDM_ISC_TYPE_ISCPRHD102:
01433                 case FEDM_ISC_TYPE_ISCLR2000:
01434                 case FEDM_ISC_TYPE_ISCLR2500_A:
01435                 case FEDM_ISC_TYPE_ISCLR2500_B:
01436                 // UHF-Reader
01437                 case FEDM_ISC_TYPE_ISCMRU102:
01438                 case FEDM_ISC_TYPE_ISCMRU200:
01439                 case FEDM_ISC_TYPE_ISCLRU1000:
01440                 case FEDM_ISC_TYPE_ISCLRU2000:
01441                 case FEDM_ISC_TYPE_ISCLRU3000:
01442                         // tag <hw-info>
01443                         child = BuildTag(FEDM_XML_TAG_HW_INFO_UC);
01444                         if(child == NULL)
01445                         {
01446                                 return m_iLastError;
01447                         }
01448 #if defined(__BORLANDC__) || defined(_MSC_VER)
01449                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcHwInfo[0], m_pReaderInfo->ucRfcHwInfo[0]);
01450 #else
01451                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcHwInfo[0], m_pReaderInfo->ucRfcHwInfo[0]);
01452 #endif
01453                         AddTagValue(child, wcTmp);
01454                         AddTagItem(sub, child);
01455 
01456                         // tag <ahw-info>
01457                         child = BuildTag(FEDM_XML_TAG_AHW_INFO_UC);
01458                         if(child == NULL)
01459                         {
01460                                 return m_iLastError;
01461                         }
01462 #if defined(__BORLANDC__) || defined(_MSC_VER)
01463                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcAHw[0], m_pReaderInfo->ucRfcAHw[0]);
01464 #else
01465                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcAHw[0], m_pReaderInfo->ucRfcAHw[0]);
01466 #endif
01467                         AddTagValue(child, wcTmp);
01468                         AddTagItem(sub, child);
01469 
01470                         // tag <dhw-info>
01471                         child = BuildTag(FEDM_XML_TAG_DHW_INFO_UC);
01472                         if(child == NULL)
01473                         {
01474                                 return m_iLastError;
01475                         }
01476 #if defined(__BORLANDC__) || defined(_MSC_VER)
01477                         swprintf(wcTmp, L"0x%02X%02X", m_pReaderInfo->ucRfcDHw[0], m_pReaderInfo->ucRfcDHw[0]);
01478 #else
01479                         swprintf(wcTmp, 128, L"0x%02X%02X", m_pReaderInfo->ucRfcDHw[0], m_pReaderInfo->ucRfcDHw[0]);
01480 #endif
01481                         AddTagValue(child, wcTmp);
01482                         AddTagItem(sub, child);
01483 
01484                         if(m_pReaderInfo->ucRfcFrequency)
01485                         {
01486                                 // tag <frequency>
01487                                 child = BuildTag(FEDM_XML_TAG_FREQUENCY_UC);
01488                                 if(child == NULL)
01489                                 {
01490                                         return m_iLastError;
01491                                 }
01492                                 switch(m_pReaderInfo->ucRfcFrequency&0x03)
01493                                 {
01494                                 case 1:
01495                                         AddTagValue(child, L"EU");
01496                                         break;
01497                                 case 2:
01498                                         AddTagValue(child, L"FCC");
01499                                         break;
01500                                 }
01501                                 AddTagItem(sub, child);
01502                         }
01503 
01504                         break;
01505                 }
01506         
01507         } //  if(m_pReaderInfo->bIsMode0x10Read)
01508 
01509         // ####################################################################################
01510         // mode: 0x80 - device information with serial number and licensed options
01511         // ####################################################################################
01512         if(m_pReaderInfo->bIsMode0x80Read)
01513         {
01514                 // tag <device-info>
01515                 child = BuildTag(FEDM_XML_TAG_DEVICE_INFO_UC);
01516                 if(child == NULL)
01517                 {
01518                         return m_iLastError;
01519                 }
01520                 AddTagItem(reader, child);
01521                 sub = child;
01522 
01523                 // tag <device-id>
01524                 child = BuildTag(FEDM_XML_TAG_DEVICE_ID_UC);
01525                 if(child == NULL)
01526                 {
01527                         return m_iLastError;
01528                 }
01529 #if defined(__BORLANDC__) || defined(_MSC_VER)
01530                 swprintf(wcTmp, L"%u", m_pReaderInfo->GetDeviceID());
01531 #else
01532                 swprintf(wcTmp, 128, L"%u", m_pReaderInfo->GetDeviceID());
01533 #endif
01534                 AddTagValue(child, wcTmp);
01535                 AddTagItem(sub, child);
01536 
01537                 // tag <customer-id>
01538                 child = BuildTag(FEDM_XML_TAG_CUSTOMER_ID_UC);
01539                 if(child == NULL)
01540                 {
01541                         return m_iLastError;
01542                 }
01543                 uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseCustom[0]<<24);
01544                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseCustom[1]<<16);
01545                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseCustom[2]<<8);
01546                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseCustom[3]);
01547 #if defined(__BORLANDC__) || defined(_MSC_VER)
01548                 swprintf(wcTmp, L"0x%08X", uiTmp);
01549 #else
01550                 swprintf(wcTmp, 128, L"0x%08X", uiTmp);
01551 #endif
01552                 AddTagValue(child, wcTmp);
01553                 AddTagItem(sub, child);
01554 
01555                 // tag <firmware-version>
01556                 child = BuildTag(FEDM_XML_TAG_FIRMWARE_VERSION_UC);
01557                 if(child == NULL)
01558                 {
01559                         return m_iLastError;
01560                 }
01561                 uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseFw[0]<<8);
01562                 uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseFw[1]);
01563 #if defined(__BORLANDC__) || defined(_MSC_VER)
01564                 swprintf(wcTmp, L"0x%04X", uiTmp);
01565 #else
01566                 swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01567 #endif
01568                 AddTagValue(child, wcTmp);
01569                 AddTagItem(sub, child);
01570 
01571                 if(pReader->GetReaderType() == FEDM_ISC_TYPE_ISCPRHD102)
01572                 {
01573                         // tag <hf-transponder-driver>
01574                         child = BuildTag(FEDM_XML_TAG_HF_TRANSPONDER_DRIVER_UC);
01575                         if(child == NULL)
01576                         {
01577                                 return m_iLastError;
01578                         }
01579                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseTrType[0]<<8);
01580                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseTrType[1]);
01581 #if defined(__BORLANDC__) || defined(_MSC_VER)
01582                         swprintf(wcTmp, L"0x%04X", uiTmp);
01583 #else
01584                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01585 #endif
01586                         AddTagValue(child, wcTmp);
01587                         AddTagItem(sub, child);
01588 
01589                         // tag <hf-reader-functions>
01590                         child = BuildTag(FEDM_XML_TAG_HF_READER_FUNCTIONS_UC);
01591                         if(child == NULL)
01592                         {
01593                                 return m_iLastError;
01594                         }
01595                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseFct[0]<<8);
01596                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseFct[1]);
01597 #if defined(__BORLANDC__) || defined(_MSC_VER)
01598                         swprintf(wcTmp, L"0x%04X", uiTmp);
01599 #else
01600                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01601 #endif
01602                         AddTagValue(child, wcTmp);
01603                         AddTagItem(sub, child);
01604 
01605                         // tag <uhf-transponder-driver>
01606                         child = BuildTag(FEDM_XML_TAG_UHF_TRANSPONDER_DRIVER_UC);
01607                         if(child == NULL)
01608                         {
01609                                 return m_iLastError;
01610                         }
01611                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseUhfTrType[0]<<8);
01612                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseUhfTrType[1]);
01613 #if defined(__BORLANDC__) || defined(_MSC_VER)
01614                         swprintf(wcTmp, L"0x%04X", uiTmp);
01615 #else
01616                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01617 #endif
01618                         AddTagValue(child, wcTmp);
01619                         AddTagItem(sub, child);
01620 
01621                         // tag <uhf-reader-functions>
01622                         child = BuildTag(FEDM_XML_TAG_UHF_READER_FUNCTIONS_UC);
01623                         if(child == NULL)
01624                         {
01625                                 return m_iLastError;
01626                         }
01627                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseUhfFct[0]<<8);
01628                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseUhfFct[1]);
01629 #if defined(__BORLANDC__) || defined(_MSC_VER)
01630                         swprintf(wcTmp, L"0x%04X", uiTmp);
01631 #else
01632                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01633 #endif
01634                         AddTagValue(child, wcTmp);
01635                         AddTagItem(sub, child);
01636                 }
01637                 else
01638                 {
01639                         // tag <transponder-driver>
01640                         child = BuildTag(FEDM_XML_TAG_TRANSPONDER_DRIVER_UC);
01641                         if(child == NULL)
01642                         {
01643                                 return m_iLastError;
01644                         }
01645                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseTrType[0]<<8);
01646                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseTrType[1]);
01647 #if defined(__BORLANDC__) || defined(_MSC_VER)
01648                         swprintf(wcTmp, L"0x%04X", uiTmp);
01649 #else
01650                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01651 #endif
01652                         AddTagValue(child, wcTmp);
01653                         AddTagItem(sub, child);
01654 
01655                         // tag <reader-functions>
01656                         child = BuildTag(FEDM_XML_TAG_READER_FUNCTIONS_UC);
01657                         if(child == NULL)
01658                         {
01659                                 return m_iLastError;
01660                         }
01661                         uiTmp  = ((unsigned int)m_pReaderInfo->ucRfcLicenseFct[0]<<8);
01662                         uiTmp += ((unsigned int)m_pReaderInfo->ucRfcLicenseFct[1]);
01663 #if defined(__BORLANDC__) || defined(_MSC_VER)
01664                         swprintf(wcTmp, L"0x%04X", uiTmp);
01665 #else
01666                         swprintf(wcTmp, 128, L"0x%04X", uiTmp);
01667 #endif
01668                         AddTagValue(child, wcTmp);
01669                         AddTagItem(sub, child);
01670                 }
01671 
01672         } //  if(m_pReaderInfo->bIsMode0x80Read)
01673 
01674         FEDM_RETURN(FEDM_OK);
01675 }
01676 
01677 
01678 //#####################################################################################
01679 // query functions
01680 //#####################################################################################
01681 
01682 /***************************************************************************
01683   Begin         :       23.04.2003 / M. Hultsch
01684   Version       :       01.09.08 / 21.06.2004 / M. Hultsch
01685 
01686   Function              :       open a xml document and get the document type
01687 
01688   Parameters    :       char* sFileName - pointer to string with file name
01689                                         char* sDocType  - pointer to string for document type
01690 
01691   Return value  :       FEDM_OK or error code (<0)
01692 
01693 ***************************************************************************/
01694 int FEDM_XMLReaderCfgDataModul::QueryDocType(char* sFileName, char* sDocType)
01695 {
01696         int iBack = 0;
01697         FEDM_XML_TREEITEM* root = NULL;
01698         FEDM_XML_TREEITEM* parent = NULL;
01699         FEDM_XML_TREEITEM* child = NULL;
01700 
01701         
01702         iBack = OpenDoc(sFileName, "r");
01703         if(iBack)
01704                 return iBack;
01705         
01706         // is it a xml document?
01707         if(IsXmlDoc())
01708         {
01709                 CloseDoc();
01710                 return m_iLastError;
01711         }
01712 
01713         // has the xml document an OBID tag?
01714         if(HasOBIDTag())
01715         {
01716                 CloseDoc();
01717                 return m_iLastError;
01718         }
01719         
01720         // read complete xml document into string
01721         if(ReadDoc())
01722         {
01723                 CloseDoc();
01724                 return m_iLastError;
01725         }
01726 
01727         CloseDoc();
01728 
01729         // root tag
01730         root = FindTag(FEDM_XML_TAG_OBID_UC);
01731         if(root == NULL)
01732                 return m_iLastError;
01733         AddTagItem(NULL, root);
01734 
01735         // header tag
01736         child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
01737         if(child == NULL)
01738         {
01739                 DeleteXmlTree(); // clean up
01740                 return m_iLastError;
01741         }
01742         AddTagItem(root, child);
01743         parent = child;
01744 
01745         // header tag document type
01746         child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
01747         if(child == NULL)
01748         {
01749                 DeleteXmlTree(); // clean up
01750                 return m_iLastError;
01751         }
01752 
01753 #if defined(__BORLANDC__) || defined(_MSC_VER)
01754         swscanf(child->sValue.c_str(), L"%S", sDocType);
01755 #elif defined(_FEDM_SUPPORT_UCLINUX)
01756         FEDM_SWSCANF(child->sValue.c_str(), sDocType);
01757 #else
01758         swscanf(child->sValue.c_str(), L"%s", sDocType);
01759 #endif
01760         
01761         delete child;
01762         DeleteXmlTree(); // clean up
01763 
01764         FEDM_RETURN(FEDM_OK);
01765 }
01766 
01767 /***************************************************************************
01768   Begin         :       23.04.2003 / M. Hultsch
01769   Version       :       01.09.08 / 21.06.2004 / M. Hultsch
01770 
01771   Function              :       open a xml document and get the doc version
01772 
01773   Parameters    :       char* sFileName         - pointer to string with file name
01774                                         char* sDocVersion       - pointer to string for document version
01775 
01776   Return value  :       FEDM_OK or error code (<0)
01777 
01778 ***************************************************************************/
01779 int FEDM_XMLReaderCfgDataModul::QueryDocVersion(char* sFileName, char* sDocVersion)
01780 {
01781         int iBack = 0;
01782         FEDM_XML_TREEITEM* root = NULL;
01783         FEDM_XML_TREEITEM* parent = NULL;
01784         FEDM_XML_TREEITEM* child = NULL;
01785 
01786         
01787         iBack = OpenDoc(sFileName, "r");
01788         if(iBack)
01789                 return iBack;
01790         
01791         // is it a xml document?
01792         if(IsXmlDoc())
01793         {
01794                 CloseDoc();
01795                 return m_iLastError;
01796         }
01797 
01798         // has the xml document an OBID tag?
01799         if(HasOBIDTag())
01800         {
01801                 CloseDoc();
01802                 return m_iLastError;
01803         }
01804         
01805         // read complete xml document into string
01806         if(ReadDoc())
01807         {
01808                 CloseDoc();
01809                 return m_iLastError;
01810         }
01811 
01812         CloseDoc();
01813 
01814         // root tag
01815         root = FindTag(FEDM_XML_TAG_OBID_UC);
01816         if(root == NULL)
01817                 return m_iLastError;
01818         AddTagItem(NULL, root);
01819 
01820         // header tag
01821         child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
01822         if(child == NULL)
01823         {
01824                 DeleteXmlTree(); // clean up
01825                 return m_iLastError;
01826         }
01827         AddTagItem(root, child);
01828         parent = child;
01829 
01830         // header tag document type
01831         child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
01832         if(child == NULL)
01833         {
01834                 DeleteXmlTree(); // clean up
01835                 return m_iLastError;
01836         }
01837         m_wsDocType = child->sValue;
01838         AddTagItem(parent, child);
01839 
01840         // header tag document version
01841         child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
01842         if(child == NULL)
01843         {
01844                 DeleteXmlTree(); // clean up
01845                 return m_iLastError;
01846         }
01847 
01848 #if defined(__BORLANDC__) || defined(_MSC_VER)
01849         swscanf(child->sValue.c_str(), L"%S", sDocVersion);
01850 #elif defined(_FEDM_SUPPORT_UCLINUX)
01851         FEDM_SWSCANF(child->sValue.c_str(), sDocVersion);
01852 #else
01853         swscanf(child->sValue.c_str(), L"%s", sDocVersion);
01854 #endif
01855 
01856         delete child;
01857         DeleteXmlTree(); // clean up
01858 
01859         FEDM_RETURN(FEDM_OK);
01860 }
01861 
01862 /***************************************************************************
01863   Begin         :       23.04.2003 / M. Hultsch
01864   Version       :       01.09.08 / 21.06.2004 / M. Hultsch
01865 
01866   Function              :       open a xml document and get the family code
01867 
01868   Parameters    :       char* sFileName - pointer to string with file name
01869                                         char* sFamCode  - pointer to string for family code
01870 
01871   Return value  :       FEDM_OK or error code (<0)
01872 
01873 ***************************************************************************/
01874 int FEDM_XMLReaderCfgDataModul::QueryReaderFamily(char* sFileName, char* sFamCode)
01875 {
01876         int iBack = 0;
01877         FEDM_XML_TREEITEM* root = NULL;
01878         FEDM_XML_TREEITEM* parent = NULL;
01879         FEDM_XML_TREEITEM* child = NULL;
01880 
01881         
01882         iBack = OpenDoc(sFileName, "r");
01883         if(iBack)
01884                 return iBack;
01885         
01886         // is it a xml document?
01887         if(IsXmlDoc())
01888         {
01889                 CloseDoc();
01890                 return m_iLastError;
01891         }
01892 
01893         // has the xml document an OBID tag?
01894         if(HasOBIDTag())
01895         {
01896                 CloseDoc();
01897                 return m_iLastError;
01898         }
01899         
01900         // read complete xml document into string
01901         if(ReadDoc())
01902         {
01903                 CloseDoc();
01904                 return m_iLastError;
01905         }
01906 
01907         CloseDoc();
01908 
01909         // root tag
01910         root = FindTag(FEDM_XML_TAG_OBID_UC);
01911         if(root == NULL)
01912                 return m_iLastError;
01913         AddTagItem(NULL, root);
01914 
01915         // header tag
01916         child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
01917         if(child == NULL)
01918         {
01919                 DeleteXmlTree(); // clean up
01920                 return m_iLastError;
01921         }
01922         AddTagItem(root, child);
01923         parent = child;
01924 
01925         // header tag document type
01926         child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
01927         if(child == NULL)
01928         {
01929                 DeleteXmlTree(); // clean up
01930                 return m_iLastError;
01931         }
01932         m_wsDocType = child->sValue;
01933         AddTagItem(parent, child);
01934 
01935         // header tag document version
01936         child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
01937         if(child == NULL)
01938         {
01939                 DeleteXmlTree(); // clean up
01940                 return m_iLastError;
01941         }
01942         if(child->sValue != FEDM_XML_STRING_DOC_VERSION_UC)
01943         {
01944                 m_wsDocVer = child->sValue;
01945                 delete child;
01946                 DeleteXmlTree(); // clean up
01947                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_VERSION);
01948         }
01949         AddTagItem(parent, child);
01950 
01951         // header tag reader family name
01952         child = FindTag(FEDM_XML_TAG_READER_FAM_UC);
01953         if(child == NULL)
01954         {
01955                 DeleteXmlTree(); // clean up
01956                 return m_iLastError;
01957         }
01958 
01959         // check the family code
01960         if(child->sValue.size() > 4)
01961         {
01962                 delete child;
01963                 DeleteXmlTree(); // clean up
01964                 FEDM_RETURN(FEDM_XML_ERROR_DOC_FILE_FAMILY);
01965         }
01966 
01967 #if defined(__BORLANDC__) || defined(_MSC_VER)
01968         swscanf(child->sValue.c_str(), L"%S", sFamCode);
01969 #elif defined(_FEDM_SUPPORT_UCLINUX)
01970         FEDM_SWSCANF(child->sValue.c_str(), sFamCode);
01971 #else
01972         swscanf(child->sValue.c_str(), L"%s", sFamCode);
01973 #endif
01974         
01975         delete child;
01976         DeleteXmlTree(); // clean up
01977 
01978         FEDM_RETURN(FEDM_OK);
01979 }
01980 
01981 /***************************************************************************
01982   Begin         :       23.04.2003 / M. Hultsch
01983   Version       :       01.09.08 / 21.06.2004 / M. Hultsch
01984 
01985   Function              :       open a xml document and get the reader type
01986 
01987   Parameters    :       -
01988 
01989   Return value  :       reader type (>0) or error code (<0)
01990 
01991 ***************************************************************************/
01992 int FEDM_XMLReaderCfgDataModul::QueryReaderType(char* sFileName)
01993 {
01994         char cValue[5];
01995         int iType = 0;
01996         int iBack = 0;
01997         FEDM_XML_TREEITEM* root = NULL;
01998         FEDM_XML_TREEITEM* parent = NULL;
01999         FEDM_XML_TREEITEM* child = NULL;
02000 
02001         
02002         iBack = OpenDoc(sFileName, "r");
02003         if(iBack)
02004                 return iBack;
02005         
02006         // is it a xml document?
02007         if(IsXmlDoc())
02008         {
02009                 CloseDoc();
02010                 return m_iLastError;
02011         }
02012 
02013         // has the xml document an OBID tag?
02014         if(HasOBIDTag())
02015         {
02016                 CloseDoc();
02017                 return m_iLastError;
02018         }
02019         
02020         // read complete xml document into string
02021         if(ReadDoc())
02022         {
02023                 CloseDoc();
02024                 return m_iLastError;
02025         }
02026 
02027         CloseDoc();
02028 
02029         // root tag
02030         root = FindTag(FEDM_XML_TAG_OBID_UC);
02031         if(root == NULL)
02032                 return m_iLastError;
02033         AddTagItem(NULL, root);
02034 
02035         // header tag
02036         child = FindTag(FEDM_XML_TAG_FILE_HDR_UC);
02037         if(child == NULL)
02038         {
02039                 DeleteXmlTree(); // clean up
02040                 return m_iLastError;
02041         }
02042         AddTagItem(root, child);
02043         parent = child;
02044 
02045         // header tag document type
02046         child = FindTag(FEDM_XML_TAG_DOC_TYPE_UC);
02047         if(child == NULL)
02048         {
02049                 DeleteXmlTree(); // clean up
02050                 return m_iLastError;
02051         }
02052         m_wsDocType = child->sValue;
02053         AddTagItem(parent, child);
02054 
02055         // header tag document version
02056         child = FindTag(FEDM_XML_TAG_DOC_VERSION_UC);
02057         if(child == NULL)
02058         {
02059                 DeleteXmlTree(); // clean up
02060                 return m_iLastError;
02061         }
02062         if(child->sValue != FEDM_XML_STRING_DOC_VERSION_UC)
02063         {
02064                 m_wsDocVer = child->sValue;
02065                 delete child;
02066                 DeleteXmlTree(); // clean up
02067                 return FEDM_XML_ERROR_DOC_FILE_VERSION;
02068         }
02069         AddTagItem(parent, child);
02070 
02071         // header tag reader type
02072         child = FindTag(FEDM_XML_TAG_READER_TYPE_UC);
02073         if(child == NULL)
02074         {
02075                 DeleteXmlTree(); // clean up
02076                 return m_iLastError;
02077         }
02078 
02079 #if defined(__BORLANDC__) || defined(_MSC_VER)
02080         swscanf(child->sValue.c_str(), L"%S", cValue);
02081 #elif defined(_FEDM_SUPPORT_UCLINUX)
02082         FEDM_SWSCANF(child->sValue.c_str(), cValue);
02083 #else
02084         swscanf(child->sValue.c_str(), L"%s", cValue);
02085 #endif
02086         sscanf(cValue, "%d", &iType);
02087 
02088         delete child;
02089         DeleteXmlTree(); // clean up
02090 
02091         return iType;
02092 }
02093 
02094 
02095 
02096 //#####################################################################################
02097 // get/set functions
02098 //#####################################################################################
02099 
02100 void FEDM_XMLReaderCfgDataModul::SetReaderInfo(FEDM_ISC_READER_INFO* pReaderInfo)
02101 {
02102         m_pReaderInfo = pReaderInfo;
02103 }
02104 
02105 
02106 /***************************************************************************
02107   Begin         :       23.04.2003 / M. Hultsch
02108   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02109 
02110   Function              :       gets the comment
02111 
02112   Parameters    :       string& sComment        - reference to string with comment
02113 
02114   Return value  :       -
02115 
02116 ***************************************************************************/
02117 void FEDM_XMLReaderCfgDataModul::GetComment(string& sComment)
02118 {
02119         char cTmp[256];
02120 
02121         if(m_wsComment.size() > 256)
02122                 return;
02123 
02124 #if defined(__BORLANDC__) || defined(_MSC_VER)
02125         sprintf(cTmp, "%S", m_wsComment.c_str());
02126 #else
02127         sprintf(cTmp, "%s", (const char*)m_wsComment.c_str());
02128 #endif
02129 
02130         sComment = cTmp;
02131 }
02132 
02133 /***************************************************************************
02134   Begin         :       23.04.2003 / M. Hultsch
02135   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02136 
02137   Function              :       gets the comment
02138 
02139   Parameters    :       string& sPrgName        - reference to string with program name
02140 
02141   Return value  :       -
02142 
02143 ***************************************************************************/
02144 void FEDM_XMLReaderCfgDataModul::GetPrgName(string& sPrgName)
02145 {
02146         char cTmp[256];
02147 
02148         if(m_wsPrgName.size() > 256)
02149                 return;
02150 
02151 #if defined(__BORLANDC__) || defined(_MSC_VER)
02152         sprintf(cTmp, "%S", m_wsPrgName.c_str());
02153 #else
02154         sprintf(cTmp, "%s", (const char*)m_wsPrgName.c_str());
02155 #endif
02156 
02157         sPrgName = cTmp;
02158 }
02159 
02160 /***************************************************************************
02161   Begin         :       23.04.2003 / M. Hultsch
02162   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02163 
02164   Function              :       gets the program version number
02165 
02166   Parameters    :       string& sPrgVer - reference to string with program version number
02167 
02168   Return value  :       -
02169 
02170 ***************************************************************************/
02171 void FEDM_XMLReaderCfgDataModul::GetPrgVer(string& sPrgVer)
02172 {
02173         char cTmp[256];
02174 
02175         if(m_wsPrgVer.size() > 256)
02176                 return;
02177 
02178 #if defined(__BORLANDC__) || defined(_MSC_VER)
02179         sprintf(cTmp, "%S", m_wsPrgVer.c_str());
02180 #else
02181         sprintf(cTmp, "%s", (const char*)m_wsPrgVer.c_str());
02182 #endif
02183 
02184         sPrgVer = cTmp;
02185 }
02186 
02187 /***************************************************************************
02188   Begin         :       23.05.2003 / M. Hultsch
02189   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02190 
02191   Function              :       gets the host name/address
02192 
02193   Parameters    :       string& sHost   - reference to string with host name/address
02194 
02195   Return value  :       -
02196 
02197 ***************************************************************************/
02198 void FEDM_XMLReaderCfgDataModul::GetHost(string& sHost)
02199 {
02200         char cTmp[256];
02201 
02202         if(m_wsHost.size() > 256)
02203                 return;
02204 
02205 #if defined(__BORLANDC__) || defined(_MSC_VER)
02206         sprintf(cTmp, "%S", m_wsHost.c_str());
02207 #else
02208         sprintf(cTmp, "%s", (const char*)m_wsHost.c_str());
02209 #endif
02210 
02211         sHost = cTmp;
02212 }
02213 
02214 /***************************************************************************
02215   Begin         :       23.05.2003 / M. Hultsch
02216   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02217 
02218   Function              :       gets the port number
02219 
02220   Parameters    :       string& sPort   - reference to string with port number
02221 
02222   Return value  :       -
02223 
02224 ***************************************************************************/
02225 void FEDM_XMLReaderCfgDataModul::GetPort(string& sPort)
02226 {
02227         char cTmp[256];
02228 
02229         if(m_wsPort.size() > 256)
02230                 return;
02231 
02232 #if defined(__BORLANDC__) || defined(_MSC_VER)
02233         sprintf(cTmp, "%S", m_wsPort.c_str());
02234 #else
02235         sprintf(cTmp, "%s", (const char*)m_wsPort.c_str());
02236 #endif
02237 
02238         sPort = cTmp;
02239 }
02240 
02241 /***************************************************************************
02242   Begin         :       11.07.2003 / M. Hultsch
02243   Version       :       01.08.00 / 04.09.2003 / M. Hultsch
02244 
02245   Function              :       gets the last communication mode
02246 
02247   Parameters    :       string& sMode   - reference to string with communication mode
02248 
02249   Return value  :       -
02250 
02251 ***************************************************************************/
02252 void FEDM_XMLReaderCfgDataModul::GetCommMode(string& sMode)
02253 {
02254         char cTmp[256];
02255 
02256         if(m_wsCommMode.size() > 256)
02257                 return;
02258 
02259 #if defined(__BORLANDC__) || defined(_MSC_VER)
02260         sprintf(cTmp, "%S", m_wsCommMode.c_str());
02261 #else
02262         sprintf(cTmp, "%s", (const char*)m_wsCommMode.c_str());
02263 #endif
02264 
02265         sMode = cTmp;
02266 }
02267 
02268 /***************************************************************************
02269   Begin         :       23.04.2003 / M. Hultsch
02270   Version       :       01.08.00 / 01.09.2003 / M. Hultsch
02271 
02272   Function              :       sets the comment
02273 
02274   Parameters    :       string sComment - string with comment
02275 
02276   Return value  :       -
02277 
02278 ***************************************************************************/
02279 void FEDM_XMLReaderCfgDataModul::SetComment(string sComment)
02280 {
02281         wchar_t wcTmp[256];
02282 
02283         if(sComment.size() > 256)
02284                 return;
02285 
02286 #if defined(__BORLANDC__) || defined(_MSC_VER)
02287         swprintf(wcTmp, L"%S", sComment.c_str());
02288 #else
02289         swprintf(wcTmp, 256, L"%s", sComment.c_str());
02290 #endif
02291 
02292         m_wsComment = wcTmp;
02293 }
02294 
02295 /***************************************************************************
02296   Begin         :       23.04.2003 / M. Hultsch
02297   Version       :       01.08.00 / 01.08.2003 / M. Hultsch
02298 
02299   Function              :       sets the program name
02300 
02301   Parameters    :       string sPrgName - string with program name
02302 
02303   Return value  :       -
02304 
02305 ***************************************************************************/
02306 void FEDM_XMLReaderCfgDataModul::SetPrgName(string sPrgName)
02307 {
02308         wchar_t wcTmp[256];
02309 
02310         if(sPrgName.size() > 256)
02311                 return;
02312 
02313 #if defined(__BORLANDC__) || defined(_MSC_VER)
02314         swprintf(wcTmp, L"%S", sPrgName.c_str());
02315 #else
02316         swprintf(wcTmp, 256, L"%s", sPrgName.c_str());
02317 #endif
02318 
02319         m_wsPrgName = wcTmp;
02320 }
02321 
02322 /***************************************************************************
02323   Begin         :       23.04.2003 / M. Hultsch
02324   Version       :       01.08.00 / 01.09.2003 / M. Hultsch
02325 
02326   Function              :       sets the program version number
02327 
02328   Parameters    :       string sPrgVer  - string with program version number
02329 
02330   Return value  :       -
02331 
02332 ***************************************************************************/
02333 void FEDM_XMLReaderCfgDataModul::SetPrgVer(string sPrgVer)
02334 {
02335         wchar_t wcTmp[256];
02336 
02337         if(sPrgVer.size() > 256)
02338                 return;
02339 
02340 #if defined(__BORLANDC__) || defined(_MSC_VER)
02341         swprintf(wcTmp, L"%S", sPrgVer.c_str());
02342 #else
02343         swprintf(wcTmp, 256, L"%s", sPrgVer.c_str());
02344 #endif
02345 
02346         m_wsPrgVer = wcTmp;
02347 }
02348 
02349 #endif // #ifdef _FEDM_XML_SUPPORT


maggie_rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Mon Sep 14 2015 03:05:30