X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FATC%2Fground.hxx;h=b0cf1f3d86fbe0fc89eaf5b8af1d4548a54cd675;hb=4606f96e139204d5b2d76ee93c3b0c66885b5f5f;hp=d15fbc2a79da3759579d0585122b778f582fa4bf;hpb=01be2ed8e4156688c7e5ad8e77d9219716609f9f;p=flightgear.git diff --git a/src/ATC/ground.hxx b/src/ATC/ground.hxx index d15fbc2a7..b0cf1f3d8 100644 --- a/src/ATC/ground.hxx +++ b/src/ATC/ground.hxx @@ -35,7 +35,10 @@ SG_USING_STD(ios); #include #include "ATC.hxx" +//#include "ATCmgr.hxx" #include "ATCProjection.hxx" +#include "AIEntity.hxx" +//#include "AILocalTraffic.hxx" // RunwayDetails - this is a temporary hack SG_USING_STD(map); SG_USING_STD(vector); @@ -132,7 +135,7 @@ typedef gate_map_type::iterator gate_map_iterator; typedef gate_map_type::const_iterator gate_map_const_iterator; // Runways - all the runway stuff is likely to change in the future -typedef struct Rwy { +struct Rwy { int id; //note this is a very simplified scheme for now - R & L are not differentiated //It should work for simple one rwy airports node_array_type exits; //Array of available exits from runway @@ -140,6 +143,7 @@ typedef struct Rwy { // Eventually we will also want some encoding of real-life preferred runways // This will get us up and running for single runway airports though. }; + typedef vector < Rwy > runway_array_type; typedef runway_array_type::iterator runway_array_iterator; typedef runway_array_type::const_iterator runway_array_const_iterator; @@ -177,28 +181,41 @@ typedef shortest_path_map_type::iterator shortest_path_map_iterator; //////////////////////////////////////////////// // Planes active within the ground network. -// somewhere in the ATC/AI system we are going to have defined something like -// typedef struct plane_rec -// list plane_rec_list_type -/* + // A more specialist plane rec to include ground information -typedef struct ground_rec { - plane_rec plane; - point current_pos; - node destination; - node last_clearance; +struct GroundRec { + FGAIEntity* planePtr; // This might move to the planeRec eventually + + PlaneRec plane; + Point3D current_pos; + node* destination; + node* last_clearance; + bool taxiRequestOutstanding; // Plane has requested taxi and we haven't responded yet + double clearanceCounter; // Hack for communication timing - counter since clearance requested in seconds + bool cleared; // set true when the plane has been cleared to somewhere bool incoming; //true for arrivals, false for departures // status? // Almost certainly need to add more here }; -typedef list ground_rec_list; +typedef list < GroundRec* > ground_rec_list; typedef ground_rec_list::iterator ground_rec_list_itr; typedef ground_rec_list::const_iterator ground_rec_list_const_itr; -*/ + ////////////////////////////////////////////////////////////////////////////////////////// +// Hack +// perhaps we could use an FGRunway instead of this +struct GRunwayDetails { + 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 hdg; // true runway heading + double length; // In *METERS* + string rwyID; +}; + /////////////////////////////////////////////////////////////////////////////// // // FGGround @@ -212,20 +229,17 @@ public: ~FGGround(); void Init(); - void Update(); + void Update(double dt); inline string get_trans_ident() { return trans_ident; } - inline atc_type GetType() { return GROUND; } inline void SetDisplay() {display = true;} inline void SetNoDisplay() {display = false;} - // Its possible that NewArrival and NewDeparture should simply be rolled into Request. - // Contact ground control on arrival, assumed to request any gate //void NewArrival(plane_rec plane); // Contact ground control on departure, assumed to request currently active runway. - //void NewDeparture(plane_rec plane); + void RequestDeparture(PlaneRec plane, FGAIEntity* requestee); // Contact ground control when the calling routine doesn't know if arrival // or departure is appropriate. @@ -243,19 +257,28 @@ public: // Return a pointer to an unused gate Gate* GetGateNode(); + // Return a pointer to a hold short node + node* GetHoldShortNode(string rwyID); + // Runway stuff - this might change in the future. // Get a list of exits from a given runway // It is up to the calling function to check for non-zero size of returned array before use - node_array_type GetExits(int rwyID); + node_array_type GetExits(string rwyID); // Get a path from one node to another ground_network_path_type GetPath(node* A, node* B); // Get a path from a node to a runway threshold ground_network_path_type GetPath(node* A, string rwyID); + + // Get a path from a node to a runway hold short point + // Bit of a hack this at the moment! + ground_network_path_type GetPathToHoldShort(node* A, string rwyID); private: - + FGATCMgr* ATCmgr; + // This is purely for synactic convienience to avoid writing globals->get_ATC_mgr()-> all through the code! + // Need a data structure to hold details of the various active planes // Need a data structure to hold details of the logical network // including which gates are filled - or possibly another data structure @@ -271,10 +294,6 @@ private: // A map of all the gates indexed against internal (FGFS) ID gate_map_type gates; gate_map_iterator gatesItr; - - // Runway stuff - this might change in the future. - //runway_array_type runways; // STL way - Rwy runways[36]; // quick hack! FGATCAlignedProjection ortho; @@ -284,15 +303,16 @@ private: // Find the shortest route through the logical network between two points. //FindShortestRoute(point a, point b); - // Project a point in WGS84 lat/lon onto the local gnomonic. - //ConvertWGS84ToXY(sgVec3 wgs84, point xy); - // Assign a gate or parking location to a new arrival //AssignGate(ground_rec &g); // Generate the next clearance for an airplane //NextClearance(ground_rec &g); + // environment - need to make sure we're getting the surface winds and not winds aloft. + SGPropertyNode* wind_from_hdg; //degrees + SGPropertyNode* wind_speed_knots; //knots + 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. // for failure modeling @@ -300,6 +320,25 @@ private: bool ground_failed; // ground failed? bool networkLoadOK; // Indicates whether LoadNetwork returned true or false at last attempt + // Tower control + bool untowered; // True if this is an untowered airport (we still need the ground class for shortest path implementation etc + //FGATC* tower; // Pointer to the tower control + + // Logical runway details - this might change in the future. + //runway_array_type runways; // STL way + Rwy runways[37]; // quick hack! + + // Physical runway details + double aptElev; // Airport elevation + string activeRwy; // Active runway number - For now we'll disregard multiple / alternate runway operation. + RunwayDetails rwy; // Assumed to be the active one for now.// Figure out which runways are active. + + // For now we'll just be simple and do one active runway - eventually this will get much more complex + // Copied from FGTower - TODO - it would be better to implement this just once, and have ground call tower + // for runway operation details, but at the moment we can't guarantee that tower control at a given airport + // will be initialised before ground so we can't do that. + void DoRwyDetails(); + // Load the logical ground network for this airport from file. // Return true if successfull. bool LoadNetwork(); @@ -318,8 +357,12 @@ private: // Returns NULL if unsuccessful. node* GetThresholdNode(string rwyID); - // A shortest path algorithm sort of from memory (I can't find the bl&*dy book again!) + // A shortest path algorithm from memory (I can't find the bl&*dy book again!) ground_network_path_type GetShortestPath(node* A, node* B); + + // Planes + ground_rec_list ground_traffic; + ground_rec_list_itr ground_traffic_itr; }; #endif // _FG_GROUND_HXX