X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FAutopilot%2Froute_mgr.hxx;h=a8168924807a5ec582759dfd63becd271d527ce6;hb=7563ece882247d1fa5ae105c8445d93048da041b;hp=21e095086fbcb88e8658ae2eed9a2a11af9628cf;hpb=d05121ef4689d2b50b3fe1848cbb0d1f5a1db877;p=flightgear.git diff --git a/src/Autopilot/route_mgr.hxx b/src/Autopilot/route_mgr.hxx index 21e095086..a81689248 100644 --- a/src/Autopilot/route_mgr.hxx +++ b/src/Autopilot/route_mgr.hxx @@ -16,7 +16,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. // // $Id$ @@ -24,26 +24,16 @@ #ifndef _ROUTE_MGR_HXX #define _ROUTE_MGR_HXX 1 -#ifndef __cplusplus -# error This library requires C++ -#endif - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include STL_STRING -#include - -SG_USING_STD(string); -SG_USING_STD(vector); - #include -#include +#include #include +// forward decls +class SGRoute; +class SGPath; + +class FGAirport; +typedef SGSharedPtr FGAirportRef; /** * Top level route manager class @@ -54,55 +44,163 @@ class FGRouteMgr : public SGSubsystem { private: - - SGRoute *route; - + SGRoute* _route; + time_t _takeoffTime; + time_t _touchdownTime; + FGAirportRef _departure; + FGAirportRef _destination; + // automatic inputs - SGPropertyNode *lon; - SGPropertyNode *lat; - SGPropertyNode *alt; - - // automatic outputs - SGPropertyNode *true_hdg_deg; - - SGPropertyNode *wp0_id; - SGPropertyNode *wp0_dist; - SGPropertyNode *wp0_eta; - - SGPropertyNode *wp1_id; - SGPropertyNode *wp1_dist; - SGPropertyNode *wp1_eta; - - SGPropertyNode *wpn_id; - SGPropertyNode *wpn_dist; - SGPropertyNode *wpn_eta; - - + SGPropertyNode_ptr lon; + SGPropertyNode_ptr lat; + SGPropertyNode_ptr alt; + SGPropertyNode_ptr magvar; + + // automatic outputs + SGPropertyNode_ptr departure; ///< departure airport information + SGPropertyNode_ptr destination; ///< destination airport information + SGPropertyNode_ptr alternate; ///< alternate airport information + SGPropertyNode_ptr cruise; ///< cruise information + + SGPropertyNode_ptr totalDistance; + SGPropertyNode_ptr ete; + SGPropertyNode_ptr elapsedFlightTime; + + SGPropertyNode_ptr active; + SGPropertyNode_ptr airborne; + + SGPropertyNode_ptr wp0; + SGPropertyNode_ptr wp1; + SGPropertyNode_ptr wpn; + + + SGPropertyNode_ptr _pathNode; + SGPropertyNode_ptr _currentWpt; + + + /** + * Signal property to notify people that the route was edited + */ + SGPropertyNode_ptr _edited; + + /** + * Signal property to notify when the last waypoint is reached + */ + SGPropertyNode_ptr _finished; + + void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance); + + class InputListener : public SGPropertyChangeListener { + public: + InputListener(FGRouteMgr *m) : mgr(m) {} + virtual void valueChanged (SGPropertyNode * prop); + private: + FGRouteMgr *mgr; + }; + + SGPropertyNode_ptr input; + SGPropertyNode_ptr weightOnWheels; + + InputListener *listener; + SGPropertyNode_ptr mirror; + + /** + * Create a SGWayPoint from a string in the following format: + * - simple identifier + * - decimal-lon,decimal-lat + * - airport-id/runway-id + * - navaid/radial-deg/offset-nm + */ + SGWayPoint* make_waypoint(const string& target); + + /** + * Helper to keep various pieces of state in sync when the SGRoute is + * modified (waypoints added, inserted, removed). Notably, this fires the + * 'edited' signal. + */ + void waypointsChanged(); + + void update_mirror(); + + void currentWaypointChanged(); + + /** + * Parse a route/wp node (from a saved, property-lsit formatted route) + */ + void parseRouteWaypoint(SGPropertyNode* aWP); + + /** + * Check if we've reached the final waypoint. + * Returns true if we have. + */ + bool checkFinished(); + +// tied getters and setters + const char* getDepartureICAO() const; + const char* getDepartureName() const; + void setDepartureICAO(const char* aIdent); + + const char* getDestinationICAO() const; + const char* getDestinationName() const; + void setDestinationICAO(const char* aIdent); + public: FGRouteMgr(); ~FGRouteMgr(); void init (); + void postinit (); void bind (); void unbind (); void update (double dt); bool build (); - void add_waypoint( SGWayPoint wp ) { - route->add_waypoint( wp ); - } - - SGWayPoint get_waypoint( int i ) const { - return route->get_waypoint(i); - } - - SGWayPoint pop_waypoint(); - - int size() const { - return route->size(); - } + void new_waypoint( const string& tgt_alt, int n = -1 ); + void add_waypoint( const SGWayPoint& wp, int n = -1 ); + SGWayPoint pop_waypoint( int i = 0 ); + + SGWayPoint get_waypoint( int i ) const; + int size() const; + + bool isRouteActive() const; + + int currentWaypoint() const; + + /** + * Find a waypoint in the route, by position, and return its index, or + * -1 if no matching waypoint was found in the route. + */ + int findWaypoint(const SGGeod& aPos) const; + + /** + * Activate a built route. This checks for various mandatory pieces of + * data, such as departure and destination airports, and creates waypoints + * for them on the route structure. + * + * returns true if the route was activated successfully, or false if the + * route could not be activated for some reason + */ + bool activate(); + + /** + * Step to the next waypoint on the active route + */ + void sequence(); + + /** + * + */ + void jumpToIndex(int index); + + /** + * + */ + void setWaypointTargetAltitudeFt(unsigned int index, int altFt); + + void saveRoute(); + void loadRoute(); };