1
0
Fork 0

AI traffic now honors separate runway assignments for different types of

traffic (i.e. commercial airliners will use a differnt part of the airport
than general avation, ultralight and/or military traffic.
This commit is contained in:
durk 2007-06-28 18:30:35 +00:00
parent cb15006f53
commit f4529e5cfe
3 changed files with 68 additions and 32 deletions

View file

@ -134,15 +134,17 @@ private:
void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&); void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&); void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
void createTakeOff(bool, FGAirport *, double); void createTakeOff(bool, FGAirport *, double, const string&);
void createClimb(bool, FGAirport *, double, double); void createClimb(bool, FGAirport *, double, double, const string&);
void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double); void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double, const string&);
void createDecent(FGAirport *); void createDecent(FGAirport *, const string&);
void createLanding(FGAirport *); void createLanding(FGAirport *);
void createParking(FGAirport *, double radius); void createParking(FGAirport *, double radius);
void deleteWaypoints(); void deleteWaypoints();
void resetWaypoints(); void resetWaypoints();
string getRunwayClassFromTrafficType(string fltType);
//void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double); //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double);
void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon); void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
}; };

View file

@ -53,16 +53,16 @@ void FGAIFlightPlan::create(FGAirport *dep, FGAirport *arr, int legNr,
radius, fltType, aircraftType, airline); radius, fltType, aircraftType, airline);
break; break;
case 3: case 3:
createTakeOff(firstFlight, dep, speed); createTakeOff(firstFlight, dep, speed, fltType);
break; break;
case 4: case 4:
createClimb(firstFlight, dep, speed, alt); createClimb(firstFlight, dep, speed, alt, fltType);
break; break;
case 5: case 5:
createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt); createCruise(firstFlight, dep,arr, latitude, longitude, speed, alt, fltType);
break; break;
case 6: case 6:
createDecent(arr); createDecent(arr, fltType);
break; break;
case 7: case 7:
createLanding(arr); createLanding(arr);
@ -225,17 +225,15 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
//wpt->on_ground = true; //wpt->on_ground = true;
//waypoints.push_back(wpt); //waypoints.push_back(wpt);
} }
// "NOTE: this is currently fixed to "com" for commercial traffic string rwyClass = getRunwayClassFromTrafficType(fltType);
// Should be changed to be used dynamically to allow "gen" and "mil" apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
// as well
apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(), if (!(globals->get_runways()->search(apt->getId(),
activeRunway, activeRunway,
&rwy))) &rwy)))
{ {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " << SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
activeRunway << activeRunway <<
" at airport " << apt->getId()); " at airport " << apt->getId() << " of class " << rwyClass << " (1)");
exit(1); exit(1);
} }
@ -572,7 +570,7 @@ void FGAIFlightPlan::createTaxi(bool firstFlight, int direction,
* CreateTakeOff * CreateTakeOff
* initialize the Aircraft at the parking location * initialize the Aircraft at the parking location
******************************************************************/ ******************************************************************/
void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed) void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double speed, const string &fltType)
{ {
double heading; double heading;
double lat, lon, az; double lat, lon, az;
@ -585,17 +583,15 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
if (firstFlight) if (firstFlight)
{ {
//string name; //string name;
// "NOTE: this is currently fixed to "com" for commercial traffic string rwyClass = getRunwayClassFromTrafficType(fltType);
// Should be changed to be used dynamically to allow "gen" and "mil" apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
// as well
apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(), if (!(globals->get_runways()->search(apt->getId(),
activeRunway, activeRunway,
&rwy))) &rwy)))
{ {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " << SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
activeRunway << activeRunway <<
" at airport " << apt->getId()); " at airport " << apt->getId()<< " of class " << rwyClass << " (2)");
exit(1); exit(1);
} }
} }
@ -709,7 +705,7 @@ void FGAIFlightPlan::createTakeOff(bool firstFlight, FGAirport *apt, double spee
* CreateClimb * CreateClimb
* initialize the Aircraft at the parking location * initialize the Aircraft at the parking location
******************************************************************/ ******************************************************************/
void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt) void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed, double alt, const string &fltType)
{ {
double heading; double heading;
//FGRunway rwy; //FGRunway rwy;
@ -721,17 +717,15 @@ void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed,
if (firstFlight) if (firstFlight)
{ {
//string name; //string name;
// "NOTE: this is currently fixed to "com" for commercial traffic string rwyClass = getRunwayClassFromTrafficType(fltType);
// Should be changed to be used dynamically to allow "gen" and "mil" apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
// as well
apt->getDynamics()->getActiveRunway("com", 1, activeRunway);
if (!(globals->get_runways()->search(apt->getId(), if (!(globals->get_runways()->search(apt->getId(),
activeRunway, activeRunway,
&rwy))) &rwy)))
{ {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " << SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
activeRunway << activeRunway <<
" at airport " << apt->getId()); " at airport " << apt->getId()<< " of class " << rwyClass << " (3)");
exit(1); exit(1);
} }
} }
@ -846,7 +840,7 @@ void FGAIFlightPlan::createClimb(bool firstFlight, FGAirport *apt, double speed,
* CreateDecent * CreateDecent
* initialize the Aircraft at the parking location * initialize the Aircraft at the parking location
******************************************************************/ ******************************************************************/
void FGAIFlightPlan::createDecent(FGAirport *apt) void FGAIFlightPlan::createDecent(FGAirport *apt, const string &fltType)
{ {
// Ten thousand ft. Slowing down to 240 kts // Ten thousand ft. Slowing down to 240 kts
@ -860,14 +854,15 @@ void FGAIFlightPlan::createDecent(FGAirport *apt)
//Beginning of Decent //Beginning of Decent
//string name; //string name;
// allow "mil" and "gen" as well // allow "mil" and "gen" as well
apt->getDynamics()->getActiveRunway("com", 2, activeRunway); string rwyClass = getRunwayClassFromTrafficType(fltType);
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway);
if (!(globals->get_runways()->search(apt->getId(), if (!(globals->get_runways()->search(apt->getId(),
activeRunway, activeRunway,
&rwy))) &rwy)))
{ {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " << SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
activeRunway << activeRunway <<
" at airport " << apt->getId()); " at airport " << apt->getId()<< " of class " << rwyClass << " (4)");
exit(1); exit(1);
} }
@ -1045,3 +1040,42 @@ void FGAIFlightPlan::createParking(FGAirport *apt, double radius)
wpt->routeIndex = 0; wpt->routeIndex = 0;
waypoints.push_back(wpt); waypoints.push_back(wpt);
} }
/**
*
* @param fltType a string describing the type of
* traffic, normally used for gate assignments
* @return a converted string that gives the runway
* preference schedule to be used at aircraft having
* a preferential runway schedule implemented (i.e.
* having a rwyprefs.xml file
*
* Currently valid traffic types for gate assignment:
* - gate (commercial gate)
* - cargo (commercial gargo),
* - ga (general aviation) ,
* - ul (ultralight),
* - mil-fighter (military - fighter),
* - mil-transport (military - transport)
*
* Valid runway classes:
* - com (commercial traffic: jetliners, passenger and cargo)
* - gen (general aviation)
* - ul (ultralight: I can imagine that these may share a runway with ga on some airports)
* - mil (all military traffic)
*/
string FGAIFlightPlan::getRunwayClassFromTrafficType(string fltType)
{
if ((fltType == "gate") || (fltType == "cargo")) {
return string("com");
}
if (fltType == "ga") {
return string ("gen");
}
if (fltType == "ul") {
return string("ul");
}
if ((fltType == "mil-fighter") || (fltType == "mil-transport")) {
return string("mil");
}
}

View file

@ -319,7 +319,7 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep, void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
FGAirport *arr, double latitude, FGAirport *arr, double latitude,
double longitude, double speed, double longitude, double speed,
double alt) double alt, const string& fltType)
{ {
double wind_speed; double wind_speed;
double wind_heading; double wind_heading;
@ -344,15 +344,15 @@ void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
waypoints.push_back(wpt); waypoints.push_back(wpt);
// should be changed dynamically to allow "gen" and "mil" string rwyClass = getRunwayClassFromTrafficType(fltType);
arr->getDynamics()->getActiveRunway("com", 2, activeRunway); arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway);
if (!(globals->get_runways()->search(arr->getId(), if (!(globals->get_runways()->search(arr->getId(),
activeRunway, activeRunway,
&rwy))) &rwy)))
{ {
SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " << SG_LOG(SG_INPUT, SG_ALERT, "Failed to find runway " <<
activeRunway << activeRunway <<
" at airport " << arr->getId()); " at airport " << arr->getId()<< " of class " << rwyClass << " (5)");
exit(1); exit(1);
} }
heading = rwy._heading; heading = rwy._heading;