]> git.mxchange.org Git - flightgear.git/blob - src/ATC/AIGAVFRTraffic.hxx
Roy Vegard Ovesen:
[flightgear.git] / src / ATC / 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21
22 #ifndef _FG_AIGAVFRTraffic_HXX
23 #define _FG_AIGAVFRTraffic_HXX
24
25 #include <plib/sg.h>
26 #include <plib/ssg.h>
27 #include <simgear/math/point3d.hxx>
28 #include <Main/fg_props.hxx>
29
30 #include "tower.hxx"
31 #include "AIPlane.hxx"
32 #include "ATCProjection.hxx"
33 #include "ground.hxx"
34 #include "AILocalTraffic.hxx"
35
36 #include <string>
37 SG_USING_STD(string);
38
39 class FGAIGAVFRTraffic : public FGAILocalTraffic {
40         
41 public:
42         
43         FGAIGAVFRTraffic();
44         ~FGAIGAVFRTraffic();
45         
46         // Init en-route to destID at point pt. (lat, lon, elev) (elev in meters, lat and lon in degrees).
47         bool Init(Point3D pt, string destID, const string& callsign);
48         // Init at srcID to fly to destID
49         bool Init(string srcID, string destID, const string& callsign, OperatingState state = PARKED);
50         
51         // Run the internal calculations
52         void Update(double dt);
53         
54         // Return what type of landing we're doing on this circuit
55         //LandingType GetLandingOption();
56         
57         void RegisterTransmission(int code);
58         
59         // Process callbacks sent by base class
60         // (These codes are not related to the codes above)
61         void ProcessCallback(int code);
62         
63 protected:
64         
65         // Do what is necessary to land and parkup at home airport
66         void ReturnToBase(double dt);
67         
68         //void GetRwyDetails(string id);
69         
70         
71 private:
72         FGATCMgr* ATC;  
73         // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
74
75         // High-level stuff
76         OperatingState operatingState;
77         bool touchAndGo;        //True if circuits should be flown touch and go, false for full stop
78         
79         // Performance characteristics of the plane in knots and ft/min - some of this might get moved out into FGAIPlane
80         double best_rate_of_climb_speed;
81         double best_rate_of_climb;
82         double nominal_climb_speed;
83         double nominal_climb_rate;
84         double nominal_cruise_speed;
85         double nominal_circuit_speed;
86         double nominal_descent_rate;
87         double nominal_approach_speed;
88         double nominal_final_speed;
89         double stall_speed_landing_config;
90         
91         // environment - some of this might get moved into FGAIPlane
92         SGPropertyNode* wind_from_hdg;  //degrees
93         SGPropertyNode* wind_speed_knots;               //knots
94         
95         atc_type changeFreqType;        // the service we need to change to
96
97         void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
98         
99         // GA VFR specific
100         bool _towerContactedIncoming;
101         bool _straightIn;
102         bool _clearedStraightIn;
103         bool _downwindEntry;
104         bool _clearedDownwindEntry;
105         Point3D _wp;    // Next waypoint (ie. the one we're currently heading for)
106         bool _enroute;
107         string _destID;
108         bool _climbout;
109         double _cruise_alt;
110         double _cruise_ias;
111         double _cruise_climb_ias;
112         Point3D _destPos;
113         bool _local;
114         bool _incoming;
115         bool _established;
116         bool _e45;
117         bool _entering;
118         bool _turning;
119         
120         //ssgBranch* _model;
121         
122         int GetQuadrangleAltitude(int dir, int des_alt);
123         
124         Point3D GetPatternApproachPos();
125         
126         void FlyPlane(double dt);
127         
128         // HACK for testing - remove or comment out before CVS commit!!!
129         //bool _towerContactPrinted;
130 };
131
132 #endif  // _FG_AILocalTraffic_HXX