1 /* -*- Mode: C++ -*- *****************************************************
3 * Written by Durk Talsma. Started May 5, 2004
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.
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.
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.
20 **************************************************************************/
22 /**************************************************************************
23 * This file contains the definition of the class Shedule.
25 * A schedule is basically a number of scheduled flights, wich can be
26 * assigned to an AI aircraft.
27 **************************************************************************/
29 #ifndef _FGSCHEDULE_HXX_
30 #define _FGSCHEDULE_HXX_
32 #define TRAFFICTOAIDISTTOSTART 150.0
33 #define TRAFFICTOAIDISTTODIE 200.0
47 string flightIdentifier;
48 string currentDestination;
50 FGScheduledFlightVec flights;
54 double distanceToUser;
57 unsigned int runCount;
65 void scheduleFlights(time_t now);
66 int groundTimeFromRadius();
69 * Transition this schedule from distant mode to AI mode;
70 * create the AIAircraft (and flight plan) and register with the AIManager
72 bool createAIAircraft(FGScheduledFlight* flight, double speedKnots, time_t deptime);
75 FGAISchedule(); // constructor
76 FGAISchedule(string model,
87 double offset); // construct & init
88 FGAISchedule(const FGAISchedule &other); // copy constructor
92 ~FGAISchedule(); //destructor
94 static bool validModelPath(const std::string& model);
96 bool update(time_t now, const SGVec3d& userCart);
100 //void setClosestDistanceToUser();
101 bool next(); // forces the schedule to move on to the next flight.
103 // TODO: rework these four functions
104 time_t getDepartureTime () { return (*flights.begin())->getDepartureTime (); };
105 FGAirport * getDepartureAirport () { return (*flights.begin())->getDepartureAirport(); };
106 FGAirport * getArrivalAirport () { return (*flights.begin())->getArrivalAirport (); };
107 int getCruiseAlt () { return (*flights.begin())->getCruiseAlt (); };
108 double getRadius () { return radius; };
109 double getGroundOffset () { return groundOffset;};
110 const string& getFlightType () { return flightType;};
111 const string& getAirline () { return airline; };
112 const string& getAircraft () { return acType; };
113 const string& getCallSign () { return (*flights.begin())->getCallSign (); };
114 const string& getRegistration () { return registration;};
115 const string& getFlightRules () { return (*flights.begin())->getFlightRules (); };
116 bool getHeavy () { return heavy; };
117 double getCourse () { return courseToDest; };
118 unsigned int getRunCount () { return runCount; };
119 unsigned int getHits () { return hits; };
121 void setrunCount(unsigned int count) { runCount = count; };
122 void setHits (unsigned int count) { hits = count; };
124 double getScore () { return score; };
126 void assign (FGScheduledFlight *ref) { flights.push_back(ref); };
127 void setFlightType (string val ) { flightType = val; };
128 FGScheduledFlight*findAvailableFlight (const string ¤tDestination, const string &req, time_t min=0, time_t max=0);
129 // used to sort in decending order of score: I've probably found a better way to
130 // decending order sorting, but still need to test that.
131 bool operator< (const FGAISchedule &other) const;
132 void taint() { valid = false; };
133 int getLastUsed() { return lastRun; };
134 void setLastUsed(unsigned int val) {lastRun = val; };
135 //void * getAiRef () { return AIManagerRef; };
136 //FGAISchedule* getAddress () { return this;};
140 typedef vector<FGAISchedule*> ScheduleVector;
141 typedef vector<FGAISchedule*>::iterator ScheduleVectorIterator;
143 bool compareSchedules(FGAISchedule*a, FGAISchedule*b);