]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/approach.hxx
Modified Files:
[flightgear.git] / src / ATC / approach.hxx
index a5217abf595aa282b14caf3f5101069242a7da2c..9aec71d0174e96bc9535d99387d31ffe8ca27609 100644 (file)
@@ -16,7 +16,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 
 #ifndef _FG_APPROACH_HXX
 #ifdef SG_HAVE_STD_INCLUDES
 #  include <istream>
 #include <iomanip>
-#elif defined( __BORLANDC__ ) || (__APPLE__)
+#elif defined( SG_HAVE_NATIVE_SGI_COMPILERS )
+#  include <iostream.h>
+#elif defined( __BORLANDC__ )
 #  include <iostream>
 #else
 #  include <istream.h>
 #include <iomanip.h>
 #endif
 
+#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
 SG_USING_STD(istream);
+#endif
+
 SG_USING_STD(string);
 
 #include "ATC.hxx"
+#include "transmission.hxx"
 
 //DCL - a complete guess for now.
 #define FG_APPROACH_DEFAULT_RANGE 100
 
-// Contains all information about a plane that the approach control needs
-const int max_planes = 20;  // max number of planes on the stack
-const int max_wp = 10;      // max number of waypoints for approach phase
+// Contains all the information about a plane that the approach control needs
+const int    max_planes = 20;  // max number of planes on the stack
+const int    max_wp = 10;      // max number of waypoints for approach phase
+const double max_ta = 130;     // max turning angle for plane during approach
+const double tbm    = 2.0;     // min time (in sec) between two messages
+const double lfl    = 10.0;    // length of final leg
+
 struct PlaneApp {
 
   // variables for plane if it's on the radar
@@ -69,6 +79,9 @@ struct PlaneApp {
                          // 0 = no contact yet
                          // 1 = in contact
                          // 2 = handed off to tower
+  double turn_rate;      // standard turning rate of the plane in seconds per degree
+  double desc_rate;      // standard descent rate of the plane in feets per minute
+  double clmb_rate;      // standard climb rate of the plane in feets per minute
 
   // additional variables if contact has been established
   int    wpn;                 // number of waypoints
@@ -76,7 +89,7 @@ struct PlaneApp {
                               // first wp in list is airport
                               // last waypoint point at which contact was established
                               // second index: 0 = bearing to airport
-                              // second index: 1 = distance to aiport
+                              // second index: 1 = distance to airport
                               // second index: 2 = alt 
                               // second index: 3 = ETA
                               // second index: 4 = heading to next waypoint
@@ -85,30 +98,44 @@ struct PlaneApp {
   double dnwp;           // distance to next waypoint
   double dcc;            // closest distance to current assigned course
   double dnc;            // closest distance to course from next to next to next wp
-  double aalt;           // assigned alt at next waypoint
+  double aalt;           // assigned altitude
   double ahdg;           // assigned heading
   bool   on_crs;         // is the plane on course?
+  bool   wp_change;      // way point has changed
   double tlm;            // time when last message was sent
-
-  PlaneApp(void);
+  TransCode lmc;         // code of last message
 };
 
 
 class FGApproach : public FGATC {
 
   int      bucket;
+
   string active_runway;         
   double active_rw_hdg;
+  double active_rw_lon;
+  double active_rw_lat;
+  double active_rw_len;
 
-  bool     display;            // Flag to indicate whether we should be outputting to the display.
-  bool     displaying;         // Flag to indicate whether we are outputting to the display.
   int      num_planes;          // number of planes on the stack
   PlaneApp planes[max_planes];  // Array of planes
   string   transmission;
   bool     first;
 
-  SGPropertyNode *comm1_node;
-  SGPropertyNode *comm2_node;
+  SGPropertyNode_ptr comm1_node;
+  SGPropertyNode_ptr comm2_node;
+
+  SGPropertyNode_ptr atcmenu_node;
+  SGPropertyNode_ptr atcopt0_node;
+  SGPropertyNode_ptr atcopt1_node;
+  SGPropertyNode_ptr atcopt2_node;
+  SGPropertyNode_ptr atcopt3_node;
+  SGPropertyNode_ptr atcopt4_node;
+  SGPropertyNode_ptr atcopt5_node;
+  SGPropertyNode_ptr atcopt6_node;
+  SGPropertyNode_ptr atcopt7_node;
+  SGPropertyNode_ptr atcopt8_node;
+  SGPropertyNode_ptr atcopt9_node;
 
   // for failure modeling
   string trans_ident;  // transmitted ident
@@ -121,43 +148,59 @@ public:
 
   void Init();
 
-  void Update();
+  void Update(double dt);
 
   // Add new plane to stack if not already registered 
   // Input:  pid - id of plane (name) 
   // Output: "true" if added; "false" if already existend
-  void AddPlane(string pid);
+  void AddPlane(const string& pid);
 
   // Remove plane from stack if out of range
   int RemovePlane();
   
-  //Indicate that this instance should be outputting to the ATC display
-  inline void SetDisplay(void) {display = true;}
-  
-  //Indicate that this instance should not be outputting to the ATC display
-  inline void SetNoDisplay(void) {display = false;}
-  
   inline double get_bucket() const { return bucket; }
   inline int get_pnum() const { return num_planes; }
-  inline string get_trans_ident() { return trans_ident; }
-  inline atc_type GetType() { return APPROACH; }
+  inline const string& get_trans_ident() { return trans_ident; }
   
 private:
 
+  void calc_wp( const int &i);
+
   void update_plane_dat();
 
   void get_active_runway();
 
+  void update_param(const int &i);
+
+  double round_alt( bool hl, double alt );
+
+  double angle_diff_deg( const double &a1, const double &a2);
+
+  void set_message(const string &s);
+
+// ========================================================================
+// get point2 given starting point1 and course and distance
+// input:  point1 = heading in degrees, distance
+// input:  course in degrees, distance
+// output: point2 = heading in degrees, distance
+// ========================================================================
+  void calc_cd_head_dist(const double &h1, const double &d1,
+                        const double &course, const double &dist,
+                        double *h2, double *d2);
+
+
 // ========================================================================
 // get heading and distance between two points; point2 ---> point1
-// input: point1 = heading in degrees, distance
-// input: point2 = heading in degrees, distance
-// ouput: course in degrees, distance
+// input:  point1 = heading in degrees, distance
+// input:  point2 = heading in degrees, distance
+// output: course in degrees, distance
 // ========================================================================
   void calc_hd_course_dist(const double &h1, const double &d1,
                           const double &h2, const double &d2,
                           double *course, double *dist);
 
+
+
 // ========================================================================
 // closest distance between a point and a straigt line in 2 dim.
 // the input variables are given in (heading, distance) 
@@ -172,14 +215,17 @@ private:
                       const double &h3);
 
   // Pointers to current users position
-  SGPropertyNode *lon_node;
-  SGPropertyNode *lat_node;
-  SGPropertyNode *elev_node;
+  SGPropertyNode_ptr lon_node;
+  SGPropertyNode_ptr lat_node;
+  SGPropertyNode_ptr elev_node;
+  SGPropertyNode_ptr hdg_node;
+  SGPropertyNode_ptr speed_node;
+  SGPropertyNode_ptr etime_node;
   
   //Update the transmission string
   void UpdateTransmission(void);
-
+  
+  friend istream& operator>> ( istream&, FGApproach& );
 };
 
 #endif // _FG_APPROACH_HXX
-