]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIFlightPlan.hxx
Merge branch 'maint' into next
[flightgear.git] / src / AIModel / AIFlightPlan.hxx
1 // FGAIFlightPlan - class for loading and storing  AI flight plans
2 // Written by David Culp, started May 2004
3 // - davidculp2@comcast.net
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 #ifndef _FG_AIFLIGHTPLAN_HXX
20 #define _FG_AIFLIGHTPLAN_HXX
21
22 #include <simgear/compiler.h>
23 #include <vector>
24 #include <string>
25
26
27 #include <Airports/simple.hxx>
28 #include <Navaids/awynet.hxx>
29
30 #include "AIBase.hxx"
31
32
33
34 using std::vector;
35 using std::string;
36
37 class FGTaxiRoute;
38 class FGRunway;
39 class FGAIAircraft;
40
41 class FGAIFlightPlan {
42
43 public:
44
45   typedef struct {
46    string name;
47    double latitude;
48    double longitude;
49    double altitude;
50    double speed;
51    double crossat;
52    bool finished;
53    bool gear_down;
54    bool flaps_down;
55    bool on_ground;
56     int routeIndex;  // For AI/ATC purposes;
57    double time_sec;
58    string time;
59
60   } waypoint;
61
62   FGAIFlightPlan(const string& filename);
63   FGAIFlightPlan(FGAIAircraft *,
64                  const std::string& p,
65                  double course,
66                  time_t start,
67                  FGAirport *dep,
68                  FGAirport *arr,
69                  bool firstLeg,
70                  double radius,
71                  double alt,
72                  double lat,
73                  double lon,
74                  double speed,
75                  const string& fltType,
76                  const string& acType,
77                  const string& airline);
78    ~FGAIFlightPlan();
79
80    waypoint* const getPreviousWaypoint( void ) const;
81    waypoint* const getCurrentWaypoint( void ) const;
82    waypoint* const getNextWaypoint( void ) const;
83    void IncrementWaypoint( bool erase );
84
85    double getDistanceToGo(double lat, double lon, waypoint* wp) const;
86    int getLeg () const { return leg;};
87    void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
88    void setLeadDistance(double distance_ft);
89    double getLeadDistance( void ) const {return lead_distance;}
90    double getBearing(waypoint* previous, waypoint* next) const;
91    double getBearing(double lat, double lon, waypoint* next) const;
92   time_t getStartTime() const { return start_time; }
93
94   void    create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
95                  bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
96
97   void setLeg(int val) { leg = val;}
98   void setTime(time_t st) { start_time = st; }
99   int getGate() const { return gateId; }
100   double getLeadInAngle() const { return leadInAngle; }
101   const string& getRunway() const;
102   
103   void setRepeat(bool r) { repeat = r; }
104   bool getRepeat(void) const { return repeat; }
105   void restart(void);
106   int getNrOfWayPoints() { return waypoints.size(); }
107   int getRouteIndex(int i); // returns the AI related index of this current routes. 
108   FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
109   void deleteTaxiRoute();
110   string getRunway() { return activeRunway; }
111   bool isActive(time_t time) {return time >= this->getStartTime();}
112
113 private:
114   FGRunway* rwy;
115   typedef vector <waypoint*> wpt_vector_type;
116   typedef wpt_vector_type::const_iterator wpt_vector_iterator;
117
118   wpt_vector_type       waypoints;
119   wpt_vector_iterator   wpt_iterator;
120
121   bool repeat;
122   double distance_to_go;
123   double lead_distance;
124   double leadInAngle;
125   time_t start_time;
126   int leg;
127   int gateId, lastNodeVisited;
128   string activeRunway;
129   FGAirRoute airRoute;
130   FGTaxiRoute *taxiRoute;
131
132   void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
133   void createPushBackFallBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
134   void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const string&);
135   void createClimb(bool, FGAirport *, double, double, const string&);
136   void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
137   void createDecent(FGAirport *, const string&);
138   void createLanding(FGAirport *);
139   void createParking(FGAirport *, double radius);
140   void deleteWaypoints(); 
141   void resetWaypoints();
142
143   void createLandingTaxi(FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
144   void createDefaultLandingTaxi(FGAirport* aAirport);
145   void createDefaultTakeoffTaxi(FGAirport* aAirport, FGRunway* aRunway);
146   void createTakeoffTaxi(bool firstFlight, FGAirport *apt, double radius, const string& fltType, const string& acType, const string& airline);
147         
148   waypoint* createOnGround(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
149   waypoint* createInAir(const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed);
150   waypoint* cloneWithPos(waypoint* aWpt, const std::string& aName, const SGGeod& aPos);
151     
152   string getRunwayClassFromTrafficType(string fltType);
153
154   //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
155  void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
156 };    
157
158 #endif  // _FG_AIFLIGHTPLAN_HXX