1
0
Fork 0

* A new algorithm for determining hold position instructions. This version still needs some finetuning, but already appears to be more solid than the old version.

* Some tweaks to the traffic scheduling algorithm.
* Misc cleanup.
This commit is contained in:
Durk Talsma 2011-10-03 20:54:58 +02:00
parent ab84ff5904
commit 4640f5bb02
9 changed files with 1301 additions and 878 deletions

View file

@ -773,10 +773,10 @@ bool FGAIAircraft::leadPointReached(FGAIWaypoint* curr) {
} }
if (trafficRef) { if (trafficRef) {
//cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl; //cerr << "Tracking callsign : \"" << fgGetString("/ai/track-callsign") << "\"" << endl;
/* if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) { if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " " cerr << trafficRef->getCallSign() << " " << tgt_altitude_ft << " " << _getSpeed() << " "
<< _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->name << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << endl; << _getAltitude() << " "<< _getLatitude() << " " << _getLongitude() << " " << dist_to_go << " " << lead_dist << " " << curr->getName() << " " << vs << " " << tgt_vs << " " << bearing << " " << minBearing << " " << speedFraction << " " << invisible << endl;
}*/ }
} }
if ((dist_to_go < lead_dist) || (bearing > (minBearing * 1.1))) { if ((dist_to_go < lead_dist) || (bearing > (minBearing * 1.1))) {
minBearing = 360; minBearing = 360;
@ -1223,20 +1223,20 @@ bool FGAIAircraft::reachedEndOfCruise(double &distance) {
double distanceCovered = descentSpeed * descentTimeNeeded; double distanceCovered = descentSpeed * descentTimeNeeded;
//cerr << "Tracking : " << fgGetString("/ai/track-callsign"); //cerr << "Tracking : " << fgGetString("/ai/track-callsign");
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) { // if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
cerr << "Checking for end of cruise stage for :" << trafficRef->getCallSign() << endl; // cerr << "Checking for end of cruise stage for :" << trafficRef->getCallSign() << endl;
cerr << "Descent rate : " << descentRate << endl; // cerr << "Descent rate : " << descentRate << endl;
cerr << "Descent speed : " << descentSpeed << endl; // cerr << "Descent speed : " << descentSpeed << endl;
cerr << "VerticalDistance : " << verticalDistance << ". Altitude : " << altitude_ft << ". Elevation " << trafficRef->getArrivalAirport()->getElevation() << endl; // cerr << "VerticalDistance : " << verticalDistance << ". Altitude : " << altitude_ft << ". Elevation " << trafficRef->getArrivalAirport()->getElevation() << endl;
cerr << "DecentTimeNeeded : " << descentTimeNeeded << endl; // cerr << "DecentTimeNeeded : " << descentTimeNeeded << endl;
cerr << "DistanceCovered : " << distanceCovered << endl; // cerr << "DistanceCovered : " << distanceCovered << endl;
} // }
//cerr << "Distance = " << distance << endl; //cerr << "Distance = " << distance << endl;
distance = distanceCovered; distance = distanceCovered;
if (dist < distanceCovered) { if (dist < distanceCovered) {
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) { // if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
//exit(1); // //exit(1);
} // }
return true; return true;
} else { } else {
return false; return false;
@ -1290,8 +1290,8 @@ time_t FGAIAircraft::checkForArrivalTime(string wptName) {
time_t ete = tracklength / ((speed * SG_NM_TO_METER) / 3600.0); time_t ete = tracklength / ((speed * SG_NM_TO_METER) / 3600.0);
time_t secondsToGo = arrivalTime - now; time_t secondsToGo = arrivalTime - now;
if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) { // if (trafficRef->getCallSign() == fgGetString("/ai/track-callsign")) {
cerr << "Checking arrival time: ete " << ete << ". Time to go : " << secondsToGo << ". Track length = " << tracklength << endl; // cerr << "Checking arrival time: ete " << ete << ". Time to go : " << secondsToGo << ". Track length = " << tracklength << endl;
} // }
return (ete - secondsToGo); // Positive when we're too slow... return (ete - secondsToGo); // Positive when we're too slow...
} }

View file

@ -62,6 +62,11 @@ bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep,
case 1: case 1:
retVal = createPushBack(ac, firstFlight, dep, latitude, longitude, retVal = createPushBack(ac, firstFlight, dep, latitude, longitude,
radius, fltType, aircraftType, airline); radius, fltType, aircraftType, airline);
// Pregenerate the
if (retVal) {
waypoints.back()->setName( waypoints.back()->getName() + string("legend"));
retVal = createTakeoffTaxi(ac, false, dep, radius, fltType, aircraftType, airline);
}
break; break;
case 2: case 2:
retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType, retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType,

View file

@ -247,5 +247,7 @@ void FGATCManager::update ( double time ) {
//cerr << "Adding groundnetWork to the scenegraph::update" << endl; //cerr << "Adding groundnetWork to the scenegraph::update" << endl;
prevController = controller; prevController = controller;
} }
//globals->get_scenery()->get_scene_graph()->addChild(node); for (AtcVecIterator atc = activeStations.begin(); atc != activeStations.end(); atc++) {
(*atc)->update(time);
}
} }

View file

@ -144,13 +144,15 @@ time_t ActiveRunway::requestTimeSlot(time_t eta)
* FGTrafficRecord * FGTrafficRecord
**************************************************************************/ **************************************************************************/
FGTrafficRecord::FGTrafficRecord(): FGTrafficRecord::FGTrafficRecord():
id(0), waitsForId(0), id(0), waitsForId(0),
currentPos(0), currentPos(0),
leg(0), leg(0),
frequencyId(0), frequencyId(0),
state(0), state(0),
allowTransmission(true), allowTransmission(true),
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0) allowPushback(true),
priority(0),
latitude(0), longitude(0), heading(0), speed(0), altitude(0), radius(0)
{ {
} }
@ -400,6 +402,14 @@ bool FGTrafficRecord::isOpposing(FGGroundNetwork * net,
return false; return false;
} }
bool FGTrafficRecord::isActive(int margin)
{
time_t now = time(NULL) + fgGetLong("/sim/time/warp");
time_t deptime = aircraft->getTrafficRef()->getDepartureTime();
return ((now + margin) > deptime);
}
void FGTrafficRecord::setSpeedAdjustment(double spd) void FGTrafficRecord::setSpeedAdjustment(double spd)
{ {
instruction.setChangeSpeed(true); instruction.setChangeSpeed(true);
@ -414,31 +424,12 @@ void FGTrafficRecord::setHeadingAdjustment(double heading)
bool FGTrafficRecord::pushBackAllowed() bool FGTrafficRecord::pushBackAllowed()
{ {
// With the user ATC / AI integration, checking whether the user's aircraft is near no longer works, because return allowPushback;
// this will effectively block the user's aircraft itself from receiving pushback clearance.
// So, what can we do?
/*
double course, az2, dist;
SGGeod curr(SGGeod::fromDegM(getLongitude(),
getLatitude(), getAltitude()));
double userLatitude = fgGetDouble("/position/latitude-deg");
double userLongitude = fgGetDouble("/position/longitude-deg");
SGGeod user(SGGeod::fromDeg(userLongitude, userLatitude));
SGGeodesy::inverse(curr, user, course, az2, dist);
//cerr << "Distance to user : " << dist << endl;
return (dist > 250);
*/
// In essence, we should check whether the pusbback route itself, as well as the associcated
// taxiways near the pushback point are free of traffic.
// To do so, we need to
return true;
} }
/*************************************************************************** /***************************************************************************
* FGATCInstruction * FGATCInstruction
* *
@ -770,7 +761,7 @@ void FGATCController::init()
* *
**************************************************************************/ **************************************************************************/
FGTowerController::FGTowerController(FGAirportDynamics *par) : FGTowerController::FGTowerController(FGAirportDynamics *par) :
FGATCController() FGATCController()
{ {
parent = par; parent = par;
} }
@ -899,6 +890,8 @@ void FGTowerController::updateAircraftInformation(int id, double lat, double lon
rwy->setCleared(id); rwy->setCleared(id);
} }
} }
} else {
} }
} }
@ -1006,6 +999,11 @@ string FGTowerController::getName() {
return string(parent->getId() + "-tower"); return string(parent->getId() + "-tower");
} }
void FGTowerController::update(double dt)
{
}
/*************************************************************************** /***************************************************************************
@ -1285,6 +1283,7 @@ void FGStartupController::render(bool visible)
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) { //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
double dx = 0; double dx = 0;
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) { for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
if (i->isActive(300)) {
// Handle start point // Handle start point
int pos = i->getCurrentPosition(); int pos = i->getCurrentPosition();
//cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl; //cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
@ -1312,7 +1311,7 @@ void FGStartupController::render(bool visible)
if (isUserAircraft((i)->getAircraft())) { if (isUserAircraft((i)->getAircraft())) {
elevationStart = fgGetDouble("/position/ground-elev-m"); elevationStart = fgGetDouble("/position/ground-elev-m");
} else { } else {
elevationStart = ((i)->getAircraft()->_getAltitude()); elevationStart = ((i)->getAircraft()->_getAltitude() * SG_FEET_TO_METER);
} }
double elevationEnd = segment->getEnd()->getElevation(); double elevationEnd = segment->getEnd()->getElevation();
if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) { if ((elevationEnd == 0) || (elevationEnd == parent->getElevation())) {
@ -1335,8 +1334,8 @@ void FGStartupController::render(bool visible)
//cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl; //cerr << "1. Using mean elevation : " << elevationMean << " and " << slope << endl;
WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean + 0.5, -(heading), slope ); WorldCoordinate( obj_pos, center.getLatitudeDeg(), center.getLongitudeDeg(), elevationMean + 0.5 + dx, -(heading), slope );
; ;
obj_trans->setMatrix( obj_pos ); obj_trans->setMatrix( obj_pos );
//osg::Vec3 center(0, 0, 0) //osg::Vec3 center(0, 0, 0)
@ -1351,7 +1350,12 @@ void FGStartupController::render(bool visible)
geode->setName("test"); geode->setName("test");
geode->addDrawable(geometry); geode->addDrawable(geometry);
//osg::Node *custom_obj; //osg::Node *custom_obj;
SGMaterial *mat = matlib->find("UnidirectionalTaper"); SGMaterial *mat;
if (segment->hasBlock()) {
mat = matlib->find("UnidirectionalTaperRed");
} else {
mat = matlib->find("UnidirectionalTaperGreen");
}
if (mat) if (mat)
geode->setEffect(mat->get_effect()); geode->setEffect(mat->get_effect());
obj_trans->addChild(geode); obj_trans->addChild(geode);
@ -1362,7 +1366,7 @@ void FGStartupController::render(bool visible)
} else { } else {
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl; //cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
} }
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) { for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
osg::Matrix obj_pos; osg::Matrix obj_pos;
int k = (*j); int k = (*j);
if (k > 0) { if (k > 0) {
@ -1406,7 +1410,7 @@ void FGStartupController::render(bool visible)
//cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl; //cerr << "2. Using mean elevation : " << elevationMean << " and " << slope << endl;
WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), elevationMean + 0.5, -(segment->getHeading()), slope ); WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), elevationMean + 0.5 + dx, -(segment->getHeading()), slope );
//WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) ); //WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) );
@ -1423,7 +1427,12 @@ void FGStartupController::render(bool visible)
geode->setName("test"); geode->setName("test");
geode->addDrawable(geometry); geode->addDrawable(geometry);
//osg::Node *custom_obj; //osg::Node *custom_obj;
SGMaterial *mat = matlib->find("UnidirectionalTaper"); SGMaterial *mat;
if (segment->hasBlock()) {
mat = matlib->find("UnidirectionalTaperRed");
} else {
mat = matlib->find("UnidirectionalTaperGreen");
}
if (mat) if (mat)
geode->setEffect(mat->get_effect()); geode->setEffect(mat->get_effect());
obj_trans->addChild(geode); obj_trans->addChild(geode);
@ -1434,7 +1443,8 @@ void FGStartupController::render(bool visible)
//cerr << "BIG FAT WARNING: k is here : " << pos << endl; //cerr << "BIG FAT WARNING: k is here : " << pos << endl;
} }
} }
//dx += 0.1; dx += 0.2;
}
} }
globals->get_scenery()->get_scene_graph()->addChild(group); globals->get_scenery()->get_scene_graph()->addChild(group);
} }
@ -1444,13 +1454,19 @@ string FGStartupController::getName() {
return string(parent->getId() + "-startup"); return string(parent->getId() + "-startup");
} }
void FGStartupController::update(double dt)
{
}
/*************************************************************************** /***************************************************************************
* class FGApproachController * class FGApproachController
* *
**************************************************************************/ **************************************************************************/
FGApproachController::FGApproachController(FGAirportDynamics *par): FGApproachController::FGApproachController(FGAirportDynamics *par):
FGATCController() FGATCController()
{ {
parent = par; parent = par;
} }
@ -1567,6 +1583,10 @@ void FGApproachController::signOff(int id)
} }
} }
void FGApproachController::update(double dt)
{
}

View file

@ -38,11 +38,14 @@
#include <simgear/structure/SGReferenced.hxx> #include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx> #include <simgear/structure/SGSharedPtr.hxx>
#include <string> #include <string>
#include <vector> #include <vector>
#include <list>
using std::string; using std::string;
using std::vector; using std::vector;
using std::list;
typedef vector<int> intVec; typedef vector<int> intVec;
@ -76,29 +79,65 @@ public:
FGATCInstruction(); FGATCInstruction();
bool hasInstruction (); bool hasInstruction ();
bool getHoldPattern () { return holdPattern; }; bool getHoldPattern () {
bool getHoldPosition () { return holdPosition; }; return holdPattern;
bool getChangeSpeed () { return changeSpeed; }; };
bool getChangeHeading () { return changeHeading; }; bool getHoldPosition () {
bool getChangeAltitude() { return changeAltitude; }; return holdPosition;
};
bool getChangeSpeed () {
return changeSpeed;
};
bool getChangeHeading () {
return changeHeading;
};
bool getChangeAltitude() {
return changeAltitude;
};
double getSpeed () { return speed; }; double getSpeed () {
double getHeading () { return heading; }; return speed;
double getAlt () { return alt; }; };
double getHeading () {
return heading;
};
double getAlt () {
return alt;
};
bool getCheckForCircularWait() { return resolveCircularWait; }; bool getCheckForCircularWait() {
return resolveCircularWait;
};
void setHoldPattern (bool val) { holdPattern = val; }; void setHoldPattern (bool val) {
void setHoldPosition (bool val) { holdPosition = val; }; holdPattern = val;
void setChangeSpeed (bool val) { changeSpeed = val; }; };
void setChangeHeading (bool val) { changeHeading = val; }; void setHoldPosition (bool val) {
void setChangeAltitude(bool val) { changeAltitude = val; }; holdPosition = val;
};
void setChangeSpeed (bool val) {
changeSpeed = val;
};
void setChangeHeading (bool val) {
changeHeading = val;
};
void setChangeAltitude(bool val) {
changeAltitude = val;
};
void setResolveCircularWait (bool val) { resolveCircularWait = val; }; void setResolveCircularWait (bool val) {
resolveCircularWait = val;
};
void setSpeed (double val) { speed = val; }; void setSpeed (double val) {
void setHeading (double val) { heading = val; }; speed = val;
void setAlt (double val) { alt = val; }; };
void setHeading (double val) {
heading = val;
};
void setAlt (double val) {
alt = val;
};
}; };
@ -117,6 +156,8 @@ private:
int frequencyId; int frequencyId;
int state; int state;
bool allowTransmission; bool allowTransmission;
bool allowPushback;
int priority;
time_t timer; time_t timer;
intVec intentions; intVec intentions;
FGATCInstruction instruction; FGATCInstruction instruction;
@ -129,70 +170,155 @@ private:
public: public:
FGTrafficRecord(); FGTrafficRecord();
void setId(int val) { id = val; }; void setId(int val) {
void setRadius(double rad) { radius = rad;}; id = val;
};
void setRadius(double rad) {
radius = rad;
};
void setPositionAndIntentions(int pos, FGAIFlightPlan *route); void setPositionAndIntentions(int pos, FGAIFlightPlan *route);
void setRunway(string rwy) { runway = rwy;}; void setRunway(string rwy) {
void setLeg(int lg) { leg = lg;}; runway = rwy;
int getId() { return id;}; };
int getState() { return state;}; void setLeg(int lg) {
void setState(int s) { state = s;} leg = lg;
FGATCInstruction getInstruction() { return instruction;}; };
bool hasInstruction() { return instruction.hasInstruction(); }; 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); void setPositionAndHeading(double lat, double lon, double hdg, double spd, double alt);
bool checkPositionAndIntentions(FGTrafficRecord &other); bool checkPositionAndIntentions(FGTrafficRecord &other);
int crosses (FGGroundNetwork *, FGTrafficRecord &other); int crosses (FGGroundNetwork *, FGTrafficRecord &other);
bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node); bool isOpposing (FGGroundNetwork *, FGTrafficRecord &other, int node);
bool isActive(int margin);
bool onRoute(FGGroundNetwork *, FGTrafficRecord &other); bool onRoute(FGGroundNetwork *, FGTrafficRecord &other);
bool getSpeedAdjustment() { return instruction.getChangeSpeed(); }; bool getSpeedAdjustment() {
return instruction.getChangeSpeed();
};
double getLatitude () { return latitude ; }; double getLatitude () {
double getLongitude() { return longitude; }; return latitude ;
double getHeading () { return heading ; }; };
double getSpeed () { return speed ; }; double getLongitude() {
double getAltitude () { return altitude ; }; return longitude;
double getRadius () { return radius ; }; };
double getHeading () {
return heading ;
};
double getSpeed () {
return speed ;
};
double getAltitude () {
return altitude ;
};
double getRadius () {
return radius ;
};
int getWaitsForId () { return waitsForId; }; int getWaitsForId () {
return waitsForId;
};
void setSpeedAdjustment(double spd); void setSpeedAdjustment(double spd);
void setHeadingAdjustment(double heading); void setHeadingAdjustment(double heading);
void clearSpeedAdjustment () { instruction.setChangeSpeed (false); }; void clearSpeedAdjustment () {
void clearHeadingAdjustment() { instruction.setChangeHeading(false); }; instruction.setChangeSpeed (false);
};
void clearHeadingAdjustment() {
instruction.setChangeHeading(false);
};
bool hasHeadingAdjustment() { return instruction.getChangeHeading(); }; bool hasHeadingAdjustment() {
bool hasHoldPosition() { return instruction.getHoldPosition(); }; return instruction.getChangeHeading();
void setHoldPosition (bool inst) { instruction.setHoldPosition(inst); }; };
bool hasHoldPosition() {
return instruction.getHoldPosition();
};
void setHoldPosition (bool inst) {
instruction.setHoldPosition(inst);
};
void setWaitsForId(int id) { waitsForId = id; }; void setWaitsForId(int id) {
waitsForId = id;
};
void setResolveCircularWait() { instruction.setResolveCircularWait(true); }; void setResolveCircularWait() {
void clearResolveCircularWait() { instruction.setResolveCircularWait(false); }; instruction.setResolveCircularWait(true);
};
void clearResolveCircularWait() {
instruction.setResolveCircularWait(false);
};
string getRunway() { return runway; }; string getRunway() {
return runway;
};
//void setCallSign(string clsgn) { callsign = clsgn; }; //void setCallSign(string clsgn) { callsign = clsgn; };
void setAircraft(FGAIAircraft *ref) { aircraft = ref;}; void setAircraft(FGAIAircraft *ref) {
void updateState() { state++; allowTransmission=true; }; aircraft = ref;
};
void updateState() {
state++;
allowTransmission=true;
};
//string getCallSign() { return callsign; }; //string getCallSign() { return callsign; };
FGAIAircraft *getAircraft() { return aircraft;}; FGAIAircraft *getAircraft() {
int getTime() { return timer; }; return aircraft;
int getLeg() { return leg; }; };
void setTime(time_t time) { timer = time; }; int getTime() {
return timer;
};
int getLeg() {
return leg;
};
void setTime(time_t time) {
timer = time;
};
bool pushBackAllowed(); bool pushBackAllowed();
bool allowTransmissions() { return allowTransmission; }; bool allowTransmissions() {
void suppressRepeatedTransmissions () { allowTransmission=false; }; return allowTransmission;
void allowRepeatedTransmissions () { allowTransmission=true; }; };
void nextFrequency() { frequencyId++; }; void allowPushBack() { allowPushback =true;};
int getNextFrequency() { return frequencyId; }; void denyPushBack () { allowPushback = false;};
intVec& getIntentions() { return intentions; }; void suppressRepeatedTransmissions () {
int getCurrentPosition() { return currentPos; }; allowTransmission=false;
};
void allowRepeatedTransmissions () {
allowTransmission=true;
};
void nextFrequency() {
frequencyId++;
};
int getNextFrequency() {
return frequencyId;
};
intVec& getIntentions() {
return intentions;
};
int getCurrentPosition() {
return currentPos;
};
void setPriority(int p) { priority = p; };
int getPriority() { return priority; };
}; };
typedef vector<FGTrafficRecord> TrafficVector; typedef list<FGTrafficRecord> TrafficVector;
typedef vector<FGTrafficRecord>::iterator TrafficVectorIterator; typedef list<FGTrafficRecord>::iterator TrafficVectorIterator;
typedef vector<time_t> TimeVector; typedef vector<time_t> TimeVector;
typedef vector<time_t>::iterator TimeVectorIterator; typedef vector<time_t>::iterator TimeVectorIterator;
@ -214,21 +340,41 @@ private:
AircraftVec departureCue; AircraftVec departureCue;
public: public:
ActiveRunway(string r, int cc) { rwy = r; currentlyCleared = cc; distanceToFinal = 6.0 * SG_NM_TO_METER; }; ActiveRunway(string r, int cc) {
rwy = r;
currentlyCleared = cc;
distanceToFinal = 6.0 * SG_NM_TO_METER;
};
string getRunwayName() { return rwy; }; string getRunwayName() {
int getCleared () { return currentlyCleared; }; return rwy;
double getApproachDistance() { return distanceToFinal; }; };
int getCleared () {
return currentlyCleared;
};
double getApproachDistance() {
return distanceToFinal;
};
//time_t getEstApproachTime() { return estimatedArrival; }; //time_t getEstApproachTime() { return estimatedArrival; };
//void setEstApproachTime(time_t time) { estimatedArrival = time; }; //void setEstApproachTime(time_t time) { estimatedArrival = time; };
void addToDepartureCue(FGAIAircraft *ac) { departureCue.push_back(ac); }; void addToDepartureCue(FGAIAircraft *ac) {
void setCleared(int number) { currentlyCleared = number; }; departureCue.push_back(ac);
};
void setCleared(int number) {
currentlyCleared = number;
};
time_t requestTimeSlot(time_t eta); time_t requestTimeSlot(time_t eta);
int getDepartureCueSize() { return departureCue.size(); }; int getDepartureCueSize() {
FGAIAircraft* getFirstAircraftInDepartureCue() { return departureCue.size() ? *(departureCue.begin()) : NULL; }; return departureCue.size();
void updateDepartureCue() { departureCue.erase(departureCue.begin()); } };
FGAIAircraft* getFirstAircraftInDepartureCue() {
return departureCue.size() ? *(departureCue.begin()) : NULL;
};
void updateDepartureCue() {
departureCue.erase(departureCue.begin());
}
}; };
typedef vector<ActiveRunway> ActiveRunwayVec; typedef vector<ActiveRunway> ActiveRunwayVec;
@ -283,7 +429,8 @@ public:
typedef enum { typedef enum {
ATC_AIR_TO_GROUND, ATC_AIR_TO_GROUND,
ATC_GROUND_TO_AIR } AtcMsgDir; ATC_GROUND_TO_AIR
} AtcMsgDir;
FGATCController(); FGATCController();
virtual ~FGATCController(); virtual ~FGATCController();
void init(); void init();
@ -298,13 +445,19 @@ public:
virtual bool hasInstruction(int id) = 0; virtual bool hasInstruction(int id) = 0;
virtual FGATCInstruction getInstruction(int id) = 0; virtual FGATCInstruction getInstruction(int id) = 0;
double getDt() { return dt_count; }; double getDt() {
void setDt(double dt) { dt_count = dt;}; return dt_count;
};
void setDt(double dt) {
dt_count = dt;
};
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible); void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
string getGateName(FGAIAircraft *aircraft); string getGateName(FGAIAircraft *aircraft);
virtual void render(bool) = 0; virtual void render(bool) = 0;
virtual string getName() = 0; virtual string getName() = 0;
virtual void update(double) = 0;
private: private:
@ -336,8 +489,13 @@ public:
virtual void render(bool); virtual void render(bool);
virtual string getName(); virtual string getName();
bool hasActiveTraffic() { return activeTraffic.size() != 0; }; virtual void update(double dt);
TrafficVector &getActiveTraffic() { return activeTraffic; }; bool hasActiveTraffic() {
return activeTraffic.size() != 0;
};
TrafficVector &getActiveTraffic() {
return activeTraffic;
};
}; };
/****************************************************************************** /******************************************************************************
@ -367,9 +525,14 @@ public:
virtual void render(bool); virtual void render(bool);
virtual string getName(); virtual string getName();
virtual void update(double dt);
bool hasActiveTraffic() { return activeTraffic.size() != 0; }; bool hasActiveTraffic() {
TrafficVector &getActiveTraffic() { return activeTraffic; }; 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. // 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, bool checkTransmissionState(int st, time_t now, time_t startTime, TrafficVectorIterator i, AtcMsgId msgId,
@ -402,11 +565,16 @@ public:
virtual void render(bool); virtual void render(bool);
virtual string getName(); virtual string getName();
virtual void update(double dt);
ActiveRunway* getRunway(string name); ActiveRunway* getRunway(string name);
bool hasActiveTraffic() { return activeTraffic.size() != 0; }; bool hasActiveTraffic() {
TrafficVector &getActiveTraffic() { return activeTraffic; }; return activeTraffic.size() != 0;
};
TrafficVector &getActiveTraffic() {
return activeTraffic;
};
}; };

View file

@ -71,12 +71,24 @@ public:
FGAirportDynamics(FGAirport* ap); FGAirportDynamics(FGAirport* ap);
~FGAirportDynamics(); ~FGAirportDynamics();
void addAwosFreq (int val) { freqAwos.push_back(val); }; void addAwosFreq (int val) {
void addUnicomFreq (int val) { freqUnicom.push_back(val); }; freqAwos.push_back(val);
void addClearanceFreq(int val) { freqClearance.push_back(val); }; };
void addGroundFreq (int val) { freqGround.push_back(val); }; void addUnicomFreq (int val) {
void addTowerFreq (int val) { freqTower.push_back(val); }; freqUnicom.push_back(val);
void addApproachFreq (int val) { freqApproach.push_back(val); }; };
void addClearanceFreq(int val) {
freqClearance.push_back(val);
};
void addGroundFreq (int val) {
freqGround.push_back(val);
};
void addTowerFreq (int val) {
freqTower.push_back(val);
};
void addApproachFreq (int val) {
freqApproach.push_back(val);
};
void init(); void init();
double getLongitude() const; double getLongitude() const;
@ -96,21 +108,33 @@ public:
FGParking *getParking(int i); FGParking *getParking(int i);
void releaseParking(int id); void releaseParking(int id);
string getParkingName(int i); string getParkingName(int i);
int getNrOfParkings() { return parkings.size(); }; int getNrOfParkings() {
return parkings.size();
};
//FGAirport *getAddress() { return this; }; //FGAirport *getAddress() { return this; };
//const string &getName() const { return _name;}; //const string &getName() const { return _name;};
// Returns degrees // Returns degrees
// Departure / Arrival procedures // Departure / Arrival procedures
FGSidStar * getSIDs() { return &SIDs; }; FGSidStar * getSIDs() {
return &SIDs;
};
FGAIFlightPlan * getSID(string activeRunway, double heading); FGAIFlightPlan * getSID(string activeRunway, double heading);
// ATC related functions. // ATC related functions.
FGStartupController *getStartupController() { return &startupController; }; FGStartupController *getStartupController() {
FGGroundNetwork *getGroundNetwork() { return &groundNetwork; }; return &startupController;
FGTowerController *getTowerController() { return &towerController; }; };
FGApproachController *getApproachController() { return &approachController; }; FGGroundNetwork *getGroundNetwork() {
return &groundNetwork;
};
FGTowerController *getTowerController() {
return &towerController;
};
FGApproachController *getApproachController() {
return &approachController;
};
int getGroundFrequency(unsigned leg); int getGroundFrequency(unsigned leg);
int getTowerFrequency (unsigned nr); int getTowerFrequency (unsigned nr);

View file

@ -205,6 +205,11 @@ bool compare_segments(FGTaxiSegment * a, FGTaxiSegment * b)
return (*a) < (*b); return (*a) < (*b);
} }
bool compare_trafficrecords(FGTrafficRecord a, FGTrafficRecord b)
{
return (a.getIntentions().size() < b.getIntentions().size());
}
FGGroundNetwork::FGGroundNetwork() FGGroundNetwork::FGGroundNetwork()
{ {
hasNetwork = false; hasNetwork = false;
@ -623,7 +628,8 @@ void FGGroundNetwork::announcePosition(int id,
rec.setPositionAndHeading(lat, lon, heading, speed, alt); rec.setPositionAndHeading(lat, lon, heading, speed, alt);
rec.setRadius(radius); // only need to do this when creating the record. rec.setRadius(radius); // only need to do this when creating the record.
rec.setAircraft(aircraft); rec.setAircraft(aircraft);
activeTraffic.push_back(rec); activeTraffic.push_front(rec);
} else { } else {
i->setPositionAndIntentions(currentPosition, intendedRoute); i->setPositionAndIntentions(currentPosition, intendedRoute);
i->setPositionAndHeading(lat, lon, heading, speed, alt); i->setPositionAndHeading(lat, lon, heading, speed, alt);
@ -747,9 +753,9 @@ void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
bool needsTaxiClearance = current->getAircraft()->getTaxiClearanceRequest(); bool needsTaxiClearance = current->getAircraft()->getTaxiClearanceRequest();
if (!needsTaxiClearance) { if (!needsTaxiClearance) {
checkHoldPosition(id, lat, lon, heading, speed, alt); checkHoldPosition(id, lat, lon, heading, speed, alt);
if (checkForCircularWaits(id)) { //if (checkForCircularWaits(id)) {
i->setResolveCircularWait(); // i->setResolveCircularWait();
} //}
} else { } else {
current->setHoldPosition(true); current->setHoldPosition(true);
int state = current->getState(); int state = current->getState();
@ -795,7 +801,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
double speed, double alt) double speed, double alt)
{ {
TrafficVectorIterator current, closest; TrafficVectorIterator current, closest, closestOnNetwork;
TrafficVectorIterator i = activeTraffic.begin(); TrafficVectorIterator i = activeTraffic.begin();
bool otherReasonToSlowDown = false; bool otherReasonToSlowDown = false;
bool previousInstruction; bool previousInstruction;
@ -840,7 +846,9 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
if ((dist < mindist) && (bearing < 60.0)) { if ((dist < mindist) && (bearing < 60.0)) {
mindist = dist; mindist = dist;
closest = i; closest = i;
closestOnNetwork = i;
minbearing = bearing; minbearing = bearing;
} }
} }
//Check traffic at the tower controller //Check traffic at the tower controller
@ -887,7 +895,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
} }
*/ */
current->clearSpeedAdjustment(); current->clearSpeedAdjustment();
bool needBraking = false;
if (current->checkPositionAndIntentions(*closest) if (current->checkPositionAndIntentions(*closest)
|| otherReasonToSlowDown) { || otherReasonToSlowDown) {
double maxAllowableDistance = double maxAllowableDistance =
@ -901,6 +909,7 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
if (closest->getId() != current->getId()) { if (closest->getId() != current->getId()) {
current->setSpeedAdjustment(closest->getSpeed() * current->setSpeedAdjustment(closest->getSpeed() *
(mindist / 100)); (mindist / 100));
needBraking = true;
if ( if (
closest->getAircraft()->getTakeOffStatus() && closest->getAircraft()->getTakeOffStatus() &&
(current->getAircraft()->getTrafficRef()->getDepartureAirport() == closest->getAircraft()->getTrafficRef()->getDepartureAirport()) && (current->getAircraft()->getTrafficRef()->getDepartureAirport() == closest->getAircraft()->getTrafficRef()->getDepartureAirport()) &&
@ -920,6 +929,9 @@ void FGGroundNetwork::checkSpeedAdjustment(int id, double lat,
} }
} }
} }
if ((closest == closestOnNetwork) && (current->getPriority() < closest->getPriority()) && needBraking) {
swap(current, closest);
}
} }
} }
@ -956,8 +968,28 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
bool origStatus = current->hasHoldPosition(); bool origStatus = current->hasHoldPosition();
current->setHoldPosition(false); current->setHoldPosition(false);
SGGeod curr(SGGeod::fromDegM(lon, lat, alt)); SGGeod curr(SGGeod::fromDegM(lon, lat, alt));
int currentRoute = i->getCurrentPosition();
int nextRoute;
if (i->getIntentions().size()) {
nextRoute = (*(i->getIntentions().begin()));
} else {
nextRoute = 0;
}
if (currentRoute > 0) {
FGTaxiSegment *tx = findSegment(currentRoute);
FGTaxiSegment *nx;
if (nextRoute) {
nx = findSegment(nextRoute);
} else {
nx = tx;
}
if (tx->hasBlock() || nx->hasBlock() ) {
current->setHoldPosition(true);
}
}
for (i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
/* for (i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
if (i->getId() != current->getId()) { if (i->getId() != current->getId()) {
int node = current->crosses(this, *i); int node = current->crosses(this, *i);
if (node != -1) { if (node != -1) {
@ -1029,7 +1061,7 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
} }
} }
} }
} } */
bool currStatus = current->hasHoldPosition(); bool currStatus = current->hasHoldPosition();
current->setHoldPosition(origStatus); current->setHoldPosition(origStatus);
// Either a Hold Position or a resume taxi transmission has been issued // Either a Hold Position or a resume taxi transmission has been issued
@ -1350,7 +1382,12 @@ void FGGroundNetwork::render(bool visible)
geode->setName("test"); geode->setName("test");
geode->addDrawable(geometry); geode->addDrawable(geometry);
//osg::Node *custom_obj; //osg::Node *custom_obj;
SGMaterial *mat = matlib->find("UnidirectionalTaper"); SGMaterial *mat;
if (segments[pos]->hasBlock()) {
mat = matlib->find("UnidirectionalTaperRed");
} else {
mat = matlib->find("UnidirectionalTaperGreen");
}
if (mat) if (mat)
geode->setEffect(mat->get_effect()); geode->setEffect(mat->get_effect());
obj_trans->addChild(geode); obj_trans->addChild(geode);
@ -1361,7 +1398,7 @@ void FGGroundNetwork::render(bool visible)
} else { } else {
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl; //cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
} }
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) { for (intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
osg::Matrix obj_pos; osg::Matrix obj_pos;
int k = (*j)-1; int k = (*j)-1;
if (k >= 0) { if (k >= 0) {
@ -1419,7 +1456,12 @@ void FGGroundNetwork::render(bool visible)
geode->setName("test"); geode->setName("test");
geode->addDrawable(geometry); geode->addDrawable(geometry);
//osg::Node *custom_obj; //osg::Node *custom_obj;
SGMaterial *mat = matlib->find("UnidirectionalTaper"); SGMaterial *mat;
if (segments[k]->hasBlock()) {
mat = matlib->find("UnidirectionalTaperRed");
} else {
mat = matlib->find("UnidirectionalTaperGreen");
}
if (mat) if (mat)
geode->setEffect(mat->get_effect()); geode->setEffect(mat->get_effect());
obj_trans->addChild(geode); obj_trans->addChild(geode);
@ -1437,3 +1479,96 @@ void FGGroundNetwork::render(bool visible)
string FGGroundNetwork::getName() { string FGGroundNetwork::getName() {
return string(parent->getId() + "-ground"); return string(parent->getId() + "-ground");
} }
void FGGroundNetwork::update(double dt)
{
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
(*tsi)->unblock();
}
int priority = 1;
//sort(activeTraffic.begin(), activeTraffic.end(), compare_trafficrecords);
// Handle traffic that is under ground control first; this way we'll prevent clutter at the gate areas.
// Don't allow an aircraft to pushback when a taxiing aircraft is currently using part of the intended route.
for (TrafficVectorIterator i = parent->getDynamics()->getStartupController()->getActiveTraffic().begin();
i != parent->getDynamics()->getStartupController()->getActiveTraffic().end(); i++) {
i->allowPushBack();
i->setPriority(priority++);
if (i->isActive(60)) {
// Check for all active aircraft whether it's current pos segment is
// an opposite of one of the departing aircraft's intentions
for (TrafficVectorIterator j = activeTraffic.begin(); j != activeTraffic.end(); j++) {
int pos = j->getCurrentPosition();
if (pos > 0) {
FGTaxiSegment *seg = segments[pos-1]->opposite();
if (seg) {
int posReverse = seg->getIndex();
for (intVecIterator k = i->getIntentions().begin(); k != i->getIntentions().end(); k++) {
if ((*k) == posReverse) {
i->denyPushBack();
segments[posReverse-1]->block();
}
}
}
}
}
// if the current aircraft is still allowed to pushback, we can start reserving a route for if by blocking all the entry taxiways.
if (i->pushBackAllowed()) {
int pos = i->getCurrentPosition();
if (pos > 0) {
FGTaxiSegment *seg = segments[pos-1];
FGTaxiNode *node = seg->getEnd();
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
(*tsi)->block();
}
}
}
for (intVecIterator j = i->getIntentions().begin(); j != i->getIntentions().end(); j++) {
int pos = (*j);
if (pos > 0) {
FGTaxiSegment *seg = segments[pos-1];
FGTaxiNode *node = seg->getEnd();
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
(*tsi)->block();
}
}
}
}
}
}
}
for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
i->setPriority(priority++);
int pos = i->getCurrentPosition();
if (pos > 0) {
if (segments[pos-1]->hasBlock()) {
SG_LOG(SG_GENERAL, SG_ALERT, "Taxiway incursion for AI aircraft" << i->getAircraft()->getCallSign());
}
}
intVecIterator ivi;
for (ivi = i->getIntentions().begin(); ivi != i->getIntentions().end(); ivi++) {
int segIndex = (*ivi);
if (segIndex > 0) {
if (segments[segIndex-1]->hasBlock())
break;
}
}
//after this, ivi points just behind the last valid unblocked taxi segment.
for (intVecIterator j = i->getIntentions().begin(); j != ivi; j++) {
int pos = (*j);
if (pos > 0) {
FGTaxiSegment *seg = segments[pos-1];
FGTaxiNode *node = seg->getEnd();
for (FGTaxiSegmentVectorIterator tsi = segments.begin(); tsi != segments.end(); tsi++) {
if (((*tsi)->getEnd() == node) && ((*tsi) != seg)) {
(*tsi)->block();
}
}
}
}
}
}

View file

@ -67,6 +67,7 @@ private:
SGGeod center; SGGeod center;
bool isActive; bool isActive;
bool isPushBackRoute; bool isPushBackRoute;
bool isBlocked;
FGTaxiNode *start; FGTaxiNode *start;
FGTaxiNode *end; FGTaxiNode *end;
int index; int index;
@ -82,6 +83,7 @@ public:
heading(0), heading(0),
isActive(0), isActive(0),
isPushBackRoute(0), isPushBackRoute(0),
isBlocked(0),
start(0), start(0),
end(0), end(0),
index(0), index(0),
@ -97,6 +99,7 @@ public:
center (other.center), center (other.center),
isActive (other.isActive), isActive (other.isActive),
isPushBackRoute (other.isPushBackRoute), isPushBackRoute (other.isPushBackRoute),
isBlocked (other.isBlocked),
start (other.start), start (other.start),
end (other.end), end (other.end),
index (other.index), index (other.index),
@ -113,6 +116,7 @@ public:
center = other.center; center = other.center;
isActive = other.isActive; isActive = other.isActive;
isPushBackRoute = other.isPushBackRoute; isPushBackRoute = other.isPushBackRoute;
isBlocked = other.isBlocked;
start = other.start; start = other.start;
end = other.end; end = other.end;
index = other.index; index = other.index;
@ -120,33 +124,74 @@ public:
return *this; return *this;
}; };
void setIndex (int val) { index = val; }; void setIndex (int val) {
void setStartNodeRef (int val) { startNode = val; }; index = val;
void setEndNodeRef (int val) { endNode = val; }; };
void setStartNodeRef (int val) {
startNode = val;
};
void setEndNodeRef (int val) {
endNode = val;
};
void setOpposite(FGTaxiSegment *opp) { oppositeDirection = opp; }; void setOpposite(FGTaxiSegment *opp) {
oppositeDirection = opp;
};
void setStart(FGTaxiNodeVector *nodes); void setStart(FGTaxiNodeVector *nodes);
void setEnd (FGTaxiNodeVector *nodes); void setEnd (FGTaxiNodeVector *nodes);
void setPushBackType(bool val) { isPushBackRoute = val; }; void setPushBackType(bool val) {
isPushBackRoute = val;
};
void setDimensions(double elevation); void setDimensions(double elevation);
void block() {
isBlocked = true;
}
void unblock() {
isBlocked = false;
};
bool hasBlock() {
return isBlocked;
};
FGTaxiNode * getEnd() { return end;}; FGTaxiNode * getEnd() {
FGTaxiNode * getStart() { return start; }; return end;
double getLength() { return length; }; };
int getIndex() { return index; }; FGTaxiNode * getStart() {
double getLatitude() { return center.getLatitudeDeg(); }; return start;
double getLongitude() { return center.getLongitudeDeg(); }; };
double getHeading() { return heading; }; double getLength() {
bool isPushBack() { return isPushBackRoute; }; return length;
};
int getIndex() {
return index;
};
double getLatitude() {
return center.getLatitudeDeg();
};
double getLongitude() {
return center.getLongitudeDeg();
};
double getHeading() {
return heading;
};
bool isPushBack() {
return isPushBackRoute;
};
int getPenalty(int nGates); int getPenalty(int nGates);
FGTaxiSegment *getAddress() { return this;}; FGTaxiSegment *getAddress() {
return this;
};
bool operator<(const FGTaxiSegment &other) const { return index < other.index; }; bool operator<(const FGTaxiSegment &other) const {
return index < other.index;
};
//bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; }; //bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; };
FGTaxiSegment *opposite() { return oppositeDirection; }; FGTaxiSegment *opposite() {
return oppositeDirection;
};
void setCourseDiff(double crse); void setCourseDiff(double crse);
@ -176,7 +221,11 @@ private:
intVecIterator currRoute; intVecIterator currRoute;
public: public:
FGTaxiRoute() { distance = 0; currNode = nodes.begin(); currRoute = routes.begin();}; FGTaxiRoute() {
distance = 0;
currNode = nodes.begin();
currRoute = routes.begin();
};
FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) { FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) {
nodes = nds; nodes = nds;
routes = rts; routes = rts;
@ -205,15 +254,26 @@ public:
currRoute(routes.begin()) currRoute(routes.begin())
{}; {};
bool operator< (const FGTaxiRoute &other) const {return distance < other.distance; }; bool operator< (const FGTaxiRoute &other) const {
bool empty () { return nodes.begin() == nodes.end(); }; return distance < other.distance;
};
bool empty () {
return nodes.begin() == nodes.end();
};
bool next(int *nde); bool next(int *nde);
bool next(int *nde, int *rte); bool next(int *nde, int *rte);
void rewind(int legNr); void rewind(int legNr);
void first() { currNode = nodes.begin(); currRoute = routes.begin(); }; void first() {
int size() { return nodes.size(); }; currNode = nodes.begin();
int nodesLeft() { return nodes.end() - currNode; }; currRoute = routes.begin();
};
int size() {
return nodes.size();
};
int nodesLeft() {
return nodes.end() - currNode;
};
// int getDepth() { return depth; }; // int getDepth() { return depth; };
}; };
@ -266,8 +326,12 @@ public:
void addSegment(const FGTaxiSegment& seg); void addSegment(const FGTaxiSegment& seg);
void init(); void init();
bool exists() { return hasNetwork; }; bool exists() {
void setTowerController(FGTowerController *twrCtrlr) { towerController = twrCtrlr; }; return hasNetwork;
};
void setTowerController(FGTowerController *twrCtrlr) {
towerController = twrCtrlr;
};
int findNearestNode(double lat, double lon); int findNearestNode(double lat, double lon);
int findNearestNode(const SGGeod& aGeod); int findNearestNode(const SGGeod& aGeod);
@ -277,9 +341,13 @@ public:
FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true); FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);
//void trace(FGTaxiNode *, int, int, double dist); //void trace(FGTaxiNode *, int, int, double dist);
int getNrOfNodes() { return nodes.size(); }; int getNrOfNodes() {
return nodes.size();
};
void setParent(FGAirport *par) { parent = par; }; void setParent(FGAirport *par) {
parent = par;
};
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute, virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
double lat, double lon, double hdg, double spd, double alt, double lat, double lon, double hdg, double spd, double alt,
@ -294,6 +362,7 @@ public:
bool checkForCircularWaits(int id); bool checkForCircularWaits(int id);
virtual void render(bool); virtual void render(bool);
virtual string getName(); virtual string getName();
virtual void update(double dt);
void saveElevationCache(); void saveElevationCache();
}; };

View file

@ -380,7 +380,7 @@ void FGAISchedule::scheduleFlights(time_t now)
FGScheduledFlight *flight = NULL; FGScheduledFlight *flight = NULL;
do { do {
if (currentDestination.empty()) { if (currentDestination.empty()) {
flight = findAvailableFlight(userPort, flightIdentifier, now, (now+6400)); //flight = findAvailableFlight(userPort, flightIdentifier, now, (now+1800));
if (!flight) if (!flight)
flight = findAvailableFlight(currentDestination, flightIdentifier); flight = findAvailableFlight(currentDestination, flightIdentifier);
} else { } else {
@ -423,7 +423,7 @@ void FGAISchedule::scheduleFlights(time_t now)
<< " " << arrT << ":"); << " " << arrT << ":");
flights.push_back(flight); flights.push_back(flight);
} while (currentDestination != startingPort); } while (1); //(currentDestination != startingPort);
SG_LOG(SG_GENERAL, SG_BULK, " Done "); SG_LOG(SG_GENERAL, SG_BULK, " Done ");
} }