1
0
Fork 0

AI Aircraft not taking off because TowerController signOff was not called.

This commit is contained in:
portree_kid 2022-06-20 21:32:52 +02:00
parent 5a3528f782
commit ce7b5eb094
4 changed files with 26 additions and 8 deletions

View file

@ -388,7 +388,9 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
}
prev = fp->getPreviousWaypoint();
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;
}

View file

@ -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);

View file

@ -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 {

View file

@ -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 */
SGSharedPtr<FGAIAircraft>ActiveRunway::getFirstOfStatus(int stat) const
{
auto it = std::find_if(departureQueue.begin(), departureQueue.end(), [stat](const SGSharedPtr<FGAIAircraft>& acft) {