]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIAircraft.hxx
- remove trailing spaces
[flightgear.git] / src / AIModel / AIAircraft.hxx
1 // FGAIAircraft - AIBase derived class creates an AI aircraft
2 //
3 // Written by David Culp, started October 2003.
4 //
5 // Copyright (C) 2003  David P. Culp - davidculp2@comcast.net
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef _FG_AIAircraft_HXX
22 #define _FG_AIAircraft_HXX
23
24 #include "AIManager.hxx"
25 #include "AIBase.hxx"
26
27 #include <Traffic/SchedFlight.hxx>
28 #include <Traffic/Schedule.hxx>
29
30 #include <string>
31 SG_USING_STD(string);
32
33
34 class FGAIAircraft : public FGAIBase {
35
36 private:
37     typedef struct {
38         double accel;
39         double decel;
40         double climb_rate;
41         double descent_rate;
42         double takeoff_speed;
43         double climb_speed;
44         double cruise_speed;
45         double descent_speed;
46         double land_speed;
47     } PERF_STRUCT;
48
49 public:
50     enum aircraft_e {LIGHT=0, WW2_FIGHTER, JET_TRANSPORT, JET_FIGHTER, TANKER};
51     static const PERF_STRUCT settings[];
52
53     FGAIAircraft(FGAISchedule *ref=0);
54     ~FGAIAircraft();
55
56     virtual void readFromScenario(SGPropertyNode* scFileNode);
57
58     virtual bool init();
59     virtual void bind();
60     virtual void unbind();
61     virtual void update(double dt);
62
63     void setPerformance(const std::string& perfString);
64     void SetPerformance(const PERF_STRUCT *ps);
65     void setFlightPlan(const std::string& fp, bool repat = false);
66     void SetFlightPlan(FGAIFlightPlan *f);
67     FGAIFlightPlan* GetFlightPlan() const { return fp; };
68     void AccelTo(double speed);
69     void PitchTo(double angle);
70     void RollTo(double angle);
71     void YawTo(double angle);
72     void ClimbTo(double altitude);
73     void TurnTo(double heading);
74     void ProcessFlightPlan( double dt, time_t now );
75     void setCallSign(const string& );
76     void setTACANChannelID(const string& );
77
78     void getGroundElev(double dt);
79     void doGroundAltitude();
80     void loadNextLeg  ();
81
82     void setAcType(const string& ac) { acType = ac; };
83     void setCompany(const string& comp) { company = comp;};
84
85     inline void SetTanker(bool setting) { isTanker = setting; };
86     virtual const char* getTypeString(void) const { return "aircraft"; }
87
88 private:
89     FGAISchedule *trafficRef;
90
91     bool hdg_lock;
92     bool alt_lock;
93     double dt_count;
94     double dt_elev_count;
95     double headingChangeRate;
96     double groundTargetSpeed;
97     double groundOffset;
98     double dt;
99
100     const PERF_STRUCT *performance;
101     bool use_perf_vs;
102     SGPropertyNode* refuel_node;
103     bool isTanker;
104
105     void Run(double dt);
106     double sign(double x);
107
108     string acType;
109     string company;
110
111     int spinCounter;
112     double prevSpeed;
113     double prev_dist_to_go;
114
115     bool _getGearDown() const;
116     bool reachedWaypoint;
117     string callsign;             // The callsign of this tanker.
118     string TACAN_channel_id;     // The TACAN channel of this tanker
119     bool contact;                // set if this tanker is within fuelling range
120 };
121
122
123 #endif  // _FG_AIAircraft_HXX