Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

GPS.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/flux/flux/GPS.h,v 1.7 2001/10/31 23:20:04 srobinsn Exp $
00002 // GPS.h: interface for the GPS class.
00003 //
00004 //      Models the Global Positoning System for a spacecraft. Handles time
00005 //      position, and orientation for the instrument as a whole.
00007 
00008 #if !defined(_H_GPS_CLASS)
00009 #define _H_GPS_CLASS
00010 
00011 #if _MSC_VER > 1000
00012 #pragma once
00013 #endif // _MSC_VER > 1000
00014 
00015 #include "facilities/Scheduler.h"
00016 #include "facilities/Observer.h"
00017 #include "geometry/Point.h"
00018 
00019 #include <iostream>
00020 
00021 class Orbit;
00022 // 
00023 //  class GPS
00024 //
00026 /*!  object is used to compute the spacecraft's position and pointing characteristics.
00027   Time is tracked through this object, and synchronized with the Scheduler for 
00028   discrete event simulation. An expansion factor is provided to allow for acceleration
00029   or randomization of the orbit. If the expansion factor is negative, then the position
00030   of the spacecraft is chosen as a random distribution over an orbit. Otherwise, the expansion
00031   factor represents an acceleration of the spacecraft's orbit. Ie. an expansion factor
00032   of 2 would reduce the orbit period of the spacecraft by 1/2.
00033 */
00034 class GPS  
00035 {
00036 public:
00037     class Coords {
00038     public:
00039         Coords( double alat, double alon, double apitch
00040             , double ayaw, double aroll, GPStime atime, double phase ); 
00041         Coords();
00042         
00043         GPStime time () const { return m_time; }
00044         double  lat () const { return m_lat; }
00045         double  lon () const { return m_lon; }
00046         double  pitch () const { return m_pitch; }
00047         double  yaw () const { return m_yaw; }
00048         double  roll () const { return m_roll; }
00049         double  phase () const { return m_phase; }
00050         
00051     private:
00052         GPStime m_time;
00053         double m_lat, m_lon, m_pitch, m_yaw, m_roll, m_phase;
00054     };
00055     
00056     // const access
00057     
00059     GPStime     time () const; 
00061     double      lat () const; 
00063     double      lon () const; 
00065     double      pitch () const; 
00067     double      yaw () const; 
00069     double      roll () const; 
00071     double      phase () const;
00073     const Orbit* orbit () const;
00075     Coords      state () const;  
00077     double      expansion () const; 
00079     GPStime     sampleintvl () const; 
00081     double     ascendingLon()const; 
00083     std::pair<double,double> rotateAngles(); 
00084     // set data
00085     
00087     void    orbit ( Orbit* );
00089     void    pass ( double );
00091     void    phase ( double );
00093     void    expansion ( double );
00095     void    synch ();    
00097     void    sampleintvl ( GPStime );
00099     void    ascendingLon(double);   
00101     void        rotateAngles(std::pair<double,double> coords); 
00102     
00104     void    printOn(std::ostream& out) const; 
00105     
00106     // notification
00107     void notifyObservers() { m_notification.notify();}
00108     Subject&    notification() { return m_notification; }
00109     
00110     // static access/destruction
00111     static GPS* instance();
00112     static void     kill ();
00113     
00115     /*Vector*/std::pair<double,double> galToGlast(std::pair<double,double> galcoords);
00116     
00117     
00118     
00119     protected:
00120         // singleton - protect ctor/dtor
00121         GPS();
00122         virtual ~GPS();
00123         
00124         // only class/subclasses have access
00125         void    pitch ( double );       // set pitch
00126         void    yaw ( double );         // set yaw
00127         void    roll ( double );        // set roll
00128         void    lat ( double );         // set latitude
00129         void    lon ( double );         // set longitude
00130         void    time ( GPStime );       // set time
00131         Orbit*  orbit ();               // access the orbit (for manipulation)
00132         GPStime orbittime () const;     // access to orbit time
00133         void    orbittime ( GPStime );  // set orbit time
00134         void    setState ( const GPS::Coords& ); // set the orbital parameters
00135         std::pair<double,double> m_rotangles;  //angles for coordinate rotation
00136         
00137         
00138         
00139         
00140         // friends
00141         friend class FluxGenerator;
00142         
00143     private:
00144         static GPS* s_instance;
00145         
00146         Orbit*  m_orbit;        // orbital position object 
00147         double  m_expansion;    // orbit expansion factor
00148         GPStime m_time;     // global time
00149         GPStime m_orbittime;    // time in orbit (depends on expansion)
00150         double  m_sampleintvl;  // interval to sample for each pt. in the orbit - to normalize spectra
00151         
00152         // notification
00153         Subject    m_notification; 
00154         
00155 };
00156 
00157 inline std::istream&    operator>>(std::istream& i, GPS::Coords& c) {
00158     double  p, y, r, lt, ln, tm, ph;
00159     i >> lt; i >> ln; i >> p; i >> y; i >> r; i >> tm; i >> ph;
00160     c = GPS::Coords( lt, ln, p, y, r, tm, ph );
00161     return i;
00162 }
00163 
00164 inline std::ostream&    operator<<(std::ostream& o, const GPS::Coords& c) {
00165     o << ' ' << c.lat() << ' ' << c.lon() << ' ' 
00166         << c.pitch() << ' ' << c.yaw() << ' ' 
00167         << c.roll() << ' ' << c.time() <<' ' << c.phase();
00168     return o;
00169 }
00170 #endif // !defined(AFX_GPS_H__F9844433_4E64_11D2_B4DD_00A0C9960210__INCLUDED_)

Generated at Wed Nov 21 12:20:34 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000