X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATC%2Ftrafficcontrol.hxx;h=fcbaf9bf07a2a029a1bdd3c47b25991294074ab1;hb=ed434d9967b0b23e4abb172d699ef956246f4bf9;hp=d069a5b84120af9e5fa2773b4f13383c0b3f7dde;hpb=dee0b6459e41f7c08e74321c51f3149f955262a0;p=flightgear.git diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index d069a5b84..fcbaf9bf0 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -26,11 +26,17 @@ # error This library requires C++ #endif +#include +#include +#include +#include #include +// There is probably a better include than sg_geodesy to get the SG_NM_TO_METER... +#include #include - - +#include +#include #include #include @@ -46,6 +52,7 @@ typedef vector::iterator intVecIterator; class FGAIFlightPlan; // forward reference class FGGroundNetwork; // forward reference class FGAIAircraft; // forward reference +class FGAirportDynamics; /************************************************************************************** * class FGATCInstruction @@ -180,11 +187,16 @@ public: void allowRepeatedTransmissions () { allowTransmission=true; }; void nextFrequency() { frequencyId++; }; int getNextFrequency() { return frequencyId; }; + intVec& getIntentions() { return intentions; }; + int getCurrentPosition() { return currentPos; }; }; 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 @@ -195,11 +207,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; @@ -207,19 +226,23 @@ 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: + bool initialized; + protected: bool available; time_t lastTransmission; double dt_count; - + osg::Group* group; string formatATCFrequency3_2(int ); string genTransponderCode(string fltRules); + bool isUserAircraft(FGAIAircraft*); public: typedef enum { @@ -245,21 +268,30 @@ public: ATC_AIR_TO_GROUND, ATC_GROUND_TO_AIR } AtcMsgDir; FGATCController(); - virtual ~FGATCController() {}; + virtual ~FGATCController(); + void init(); + 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; double getDt() { return dt_count; }; void setDt(double dt) { dt_count = dt;}; - void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir); + void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible); string getGateName(FGAIAircraft *aircraft); + virtual void render(bool) = 0; + virtual string getName() = 0; + + +private: + + AtcMsgDir lastTransmissionDirection; }; /****************************************************************************** @@ -270,20 +302,23 @@ class FGTowerController : public FGATCController private: TrafficVector activeTraffic; ActiveRunwayVec activeRunways; + FGAirportDynamics *parent; public: - FGTowerController(); + FGTowerController(FGAirportDynamics *parent); virtual ~FGTowerController() {}; 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 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); + virtual void render(bool); + virtual string getName(); bool hasActiveTraffic() { return activeTraffic.size() != 0; }; TrafficVector &getActiveTraffic() { return activeTraffic; }; }; @@ -298,23 +333,64 @@ class FGStartupController : public FGATCController private: TrafficVector activeTraffic; //ActiveRunwayVec activeRunways; + FGAirportDynamics *parent; public: - FGStartupController(); + FGStartupController(FGAirportDynamics *parent); virtual ~FGStartupController() {}; 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 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); + virtual void render(bool); + virtual string getName(); + bool hasActiveTraffic() { return activeTraffic.size() != 0; }; TrafficVector &getActiveTraffic() { return activeTraffic; }; + // Hpoefully, we can move this function to the base class, but I need to verify what is needed for the other controllers before doing so. + bool checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId, + AtcMsgDir msgDir); + }; +/****************************************************************************** + * class FGTowerControl + *****************************************************************************/ +class FGApproachController : public FGATCController +{ +private: + TrafficVector activeTraffic; + ActiveRunwayVec activeRunways; + FGAirportDynamics *parent; + +public: + FGApproachController(FGAirportDynamics * parent); + 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); + + virtual void render(bool); + virtual string getName(); + + ActiveRunway* getRunway(string name); + + bool hasActiveTraffic() { return activeTraffic.size() != 0; }; + TrafficVector &getActiveTraffic() { return activeTraffic; }; +}; + + #endif // _TRAFFIC_CONTROL_HXX