# error This library requires C++
#endif
+#include <osg/Geode>
+#include <osg/Geometry>
+#include <osg/MatrixTransform>
+#include <osg/Shape>
#include <simgear/compiler.h>
// There is probably a better include than sg_geodesy to get the SG_NM_TO_METER...
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
-
-
#include <string>
#include <vector>
class FGAIFlightPlan; // forward reference
class FGGroundNetwork; // forward reference
class FGAIAircraft; // forward reference
+class FGAirportDynamics;
/**************************************************************************************
* class FGATCInstruction
void allowRepeatedTransmissions () { allowTransmission=true; };
void nextFrequency() { frequencyId++; };
int getNextFrequency() { return frequencyId; };
+ intVec& getIntentions() { return intentions; };
+ int getCurrentPosition() { return currentPos; };
};
typedef vector<FGTrafficRecord> TrafficVector;
typedef vector<time_t> TimeVector;
typedef vector<time_t>::iterator TimeVectorIterator;
+typedef vector<FGAIAircraft*> AircraftVec;
+typedef vector<FGAIAircraft*>::iterator AircraftVecIterator;
/***********************************************************************
* Active runway, a utility class to keep track of which aircraft has
int currentlyCleared;
double distanceToFinal;
TimeVector estimatedArrivalTimes;
+ AircraftVec departureCue;
+
public:
ActiveRunway(string r, int cc) { rwy = r; currentlyCleared = cc; distanceToFinal = 6.0 * SG_NM_TO_METER; };
//time_t getEstApproachTime() { return estimatedArrival; };
//void setEstApproachTime(time_t time) { estimatedArrival = time; };
+ void addToDepartureCue(FGAIAircraft *ac) { departureCue.push_back(ac); };
+ void setCleared(int number) { currentlyCleared = number; };
time_t requestTimeSlot(time_t eta);
+
+ int getDepartureCueSize() { return departureCue.size(); };
+ FGAIAircraft* getFirstAircraftInDepartureCue() { return departureCue.size() ? *(departureCue.begin()) : NULL; };
+ void updateDepartureCue() { departureCue.erase(departureCue.begin()); }
};
typedef vector<ActiveRunway> ActiveRunwayVec;
*************************************************************************************/
class FGATCController
{
+private:
+
+
protected:
+ bool initialized;
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 {
MSG_HOLD_POSITION,
MSG_ACKNOWLEDGE_HOLD_POSITION,
MSG_RESUME_TAXI,
- MSG_ACKNOWLEDGE_RESUME_TAXI } AtcMsgId;
+ MSG_ACKNOWLEDGE_RESUME_TAXI,
+ MSG_REPORT_RUNWAY_HOLD_SHORT,
+ MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT,
+ MSG_SWITCH_TOWER_FREQUENCY,
+ MSG_ACKNOWLEDGE_SWITCH_TOWER_FREQUENCY
+ } AtcMsgId;
+
typedef enum {
ATC_AIR_TO_GROUND,
ATC_GROUND_TO_AIR } AtcMsgDir;
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,
double getDt() { return dt_count; };
void setDt(double dt) { dt_count = dt;};
- void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
+ void transmit(FGTrafficRecord *rec, FGAirportDynamics *parent, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
string getGateName(FGAIAircraft *aircraft);
+ virtual void render(bool) = 0;
+ virtual string getName() = 0;
+ int calculate_attenuation(FGTrafficRecord * rec, FGAirportDynamics *parent, int ground_to_air);
+
+private:
+
+ AtcMsgDir lastTransmissionDirection;
};
/******************************************************************************
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,
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; };
};
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,
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);
+
};
/******************************************************************************
private:
TrafficVector activeTraffic;
ActiveRunwayVec activeRunways;
+ FGAirportDynamics *parent;
public:
- FGApproachController();
- virtual ~FGApproachController() {};
+ 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,
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; };