1 // FGAIPlane - abstract base class for an AI plane
3 // Written by David Luff, started 2002.
5 // Copyright (C) 2002 David C. Luff - david.luff@nottingham.ac.uk
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef _FG_AI_PLANE_HXX
22 #define _FG_AI_PLANE_HXX
26 #include <simgear/math/point3d.hxx>
27 #include <simgear/scene/model/model.hxx>
29 #include "AIEntity.hxx"
47 ostream& operator << (ostream& os, PatternLeg pl);
56 ostream& operator << (ostream& os, LandingType lt);
58 /*****************************************************************
60 * FGAIPlane - this class is derived from FGAIEntity and adds the
61 * practical requirement for an AI plane - the ability to send radio
62 * communication, and simple performance details for the actual AI
63 * implementation to use. The AI implementation is expected to be
64 * in derived classes - this class does nothing useful on its own.
66 ******************************************************************/
67 class FGAIPlane : public FGAIEntity {
74 // Run the internal calculations
75 void Update(double dt);
77 // Send a transmission *TO* the AIPlane.
78 // FIXME int code is a hack - eventually this will receive Alexander's coded messages.
79 virtual void RegisterTransmission(int code);
81 // Return the current pattern leg the plane is flying.
82 inline PatternLeg GetLeg() {return leg;}
84 // Return what type of landing we're doing on this circuit
85 virtual LandingType GetLandingOption();
87 // Return the callsign
88 inline string GetCallsign() {return plane.callsign;}
93 double mag_hdg; // degrees - the heading that the physical aircraft is *pointing*
94 double track; // track that the physical aircraft is *following* - degrees relative to *true* north
95 double crab; // Difference between heading and track due to wind.
96 double mag_var; // degrees
97 double IAS; // Indicated airspeed in knots
98 double vel; // velocity along track in knots
99 double vel_si; // velocity along track in m/s
100 double slope; // Actual slope that the plane is flying (degrees) - +ve is uphill
101 double AoA; // degrees - difference between slope and pitch
102 // We'll assume that the plane doesn't yaw or slip - the track/heading difference is to allow for wind
104 double freq; // The comm frequency that we're operating on
106 // We need some way for this class to display its radio transmissions if on the
107 // same frequency and in the vicinity of the user's aircraft
108 // This may need to be done independently of ATC eg CTAF
109 // Make radio transmission - this simply sends the transmission for physical rendering if the users
110 // aircraft is on the same frequency and in range. It is up to the derived classes to let ATC know
112 string pending_transmission; // derived classes set this string before calling Transmit(...)
113 FGATC* tuned_station; // and this if they are tuned to ATC
115 // Transmit a message when channel becomes free of other dialog
116 void Transmit(int callback_code = 0);
118 // Transmit a message if channel becomes free within timeout (seconds). timeout of zero implies no limit
119 void ConditionalTransmit(double timeout, int callback_code = 0);
121 // Transmit regardless of other dialog on the channel eg emergency
122 void ImmediateTransmit(int callback_code = 0);
124 void Bank(double angle);
125 void LevelWings(void);
127 virtual void ProcessCallback(int code);
134 int _callback_code; // A callback code to be notified and processed by the derived classes
135 // A value of zero indicates no callback required
136 bool _transmit; // we are to transmit
137 bool _transmitting; // we are transmitting
141 // Render a transmission (in string pending_transmission)
142 // Outputs the transmission either on screen or as audio depending on user preference
143 // The refname is a string to identify this sample to the sound manager
144 // The repeating flag indicates whether the message should be repeated continuously or played once.
145 void Render(string refname, bool repeating);
147 // Cease rendering a transmission.
148 // Requires the sound manager refname if audio, else "".
149 void NoRender(string refname);
151 // Rendering related stuff
152 bool voice; // Flag - true if we are using voice
153 bool playing; // Indicates a message in progress
154 bool voiceOK; // Flag - true if at least one voice has loaded OK
158 #endif // _FG_AI_PLANE_HXX