X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FAIModel%2FAIFlightPlan.hxx;h=e5e4bb10db4090f3b77f281d429954de4101ec4b;hb=b1854459b3100e4c51e3a5704caa4e2c3869228c;hp=fd39683056aa4d42f88a84d768dc37ac0da0e3cf;hpb=f5c2c630ebe3599f2b72dc4e0bca2ad427767b80;p=flightgear.git diff --git a/src/AIModel/AIFlightPlan.hxx b/src/AIModel/AIFlightPlan.hxx index fd3968305..e5e4bb10d 100644 --- a/src/AIModel/AIFlightPlan.hxx +++ b/src/AIModel/AIFlightPlan.hxx @@ -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 St, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef _FG_AIFLIGHTPLAN_HXX #define _FG_AIFLIGHTPLAN_HXX @@ -30,11 +30,8 @@ class FGAIAircraft; class FGAirport; class SGGeod; -class FGAIFlightPlan { - -public: - - typedef struct { +class FGAIWaypoint { +private: std::string name; double latitude; double longitude; @@ -47,10 +44,52 @@ public: bool on_ground; int routeIndex; // For AI/ATC purposes; double time_sec; - double trackLength; // distance from previous waypoint (for AI purposes); + double trackLength; // distance from previous FGAIWaypoint (for AI purposes); std::string time; - } waypoint; +public: + FGAIWaypoint(); + ~FGAIWaypoint() {}; + void setName (std::string nam) { name = nam; }; + void setLatitude (double lat) { latitude = lat; }; + void setLongitude (double lon) { longitude = lon; }; + void setAltitude (double alt) { altitude = alt; }; + void setSpeed (double spd) { speed = spd; }; + void setCrossat (double val) { crossat = val; }; + void setFinished (bool fin) { finished = fin; }; + void setGear_down (bool grd) { gear_down = grd; }; + void setFlaps_down (bool fld) { flaps_down = fld; }; + void setOn_ground (bool grn) { on_ground = grn; }; + void setRouteIndex (int rte) { routeIndex = rte; }; + void setTime_sec (double ts ) { time_sec = ts; }; + void setTrackLength (double tl ) { trackLength = tl; }; + void setTime (std::string tme) { time = tme; }; + + bool contains(std::string name); + + std::string getName () { return name; }; + double getLatitude () { return latitude; }; + double getLongitude () { return longitude; }; + double getAltitude () { return altitude; }; + double getSpeed () { return speed; }; + + double getCrossat () { return crossat; }; + bool getGear_down () { return gear_down; }; + bool getFlaps_down () { return flaps_down; }; + bool getOn_ground () { return on_ground; }; + int getRouteIndex () { return routeIndex; }; + bool isFinished () { return finished; }; + double getTime_sec () { return time_sec; }; + double getTrackLength() { return trackLength; }; + std::string getTime () { return time; }; + + }; + + +class FGAIFlightPlan { + +public: + FGAIFlightPlan(); FGAIFlightPlan(const std::string& filename); FGAIFlightPlan(FGAIAircraft *, @@ -70,29 +109,34 @@ public: const std::string& airline); ~FGAIFlightPlan(); - waypoint* const getPreviousWaypoint( void ) const; - waypoint* const getCurrentWaypoint( void ) const; - waypoint* const getNextWaypoint( void ) const; + FGAIWaypoint* const getPreviousWaypoint( void ) const; + FGAIWaypoint* const getCurrentWaypoint( void ) const; + FGAIWaypoint* const getNextWaypoint( void ) const; void IncrementWaypoint( bool erase ); void DecrementWaypoint( bool erase ); - double getDistanceToGo(double lat, double lon, waypoint* wp) const; + double getDistanceToGo(double lat, double lon, FGAIWaypoint* wp) const; int getLeg () const { return leg;}; - void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next); + + void setLeadDistance(double speed, double bearing, FGAIWaypoint* current, FGAIWaypoint* next); void setLeadDistance(double distance_ft); double getLeadDistance( void ) const {return lead_distance;} - double getBearing(waypoint* previous, waypoint* next) const; - double getBearing(double lat, double lon, waypoint* next) const; + double getBearing(FGAIWaypoint* previous, FGAIWaypoint* next) const; + double getBearing(double lat, double lon, FGAIWaypoint* next) const; double checkTrackLength(std::string wptName); time_t getStartTime() const { return start_time; } time_t getArrivalTime() const { return arrivalTime; } - void create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon, + bool create(FGAIAircraft *, FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon, bool firstLeg, double radius, const std::string& fltType, const std::string& aircraftType, const std::string& airline, double distance); + bool createPushBack(FGAIAircraft *, bool, FGAirport*, double radius, const std::string&, const std::string&, const std::string&); + bool createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const std::string&); void setLeg(int val) { leg = val;} void setTime(time_t st) { start_time = st; } int getGate() const { return gateId; } + void setGate(int id) { gateId = id; }; + double getLeadInAngle() const { return leadInAngle; } const std::string& getRunway() const; @@ -106,21 +150,26 @@ public: std::string getRunway() { return activeRunway; } bool isActive(time_t time) {return time >= this->getStartTime();} + void incrementLeg() { leg++;}; + void setRunway(std::string rwy) { activeRunway = rwy; }; std::string getRunwayClassFromTrafficType(std::string fltType); - void addWaypoint(waypoint* wpt) { waypoints.push_back(wpt); }; + void addWaypoint(FGAIWaypoint* wpt) { waypoints.push_back(wpt); }; void setName(std::string n) { name = n; }; std::string getName() { return name; }; void setSID(FGAIFlightPlan* fp) { sid = fp;}; FGAIFlightPlan* getSID() { return sid; }; + FGAIWaypoint *getWayPoint(int i) { return waypoints[i]; }; + FGAIWaypoint *getLastWaypoint() { return waypoints.back(); }; + + void shortenToFirst(unsigned int number, std::string name); private: - FGRunway* rwy; FGAIFlightPlan *sid; - typedef std::vector wpt_vector_type; + typedef std::vector wpt_vector_type; typedef wpt_vector_type::const_iterator wpt_vector_iterator; @@ -138,29 +187,30 @@ private: std::string activeRunway; FGTaxiRoute *taxiRoute; std::string name; - - void createPushBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&); - void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double, double, double, const std::string&, const std::string&, const std::string&); - void createTakeOff(FGAIAircraft *, bool, FGAirport *, double, const std::string&); - void createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const std::string&); - void createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const std::string&); - void createDescent(FGAIAircraft *, FGAirport *, double latitude, double longitude, double speed, double alt,const std::string&, double distance); - void createLanding(FGAIAircraft *, FGAirport *, const std::string&); - void createParking(FGAIAircraft *, FGAirport *, double radius); + bool isValid; + + void createPushBackFallBack(FGAIAircraft *, bool, FGAirport*, double radius, const std::string&, const std::string&, const std::string&); + bool createClimb(FGAIAircraft *, bool, FGAirport *, double, double, const std::string&); + bool createCruise(FGAIAircraft *, bool, FGAirport*, FGAirport*, double, double, double, double, const std::string&); + bool createDescent(FGAIAircraft *, FGAirport *, double latitude, double longitude, double speed, double alt,const std::string&, double distance); + bool createLanding(FGAIAircraft *, FGAirport *, const std::string&); + bool createParking(FGAIAircraft *, FGAirport *, double radius); void deleteWaypoints(); void resetWaypoints(); + void eraseLastWaypoint(); + void pushBackWaypoint(FGAIWaypoint *wpt); - void createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline); + bool createLandingTaxi(FGAIAircraft *, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline); void createDefaultLandingTaxi(FGAIAircraft *, FGAirport* aAirport); void createDefaultTakeoffTaxi(FGAIAircraft *, FGAirport* aAirport, FGRunway* aRunway); - void createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline); + bool createTakeoffTaxi(FGAIAircraft *, bool firstFlight, FGAirport *apt, double radius, const std::string& fltType, const std::string& acType, const std::string& airline); double getTurnRadius(double, bool); - waypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed); - waypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed); - waypoint* cloneWithPos(FGAIAircraft *, waypoint* aWpt, const std::string& aName, const SGGeod& aPos); - waypoint* clone(waypoint* aWpt); + FGAIWaypoint* createOnGround(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed); + FGAIWaypoint* createInAir(FGAIAircraft *, const std::string& aName, const SGGeod& aPos, double aElev, double aSpeed); + FGAIWaypoint* cloneWithPos(FGAIAircraft *, FGAIWaypoint* aWpt, const std::string& aName, const SGGeod& aPos); + FGAIWaypoint* clone(FGAIWaypoint* aWpt); //void createCruiseFallback(bool, FGAirport*, FGAirport*, double, double, double, double); @@ -168,7 +218,7 @@ private: public: wpt_vector_iterator getFirstWayPoint() { return waypoints.begin(); }; wpt_vector_iterator getLastWayPoint() { return waypoints.end(); }; - -}; + bool isValidPlan() { return isValid; }; +}; #endif // _FG_AIFLIGHTPLAN_HXX