00001 /************************************************************************************************/ 00002 /*! \file dsacssinterface.cpp 00003 * \brief This file contains function that are used specifically for DSACSS to parse a xml file. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.1 $ 00006 * \date $Date: 2006/07/25 20:45:06 $ 00007 ************************************************************************************************/ 00008 /*! 00009 * 00010 ************************************************************************************************/ 00011 00012 #include <dsacssinterface.h> 00013 00014 /*! \brief Checks the return value from parsing an element. 00015 * \n 0 = good response 00016 * \n returns: nothing or terminates program if not 0. 00017 */ 00018 void checkResponse(int response) 00019 { 00020 if (response) 00021 { 00022 printf( "Error: Could not correctly parse variable. " ); 00023 exit( 1 ); 00024 } 00025 } 00026 00027 /*! \brief Checks the return value from loading Xml file. \n 00028 * 0 = good response \n 00029 * returns: nothing or terminates program if not 0. 00030 */ 00031 void checkLoadFile(bool loadOkay, const char *fileName, TiXmlDocument config) 00032 { 00033 if ( !loadOkay ) 00034 { 00035 printf( "Could not load file '%s'. Error='%s'. Exiting.\n", fileName, config.ErrorDesc() ); 00036 exit( 1 ); 00037 } 00038 } 00039 00040 /*! \brief Returns inertia matrix from xml config file. \n 00041 * pass: TiXmlHandle and simulator ("WHORL-I" / "WHORL-II" etc.) \n 00042 * returns: inertia matrix 00043 */ 00044 Matrix simulatorInertia(TiXmlHandle docHandle, const char *simulator) 00045 { 00046 Matrix inertia(3,3); 00047 for(int row = 1; row <= 3; row++) 00048 { 00049 for(int column = 1; column <= 3; column++) 00050 { 00051 char index[3]; 00052 sprintf (index, "I%d%d",row,column); 00053 int response = docHandle.FirstChild( simulator ).FirstChild( "PHYSICAL_PROPERTIES" ). 00054 Child( "INERTIA", 0 ).Element() -> QueryDoubleAttribute(index, &inertia(row,column)); 00055 checkResponse(response); 00056 } 00057 } 00058 return inertia; 00059 } 00060 00061 00062 // Do not change the comments below - they will be added automatically by CVS 00063 /***************************************************************************** 00064 * $Log: dsacssinterface.cpp,v $ 00065 * Revision 1.1 2006/07/25 20:45:06 jayhawk_hokie 00066 * Initial submission 00067 * 00068 * 00069 * 00070 * 00071 ******************************************************************************/ 00072 00073 00074