00001
00002
00003
00004
00005
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
00024
00026
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
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
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
00107 void notifyObservers() { m_notification.notify();}
00108 Subject& notification() { return m_notification; }
00109
00110
00111 static GPS* instance();
00112 static void kill ();
00113
00115 std::pair<double,double> galToGlast(std::pair<double,double> galcoords);
00116
00117
00118
00119 protected:
00120
00121 GPS();
00122 virtual ~GPS();
00123
00124
00125 void pitch ( double );
00126 void yaw ( double );
00127 void roll ( double );
00128 void lat ( double );
00129 void lon ( double );
00130 void time ( GPStime );
00131 Orbit* orbit ();
00132 GPStime orbittime () const;
00133 void orbittime ( GPStime );
00134 void setState ( const GPS::Coords& );
00135 std::pair<double,double> m_rotangles;
00136
00137
00138
00139
00140
00141 friend class FluxGenerator;
00142
00143 private:
00144 static GPS* s_instance;
00145
00146 Orbit* m_orbit;
00147 double m_expansion;
00148 GPStime m_time;
00149 GPStime m_orbittime;
00150 double m_sampleintvl;
00151
00152
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_)