00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "WhorlHistory.h"
00013
00014
00015
00016
00017
00018 WhorlHistory::WhorlHistory( TiXmlHandle _handle, string _WhorlName )
00019 {
00020 m_File = new ofstream;
00021 Parse( _handle, _WhorlName );
00022 Initialize( );
00023 }
00024
00025
00026 WhorlHistory::~WhorlHistory()
00027 {
00028 Deinitialize( );
00029 }
00030
00031
00032 int WhorlHistory::Initialize( )
00033 {
00034 m_File->open( m_FileName.c_str( ) );
00035 return( 0 );
00036 }
00037
00038
00039 int WhorlHistory::Deinitialize( )
00040 {
00041 m_File->close( );
00042 delete m_File;
00043 return( 0 );
00044 }
00045
00046
00047
00048
00049
00050 int WhorlHistory::Parse( TiXmlHandle _handle, string _WhorlName )
00051 {
00052
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
00066
00067
00068
00069
00070 void WhorlHistory::AppendHistory( ssfTime _Time, Vector _AttitudeState, Vector _AttitudeControl )
00071 {
00072 ostringstream appendString;
00073 appendString << _Time;
00074
00075
00076 for( int i=0; i<7; i++ )
00077 {
00078 appendString << " " << _AttitudeState(i+1);
00079 }
00080
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
00092
00093
00094
00095
00096
00097 void WhorlHistory::AppendHistory( ssfTime _Time, Vector _AttitudeState, Vector _AttitudeControl, Vector _MRP )
00098 {
00099 ostringstream appendString;
00100 appendString << _Time;
00101
00102
00103 for( int i=0; i<7; i++ )
00104 {
00105 appendString << " " << _AttitudeState(i+1);
00106 }
00107
00108 for( int i=0; i<3; i++ )
00109 {
00110 appendString << " " << _AttitudeControl(i+1);
00111 }
00112
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
00124
00125
00126
00127
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
00136 for( int i=0; i<7; i++ )
00137 {
00138 appendString << " " << _AttitudeState(i+1);
00139 }
00140
00141 for( int i=0; i<3; i++ )
00142 {
00143 appendString << " " << _AttitudeControl(i+1);
00144 }
00145
00146 for( int i=0; i<3; i++ )
00147 {
00148 appendString << " " << _MRP(i+1);
00149 }
00150
00151 for( int i=0; i<7; i++ )
00152 {
00153 appendString << " " << _ReferenceAttitudeState(i+1);
00154 }
00155
00156 for( int i=0; i<3; i++ )
00157 {
00158 appendString << " " << _ReferenceMRP(i+1);
00159 }
00160
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
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188