Schedflight logging
This commit is contained in:
parent
3318e09441
commit
47ca5c251f
2 changed files with 49 additions and 26 deletions
|
@ -100,6 +100,13 @@ FGScheduledFlight::FGScheduledFlight(const FGScheduledFlight &other)
|
||||||
available = other.available;
|
available = other.available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cs The callsign
|
||||||
|
* @param fr The flightrules
|
||||||
|
* @param depPrt The departure ICAO
|
||||||
|
* @param arrPrt The arrival ICAO
|
||||||
|
*/
|
||||||
|
|
||||||
FGScheduledFlight::FGScheduledFlight(const string& cs,
|
FGScheduledFlight::FGScheduledFlight(const string& cs,
|
||||||
const string& fr,
|
const string& fr,
|
||||||
const string& depPrt,
|
const string& depPrt,
|
||||||
|
@ -137,7 +144,14 @@ FGScheduledFlight::FGScheduledFlight(const string& cs,
|
||||||
SG_LOG( SG_AI, SG_ALERT, "Unknown repeat period in flight plan "
|
SG_LOG( SG_AI, SG_ALERT, "Unknown repeat period in flight plan "
|
||||||
"of flight '" << cs << "': " << rep );
|
"of flight '" << cs << "': " << rep );
|
||||||
}
|
}
|
||||||
|
if (!repeatPeriod) {
|
||||||
|
SG_LOG( SG_AI, SG_ALERT, "Zero repeat period in flight plan "
|
||||||
|
"of flight '" << cs << "': " << rep );
|
||||||
|
available = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// What we still need to do is preprocess the departure and
|
// What we still need to do is preprocess the departure and
|
||||||
// arrival times.
|
// arrival times.
|
||||||
departureTime = processTimeString(deptime);
|
departureTime = processTimeString(deptime);
|
||||||
|
@ -218,26 +232,26 @@ void FGScheduledFlight::update()
|
||||||
arrivalTime += repeatPeriod;
|
arrivalTime += repeatPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //FIXME Doesn't have to be an iteration / when sitting at departure why adjust based on arrival
|
||||||
|
*/
|
||||||
|
|
||||||
void FGScheduledFlight::adjustTime(time_t now)
|
void FGScheduledFlight::adjustTime(time_t now)
|
||||||
{
|
{
|
||||||
//cerr << "1: Adjusting schedule please wait: " << now
|
// Make sure that the arrival time is in between
|
||||||
// << " " << arrivalTime << " " << arrivalTime+repeatPeriod << endl;
|
// the current time and the next repeat period.
|
||||||
// Make sure that the arrival time is in between
|
while ((arrivalTime < now) || (arrivalTime > now + repeatPeriod)) {
|
||||||
// the current time and the next repeat period.
|
if (arrivalTime < now) {
|
||||||
while ((arrivalTime < now) || (arrivalTime > now+repeatPeriod))
|
departureTime += repeatPeriod;
|
||||||
{
|
arrivalTime += repeatPeriod;
|
||||||
if (arrivalTime < now)
|
SG_LOG(SG_AI, SG_BULK, "Adjusted schedule forward : " << callsign << " " << now << " " << departureTime << " " << arrivalTime);
|
||||||
{
|
} else if (arrivalTime > now + repeatPeriod) {
|
||||||
departureTime += repeatPeriod;
|
departureTime -= repeatPeriod;
|
||||||
arrivalTime += repeatPeriod;
|
arrivalTime -= repeatPeriod;
|
||||||
}
|
SG_LOG(SG_AI, SG_BULK, "Adjusted schedule backward : " << callsign << " " << now << " " << departureTime << " " << arrivalTime);
|
||||||
else if (arrivalTime > now+repeatPeriod)
|
} else {
|
||||||
{
|
SG_LOG(SG_AI, SG_BULK, "Not Adjusted schedule : " << now);
|
||||||
departureTime -= repeatPeriod;
|
}
|
||||||
arrivalTime -= repeatPeriod;
|
|
||||||
}
|
|
||||||
// cerr << "2: Adjusting schedule please wait: " << now
|
|
||||||
// << " " << arrivalTime << " " << arrivalTime+repeatPeriod << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -579,12 +579,12 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti
|
||||||
fltEnd = tmgr->getLastFlight(req);
|
fltEnd = tmgr->getLastFlight(req);
|
||||||
|
|
||||||
|
|
||||||
//cerr << "Finding available flight " << endl;
|
SG_LOG (SG_AI, SG_BULK, "Finding available flight for " << req);
|
||||||
// For Now:
|
// For Now:
|
||||||
// Traverse every registered flight
|
// Traverse every registered flight
|
||||||
if (fltBegin == fltEnd) {
|
if (fltBegin == fltEnd) {
|
||||||
//cerr << "No Flights Scheduled for " << req << endl;
|
SG_LOG (SG_AI, SG_BULK, "No Flights Scheduled for " << req );
|
||||||
}
|
}
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (FGScheduledFlightVecIterator i = fltBegin; i != fltEnd; i++) {
|
for (FGScheduledFlightVecIterator i = fltBegin; i != fltEnd; i++) {
|
||||||
(*i)->adjustTime(now);
|
(*i)->adjustTime(now);
|
||||||
|
@ -596,10 +596,13 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti
|
||||||
//bool valid = true;
|
//bool valid = true;
|
||||||
counter++;
|
counter++;
|
||||||
if (!(*i)->isAvailable()) {
|
if (!(*i)->isAvailable()) {
|
||||||
|
SG_LOG(SG_AI, SG_BULK, "" << (*i)->getCallSign() << "is no longer available");
|
||||||
|
|
||||||
//cerr << (*i)->getCallSign() << "is no longer available" << endl;
|
//cerr << (*i)->getCallSign() << "is no longer available" << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!((*i)->getRequirement() == req)) {
|
if (!((*i)->getRequirement() == req)) {
|
||||||
|
SG_LOG(SG_AI, SG_BULK, "" << (*i)->getCallSign() << " no requirement " << (*i)->getRequirement() << " " << req);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(((*i)->getArrivalAirport()) && ((*i)->getDepartureAirport()))) {
|
if (!(((*i)->getArrivalAirport()) && ((*i)->getDepartureAirport()))) {
|
||||||
|
@ -607,17 +610,23 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string ¤tDesti
|
||||||
}
|
}
|
||||||
if (!(currentDestination.empty())) {
|
if (!(currentDestination.empty())) {
|
||||||
if (currentDestination != (*i)->getDepartureAirport()->getId()) {
|
if (currentDestination != (*i)->getDepartureAirport()->getId()) {
|
||||||
|
SG_LOG(SG_AI, SG_BULK, (*i)->getCallSign() << " not matching departure.");
|
||||||
//cerr << (*i)->getCallSign() << "Doesn't match destination" << endl;
|
//cerr << (*i)->getCallSign() << "Doesn't match destination" << endl;
|
||||||
//cerr << "Current Destination " << currentDestination << "Doesnt match flight's " <<
|
//cerr << "Current Destination " << currentDestination << "Doesnt match flight's " <<
|
||||||
// (*i)->getArrivalAirport()->getId() << endl;
|
// (*i)->getArrivalAirport()->getId() << endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! flights.empty()) {
|
if (!flights.empty()) {
|
||||||
time_t arrival = flights.back()->getArrivalTime();
|
time_t arrival = flights.back()->getArrivalTime();
|
||||||
|
time_t departure = (*i)->getDepartureTime();
|
||||||
int groundTime = groundTimeFromRadius();
|
int groundTime = groundTimeFromRadius();
|
||||||
if ((*i)->getDepartureTime() < (arrival+(groundTime)))
|
if (departure < (arrival+(groundTime))) {
|
||||||
continue;
|
SG_LOG (SG_AI, SG_BULK, "Not flight candidate : " << (*i)->getCallSign() << " Arrival : " << arrival << " Planned Departure " << departure << " < " << (arrival+groundTime) << " Diff : " << (arrival+groundTime-departure));
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
SG_LOG (SG_AI, SG_BULK, "Next flight candidate : " << (*i)->getCallSign() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (min != 0) {
|
if (min != 0) {
|
||||||
time_t dep = (*i)->getDepartureTime();
|
time_t dep = (*i)->getDepartureTime();
|
||||||
|
|
Loading…
Add table
Reference in a new issue