]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/AIPlane.hxx
Catch sound exceptions at the earliest, report problem has an alert, and continue...
[flightgear.git] / src / ATC / AIPlane.hxx
index 82eef86efd9c2ce7a951277d380f73acdca87160..ed61205bcf2f79dae72cff53539392f8a6a7113c 100644 (file)
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-/*****************************************************************
-*
-* WARNING - Curt has some ideas about AI traffic so anything in here
-* may get rewritten or scrapped.  Contact Curt curt@flightgear.org 
-* before spending any time or effort on this code!!!
-*
-******************************************************************/
-
 #ifndef _FG_AI_PLANE_HXX
 #define _FG_AI_PLANE_HXX
 
-#include <Model/model.hxx>
-#include <plib/sg.h>
-#include <plib/ssg.h>
 #include <simgear/math/point3d.hxx>
+#include <simgear/scene/model/model.hxx>
 
 #include "AIEntity.hxx"
+#include "ATC.hxx"
+
+enum PatternLeg {
+       TAKEOFF_ROLL,
+       CLIMBOUT,
+       TURN1,
+       CROSSWIND,
+       TURN2,
+       DOWNWIND,
+       TURN3,
+       BASE,
+       TURN4,
+       FINAL,
+       LANDING_ROLL,
+       LEG_UNKNOWN
+};
 
+ostream& operator << (ostream& os, PatternLeg pl);
+
+enum LandingType {
+       FULL_STOP,
+       STOP_AND_GO,
+       TOUCH_AND_GO,
+       AIP_LT_UNKNOWN
+};
+
+ostream& operator << (ostream& os, LandingType lt);
 
 /*****************************************************************
 *
@@ -50,12 +66,27 @@ class FGAIPlane : public FGAIEntity {
 
 public:
 
+       FGAIPlane();
     virtual ~FGAIPlane();
 
     // Run the internal calculations
-    virtual void Update(double dt);
+       void Update(double dt);
+       
+       // Send a transmission *TO* the AIPlane.
+       // FIXME int code is a hack - eventually this will receive Alexander's coded messages.
+       virtual void RegisterTransmission(int code);
+       
+       // Return the current pattern leg the plane is flying.
+       inline PatternLeg GetLeg() {return leg;}
+       
+       // Return what type of landing we're doing on this circuit
+       virtual LandingType GetLandingOption();
+       
+       // Return the callsign
+       inline const string& GetCallsign() {return plane.callsign;}
 
 protected:
+       PlaneRec plane;
 
     double mag_hdg;    // degrees - the heading that the physical aircraft is *pointing*
     double track;      // track that the physical aircraft is *following* - degrees relative to *true* north
@@ -76,11 +107,59 @@ protected:
     // Make radio transmission - this simply sends the transmission for physical rendering if the users
     // aircraft is on the same frequency and in range.  It is up to the derived classes to let ATC know
     // what is going on.
-    void Transmit(string msg);
-
-    void Bank(double angle);
-    void LevelWings(void);
-
+       string pending_transmission;    // derived classes set this string before calling Transmit(...)
+       FGATC* tuned_station;                   // and this if they are tuned to ATC
+       
+       // Transmit a message when channel becomes free of other dialog
+    void Transmit(int callback_code = 0);
+       
+       // Transmit a message if channel becomes free within timeout (seconds). timeout of zero implies no limit
+       void ConditionalTransmit(double timeout, int callback_code = 0);
+       
+       // Transmit regardless of other dialog on the channel eg emergency
+       void ImmediateTransmit(int callback_code = 0);
+       
+       inline void SetTrack(double t) { _tgtTrack = t; _trackSet = true; }
+       inline void ClearTrack() { _trackSet = false; }
+
+    inline void Bank(double r) { _tgtRoll = r; }
+    inline void LevelWings(void) { _tgtRoll = 0.0; }
+       
+       virtual void ProcessCallback(int code);
+       
+       PatternLeg leg;
+       
+private:
+       bool _pending;
+       double _timeout;
+       int _callback_code;     // A callback code to be notified and processed by the derived classes
+                                               // A value of zero indicates no callback required
+       bool _transmit;         // we are to transmit
+       bool _transmitting;     // we are transmitting
+       double _counter;
+       double _max_count;
+       
+       // Render a transmission (in string pending_transmission)
+       // Outputs the transmission either on screen or as audio depending on user preference
+       // The refname is a string to identify this sample to the sound manager
+       // The repeating flag indicates whether the message should be repeated continuously or played once.
+       void Render(const string& refname, bool repeating);
+
+       // Cease rendering a transmission.
+       // Requires the sound manager refname if audio, else "".
+       void NoRender(const string& refname);
+       
+       // Rendering related stuff
+       bool voice;                     // Flag - true if we are using voice
+       bool playing;           // Indicates a message in progress      
+       bool voiceOK;           // Flag - true if at least one voice has loaded OK
+       FGATCVoice* vPtr;
+       
+       // Navigation
+       double _tgtTrack;       // Track to be following if _trackSet is true
+       bool _trackSet;         // Set true if tgtTrack is to be followed
+       double _tgtRoll;
+       bool _rollSuspended;    // Set true when a derived class has suspended AIPlane's roll control
 };
 
 #endif  // _FG_AI_PLANE_HXX