2004-05-15 09:07:55 +00:00
|
|
|
// FGAIFlightPlan - class for loading and storing AI flight plans
|
|
|
|
// Written by David Culp, started May 2004
|
|
|
|
// - davidculp2@comcast.net
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
#ifndef _FG_AIFLIGHTPLAN_HXX
|
|
|
|
#define _FG_AIFLIGHTPLAN_HXX
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2004-07-22 18:50:29 +00:00
|
|
|
|
|
|
|
#include <Airports/simple.hxx>
|
2005-02-10 09:01:51 +00:00
|
|
|
#include <Airports/runways.hxx>
|
2004-07-22 18:50:29 +00:00
|
|
|
|
2004-09-07 09:53:23 +00:00
|
|
|
#include "AIBase.hxx"
|
|
|
|
|
2004-05-15 09:07:55 +00:00
|
|
|
SG_USING_STD(vector);
|
|
|
|
SG_USING_STD(string);
|
|
|
|
|
|
|
|
|
|
|
|
class FGAIFlightPlan {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
string name;
|
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double altitude;
|
|
|
|
double speed;
|
|
|
|
double crossat;
|
2004-05-18 09:09:08 +00:00
|
|
|
bool finished;
|
2004-05-15 09:07:55 +00:00
|
|
|
bool gear_down;
|
|
|
|
bool flaps_down;
|
2004-05-21 16:50:19 +00:00
|
|
|
bool on_ground;
|
2004-05-15 09:07:55 +00:00
|
|
|
} waypoint;
|
|
|
|
|
2005-10-25 13:49:55 +00:00
|
|
|
FGAIFlightPlan(const string& filename);
|
2004-09-07 09:53:23 +00:00
|
|
|
FGAIFlightPlan(FGAIModelEntity *entity,
|
2004-07-22 18:50:29 +00:00
|
|
|
double course,
|
2004-11-29 09:41:43 +00:00
|
|
|
time_t start,
|
2004-07-22 18:50:29 +00:00
|
|
|
FGAirport *dep,
|
2005-02-10 09:01:51 +00:00
|
|
|
FGAirport *arr,
|
|
|
|
bool firstLeg,
|
|
|
|
double radius,
|
2005-10-25 13:49:55 +00:00
|
|
|
const string& fltType,
|
|
|
|
const string& acType,
|
|
|
|
const string& airline);
|
2004-05-15 09:07:55 +00:00
|
|
|
~FGAIFlightPlan();
|
|
|
|
|
2005-10-26 09:03:49 +00:00
|
|
|
waypoint* const getPreviousWaypoint( void ) const;
|
|
|
|
waypoint* const getCurrentWaypoint( void ) const;
|
|
|
|
waypoint* const getNextWaypoint( void ) const;
|
2005-02-10 09:01:51 +00:00
|
|
|
void IncrementWaypoint( bool erase );
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-10-26 09:03:49 +00:00
|
|
|
double getDistanceToGo(double lat, double lon, waypoint* wp) const;
|
|
|
|
int getLeg () const { return leg;};
|
2004-05-15 09:07:55 +00:00
|
|
|
void setLeadDistance(double speed, double bearing, waypoint* current, waypoint* next);
|
|
|
|
void setLeadDistance(double distance_ft);
|
|
|
|
double getLeadDistance( void ) const {return lead_distance;}
|
2005-10-26 09:03:49 +00:00
|
|
|
double getBearing(waypoint* previous, waypoint* next) const;
|
|
|
|
double getBearing(double lat, double lon, waypoint* next) const;
|
|
|
|
time_t getStartTime() const { return start_time; };
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
void create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
|
2005-10-25 13:49:55 +00:00
|
|
|
bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
|
2004-07-22 18:50:29 +00:00
|
|
|
|
2005-02-10 09:01:51 +00:00
|
|
|
void setLeg(int val) { leg = val;};
|
|
|
|
void setTime(time_t st) { start_time = st; };
|
2005-10-26 09:03:49 +00:00
|
|
|
int getGate() const { return gateId; };
|
|
|
|
double getLeadInAngle() const { return leadInAngle; };
|
|
|
|
const string& getRunway() const { return rwy._rwy_no; };
|
|
|
|
const string& getRunwayId() const { return rwy._id; };
|
2005-06-04 09:38:52 +00:00
|
|
|
void setRepeat(bool r) { repeat = r; };
|
2005-10-26 09:03:49 +00:00
|
|
|
bool getRepeat(void) const { return repeat; };
|
2005-06-04 09:38:52 +00:00
|
|
|
void restart(void);
|
|
|
|
|
2004-05-15 09:07:55 +00:00
|
|
|
private:
|
2005-02-10 09:01:51 +00:00
|
|
|
FGRunway rwy;
|
2005-06-04 09:38:52 +00:00
|
|
|
typedef vector <waypoint*> wpt_vector_type;
|
2005-10-26 09:03:49 +00:00
|
|
|
typedef wpt_vector_type::const_iterator wpt_vector_iterator;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-06-04 09:38:52 +00:00
|
|
|
wpt_vector_type waypoints;
|
|
|
|
wpt_vector_iterator wpt_iterator;
|
2004-05-15 09:07:55 +00:00
|
|
|
|
2005-06-04 09:38:52 +00:00
|
|
|
bool repeat;
|
|
|
|
double distance_to_go;
|
|
|
|
double lead_distance;
|
2005-02-10 09:01:51 +00:00
|
|
|
double leadInAngle;
|
2005-06-04 09:38:52 +00:00
|
|
|
time_t start_time;
|
2005-02-10 09:01:51 +00:00
|
|
|
int leg;
|
|
|
|
int gateId;
|
2005-10-18 18:44:37 +00:00
|
|
|
string activeRunway;
|
2005-02-10 09:01:51 +00:00
|
|
|
|
2005-10-25 13:49:55 +00:00
|
|
|
void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
|
|
|
|
void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
|
2005-02-10 09:01:51 +00:00
|
|
|
void createTakeOff(bool, FGAirport *, double);
|
|
|
|
void createClimb(bool, FGAirport *, double, double);
|
|
|
|
void createCruise(bool, FGAirport*, FGAirport*, double, double, double, double);
|
|
|
|
void createDecent(FGAirport *);
|
|
|
|
void createLanding(FGAirport *);
|
|
|
|
void createParking(FGAirport *);
|
|
|
|
void deleteWaypoints();
|
|
|
|
void resetWaypoints();
|
2004-05-15 09:07:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_AIFLIGHTPLAN_HXX
|