From ce7b5eb094fd29620b39486c4059f9c06b414060 Mon Sep 17 00:00:00 2001 From: portree_kid Date: Mon, 20 Jun 2022 21:32:52 +0200 Subject: [PATCH] AI Aircraft not taking off because TowerController signOff was not called. --- src/AIModel/AIAircraft.cxx | 12 ++++++++++-- src/ATC/ATCController.hxx | 2 +- src/ATC/TowerController.cxx | 14 ++++++++++++-- src/ATC/trafficcontrol.cxx | 6 +++--- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 54cdc2bff..063a72713 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -388,7 +388,9 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) { } prev = fp->getPreviousWaypoint(); - SG_LOG(SG_AI, SG_BULK, getCallSign() << "|Previous WP \t" << prev->getName() << "\t" << prev->getPos()); + if (prev) { + SG_LOG(SG_AI, SG_BULK, getCallSign() << "|Previous WP \t" << prev->getName() << "\t" << prev->getPos()); + } curr = fp->getCurrentWaypoint(); if (curr) { SG_LOG(SG_AI, SG_BULK, getCallSign() << "|Current WP \t" << curr->getName() << "\t" << curr->getPos()); @@ -701,7 +703,10 @@ void FGAIAircraft::announcePositionToController() { case AILeg::TAKEOFF: //Take off tower controller if (trafficRef->getDepartureAirport()->getDynamics()) { controller = trafficRef->getDepartureAirport()->getDynamics()->getTowerController(); - towerController = 0; + if (towerController) { + SG_LOG(SG_AI, SG_BULK, " : " << controller->getName() << "#" << towerController->getName() << (controller != towerController)); + } + towerController = nullptr; } else { SG_LOG(SG_AI, SG_BULK, "Error: Could not find Dynamics at airport : " << trafficRef->getDepartureAirport()->getId()); } @@ -716,6 +721,9 @@ void FGAIAircraft::announcePositionToController() { controller = trafficRef->getArrivalAirport()->getDynamics()->getGroundController(); break; default: + if(prevController) { + SG_LOG(SG_AI, SG_BULK, "Will be signing off from " << prevController->getName()); + } controller = nullptr; break; } diff --git a/src/ATC/ATCController.hxx b/src/ATC/ATCController.hxx index 43d07b23a..7ce8c20e1 100644 --- a/src/ATC/ATCController.hxx +++ b/src/ATC/ATCController.hxx @@ -107,7 +107,7 @@ public: virtual void updateAircraftInformation(int id, SGGeod geod, double heading, double speed, double alt, double dt) = 0; - void signOff(int id); + virtual void signOff(int id); bool hasInstruction(int id); FGATCInstruction getInstruction(int id); diff --git a/src/ATC/TowerController.cxx b/src/ATC/TowerController.cxx index 319d26c24..2a78a4db2 100644 --- a/src/ATC/TowerController.cxx +++ b/src/ATC/TowerController.cxx @@ -197,22 +197,31 @@ void FGTowerController::updateAircraftInformation(int id, SGGeod geod, int clearanceId = rwy->getCleared(); if (clearanceId) { if (id == clearanceId) { + SG_LOG(SG_ATC, SG_BULK, "Unset Hold " << clearanceId << " for " << rwy->getRunwayName()); current.setHoldPosition(false); + } else { + SG_LOG(SG_ATC, SG_WARN, "Not cleared " << id << " " << clearanceId); } } else { if (current.getAircraft() == rwy->getFirstAircraftInDepartureQueue()) { + SG_LOG(SG_ATC, SG_BULK, + "Cleared " << current.getAircraft()->getCallSign() << " for " << rwy->getRunwayName() << " Id " << id); rwy->setCleared(id); auto ac = rwy->getFirstOfStatus(1); - if (ac) + if (ac) { ac->setTakeOffStatus(2); // transmit takeoff clearacne? But why twice? + } + } else { + SG_LOG(SG_ATC, SG_BULK, + "Not cleared " << current.getAircraft()->getCallSign() << " " << rwy->getFirstAircraftInDepartureQueue()->getCallSign()); } } } - void FGTowerController::signOff(int id) { + SG_LOG(SG_ATC, SG_BULK, "Signing off " << id << " from Tower"); // ensure we don't modify activeTraffic during destruction if (_isDestroying) return; @@ -232,6 +241,7 @@ void FGTowerController::signOff(int id) }); if (runwayIt != activeRunways.end()) { + SG_LOG(SG_ATC, SG_BULK, "Cleared " << id << " from " << runwayIt->getRunwayName() ); runwayIt->setCleared(0); runwayIt->updateDepartureQueue(); } else { diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index b10a6b321..f379a277d 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -92,12 +92,12 @@ time_t ActiveRunway::requestTimeSlot(time_t eta) // if the aircraft is the first arrival, add to the vector and return eta directly if (estimatedArrivalTimes.empty()) { estimatedArrivalTimes.push_back(eta); - SG_LOG(SG_ATC, SG_DEBUG, "Checked eta slots, using " << eta); + SG_LOG(SG_ATC, SG_DEBUG, getRunwayName() << "Checked eta slots, using " << eta); return eta; } else { // First check the already assigned slots to see where we need to fit the flight in TimeVectorIterator i = estimatedArrivalTimes.begin(); - SG_LOG(SG_ATC, SG_DEBUG, "Checking eta slots " << eta << ": "); + SG_LOG(SG_ATC, SG_DEBUG, getRunwayName() << " Checking eta slots " << eta << " : " << estimatedArrivalTimes.size() << " Timediff " << (eta - globals->get_time_params()->get_cur_time())); // is this needed - just a debug output? for (i = estimatedArrivalTimes.begin(); @@ -208,7 +208,7 @@ void ActiveRunway::printDepartureQueue() } -/* Fetch the first aircraft in the departure cue with a certain status */ +/* Fetch the first aircraft in the departure queue with a certain status */ SGSharedPtrActiveRunway::getFirstOfStatus(int stat) const { auto it = std::find_if(departureQueue.begin(), departureQueue.end(), [stat](const SGSharedPtr& acft) {