]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/AIGAVFRTraffic.hxx
Port over remaining Point3D usage to the more type and unit safe SG* classes.
[flightgear.git] / src / ATCDCL / AIGAVFRTraffic.hxx
1 // FGAILocalTraffic - AIEntity derived class with enough logic to
2 // fly and interact with the traffic pattern.
3 //
4 // Written by David Luff, started March 2002.
5 //
6 // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifndef _FG_AIGAVFRTraffic_HXX
23 #define _FG_AIGAVFRTraffic_HXX
24
25 #include <simgear/math/SGMath.hxx>
26 #include <Main/fg_props.hxx>
27
28 #include "AILocalTraffic.hxx"
29
30 #include <string>
31 using std::string;
32
33 class FGAIGAVFRTraffic : public FGAILocalTraffic {
34         
35 public:
36         
37         FGAIGAVFRTraffic();
38         ~FGAIGAVFRTraffic();
39         
40         // Init en-route to destID at point pt. (lat, lon, elev) (elev in meters, lat and lon in degrees).
41         bool Init(const SGGeod& pt, const string& destID, const string& callsign);
42         // Init at srcID to fly to destID
43         bool Init(const string& srcID, const string& destID, const string& callsign, OperatingState state = PARKED);
44         
45         // Run the internal calculations
46         void Update(double dt);
47         
48         // Return what type of landing we're doing on this circuit
49         //LandingType GetLandingOption();
50         
51         void RegisterTransmission(int code);
52         
53         // Process callbacks sent by base class
54         // (These codes are not related to the codes above)
55         void ProcessCallback(int code);
56         
57 protected:
58         
59         // Do what is necessary to land and parkup at home airport
60         void ReturnToBase(double dt);
61         
62         //void GetRwyDetails(string id);
63         
64         
65 private:
66         FGATCMgr* ATC;  
67         // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
68
69         // High-level stuff
70         OperatingState operatingState;
71         bool touchAndGo;        //True if circuits should be flown touch and go, false for full stop
72         
73         // Performance characteristics of the plane in knots and ft/min - some of this might get moved out into FGAIPlane
74         double best_rate_of_climb_speed;
75         double best_rate_of_climb;
76         double nominal_climb_speed;
77         double nominal_climb_rate;
78         double nominal_cruise_speed;
79         double nominal_circuit_speed;
80         double nominal_descent_rate;
81         double nominal_approach_speed;
82         double nominal_final_speed;
83         double stall_speed_landing_config;
84         
85         // environment - some of this might get moved into FGAIPlane
86         SGPropertyNode_ptr wind_from_hdg;       //degrees
87         SGPropertyNode_ptr wind_speed_knots;            //knots
88         
89         atc_type changeFreqType;        // the service we need to change to
90
91         void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
92         
93         // GA VFR specific
94         bool _towerContactedIncoming;
95         bool _straightIn;
96         bool _clearedStraightIn;
97         bool _downwindEntry;
98         bool _clearedDownwindEntry;
99         SGGeod _wp;     // Next waypoint (ie. the one we're currently heading for)
100         bool _enroute;
101         string _destID;
102         bool _climbout;
103         double _cruise_alt;
104         double _cruise_ias;
105         double _cruise_climb_ias;
106         SGGeod _destPos;
107         bool _local;
108         bool _incoming;
109         bool _established;
110         bool _e45;
111         bool _entering;
112         bool _turning;
113         
114         int GetQuadrangleAltitude(int dir, int des_alt);
115         
116         SGGeod GetPatternApproachPos();
117         
118         void FlyPlane(double dt);
119         
120         // HACK for testing - remove or comment out before CVS commit!!!
121         //bool _towerContactPrinted;
122 };
123
124 #endif  // _FG_AILocalTraffic_HXX