// 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_AILocalTraffic_HXX
#define _FG_AILocalTraffic_HXX
#include "ATCProjection.hxx"
#include "ground.hxx"
-typedef enum PatternLeg {
- TAKEOFF_ROLL,
- CLIMBOUT,
- TURN1,
- CROSSWIND,
- TURN2,
- DOWNWIND,
- TURN3,
- BASE,
- TURN4,
- FINAL,
- LANDING_ROLL
-};
+#include <string>
+SG_USING_STD(string);
-typedef enum TaxiState {
+enum TaxiState {
TD_INBOUND,
TD_OUTBOUND,
- TD_NONE
+ TD_NONE,
+ TD_LINING_UP
};
-typedef enum OperatingState {
+enum OperatingState {
IN_PATTERN,
TAXIING,
PARKED
};
-// perhaps we could use an FGRunway instead of this
-typedef struct RunwayDetails {
- Point3D threshold_pos;
- Point3D end1ortho; // ortho projection end1 (the threshold ATM)
- Point3D end2ortho; // ortho projection end2 (the take off end in the current hardwired scheme)
- double mag_hdg;
- double mag_var;
- double hdg; // true runway heading
- int ID; // 1 -> 36
-};
-
-typedef struct StartofDescent {
+struct StartofDescent {
PatternLeg leg;
double orthopos_x;
double orthopos_y;
~FGAILocalTraffic();
// Initialise
- void Init();
+ bool Init(string ICAO, OperatingState initialState = PARKED, PatternLeg initialLeg = DOWNWIND);
// Run the internal calculations
void Update(double dt);
// Go out and practice circuits
void FlyCircuits(int numCircuits, bool tag);
+ // TODO - this will get more complex and moved into the main class
+ // body eventually since the position approved to taxi to will have
+ // to be passed.
+ inline void ApproveTaxiRequest() {taxiRequestCleared = true;}
+
+ inline void DenyTaxiRequest() {taxiRequestCleared = false;}
+
+ void RegisterTransmission(int code);
+
+ // This is a hack and will probably go eventually
+ inline bool AtHoldShort() {return holdingShort;}
+
protected:
// Attempt to enter the traffic pattern in a reasonably intelligent manner
void ReturnToBase(double dt);
private:
+ FGATCMgr* ATC;
+ // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
+
// High-level stuff
OperatingState operatingState;
int circuitsToFly; //Number of circuits still to do in this session NOT INCLUDING THE CURRENT ONE
// and the runway aligned with the y axis.
// Airport/runway/pattern details
- char* airportID; // The ICAO code of the airport that we're operating around
- FGGround airport; // FIXME FIXME FIXME This is a complete hardwired cop-out at the moment - we need to connect to the correct ground in the same way we do to the tower.
+ string airportID; // The ICAO code of the airport that we're operating around
+ double aptElev; // Airport elevation
+ FGGround* ground; // A pointer to the ground control.
FGTower* tower; // A pointer to the tower control.
RunwayDetails rwy;
double patternDirection; // 1 for right, -1 for left (This is double because we multiply/divide turn rates
double stall_speed_landing_config;
double nominal_taxi_speed;
+ // Physical/rendering stuff
+ double wheelOffset; // Height above ground at which we need to render the plane whilst taxiing
+ bool elevInitGood; // We have had at least one good elev reading
+ bool inAir; // True when off the ground
+
// environment - some of this might get moved into FGAIPlane
SGPropertyNode* wind_from_hdg; //degrees
SGPropertyNode* wind_speed_knots; //knots
int numInPattern; // Number of planes in the pattern (this might get more complicated if high performance GA aircraft fly a higher pattern eventually)
int numAhead; // More importantly - how many of them are ahead of us?
double distToNext; // And even more importantly, how near are we getting to the one immediately ahead?
- PatternLeg leg; // Out current position in the pattern
+ //PatternLeg leg; // Our current position in the pattern - now moved to FGAIPlane
StartofDescent SoD; // Start of descent calculated wrt wind, pattern size & altitude, glideslope etc
// Taxiing details
// any permitted parking spot) and that all taxiing out is to runways.
bool parked;
bool taxiing;
+ bool taxiRequestPending;
+ bool taxiRequestCleared;
TaxiState taxiState;
double desiredTaxiHeading;
double taxiTurnRadius;
double nominalTaxiSpeed;
- Gate* in_dest;
+ Gate* ourGate;
ground_network_path_type path; // a path through the ground network for the plane to taxi
- int taxiPathPos; // position of iterator in taxi path when applicable
+ unsigned int taxiPathPos; // position of iterator in taxi path when applicable
node* nextTaxiNode; // next node in taxi path
+ node* holdShortNode;
//Runway out_dest; //FIXME - implement this
+ bool holdingShort;
+ bool reportReadyForDeparture; // set true when ATC has requested that the plane report when ready for departure
+ bool clearedToLineUp;
+ bool clearedToTakeOff;
+ bool liningUp; // Set true when the turn onto the runway heading is commenced when taxiing out
+ bool contactTower; // we have been told to contact tower
+ bool contactGround; // we have been told to contact ground
+ bool changeFreq; // true when we need to change frequency
+ atc_type changeFreqType; // the service we need to change to
+ double responseCounter; // timer in seconds to allow response to requests to be a little while after them
void FlyTrafficPattern(double dt);
void Taxi(double dt);
void GetNextTaxiNode();
+
+ void DoGroundElev();
+
+ void GetRwyDetails();
};
#endif // _FG_AILocalTraffic_HXX