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

WhorlHistory.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file       WhorlHistory.cpp
00003  *  \brief      An abstract class to store Whorl data.
00004  *  \author $Author: jayhawk_hokie $
00005  *  \version $Revision: 1.4 $
00006  *  \date    $Date: 2007/05/31 17:38:48 $
00007  *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*  
00009  */
00010 //////////////////////////////////////////////////////////////////////////////////////////////////
00011 
00012 #include "WhorlHistory.h"
00013    
00014 /*! \brief Constructs an empty Whorl history.
00015  *  @param _handle is a TiXmlHanlde with the configuration parameters.
00016  *  @param _WhorlName is a string with the name of the Simulator.
00017  */
00018 WhorlHistory::WhorlHistory( TiXmlHandle _handle, string _WhorlName )
00019 {
00020         m_File = new ofstream;
00021         Parse( _handle, _WhorlName );
00022         Initialize( );
00023 }
00024 
00025 /*! \brief Default Deconstructor */
00026 WhorlHistory::~WhorlHistory()
00027 {
00028         Deinitialize( );
00029 }
00030 
00031 /*! \brief Initialze function */
00032 int WhorlHistory::Initialize( )
00033 {
00034         m_File->open( m_FileName.c_str( ) );
00035         return( 0 );
00036 }
00037 
00038 /*! \brief Deinitialze function */
00039 int WhorlHistory::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 _WhorlName is a string with the name of the Simulator.
00049  */
00050 int WhorlHistory::Parse( TiXmlHandle _handle, string _WhorlName )
00051 {
00052         //const char *observer;
00053         m_FilePath = _handle.FirstChild( _WhorlName ).FirstChild( "DATA_LOGGING" ).Child( "MAIN_PATH", 0 ).Element() -> Attribute( "value" );
00054         m_TestID = _handle.FirstChild( _WhorlName ).FirstChild( "DATA_LOGGING" ).Child( "TEST_ID", 0 ).Element() -> Attribute( "value" );
00055         m_FileExtension = _handle.FirstChild( _WhorlName ).FirstChild( "DATA_LOGGING" ).Child( "FILE_EXTENSION", 0 ).Element() -> Attribute( "value" );
00056         m_ObjectName = _WhorlName;
00057         m_FileName = m_FilePath;
00058         m_FileName.append( m_TestID );
00059         m_FileName.append( "_" );
00060         m_FileName.append( m_ObjectName );
00061         m_FileName.append( m_FileExtension );
00062         return( 0 );
00063 }
00064 
00065 /*! \brief Append the time, attitude, and other states of the Simulator to a file.
00066  *  @param _Time is an ssfTime object that holds the time of wheel speed measurement.
00067  *  @param _AttitudeState is a Vector for attitude representation 1x(1:4) quaternion 1x(5:7) angular rates [rad/s]
00068  *  @param _AttitudeControl is a Vector for attitude control 1x3 [N-m]
00069  */
00070 void WhorlHistory::AppendHistory( ssfTime _Time, Vector _AttitudeState, Vector _AttitudeControl )
00071 {
00072         ostringstream appendString;
00073         appendString  << _Time;
00074 
00075         /* Attitude Vector 1x7 */
00076         for( int i=0; i<7; i++ )
00077         {
00078                 appendString << " " << _AttitudeState(i+1);
00079         }
00080         /* Control Vector 1x7 */
00081         for( int i=0; i<3; i++ )
00082         {
00083                 appendString << " " << _AttitudeControl(i+1);
00084         }
00085 
00086         *m_File << appendString.str( ) << endl;
00087 
00088         return;
00089 }
00090 
00091 /*! \brief Append the time, attitude, and other states of the Simulator to a file.
00092  *  @param _Time is an ssfTime object that holds the time of wheel speed measurement.
00093  *  @param _AttitudeState is a Vector for attitude representation 1x(1:4) quaternion 1x(5:7) angular rates [rad/s]
00094  *  @param _AttitudeControl is a Vector for attitude control 1x3 [N-m]
00095  *  @param _MRP is a Vector for attitude 1x3 
00096  */
00097 void WhorlHistory::AppendHistory( ssfTime _Time, Vector _AttitudeState, Vector _AttitudeControl, Vector _MRP )
00098 {
00099         ostringstream appendString;
00100         appendString  << _Time;
00101 
00102         /* Attitude Vector 1x7 */
00103         for( int i=0; i<7; i++ )
00104         {
00105                 appendString << " " << _AttitudeState(i+1);
00106         }
00107         /* Control Vector 1x3 */
00108         for( int i=0; i<3; i++ )
00109         {
00110                 appendString << " " << _AttitudeControl(i+1);
00111         }
00112         /* MRP Vector 1x3 */
00113         for( int i=0; i<3; i++ )
00114         {
00115                 appendString << " " << _MRP(i+1);
00116         }
00117 
00118         *m_File << appendString.str( ) << endl;
00119 
00120         return;
00121 }
00122 
00123 /*! \brief Append the time, attitude, and other states of the Simulator to a file.
00124  *  @param _Time is an ssfTime object that holds the time of wheel speed measurement.
00125  *  @param _AttitudeState is a Vector for attitude representation 1x(1:4) quaternion 1x(5:7) angular rates [rad/s]
00126  *  @param _AttitudeControl is a Vector for attitude control 1x3 [N-m]
00127  *  @param _MRP is a Vector for attitude 1x3 
00128  */
00129 void WhorlHistory::AppendHistory( ssfTime _Time, Vector _AttitudeState, Vector _AttitudeControl, Vector _MRP, 
00130         Vector _ReferenceAttitudeState, Vector _ReferenceMRP, Vector _ControlError )
00131 {
00132         ostringstream appendString;
00133         appendString  << _Time;
00134 
00135         /* Attitude Vector 1x7 */
00136         for( int i=0; i<7; i++ )
00137         {
00138                 appendString << " " << _AttitudeState(i+1);
00139         }
00140         /* Control Vector 1x3 */
00141         for( int i=0; i<3; i++ )
00142         {
00143                 appendString << " " << _AttitudeControl(i+1);
00144         }
00145         /* MRP Vector 1x3 */
00146         for( int i=0; i<3; i++ )
00147         {
00148                 appendString << " " << _MRP(i+1);
00149         }
00150         /* Reference Attitude Vector 1x7 */
00151         for( int i=0; i<7; i++ )
00152         {
00153                 appendString << " " << _ReferenceAttitudeState(i+1);
00154         }
00155         /* Reference MRP Vector 1x3 */
00156         for( int i=0; i<3; i++ )
00157         {
00158                 appendString << " " << _ReferenceMRP(i+1);
00159         }
00160         /* Control Error Vector 1x3 */
00161         for( int i=0; i<6; i++ )
00162         {
00163                 appendString << " " << _ControlError(i+1);
00164         }
00165 
00166         *m_File << appendString.str( ) << endl;
00167 
00168         return;
00169 }
00170 
00171 
00172 // Do not change the comments below - they will be added automatically by CVS
00173 /*****************************************************************************
00174 *       $Log: WhorlHistory.cpp,v $
00175 *       Revision 1.4  2007/05/31 17:38:48  jayhawk_hokie
00176 *       Added control error logging.
00177 *       
00178 *       Revision 1.3  2007/04/09 14:05:49  jayhawk_hokie
00179 *       Changed data logging for Whorl.
00180 *       
00181 *       Revision 1.2  2003/07/22 21:59:39  mavandyk
00182 *       Fixed several bugs.  Some functions have been commented out.
00183 *       
00184 *       Revision 1.1  2003/07/07 14:37:24  simpliciter
00185 *       Initial submission.  Should work once measurement issues are resolved.
00186 *       
00187 *
00188 ******************************************************************************/

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