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