X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATC%2Ftrafficcontrol.hxx;h=2550f7cb6adbee7d53820a2a0a6ed76a03197241;hb=52b0baace1d3ef636b4e1c8f8f1bd047f8d0b023;hp=027f63d7ff6be2db374f29e4f50d1a5de1b85691;hpb=f9bbf802e909701e563a9b0ca60e808419eb4218;p=flightgear.git diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index 027f63d7f..2550f7cb6 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -28,7 +28,11 @@ #include +// There is probably a better include than sg_geodesy to get the SG_NM_TO_METER... +#include #include +#include +#include @@ -107,6 +111,7 @@ private: int id, waitsForId; int currentPos; int leg; + int frequencyId; int state; bool allowTransmission; time_t timer; @@ -128,6 +133,7 @@ public: void setLeg(int lg) { leg = lg;}; int getId() { return id;}; int getState() { return state;}; + void setState(int s) { state = s;} FGATCInstruction getInstruction() { return instruction;}; bool hasInstruction() { return instruction.hasInstruction(); }; void setPositionAndHeading(double lat, double lon, double hdg, double spd, double alt); @@ -176,11 +182,16 @@ public: bool allowTransmissions() { return allowTransmission; }; void suppressRepeatedTransmissions () { allowTransmission=false; }; void allowRepeatedTransmissions () { allowTransmission=true; }; + void nextFrequency() { frequencyId++; }; + int getNextFrequency() { return frequencyId; }; }; typedef vector TrafficVector; typedef vector::iterator TrafficVectorIterator; +typedef vector TimeVector; +typedef vector::iterator TimeVectorIterator; + /*********************************************************************** * Active runway, a utility class to keep track of which aircraft has @@ -191,11 +202,18 @@ class ActiveRunway private: string rwy; int currentlyCleared; + double distanceToFinal; + TimeVector estimatedArrivalTimes; public: - ActiveRunway(string r, int cc) { rwy = r; currentlyCleared = cc; }; + ActiveRunway(string r, int cc) { rwy = r; currentlyCleared = cc; distanceToFinal = 6.0 * SG_NM_TO_METER; }; string getRunwayName() { return rwy; }; int getCleared () { return currentlyCleared; }; + double getApproachDistance() { return distanceToFinal; }; + //time_t getEstApproachTime() { return estimatedArrival; }; + + //void setEstApproachTime(time_t time) { estimatedArrival = time; }; + time_t requestTimeSlot(time_t eta); }; typedef vector ActiveRunwayVec; @@ -203,11 +221,14 @@ typedef vector::iterator ActiveRunwayVecIterator; /** * class FGATCController - * NOTE: this class serves as an abstraction layer for all sorts of ATC controller. + * NOTE: this class serves as an abstraction layer for all sorts of ATC controllers. *************************************************************************************/ class FGATCController { -private: +protected: + bool available; + time_t lastTransmission; + double dt_count; @@ -217,25 +238,35 @@ private: public: typedef enum { MSG_ANNOUNCE_ENGINE_START, - MSG_REQUEST_ENGINE_START, + MSG_REQUEST_ENGINE_START, MSG_PERMIT_ENGINE_START, MSG_DENY_ENGINE_START, MSG_ACKNOWLEDGE_ENGINE_START, MSG_REQUEST_PUSHBACK_CLEARANCE, - MSG_PERMIT_PUSHBACK_CLEARANCE, - MSG_HOLD_PUSHBACK_CLEARANCE } AtcMsgId; + MSG_PERMIT_PUSHBACK_CLEARANCE, + MSG_HOLD_PUSHBACK_CLEARANCE, + MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY, + MSG_INITIATE_CONTACT, + MSG_ACKNOWLEDGE_INITIATE_CONTACT, + MSG_REQUEST_TAXI_CLEARANCE, + MSG_ISSUE_TAXI_CLEARANCE, + MSG_ACKNOWLEDGE_TAXI_CLEARANCE, + MSG_HOLD_POSITION, + MSG_ACKNOWLEDGE_HOLD_POSITION, + MSG_RESUME_TAXI, + MSG_ACKNOWLEDGE_RESUME_TAXI } AtcMsgId; typedef enum { ATC_AIR_TO_GROUND, ATC_GROUND_TO_AIR } AtcMsgDir; - FGATCController() { dt_count = 0;}; - virtual ~FGATCController() {}; + FGATCController(); + virtual ~FGATCController(); virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute, - double lat, double lon, - double hdg, double spd, double alt, double radius, int leg, - FGAIAircraft *aircraft) = 0; + double lat, double lon, + double hdg, double spd, double alt, double radius, int leg, + FGAIAircraft *aircraft) = 0; virtual void signOff(int id) = 0; - virtual void update(int id, double lat, double lon, - double heading, double speed, double alt, double dt) = 0; + virtual void updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, double dt) = 0; virtual bool hasInstruction(int id) = 0; virtual FGATCInstruction getInstruction(int id) = 0; @@ -262,7 +293,7 @@ public: double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, + virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt); virtual bool hasInstruction(int id); virtual FGATCInstruction getInstruction(int id); @@ -280,8 +311,6 @@ class FGStartupController : public FGATCController { private: TrafficVector activeTraffic; - bool available; - time_t lastTransmission; //ActiveRunwayVec activeRunways; public: @@ -292,7 +321,7 @@ public: double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft); virtual void signOff(int id); - virtual void update(int id, double lat, double lon, + virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt); virtual bool hasInstruction(int id); virtual FGATCInstruction getInstruction(int id); @@ -302,4 +331,33 @@ public: }; +/****************************************************************************** + * class FGTowerControl + *****************************************************************************/ +class FGApproachController : public FGATCController +{ +private: + TrafficVector activeTraffic; + ActiveRunwayVec activeRunways; + +public: + FGApproachController(); + virtual ~FGApproachController() {}; + virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute, + double lat, double lon, + double hdg, double spd, double alt, double radius, int leg, + FGAIAircraft *aircraft); + virtual void signOff(int id); + virtual void updateAircraftInformation(int id, double lat, double lon, + double heading, double speed, double alt, double dt); + virtual bool hasInstruction(int id); + virtual FGATCInstruction getInstruction(int id); + + ActiveRunway* getRunway(string name); + + bool hasActiveTraffic() { return activeTraffic.size() != 0; }; + TrafficVector &getActiveTraffic() { return activeTraffic; }; +}; + + #endif // _TRAFFIC_CONTROL_HXX