]> git.mxchange.org Git - flightgear.git/blobdiff - src/Traffic/Schedule.hxx
Update VS2008 projects : use Boost 1.44.0 available in last 3rd Party archive
[flightgear.git] / src / Traffic / Schedule.hxx
index a919a7a5b4bc5292967868272244308017dbcb0c..cc80e40805a2a9d9878525302d514b4f37b6bd11 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *
  **************************************************************************/
 #ifndef _FGSCHEDULE_HXX_
 #define _FGSCHEDULE_HXX_
 
+#define TRAFFICTOAIDISTTOSTART 150.0
+#define TRAFFICTOAIDISTTODIE   200.0
 
 
 class FGAISchedule
 {
  private:
   string modelPath;
+  string homePort;
   string livery;
   string registration;
+  string airline;
+  string acType;
+  string m_class;
+  string flightType;
+  string flightIdentifier;
+  string currentDestination;
   bool heavy;
   FGScheduledFlightVec flights;
-  float lat;
-  float lon; 
-  void* AIManagerRef;
+  SGGeod position;
+  double radius;
+  double groundOffset;
+  double distanceToUser;
+  int AIManagerRef;
+  double score;
+  unsigned int runCount;
+  unsigned int hits;
   bool firstRun;
+  double courseToDest;
+  bool initialized;
 
-
+  void scheduleFlights();
+  
+  /**
+   * Transition this schedule from distant mode to AI mode;
+   * create the AIAircraft (and flight plan) and register with the AIManager
+   */
+  bool createAIAircraft(FGScheduledFlight* flight, double speedKnots, time_t deptime);
+  
  public:
   FGAISchedule();                                           // constructor
-  FGAISchedule(string, string, string, bool, FGScheduledFlightVec);  // construct & init
-  FGAISchedule(const FGAISchedule &other);             // copy constructor
+  FGAISchedule(string model, 
+               string livery,
+               string homePort, 
+               string registration, 
+               string flightId,
+               bool   heavy, 
+               string acType, 
+               string airline, 
+               string m_class, 
+               string flight_type, 
+               double radius, 
+               double offset);                              // construct & init
+  FGAISchedule(const FGAISchedule &other);                  // copy constructor
+
+
 
   ~FGAISchedule(); //destructor
 
-  void update(time_t now);
-  void next();   // forces the schedule to move on to the next flight.
+  bool update(time_t now, const SGVec3d& userCart);
+  bool init();
 
-  time_t      getDepartureTime    () { return flights.begin()->getDepartureTime   (); };
-  FGAirport * getDepartureAirport () { return flights.begin()->getDepartureAirport(); };
-  FGAirport * getArrivalAirport   () { return flights.begin()->getArrivalAirport  (); };
-  int         getCruiseAlt        () { return flights.begin()->getCruiseAlt       (); };
-  // More member functions follow later
+  double getSpeed         ();
+  //void setClosestDistanceToUser();
+  bool next();   // forces the schedule to move on to the next flight.
+
+  // TODO: rework these four functions
+   time_t      getDepartureTime    () { return (*flights.begin())->getDepartureTime   (); };
+  FGAirport * getDepartureAirport () { return (*flights.begin())->getDepartureAirport(); };
+  FGAirport * getArrivalAirport   () { return (*flights.begin())->getArrivalAirport  (); };
+  int         getCruiseAlt        () { return (*flights.begin())->getCruiseAlt       (); };
+  double      getRadius           () { return radius; };
+  double      getGroundOffset     () { return groundOffset;};
+  const string& getFlightType     () { return flightType;};
+  const string& getAirline        () { return airline; };
+  const string& getAircraft       () { return acType; };
+  const string& getCallSign       () { return (*flights.begin())->getCallSign (); };
+  const string& getRegistration   () { return registration;};
+  const string& getFlightRules    () { return (*flights.begin())->getFlightRules (); };
+  bool getHeavy                   () { return heavy; };
+  double getCourse                () { return courseToDest; };
+  unsigned int getRunCount        () { return runCount; };
+  unsigned int getHits            () { return hits; };
+
+  void         setrunCount(unsigned int count) { runCount = count; };
+  void         setHits    (unsigned int count) { hits     = count; };
+  void         setScore   ();
+  double       getScore   () { return score; };
+  FGScheduledFlight*findAvailableFlight (const string &currentDestination, const string &req);
+  // used to sort in decending order of score: I've probably found a better way to
+  // decending order sorting, but still need to test that.
+  bool operator< (const FGAISchedule &other) const { return (score > other.score); };
+  //void * getAiRef                 () { return AIManagerRef; };
+  //FGAISchedule* getAddress        () { return this;};
 
 };
 
-typedef vector<FGAISchedule>           ScheduleVector;
-typedef vector<FGAISchedule>::iterator ScheduleVectorIterator;
+typedef vector<FGAISchedule*>           ScheduleVector;
+typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator;
+
+bool compareSchedules(FGAISchedule*a, FGAISchedule*b);
 
 #endif