]> git.mxchange.org Git - flightgear.git/blob - src/Traffic/TrafficMgr.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / Traffic / TrafficMgr.cxx
1 /******************************************************************************
2  * TrafficMGr.cxx
3  * Written by Durk Talsma, started May 5, 2004.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  *
19  *
20  **************************************************************************/
21
22 /* 
23  * Traffic manager parses airlines timetable-like data and uses this to 
24  * determine the approximate position of each AI aircraft in its database.
25  * When an AI aircraft is close to the user's position, a more detailed 
26  * AIModels based simulation is set up. 
27  * 
28  * I'm currently assuming the following simplifications:
29  * 1) The earth is a perfect sphere
30  * 2) Each aircraft flies a perfect great circle route.
31  * 3) Each aircraft flies at a constant speed (with infinite accelerations and
32  *    decelerations) 
33  * 4) Each aircraft leaves at exactly the departure time. 
34  * 5) Each aircraft arrives at exactly the specified arrival time. 
35  *
36  *
37  *****************************************************************************/
38
39 #ifdef HAVE_CONFIG_H
40 #  include "config.h"
41 #endif
42
43 #include <stdlib.h>
44 #include <time.h>
45 #include <cstring>
46 #include <iostream>
47 #include <fstream>
48
49
50 #include <string>
51 #include <vector>
52 #include <algorithm>
53
54 #include <simgear/compiler.h>
55 #include <simgear/misc/sg_path.hxx>
56 #include <simgear/misc/sg_dir.hxx>
57 #include <simgear/props/props.hxx>
58 #include <simgear/route/waypoint.hxx>
59 #include <simgear/structure/subsystem_mgr.hxx>
60 #include <simgear/xml/easyxml.hxx>
61
62 #include <AIModel/AIAircraft.hxx>
63 #include <AIModel/AIFlightPlan.hxx>
64 #include <AIModel/AIBase.hxx>
65 #include <Airports/simple.hxx>
66 #include <Main/fg_init.hxx>
67
68
69
70 #include "TrafficMgr.hxx"
71
72 using std::sort;
73 using std::strcmp;
74
75 /******************************************************************************
76  * TrafficManager
77  *****************************************************************************/
78 FGTrafficManager::FGTrafficManager() :
79   inited(false),
80   enabled("/sim/traffic-manager/enabled"),
81   aiEnabled("/sim/ai/enabled"),
82   realWxEnabled("/environment/realwx/enabled"),
83   metarValid("/environment/metar/valid")
84 {
85     //score = 0;
86     //runCount = 0;
87     acCounter = 0;
88 }
89
90 FGTrafficManager::~FGTrafficManager()
91 {
92     // Save the heuristics data
93     bool saveData = false;
94     ofstream cachefile;
95     if (fgGetBool("/sim/traffic-manager/heuristics")) {
96         SGPath cacheData(fgGetString("/sim/fg-home"));
97         cacheData.append("ai");
98         string airport = fgGetString("/sim/presets/airport-id");
99
100         if ((airport) != "") {
101             char buffer[128];
102             ::snprintf(buffer, 128, "%c/%c/%c/",
103                        airport[0], airport[1], airport[2]);
104             cacheData.append(buffer);
105             if (!cacheData.exists()) {
106                 cacheData.create_dir(0777);
107             }
108             cacheData.append(airport + "-cache.txt");
109             //cerr << "Saving AI traffic heuristics" << endl;
110             saveData = true;
111             cachefile.open(cacheData.str().c_str());
112         }
113     }
114     for (ScheduleVectorIterator sched = scheduledAircraft.begin();
115          sched != scheduledAircraft.end(); sched++) {
116         if (saveData) {
117             cachefile << (*sched)->getRegistration() << " "
118                 << (*sched)->getRunCount() << " "
119                 << (*sched)->getHits() << endl;
120         }
121         delete(*sched);
122     }
123     if (saveData) {
124         cachefile.close();
125     }
126     scheduledAircraft.clear();
127     flights.clear();
128 }
129
130
131 void FGTrafficManager::init()
132 {
133     if (!enabled || !aiEnabled) {
134       return;
135     }
136   
137     heuristicsVector heuristics;
138     HeuristicMap heurMap;
139
140     if (string(fgGetString("/sim/traffic-manager/datafile")) == string("")) {
141         simgear::Dir trafficDir(SGPath(globals->get_fg_root(), "AI/Traffic"));
142         simgear::PathList d = trafficDir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
143         
144         for (unsigned int i=0; i<d.size(); ++i) {
145           simgear::Dir d2(d[i]);
146           simgear::PathList trafficFiles = d2.children(simgear::Dir::TYPE_FILE, ".xml");
147           for (unsigned int j=0; j<trafficFiles.size(); ++j) {
148             SGPath curFile = trafficFiles[j];
149             SG_LOG(SG_GENERAL, SG_DEBUG,
150                   "Scanning " << curFile.str() << " for traffic");
151             readXML(curFile.str(), *this);
152           }
153         }
154     } else {
155         fgSetBool("/sim/traffic-manager/heuristics", false);
156         SGPath path = string(fgGetString("/sim/traffic-manager/datafile"));
157         string ext = path.extension();
158         if (path.extension() == "xml") {
159             if (path.exists()) {
160                 readXML(path.str(), *this);
161             }
162         } else if (path.extension() == "conf") {
163             if (path.exists()) {
164                 readTimeTableFromFile(path);
165             }
166         } else {
167              SG_LOG(SG_GENERAL, SG_ALERT,
168                                "Unknown data format " << path.str()
169                                 << " for traffic");
170         }
171         //exit(1);
172     }
173     if (fgGetBool("/sim/traffic-manager/heuristics")) {
174         //cerr << "Processing Heuristics" << endl;
175         // Load the heuristics data
176         SGPath cacheData(fgGetString("/sim/fg-home"));
177         cacheData.append("ai");
178         string airport = fgGetString("/sim/presets/airport-id");
179         if ((airport) != "") {
180             char buffer[128];
181             ::snprintf(buffer, 128, "%c/%c/%c/",
182                        airport[0], airport[1], airport[2]);
183             cacheData.append(buffer);
184             cacheData.append(airport + "-cache.txt");
185             if (cacheData.exists()) {
186                 ifstream data(cacheData.c_str());
187                 while (1) {
188                     Heuristic h; // = new Heuristic;
189                     data >> h.registration >> h.runCount >> h.hits;
190                     if (data.eof())
191                         break;
192                     HeuristicMapIterator itr = heurMap.find(h.registration);
193                     if (itr != heurMap.end()) {
194                          SG_LOG(SG_GENERAL, SG_WARN,"Traffic Manager Warning: found duplicate tailnumber " << 
195                          h.registration << " for AI aircraft");
196                     }
197                     heurMap[h.registration] = h;
198                     heuristics.push_back(h);
199                 }
200             }
201         }
202         for (currAircraft = scheduledAircraft.begin();
203              currAircraft != scheduledAircraft.end(); currAircraft++) {
204             string registration = (*currAircraft)->getRegistration();
205             HeuristicMapIterator itr = heurMap.find(registration);
206             //cerr << "Processing heuristics for" << (*currAircraft)->getRegistration() << endl;
207             if (itr == heurMap.end()) {
208                 //cerr << "No heuristics found for " << registration << endl;
209             } else {
210                 (*currAircraft)->setrunCount(itr->second.runCount);
211                 (*currAircraft)->setHits(itr->second.hits);
212                 //cerr <<"Runcount " << itr->second->runCount << ".Hits " << itr->second->hits << endl;
213             }
214         }
215         //cerr << "Done" << endl;
216         //for (heuristicsVectorIterator hvi = heuristics.begin();
217         //     hvi != heuristics.end(); hvi++) {
218         //    delete(*hvi);
219         //}
220     }
221     // Do sorting and scoring separately, to take advantage of the "homeport| variable
222     for (currAircraft = scheduledAircraft.begin();
223          currAircraft != scheduledAircraft.end(); currAircraft++) {
224         (*currAircraft)->setScore();
225     }
226     sort(scheduledAircraft.begin(), scheduledAircraft.end(),
227          compareSchedules);
228     currAircraft = scheduledAircraft.begin();
229     currAircraftClosest = scheduledAircraft.begin();
230     
231     inited = true;
232 }
233
234 void FGTrafficManager::update(double /*dt */ )
235 {
236     if (!enabled || !aiEnabled || (realWxEnabled && !metarValid)) {
237         return;
238     }
239         
240     if (!inited) {
241     // lazy-initialization, we've been enabled at run-time
242       SG_LOG(SG_GENERAL, SG_INFO, "doing lazy-init of TrafficManager");
243       init();
244     }
245         
246     time_t now = time(NULL) + fgGetLong("/sim/time/warp");
247     if (scheduledAircraft.size() == 0) {
248         return;
249     }
250
251     SGVec3d userCart =
252         SGVec3d::fromGeod(SGGeod::
253                           fromDeg(fgGetDouble("/position/longitude-deg"),
254                                   fgGetDouble("/position/latitude-deg")));
255
256     if (currAircraft == scheduledAircraft.end()) {
257         currAircraft = scheduledAircraft.begin();
258     }
259     //cerr << "Processing << " << (*currAircraft)->getRegistration() << " with score " << (*currAircraft)->getScore() << endl;
260     if (!((*currAircraft)->update(now, userCart))) {
261         (*currAircraft)->taint();
262         // NOTE: With traffic manager II, this statement below is no longer true
263         // after proper initialization, we shouldnt get here.
264         // But let's make sure
265         //SG_LOG( SG_GENERAL, SG_ALERT, "Failed to update aircraft schedule in traffic manager");
266     }
267     currAircraft++;
268 }
269
270 void FGTrafficManager::release(int id)
271 {
272     releaseList.push_back(id);
273 }
274
275 bool FGTrafficManager::isReleased(int id)
276 {
277     IdListIterator i = releaseList.begin();
278     while (i != releaseList.end()) {
279         if ((*i) == id) {
280             releaseList.erase(i);
281             return true;
282         }
283         i++;
284     }
285     return false;
286 }
287
288
289 void FGTrafficManager::readTimeTableFromFile(SGPath infileName)
290 {
291     string model;
292     string livery;
293     string homePort;
294     string registration;
295     string flightReq;
296     bool   isHeavy;
297     string acType;
298     string airline;
299     string m_class;
300     string FlightType;
301     double radius;
302     double offset;
303
304     char buffer[256];
305     string buffString;
306     vector <string> tokens, depTime,arrTime;
307     vector <string>::iterator it;
308     ifstream infile(infileName.str().c_str());
309     while (1) {
310          infile.getline(buffer, 256);
311          if (infile.eof()) {
312              break;
313          }
314          //cerr << "Read line : " << buffer << endl;
315          buffString = string(buffer);
316          tokens.clear();
317          Tokenize(buffString, tokens, " \t");
318          //for (it = tokens.begin(); it != tokens.end(); it++) {
319          //    cerr << "Tokens: " << *(it) << endl;
320          //}
321          //cerr << endl;
322          if (!tokens.empty()) {
323              if (tokens[0] == string("AC")) {
324                  if (tokens.size() != 13) {
325                      SG_LOG(SG_GENERAL, SG_ALERT, "Error parsing traffic file " << infileName.str() << " at " << buffString);
326                      exit(1);
327                  }
328                  model          = tokens[12];
329                  livery         = tokens[6];
330                  homePort       = tokens[1];
331                  registration   = tokens[2];
332                  if (tokens[11] == string("false")) {
333                      isHeavy = false;
334                  } else {
335                      isHeavy = true;
336                  }
337                  acType         = tokens[4];
338                  airline        = tokens[5];
339                  flightReq      = tokens[3] + tokens[5];
340                  m_class        = tokens[10];
341                  FlightType     = tokens[9];
342                  radius         = atof(tokens[8].c_str());
343                  offset         = atof(tokens[7].c_str());;
344                  SG_LOG(SG_GENERAL, SG_ALERT, "Adding Aircraft" << model << " " << livery << " " << homePort << " " 
345                                                                 << registration << " " << flightReq << " " << isHeavy 
346                                                                 << " " << acType << " " << airline << " " << m_class 
347                                                                 << " " << FlightType << " " << radius << " " << offset);
348                  scheduledAircraft.push_back(new FGAISchedule(model, 
349                                                               livery, 
350                                                               homePort,
351                                                               registration, 
352                                                               flightReq,
353                                                               isHeavy,
354                                                               acType, 
355                                                               airline, 
356                                                               m_class, 
357                                                               FlightType,
358                                                               radius,
359                                                               offset));
360              }
361              if (tokens[0] == string("FLIGHT")) {
362                  //cerr << "Found flight " << buffString << " size is : " << tokens.size() << endl;
363                  if (tokens.size() != 10) {
364                      SG_LOG(SG_GENERAL, SG_ALERT, "Error parsing traffic file " << infileName.str() << " at " << buffString);
365                      exit(1);
366                  }
367                  string callsign = tokens[1];
368                  string fltrules = tokens[2];
369                  string weekdays = tokens[3];
370                  string departurePort = tokens[5];
371                  string arrivalPort   = tokens[7];
372                  int    cruiseAlt     = atoi(tokens[8].c_str());
373                  string depTimeGen    = tokens[4];
374                  string arrTimeGen    = tokens[6];
375                  string repeat        = "WEEK";
376                  string requiredAircraft = tokens[9];
377
378                  if (weekdays.size() != 7) {
379                      SG_LOG(SG_GENERAL, SG_ALERT, "Found misconfigured weekdays string" << weekdays);
380                      exit(1);
381                  }
382                  depTime.clear();
383                  arrTime.clear();
384                  Tokenize(depTimeGen, depTime, ":");
385                  Tokenize(arrTimeGen, arrTime, ":");
386                  double dep = atof(depTime[0].c_str()) + (atof(depTime[1].c_str()) / 60.0);
387                  double arr = atof(arrTime[0].c_str()) + (atof(arrTime[1].c_str()) / 60.0);
388                  //cerr << "Using " << dep << " " << arr << endl;
389                  bool arrivalWeekdayNeedsIncrement = false;
390                  if (arr < dep) {
391                        arrivalWeekdayNeedsIncrement = true;
392                  }
393                  for (int i = 0; i < 7; i++) {
394                      int j = i+1;
395                      if (weekdays[i] != '.') {
396                          char buffer[4];
397                          snprintf(buffer, 4, "%d/", j);
398                          string departureTime = string(buffer) + depTimeGen + string(":00");
399                          string arrivalTime;
400                          if (!arrivalWeekdayNeedsIncrement) {
401                              arrivalTime   = string(buffer) + arrTimeGen + string(":00");
402                          }
403                          if (arrivalWeekdayNeedsIncrement && i != 6 ) {
404                              snprintf(buffer, 4, "%d/", j+1);
405                              arrivalTime   = string(buffer) + arrTimeGen + string(":00");
406                          }
407                          if (arrivalWeekdayNeedsIncrement && i == 6 ) {
408                              snprintf(buffer, 4, "%d/", 0);
409                              arrivalTime   = string(buffer) + arrTimeGen  + string(":00");
410                          }
411                          SG_LOG(SG_GENERAL, SG_ALERT, "Adding flight " << callsign       << " "
412                                                       << fltrules       << " "
413                                                       <<  departurePort << " "
414                                                       <<  arrivalPort   << " "
415                                                       <<  cruiseAlt     << " "
416                                                       <<  departureTime << " "
417                                                       <<  arrivalTime   << " "
418                                                       << repeat        << " " 
419                                                       <<  requiredAircraft);
420
421                          flights[requiredAircraft].push_back(new FGScheduledFlight(callsign,
422                                                                  fltrules,
423                                                                  departurePort,
424                                                                  arrivalPort,
425                                                                  cruiseAlt,
426                                                                  departureTime,
427                                                                  arrivalTime,
428                                                                  repeat,
429                                                                  requiredAircraft));
430                     }
431                 }
432              }
433          }
434
435     }
436     //exit(1);
437 }
438
439
440 void FGTrafficManager::Tokenize(const string& str,
441                       vector<string>& tokens,
442                       const string& delimiters)
443 {
444     // Skip delimiters at beginning.
445     string::size_type lastPos = str.find_first_not_of(delimiters, 0);
446     // Find first "non-delimiter".
447     string::size_type pos     = str.find_first_of(delimiters, lastPos);
448
449     while (string::npos != pos || string::npos != lastPos)
450     {
451         // Found a token, add it to the vector.
452         tokens.push_back(str.substr(lastPos, pos - lastPos));
453         // Skip delimiters.  Note the "not_of"
454         lastPos = str.find_first_not_of(delimiters, pos);
455         // Find next "non-delimiter"
456         pos = str.find_first_of(delimiters, lastPos);
457     }
458 }
459
460
461 void FGTrafficManager::startXML()
462 {
463     //cout << "Start XML" << endl;
464     requiredAircraft = "";
465     homePort = "";
466 }
467
468 void FGTrafficManager::endXML()
469 {
470     //cout << "End XML" << endl;
471 }
472
473 void FGTrafficManager::startElement(const char *name,
474                                     const XMLAttributes & atts)
475 {
476     const char *attval;
477     //cout << "Start element " << name << endl;
478     //FGTrafficManager temp;
479     //for (int i = 0; i < atts.size(); i++)
480     //  if (string(atts.getName(i)) == string("include"))
481     attval = atts.getValue("include");
482     if (attval != 0) {
483         //cout << "including " << attval << endl;
484         SGPath path = globals->get_fg_root();
485         path.append("/Traffic/");
486         path.append(attval);
487         readXML(path.str(), *this);
488     }
489     elementValueStack.push_back("");
490     //  cout << "  " << atts.getName(i) << '=' << atts.getValue(i) << endl; 
491 }
492
493 void FGTrafficManager::endElement(const char *name)
494 {
495     //cout << "End element " << name << endl;
496     const string & value = elementValueStack.back();
497
498     if (!strcmp(name, "model"))
499         mdl = value;
500     else if (!strcmp(name, "livery"))
501         livery = value;
502     else if (!strcmp(name, "home-port"))
503         homePort = value;
504     else if (!strcmp(name, "registration"))
505         registration = value;
506     else if (!strcmp(name, "airline"))
507         airline = value;
508     else if (!strcmp(name, "actype"))
509         acType = value;
510     else if (!strcmp(name, "required-aircraft"))
511         requiredAircraft = value;
512     else if (!strcmp(name, "flighttype"))
513         flighttype = value;
514     else if (!strcmp(name, "radius"))
515         radius = atoi(value.c_str());
516     else if (!strcmp(name, "offset"))
517         offset = atoi(value.c_str());
518     else if (!strcmp(name, "performance-class"))
519         m_class = value;
520     else if (!strcmp(name, "heavy")) {
521         if (value == string("true"))
522             heavy = true;
523         else
524             heavy = false;
525     } else if (!strcmp(name, "callsign"))
526         callsign = value;
527     else if (!strcmp(name, "fltrules"))
528         fltrules = value;
529     else if (!strcmp(name, "port"))
530         port = value;
531     else if (!strcmp(name, "time"))
532         timeString = value;
533     else if (!strcmp(name, "departure")) {
534         departurePort = port;
535         departureTime = timeString;
536     } else if (!strcmp(name, "cruise-alt"))
537         cruiseAlt = atoi(value.c_str());
538     else if (!strcmp(name, "arrival")) {
539         arrivalPort = port;
540         arrivalTime = timeString;
541     } else if (!strcmp(name, "repeat"))
542         repeat = value;
543     else if (!strcmp(name, "flight")) {
544         // We have loaded and parsed all the information belonging to this flight
545         // so we temporarily store it. 
546         //cerr << "Pusing back flight " << callsign << endl;
547         //cerr << callsign  <<  " " << fltrules     << " "<< departurePort << " " <<  arrivalPort << " "
548         //   << cruiseAlt <<  " " << departureTime<< " "<< arrivalTime   << " " << repeat << endl;
549
550         //Prioritize aircraft 
551         string apt = fgGetString("/sim/presets/airport-id");
552         //cerr << "Airport information: " << apt << " " << departurePort << " " << arrivalPort << endl;
553         //if (departurePort == apt) score++;
554         //flights.push_back(new FGScheduledFlight(callsign,
555         //                                fltrules,
556         //                                departurePort,
557         //                                arrivalPort,
558         //                                cruiseAlt,
559         //                                departureTime,
560         //                                arrivalTime,
561         //                                repeat));
562         if (requiredAircraft == "") {
563             char buffer[16];
564             snprintf(buffer, 16, "%d", acCounter);
565             requiredAircraft = buffer;
566         }
567         SG_LOG(SG_GENERAL, SG_DEBUG, "Adding flight: " << callsign << " "
568                << fltrules << " "
569                << departurePort << " "
570                << arrivalPort << " "
571                << cruiseAlt << " "
572                << departureTime << " "
573                << arrivalTime << " " << repeat << " " << requiredAircraft);
574         // For database maintainance purposes, it may be convenient to
575         // 
576         if (fgGetBool("/sim/traffic-manager/dumpdata") == true) {
577              SG_LOG(SG_GENERAL, SG_ALERT, "Traffic Dump FLIGHT," << callsign << ","
578                           << fltrules << ","
579                           << departurePort << ","
580                           << arrivalPort << ","
581                           << cruiseAlt << ","
582                           << departureTime << ","
583                           << arrivalTime << "," << repeat << "," << requiredAircraft);
584         }
585         flights[requiredAircraft].push_back(new FGScheduledFlight(callsign,
586                                                                   fltrules,
587                                                                   departurePort,
588                                                                   arrivalPort,
589                                                                   cruiseAlt,
590                                                                   departureTime,
591                                                                   arrivalTime,
592                                                                   repeat,
593                                                                   requiredAircraft));
594         requiredAircraft = "";
595     } else if (!strcmp(name, "aircraft")) {
596         string isHeavy;
597         if (heavy) {
598             isHeavy = "true";
599         } else {
600             isHeavy = "false"; 
601         }
602         /*
603         cerr << "Traffic Dump AC," << homePort << "," << registration << "," << requiredAircraft 
604              << "," << acType << "," << livery << "," 
605              << airline << "," << offset << "," << radius << "," << flighttype << "," << isHeavy << "," << mdl << endl;*/
606         int proportion =
607             (int) (fgGetDouble("/sim/traffic-manager/proportion") * 100);
608         int randval = rand() & 100;
609         if (randval <= proportion) {
610             if (fgGetBool("/sim/traffic-manager/dumpdata") == true) {
611                 SG_LOG(SG_GENERAL, SG_ALERT, "Traffic Dump AC," << homePort << "," << registration << "," << requiredAircraft 
612                  << "," << acType << "," << livery << "," 
613                  << airline << ","  << m_class << "," << offset << "," << radius << "," << flighttype << "," << isHeavy << "," << mdl);
614             }
615             //scheduledAircraft.push_back(new FGAISchedule(mdl, 
616             //                                     livery, 
617             //                                     registration, 
618             //                                     heavy,
619             //                                     acType, 
620             //                                     airline, 
621             //                                     m_class, 
622             //                                     flighttype,
623             //                                     radius,
624             //                                     offset,
625             //                                     score,
626             //                                     flights));
627             if (requiredAircraft == "") {
628                 char buffer[16];
629                 snprintf(buffer, 16, "%d", acCounter);
630                 requiredAircraft = buffer;
631             }
632             if (homePort == "") {
633                 homePort = departurePort;
634             }
635             scheduledAircraft.push_back(new FGAISchedule(mdl,
636                                                          livery,
637                                                          homePort,
638                                                          registration,
639                                                          requiredAircraft,
640                                                          heavy,
641                                                          acType,
642                                                          airline,
643                                                          m_class,
644                                                          flighttype,
645                                                          radius, offset));
646
647             //  while(flights.begin() != flights.end()) {
648 //      flights.pop_back();
649 //       }
650         } else {
651             cerr << "Skipping : " << randval;
652         }
653         acCounter++;
654         requiredAircraft = "";
655         homePort = "";
656         //for (FGScheduledFlightVecIterator flt = flights.begin(); flt != flights.end(); flt++)
657         //  {
658         //    delete (*flt);
659         //  }
660         //flights.clear();
661         SG_LOG(SG_GENERAL, SG_BULK, "Reading aircraft : "
662                << registration << " with prioritization score " << score);
663         score = 0;
664     }
665     elementValueStack.pop_back();
666 }
667
668 void FGTrafficManager::data(const char *s, int len)
669 {
670     string token = string(s, len);
671     //cout << "Character data " << string(s,len) << endl;
672     elementValueStack.back() += token;
673 }
674
675 void FGTrafficManager::pi(const char *target, const char *data)
676 {
677     //cout << "Processing instruction " << target << ' ' << data << endl;
678 }
679
680 void FGTrafficManager::warning(const char *message, int line, int column)
681 {
682     SG_LOG(SG_IO, SG_WARN,
683            "Warning: " << message << " (" << line << ',' << column << ')');
684 }
685
686 void FGTrafficManager::error(const char *message, int line, int column)
687 {
688     SG_LOG(SG_IO, SG_ALERT,
689            "Error: " << message << " (" << line << ',' << column << ')');
690 }