]> git.mxchange.org Git - flightgear.git/blob - src/Navaids/navrecord.hxx
TACAN/mobile navaid cleanup and improvements.
[flightgear.git] / src / Navaids / navrecord.hxx
1 // navrecord.hxx -- generic vor/dme/ndb class
2 //
3 // Written by Curtis Olson, started May 2004.
4 //
5 // Copyright (C) 2004  Curtis L. Olson - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _FG_NAVRECORD_HXX
25 #define _FG_NAVRECORD_HXX
26
27 #include <iosfwd>
28
29 #include "navaids_fwd.hxx"
30 #include "positioned.hxx"
31 #include <Airports/airports_fwd.hxx>
32
33 #include <simgear/timing/timestamp.hxx>
34
35 const double FG_NAV_DEFAULT_RANGE = 50; // nm
36 const double FG_LOC_DEFAULT_RANGE = 18; // nm
37 const double FG_DME_DEFAULT_RANGE = 50; // nm
38 const double FG_NAV_MAX_RANGE = 300;    // nm
39
40 class FGNavRecord : public FGPositioned 
41 {
42
43     int freq;
44     int range;
45     double multiuse;            // can be slaved variation of VOR
46                                 // (degrees) or localizer heading
47                                 // (degrees) or dme bias (nm)
48
49     std::string mName;          // verbose name in nav database
50     PositionedID mRunway;       // associated runway, if there is one
51     PositionedID mColocated;    // Colocated DME at a navaid (ILS, VOR, TACAN, NDB)
52
53   protected:
54     mutable bool serviceable;   // for failure modeling
55
56   public:
57     FGNavRecord( PositionedID aGuid,
58                  Type type,
59                  const std::string& ident,
60                  const std::string& name,
61                  const SGGeod& aPos,
62                  int freq,
63                  int range,
64                  double multiuse,
65                  PositionedID aRunway );
66
67     inline double get_lon() const { return longitude(); } // degrees
68     inline double get_lat() const { return latitude(); } // degrees
69     inline double get_elev_ft() const { return elevation(); }
70         
71     inline int get_freq() const { return freq; }
72     inline int get_range() const { return range; }
73     inline double get_multiuse() const { return multiuse; }
74     inline void set_multiuse( double m ) { multiuse = m; }
75     inline const char *get_ident() const { return ident().c_str(); }
76
77     inline bool get_serviceable() const { return serviceable; }
78     inline const char *get_trans_ident() const { return get_ident(); }
79
80   virtual const std::string& name() const
81   { return mName; }
82   
83   /**
84    * Retrieve the runway this navaid is associated with (for ILS/LOC/GS)
85    */
86   FGRunwayRef runway() const;
87   
88   /**
89    * return the localizer width, in degrees
90    * computation is based up ICAO stdandard width at the runway threshold
91    * see implementation for further details.
92    */
93   double localizerWidth() const;
94   
95   void bindToNode(SGPropertyNode* nd) const;
96   void unbindFromNode(SGPropertyNode* nd) const;
97
98   void setColocatedDME(PositionedID other);
99   bool hasDME();
100     
101     void updateFromXML(const SGGeod& geod, double heading);
102 };
103
104 /**
105  * A mobile navaid, aka. a navaid which can change its position (eg. a mobile
106  * TACAN)
107  */
108 class FGMobileNavRecord:
109   public FGNavRecord
110 {
111   public:
112     FGMobileNavRecord( PositionedID aGuid,
113                        Type type,
114                        const std::string& ident,
115                        const std::string& name,
116                        const SGGeod& aPos,
117                        int freq,
118                        int range,
119                        double multiuse,
120                        PositionedID aRunway );
121
122     virtual const SGGeod& geod() const;
123     virtual const SGVec3d& cart() const;
124
125     void updatePos();
126
127   protected:
128     SGTimeStamp _last_position_update;
129 };
130
131 class FGTACANRecord : public SGReferenced {
132
133     std::string channel;                
134     int freq;
135      
136 public:
137     
138      FGTACANRecord(void);
139     inline ~FGTACANRecord(void) {}
140
141     inline const std::string& get_channel() const { return channel; }
142     inline int get_freq() const { return freq; }
143     friend std::istream& operator>> ( std::istream&, FGTACANRecord& );
144     };
145
146 #endif // _FG_NAVRECORD_HXX