00001
00002
00003 #if !defined(_H_GPS_CLASS)
00004 #define _H_GPS_CLASS
00005
00015 #if _MSC_VER > 1000
00016 #pragma once
00017 #endif // _MSC_VER > 1000
00018
00019 #include "facilities/Scheduler.h"
00020 #include "facilities/Observer.h"
00021 #include "geometry/Point.h"
00022 #include "geometry/Vector.h"
00023 #include "geometry/CoordTransform.h"
00024
00025 #include "astro/SkyDir.h"
00026 #include "astro/EarthOrbit.h"
00027
00028
00029 #include <iostream>
00030
00031 class Orbit;
00032
00033
00034
00036
00037 Time is tracked through this object, and synchronized with the Scheduler for
00038 discrete event simulation. An expansion factor is provided to allow for acceleration
00039 or randomization of the orbit. If the expansion factor is negative, then the position
00040 of the spacecraft is chosen as a random distribution over an orbit. Otherwise, the expansion
00041 factor represents an acceleration of the spacecraft's orbit. Ie. an expansion factor
00042 of 2 would reduce the orbit period of the spacecraft by 1/2.
00043 */
00044 class GPS
00045 {
00046 public:
00047
00048 enum RockType {
00049 NONE,
00050 UPDOWN,
00051 SLEWING,
00052 ONEPERORBIT
00053 };
00054
00055 class Coords {
00056 public:
00057 Coords( double alat, double alon, double apitch
00058 , double ayaw, double aroll, GPStime atime, double phase );
00059 Coords();
00060
00061 GPStime time () const { return m_time; }
00062 double lat () const { return m_lat; }
00063 double lon () const { return m_lon; }
00064 double pitch () const { return m_pitch; }
00065 double yaw () const { return m_yaw; }
00066 double roll () const { return m_roll; }
00067 double phase () const { return m_phase; }
00068
00069 private:
00070 GPStime m_time;
00071 double m_lat, m_lon, m_pitch, m_yaw, m_roll, m_phase;
00072 };
00073
00074
00075
00077 GPStime time () const;
00079 double lat () const;
00081 double lon () const;
00083 double pitch () const;
00085 double yaw () const;
00087 double roll () const;
00089 double phase () const;
00091 const Orbit* orbit () const;
00093 Coords state () const;
00095 double expansion () const;
00097 GPStime sampleintvl () const;
00099 double ascendingLon()const;
00101 std::pair<double,double> rotateAngles();
00102
00103
00105 void getPointingCharacteristics(double seconds);
00106
00108 void orbit ( Orbit* );
00110 void pass ( double );
00112 void phase ( double );
00114 void expansion ( double );
00116 void synch ();
00118 void sampleintvl ( GPStime );
00120 void ascendingLon(double);
00122 void rotateAngles(std::pair<double,double> coords);
00123
00125 void printOn(std::ostream& out) const;
00126
00127
00128 void notifyObservers() { m_notification.notify();}
00129 Subject& notification() { return m_notification; }
00130
00131
00132 static GPS* instance();
00133 static void kill ();
00134
00136 Rotation rockingAngleTransform(double seconds);
00137
00139 Rotation transformGlastToGalactic(double seconds);
00140
00141 Rotation GPS::CELTransform(double seconds);
00142
00143 Rotation GPS::transformCelToGlast(double seconds);
00144
00145 void rockingDegrees(double rockDegrees){m_rockDegrees = rockDegrees;}
00146
00147 Orbit* orbit ();
00148
00149 void setRockType(RockType rockType){m_rockType = rockType;}
00150 void setRockType(int rockType);
00151
00152 double RAX()const{return m_RAX;}
00153 double RAZ()const{return m_RAZ;}
00154 double DECX()const{return m_DECX;}
00155 double DECZ()const{return m_DECZ;}
00156 double RAZenith()const{return m_RAZenith;}
00157 double DECZenith()const{return m_DECZenith;}
00158
00159 Hep3Vector position(double seconds)const{
00160 double time = m_earthOrbit->dateFromSeconds(seconds);
00161 return m_earthOrbit->position(time);
00162 }
00163
00164 protected:
00165
00166 GPS();
00167 virtual ~GPS();
00168
00169
00170 void pitch ( double );
00171 void yaw ( double );
00172 void roll ( double );
00173 void lat ( double );
00174 void lon ( double );
00175 void time ( GPStime );
00176 GPStime orbittime () const;
00177 void orbittime ( GPStime );
00178 void setState ( const GPS::Coords& );
00179 std::pair<double,double> m_rotangles;
00180
00181
00182 friend class FluxGenerator;
00183
00184 private:
00185 static GPS* s_instance;
00186 astro::EarthOrbit* m_earthOrbit;
00187
00188 Orbit* m_orbit;
00189 double m_expansion;
00190 GPStime m_time;
00191 GPStime m_orbittime;
00192 double m_sampleintvl;
00193 double m_RAX,m_RAZ,m_DECX,m_DECZ;
00194 double m_RAZenith,m_DECZenith;
00195 Hep3Vector m_position;
00196
00197 Subject m_notification;
00198 double m_rockDegrees;
00199 RockType m_rockType;
00200 };
00201
00202 inline std::istream& operator>>(std::istream& i, GPS::Coords& c) {
00203 double p, y, r, lt, ln, tm, ph;
00204 i >> lt; i >> ln; i >> p; i >> y; i >> r; i >> tm; i >> ph;
00205 c = GPS::Coords( lt, ln, p, y, r, tm, ph );
00206 return i;
00207 }
00208
00209 inline std::ostream& operator<<(std::ostream& o, const GPS::Coords& c) {
00210 o << ' ' << c.lat() << ' ' << c.lon() << ' '
00211 << c.pitch() << ' ' << c.yaw() << ' '
00212 << c.roll() << ' ' << c.time() <<' ' << c.phase();
00213 return o;
00214 }
00215 #endif // !defined(AFX_GPS_H__F9844433_4E64_11D2_B4DD_00A0C9960210__INCLUDED_)