Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dep/tinyxml/examples/dsacssConfigTest.cpp

Go to the documentation of this file.
00001 /************************************************************************************************/
00002 /*! \file dsacssConfigTest.cpp
00003 *  \brief This file is a test of using timy xml parser to parse a config file for DSACSS.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.1 $
00006 *  \date    $Date: 2006/07/25 20:44:12 $
00007 ************************************************************************************************/
00008 /*!
00009 *
00010 ************************************************************************************************/
00011 
00012 #include <dsacssinterface.h>
00013 
00014 using namespace std;
00015 using namespace O_SESSAME;
00016 
00017 
00018 int main()
00019 {
00020 
00021         cout << "Testing xml parser functions" << endl;
00022         cout << "Parsing XML File..." << endl;
00023 
00024         // Specify Xml File to Parse
00025         const char *fileName = "DSACSSConfig.xml";
00026 
00027         // Declare TiXmlDocument
00028         TiXmlDocument config( fileName );
00029 
00030         // Load Xml File
00031         bool loadOkay = config.LoadFile();
00032         checkLoadFile(loadOkay, fileName, config);
00033 
00034         // Print Xml File to std
00035         cout << "Printing XML FILE to Screen" << endl;
00036         config.Print();
00037 
00038         // Declare TiXmlHandle
00039         TiXmlHandle docHandle( &config );
00040 
00041         // Define xml config path names
00042         const char *whorl_I = "WHORL-I";
00043         const char *physicalProperties = "PHYSICAL_PROPERTIES";
00044         const char *hardwareProperties = "HARDWARE_PROPERTIES";
00045         const char *magnetometer = "MAGNETOMETER";
00046         const char *attribute = "value";
00047 
00048         int response;
00049         
00050         // Get mass from xml config file
00051         double mass;
00052         response = docHandle.FirstChild( whorl_I ).FirstChild( physicalProperties  ).
00053         Child( "MASS", 0 ).Element() -> QueryDoubleAttribute(attribute, &mass);
00054         checkResponse(response);
00055         cout << "mass: \n" << mass << endl;
00056 
00057         // Get inertia matrix from xml config file
00058         Matrix inertia = simulatorInertia(docHandle, whorl_I);
00059         cout << "inerteria matrix: \n" << inertia << endl;
00060 
00061         // Get magnetometer inertial vector from xml config file
00062         Vector magnetometerInertial(3);
00063         response = docHandle.FirstChild( whorl_I ).FirstChild( hardwareProperties ).FirstChild( magnetometer ).
00064         Child( "INERTIAL_VECTOR", 0 ).Element() -> QueryDoubleAttribute("valueX", &magnetometerInertial(1));
00065         checkResponse(response);
00066         response = docHandle.FirstChild( whorl_I ).FirstChild( hardwareProperties ).FirstChild( magnetometer ).
00067         Child( "INERTIAL_VECTOR", 0 ).Element() -> QueryDoubleAttribute("valueY", &magnetometerInertial(2));
00068         checkResponse(response);
00069         response = docHandle.FirstChild( whorl_I ).FirstChild( hardwareProperties ).FirstChild( magnetometer ).
00070         Child( "INERTIAL_VECTOR", 0 ).Element() -> QueryDoubleAttribute("valueZ", &magnetometerInertial(3));
00071         checkResponse(response);
00072         cout << "magnetometer inertial vector:\n" << magnetometerInertial << endl;
00073         cout << "Finish test xml functions" << endl;
00074         
00075         return(0);
00076 }
00077 
00078 
00079 
00080 
00081 // Do not change the comments below - they will be added automatically by CVS
00082 /*****************************************************************************
00083 *       $Log: dsacssConfigTest.cpp,v $
00084 *       Revision 1.1  2006/07/25 20:44:12  jayhawk_hokie
00085 *       Initial submission.
00086 *
00087 *
00088 *
00089 *
00090 ******************************************************************************/
00091 

Generated on Wed Sep 5 12:54:20 2007 for DSACSS Operational Code by  doxygen 1.3.9.1