enum tower_traffic_type {
CIRCUIT,
- INBOUND,
+ INBOUND, // CIRCUIT traffic gets changed to INBOUND when on final of the full-stop circuit.
OUTBOUND,
TTT_UNKNOWN, // departure, but we don't know if for circuits or leaving properly
STRAIGHT_IN
- // Umm - what's the difference between INBOUND and STRAIGHT_IN ?
-}; // TODO - need some differentiation of IFR and VFR traffic in order to give the former priority.
+};
+
+ostream& operator << (ostream& os, tower_traffic_type ttt);
+
+// TODO - need some differentiation of IFR and VFR traffic in order to give the former priority.
// Structure for holding details of a plane under tower control.
// Not fixed yet - may include more stuff later.
bool clearedToTakeOff;
// ought to add time cleared to depart so we can nag if necessary
bool holdShortReported;
+ bool downwindReported;
bool longFinalReported;
bool longFinalAcknowledged;
bool finalReported;
bool onRwy; // is physically on the runway
bool nextOnRwy; // currently projected by tower to be the next on the runway
- double clearanceCounter; // Hack for communication timing - counter since clearance requested in seconds
-
// Type of operation the plane is doing
tower_traffic_type opType;
// Whereabouts in circuit if doing circuits
PatternLeg leg;
+ LandingType landingType;
+
bool isUser; // true if this plane is the user
};
void ReportGoingAround(string ID);
void ReportRunwayVacated(string ID);
void ReportReadyForDeparture(string ID);
+ void ReportDownwind(string ID);
// Contact tower when at a hold short for departure - for now we'll assume plane - maybe vehicles might want to cross runway eventually?
void ContactAtHoldShort(PlaneRec plane, FGAIPlane* requestee, tower_traffic_type operation);
bool GetCrosswindConstraint(double& cpos);
bool GetDownwindConstraint(double& dpos);
bool GetBaseConstraint(double& bpos);
-
- // Returns true if OK to transmit on this frequency
- inline bool FreqClear() { return freqClear; }
- // Indicate that the frequency is in use
- inline void FreqInUse() { freqClear = false; }
- // The idea is that AI traffic or the user ATC dialog box calls FreqInUse() when they begin transmitting,
- // and that the tower control sets freqClear back to true following a reply.
- // AI traffic should check FreqClear() is true prior to transmitting.
- // The user will just have to wait for a gap in dialog as in real life.
private:
FGATCMgr* ATCmgr;
// This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code!
+
+ // Respond to a transmission
+ void Respond();
+
+ void CheckHoldList(double dt);
+
+ void CheckCircuitList(double dt);
+
+ void CheckRunwayList(double dt);
+ void CheckApproachList(double dt);
+
+ // Currently this assumes we *are* next on the runway and doesn't check for planes about to land -
+ // this should be done prior to calling this function.
+ void ClearHoldingPlane(TowerPlaneRec* t);
+
+ // Find a pointer to plane of callsign ID within the internal data structures
+ TowerPlaneRec* FindPlane(string ID);
+
// Figure out if a given position lies on the active runway
// Might have to change when we consider more than one active rwy.
bool OnActiveRunway(Point3D pt);
// Calculate the eta of a plane to the threshold.
// For ground traffic this is the fastest they can get there.
// For air traffic this is the middle approximation.
- void CalcETA(TowerPlaneRec* tpr);
+ void CalcETA(TowerPlaneRec* tpr, bool printout = false);
// Iterate through all the lists and call CalcETA for all the planes.
void doThresholdETACalc();
// Calculate the crow-flys distance of a plane to the threshold in miles
double CalcDistOutMiles(TowerPlaneRec* tpr);
+ /*
void doCommunication();
+ */
void IssueLandingClearance(TowerPlaneRec* tpr);
void IssueGoAround(TowerPlaneRec* tpr);
void IssueDepartureClearance(TowerPlaneRec* tpr);
+ unsigned int update_count; // Convienince counter for speading computational load over several updates
+ unsigned int update_count_max; // ditto.
+
bool display; // Flag to indicate whether we should be outputting to the ATC display.
bool displaying; // Flag to indicate whether we are outputting to the ATC display.
- bool freqClear; // Flag to indicate if the frequency is clear of ongoing dialog
+ double timeSinceLastDeparture; // Time in seconds since last departure from active rwy.
+ bool departed; // set true when the above needs incrementing with time, false when it doesn't.
// environment - need to make sure we're getting the surface winds and not winds aloft.
SGPropertyNode* wind_from_hdg; //degrees
// Return the ETA of plane no. list_pos (1-based) in the traffic list.
// i.e. list_pos = 1 implies next to use runway.
- double GetTrafficETA(unsigned int list_pos);
+ double GetTrafficETA(unsigned int list_pos, bool printout = false);
// Add a tower plane rec with ETA to the traffic list in the correct position ETA-wise.
// Returns true if this could cause a threshold ETA conflict with other traffic, false otherwise.