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

History.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file History.h
00003 *  \brief Interface to the abstract History class.
00004 *  \author $Author: jayhawk_hokie $
00005 *  \version $Revision: 1.2 $
00006 *  \date    $Date: 2005/06/10 12:53:28 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /*  
00009 *
00010 */
00011 //////////////////////////////////////////////////////////////////////////////////////////////////
00012 
00013 #ifndef __HISTORY_H__
00014 #define __HISTORY_H__
00015 #include <vector>
00016 #include <functional>
00017 #include <algorithm>
00018 #include <utils/Time.h>
00019 #include <utils/Interpolator.h>
00020 using namespace std;
00021 namespace O_SESSAME {
00022 //////////////////////////////////////////////////////////////////////////////////////////////////
00023 /*! @defgroup DataHandling Data Handling
00024 *       This toolbox includes all the functionality regarding the handling, storage, importing, and 
00025 * exporting of data from the spacecraft simulation environment. The primary classes include the 
00026 * History class and its derived classes. These History objects store various spacecraft states and 
00027 * provide for various manipulations of the data.
00028 *
00029 * \par Extension Points:
00030 *
00031 */
00032 
00033 /*! @defgroup StateHistory State History 
00034 * \ingroup DataHandling
00035 */
00036 #define HISTORY_RESERVE_SIZE 1000 /*!< \brief expected history storage size. Used to reserve memory of states ahead of time. This number should be characteristic of the typical number of states in a history matrix. */
00037 /*! \brief Base class for histories storing state variables, also stores time states.
00038 * \ingroup StateHistory
00039 *
00040 *  The History class provides a common interface for the group of classes which
00041 *       store previous state information. The user can append new state information, 
00042 *       output the current state history, or reset the entire history. If the user appends
00043 *       a time which earlier than the end of the current history, the current history
00044 *       is deleted from that point on, and the new time is appended.
00045 *       The History class also provides the common storage of the time history.
00046 *
00047 * \par Examples:
00048 \code
00049 History myHistory;          // create a history with an empty collection
00050 myHistory.AppendHistory(0); // add 0 seconds to the history
00051 myHistory.ResetHistory();   // reset the history to an empty collection
00052 myHistory.AppendHistory(10);// add 10 seconds to the history
00053 
00054 cout << myHistory.GetHistory() << endl;  // Get a matrix of the stored times and output
00055 \endcode
00056 */
00057 class History
00058 {
00059 public:
00060     /*! \brief Creates an instance of History.
00061         */
00062     History();
00063     
00064     /*! \brief Default Deconstructor
00065         */
00066     virtual ~History();
00067     
00068     /*! \brief Add a time (in seconds) to the stored history.
00069         *
00070         *  if the new time is earlier than any of the stored values
00071         *       then the time history will be erased from the overlap point 
00072         *       and the new value will be appended.
00073         * @param _appendTime time (in seconds) to be added.
00074         */
00075     virtual void AppendHistory(const double &_appendTime);
00076 
00077     /*! \brief Add an ssfTime object to the stored history.
00078         *
00079         *  if the new time is earlier than any of the stored values
00080         *       then the time history will be erased from the overlap point 
00081         *       and the new value will be appended.
00082         * @param _appendTime an ssfTime object to be appended. 
00083         */
00084     virtual void AppendHistory(const ssfTime &_appendTime);
00085     
00086     /*! \brief Add a vector of ssfTime objects to the stored history.
00087         *
00088         *  if the beginning of the new time vector is earlier than 
00089         *       any of the stored values then the time history will be erased 
00090         *       from the overlap point and the new time vector will be appended.
00091         * @param _appendTime vector of ssfTime objects to be appended. 
00092         */
00093     virtual vector<ssfTime>::difference_type AppendHistory(const vector<ssfTime> &_appendTime);
00094 
00095     /*! \brief Erases the time history */
00096     void ResetHistory();
00097     
00098     /*! \brief Returns a matrix of the time history
00099         * @return nx1 matrix of the state history, where n is the number of time states stored.
00100         */
00101     virtual Matrix GetHistory();
00102     
00103     /*! \brief Returns the nearest stored,lower mesh point to the requested time.
00104         *
00105         *  interpolates using the specified interpolator if necessary.
00106         * @param _requestedTime Desired time to retrieve the state. Used to find the nearest corresponding
00107         *       lower mesh point.
00108         * @return The index of the time history vector of the nearest, lower mesh point.
00109         */
00110 
00111     /*! \brief Sets the interpolator used for calculating the states in-between stored mesh points.
00112         * @param _newInterpolator pointer to the interpolator that serves as the model type for all the 
00113         *       interpolations between meshpoints.
00114         */
00115     virtual void SetInterpolator(Interpolator* _newInterpolator);
00116     
00117 protected:
00118     /*! \brief Returns the nearest stored,lower mesh point to the requested time.
00119         *
00120         *  interpolates using the specified interpolator if necessary.
00121         * @param _requestedTime Desired time to retrieve the state. Used to find the nearest corresponding
00122         *       lower mesh point.
00123         * @return The index of the time history vector of the nearest, lower mesh point.
00124         */
00125     vector<ssfTime>::difference_type  GetState(const ssfTime& _requestedTime);
00126     
00127     /*! \brief internal vector container of the ssfTime objects describing the state history */
00128     vector<ssfTime> m_TimeHistory;
00129     
00130     /*! \brief internal storage of the original, nominal interpolator to be copied and used for all interpolations */
00131     Interpolator* m_OriginalInterpolator;  
00132     
00133     /*! \brief internal vector of time interpolations */
00134     vector<Interpolator*> m_TimeInterpolations;
00135 
00136 
00137 };
00138 
00139 } // close namespace O_SESSAME
00140 
00141 #endif
00142 
00143 
00144 // Do not change the comments below - they will be added automatically by CVS
00145 /*****************************************************************************
00146 *       $Log: History.h,v $
00147 *       Revision 1.2  2005/06/10 12:53:28  jayhawk_hokie
00148 *       Changed header file format to make it easier to link to the spacecraft code by only having to specify dsacss/dep/spacecraft/src (ex. "file.h" changed to <dir/file.h> where dir is a folder in src).
00149 *       
00150 *       Revision 1.1.1.1  2005/04/26 17:40:56  cakinli
00151 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00152 *       
00153 *       Revision 1.14  2003/10/18 21:37:27  rsharo
00154 *       Removed "../utils" from all qmake project paths. Prepended "utils
00155 *       /" to all #include directives for utils. Removed ".h" extensions from STL header
00156 *       s and referenced STL components from "std::" namespace.  Overall, changed to be
00157 *       more portable.
00158 *       
00159 *       Revision 1.13  2003/06/06 00:34:16  nilspace
00160 *       ?
00161 *       
00162 *       Revision 1.12  2003/05/27 17:35:52  nilspace
00163 *       Updated to prevent errors.
00164 *       
00165 *       Revision 1.11  2003/05/22 21:01:45  nilspace
00166 *       Updated comments.
00167 *       
00168 *       Revision 1.10  2003/05/20 17:50:01  nilspace
00169 *       Updated comments.
00170 *       
00171 *       Revision 1.9  2003/05/15 18:10:24  nilspace
00172 *       Added <functional> and <algorithm> to the include files.
00173 *       
00174 *       Revision 1.8  2003/05/13 18:45:35  nilspace
00175 *       Added interpolation functionality.
00176 *       
00177 *       Revision 1.7  2003/05/01 23:59:48  nilspace
00178 *       Commented the API.
00179 *       
00180 *       Revision 1.6  2003/05/01 18:24:36  nilspace
00181 *       Prevented overlapping Appends by removing the old states and times.
00182 *       
00183 *       Revision 1.5  2003/04/27 22:04:33  nilspace
00184 *       Created the namespace O_SESSAME.
00185 *       
00186 *       Revision 1.4  2003/04/25 17:15:00  nilspace
00187 *       Added OrbitHistory & made sure it builds.
00188 *       Moved Appending time to History.cpp.
00189 *       
00190 *       Revision 1.3  2003/04/23 17:01:02  nilspace
00191 *       Time is now stored as an ssfTime object.
00192 *       
00193 *       Revision 1.2  2003/04/23 16:30:58  nilspace
00194 *       Various bugfixes & uploading of all changed code for new programmers.
00195 *       
00196 *       Revision 1.1  2003/03/27 20:29:02  nilspace
00197 *       Initial Submission.
00198 *
00199 ******************************************************************************/

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