00001 ////////////////////////////////////////////////////////////////////////////////////////////////// 00002 /*! \file WheelHistory.cpp 00003 * \brief Encapsulation of WheelHistory object. 00004 * \author $Author: jayhawk_hokie $ 00005 * \version $Revision: 1.2 $ 00006 * \date $Date: 2007/04/09 14:05:13 $ 00007 *////////////////////////////////////////////////////////////////////////////////////////////////// 00008 /* 00009 */ 00010 ////////////////////////////////////////////////////////////////////////////////////////////////// 00011 00012 #include "WheelHistory.h" 00013 00014 /*! \brief Constructs an empty attitude history. 00015 * @param _handle is a TiXmlHanlde with the configuration parameters. 00016 * @param _wheelName is a string with the name of the momentum wheel. 00017 */ 00018 WheelHistory::WheelHistory( TiXmlHandle _handle, string _wheelName ) 00019 { 00020 m_File = new ofstream; 00021 Parse( _handle, _wheelName ); 00022 Initialize( ); 00023 } 00024 00025 /*! \brief Default Deconstructor */ 00026 WheelHistory::~WheelHistory() 00027 { 00028 Deinitialize( ); 00029 } 00030 00031 /*! \brief Initialze function */ 00032 int WheelHistory::Initialize( ) 00033 { 00034 m_File->open( m_FileName.c_str( ) ); 00035 return( 0 ); 00036 } 00037 00038 /*! \brief Deinitialze function */ 00039 int WheelHistory::Deinitialize( ) 00040 { 00041 m_File->close( ); 00042 delete m_File; // delete pointer 00043 return( 0 ); 00044 } 00045 00046 /*! \brief Parse Config file for logging parameters. 00047 * @param _handle is a TiXmlHanlde with the configuration parameters. 00048 * @param _wheelName is a string with the name of the momentum wheel. 00049 */ 00050 int WheelHistory::Parse( TiXmlHandle _handle, string _wheelName ) 00051 { 00052 //const char *observer; 00053 m_FilePath = _handle.FirstChild( "DATA_LOGGING" ).Child( "MAIN_PATH", 0 ).Element() -> Attribute( "value" ); 00054 m_TestID = _handle.FirstChild( "DATA_LOGGING" ).Child( "TEST_ID", 0 ).Element() -> Attribute( "value" ); 00055 m_FileExtension = _handle.FirstChild( "DATA_LOGGING" ).Child( "FILE_EXTENSION", 0 ).Element() -> Attribute( "value" ); 00056 m_ObjectName = _wheelName; 00057 m_FileName = m_FilePath; 00058 m_FileName.append( m_TestID ); 00059 m_FileName.append( "WheelSpeed_" ); 00060 m_FileName.append( m_ObjectName ); 00061 m_FileName.append( m_FileExtension ); 00062 // In wrong location: m_LogData = _handle.FirstChild( "PHYSICAL_PROPERTIES" ).FirstChild( m_ObjectName ).Child( "LOGGING", 0 ).Element() -> Attribute( "value" ); 00063 return( 0 ); 00064 } 00065 00066 /*! \brief Append the time and wheel speed history of a single momentum wheel to a file. 00067 * @param _Time is an ssfTime object that holds the time of wheel speed measurement. 00068 * @param _WheelSpeed is a double for the wheel speed [rad/s] 00069 */ 00070 void WheelHistory::AppendHistory( ssfTime _Time, double _WheelSpeed ) 00071 { 00072 ostringstream appendString; 00073 appendString << _Time << " " 00074 << _WheelSpeed ; 00075 *m_File << appendString.str( ) << endl; 00076 00077 return; 00078 } 00079 00080 00081 00082 // Do not change the comments below - they will be added automatically by CVS 00083 /***************************************************************************** 00084 * $Log: WheelHistory.cpp,v $ 00085 * Revision 1.2 2007/04/09 14:05:13 jayhawk_hokie 00086 * Changed data logging for momentum wheels. 00087 * 00088 * Revision 1.1.1.1 2003/06/06 18:44:15 simpliciter 00089 * Initial submission. 00090 * 00091 * 00092 ******************************************************************************/