else
groundOffset = 0;
- fp = 0;
- controller = 0;
- prevController = 0;
+ fp = 0;
+ controller = 0;
+ prevController = 0;
+ towerController = 0;
dt_count = 0;
dt_elev_count = 0;
use_perf_vs = true;
_performance = 0; //TODO initialize to JET_TRANSPORT from PerformanceDB
dt = 0;
+ scheduledForTakeoff = false;
}
}
}
+void FGAIAircraft::scheduleForATCTowerDepartureControl() {
+ if (!scheduledForTakeoff) {
+ int leg = fp->getLeg();
+ if (trafficRef) {
+ if (trafficRef->getDepartureAirport()->getDynamics()) {
+ towerController = trafficRef->getDepartureAirport()->getDynamics()->getTowerController();
+ } else {
+ cerr << "Error: Could not find Dynamics at airport : " << trafficRef->getDepartureAirport()->getId() << endl;
+ }
+ if (towerController) {
+ towerController->announcePosition(getID(), fp, fp->getCurrentWaypoint()->getRouteIndex(),
+ _getLatitude(), _getLongitude(), hdg, speed, altitude_ft,
+ trafficRef->getRadius(), leg, this);
+ }
+ }
+ }
+ scheduledForTakeoff = true;
+}
+
// Process ATC instructions and report back
void FGAIAircraft::processATC(FGATCInstruction instruction) {
if (prev->contains("legend")) {
fp->incrementLeg();
}
+ if (prev->contains(string("DepartureHold"))) {
+ scheduleForATCTowerDepartureControl();
+ }
// This is the last taxi waypoint, and marks the the end of the flight plan
// so, the schedule should update and wait for the next departure time.
bool getTaxiClearanceRequest() { return needsTaxiClearance; };
FGAISchedule * getTrafficRef() { return trafficRef; };
void setTrafficRef(FGAISchedule *ref) { trafficRef = ref; };
+ void scheduleForATCTowerDepartureControl();
+
+ inline bool isScheduledForTakeoff() { return scheduledForTakeoff; };
virtual const char* getTypeString(void) const { return "aircraft"; }
private:
FGAISchedule *trafficRef;
- FGATCController *controller, *prevController;
+ FGATCController *controller,
+ *prevController,
+ *towerController; // Only needed to make a pre-announcement
bool hdg_lock;
bool alt_lock;
void checkVisibility();
inline bool isStationary() { return ((fabs(speed)<=0.0001)&&(fabs(tgt_speed)<=0.0001));}
inline bool needGroundElevation() { if (!isStationary()) _needsGroundElevation=true;return _needsGroundElevation;}
+
double sign(double x);
bool reachedWaypoint;
bool needsTaxiClearance;
bool _needsGroundElevation;
+ bool scheduledForTakeoff;
time_t timeElapsed;
PerformanceData* _performance; // the performance data for this aircraft
createOnGround(ac, buffer, tn->getGeod(), apt->getElevation(),
ac->getPerformance()->vTaxi());
wpt->setRouteIndex(route);
+ if (taxiRoute->size() == 1) {
+ // Note that we actually have hold points in the ground network, but this is just an initial test.
+ wpt->setName( wpt->getName() + string("DepartureHold"));
+ }
waypoints.push_back(wpt);
}
return true;
}
} else {
if ((((*j) - (*i)) > (separation * 2))) { // found a potential slot
- // now check whether this slow is usable:
+ // now check whether this slot is usable:
// 1) eta should fall between the two points
// i.e. eta > i AND eta < j
//
//rec.setCallSign(callsign);
rec.setAircraft(ref);
activeTraffic.push_back(rec);
+ cerr << ref->getTrafficRef()->getCallSign() << " You are number " << activeTraffic.size() << " for takeoff " << endl;
} else {
i->setPositionAndHeading(lat, lon, heading, speed, alt);
}
int FGAirportDynamics::getGroundFrequency(unsigned leg)
{
//return freqGround.size() ? freqGround[0] : 0; };
- cerr << "Getting frequency for : " << leg << endl;
+ //cerr << "Getting frequency for : " << leg << endl;
int groundFreq = 0;
if (leg < 1) {
SG_LOG(SG_ATC, SG_ALERT,
}
}
//Check traffic at the tower controller
+ // Note, as of 2011-08-01, this should no longer be necessecary.
+ /*
if (towerController->hasActiveTraffic()) {
for (TrafficVectorIterator i =
towerController->getActiveTraffic().begin();
}
}
// Finally, check UserPosition
+ // Note, as of 2011-08-01, this should no longer be necessecary.
double userLatitude = fgGetDouble("/position/latitude-deg");
double userLongitude = fgGetDouble("/position/longitude-deg");
SGGeod user(SGGeod::fromDeg(userLongitude, userLatitude));
minbearing = bearing;
otherReasonToSlowDown = true;
}
-
+ */
current->clearSpeedAdjustment();
if (current->checkPositionAndIntentions(*closest)
if (closest->getId() != current->getId())
current->setSpeedAdjustment(closest->getSpeed() *
(mindist / 100));
+ if (closest->getAircraft()->isScheduledForTakeoff())
+ current->getAircraft()->scheduleForATCTowerDepartureControl();
else
current->setSpeedAdjustment(0); // This can only happen when the user aircraft is the one closest
if (mindist < maxAllowableDistance) {