From f7b844f4d648fc48718c17ee83f6f041174dc999 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 16 Jan 2001 20:21:03 +0000 Subject: [PATCH] More property manager interface updates. --- src/Cockpit/hud.cxx | 4 +- src/FDM/flight.cxx | 95 ++++++++++++++++++++++++++++++++++++++++++++ src/FDM/flight.hxx | 53 ++++++++++++++++++++++-- src/Main/bfi.cxx | 26 ++++++------ src/Main/bfi.hxx | 40 ------------------- src/Main/fg_init.cxx | 34 +++++++++------- 6 files changed, 179 insertions(+), 73 deletions(-) diff --git a/src/Cockpit/hud.cxx b/src/Cockpit/hud.cxx index f6097b947..fa6f25f4d 100644 --- a/src/Cockpit/hud.cxx +++ b/src/Cockpit/hud.cxx @@ -762,7 +762,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ ) } //$$$ End - added, Neetha, 28 Nov 2k -int global_day_night_switch = DAY; +static int global_day_night_switch = DAY; void HUD_masterswitch( bool incr ) { @@ -770,7 +770,7 @@ void HUD_masterswitch( bool incr ) if ( global_day_night_switch == DAY ) { global_day_night_switch = NIGHT; } else { - fgSetBool("/sim/hud/visiblity", false); + fgSetBool("/sim/hud/visibility", false); } } else { fgSetBool("/sim/hud/visibility", true); diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 1c10b6bf0..43163d4cd 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -31,6 +31,7 @@ #include #include #include
+#include
#include "External.hxx" #include "flight.hxx" @@ -143,6 +144,100 @@ FGInterface::FGInterface(void) { // Destructor FGInterface::~FGInterface() { +// unbind(); // FIXME: should be called explicitly +} + + +void +FGInterface::init () +{ + init(1.0 / fgGetInt("/sim/model-hz")); +} + +void +FGInterface::bind () +{ + // Aircraft position + fgTie("/position/latitude", this, + &(FGInterface::get_Latitude_deg), + &(FGInterface::set_Latitude_deg)); + fgTie("/position/longitude", this, + &(FGInterface::get_Longitude_deg), + &(FGInterface::set_Longitude_deg)); + fgTie("/position/altitude", this, + &(FGInterface::get_Altitude), + &(FGInterface::set_Altitude)); + fgTie("/position/altitude-agl", this, + &(FGInterface::get_Altitude_AGL)); // read-only + + // Orientation + fgTie("/orientation/roll", this, + &(FGInterface::get_Phi_deg), + &(FGInterface::set_Phi_deg)); + fgTie("/orientation/pitch", this, + &(FGInterface::get_Theta_deg), + &(FGInterface::set_Theta_deg)); + fgTie("/orientation/heading", this, + &(FGInterface::get_Psi_deg), + &(FGInterface::set_Psi_deg)); + + // Calibrated airspeed + fgTie("/velocities/airspeed", this, + &(FGInterface::get_V_calibrated_kts), + &(FGInterface::set_V_calibrated_kts)); + + // Local velocities + fgTie("/velocities/speed-north", this, + &(FGInterface::get_V_north)); + fgTie("/velocities/speed-east", this, + &(FGInterface::get_V_east), + &(FGInterface::set_V_east)); + fgTie("/velocities/speed-down", this, + &(FGInterface::get_V_down), + &(FGInterface::set_V_down)); + + // Relative wind + fgTie("/velocities/uBody", this, + &(FGInterface::get_uBody), + &(FGInterface::set_uBody)); + fgTie("/velocities/vBody", this, + &(FGInterface::get_vBody), + &(FGInterface::set_vBody)); + fgTie("/velocities/wBody", this, + &(FGInterface::get_wBody), + &(FGInterface::set_wBody)); + + // Climb and slip (read-only) + fgTie("/velocities/vertical-speed", this, + &(FGInterface::get_Climb_Rate)); // read-only + fgTie("/velocities/side-slip", this, + &(FGInterface::get_Beta)); // read-only +} + +void +FGInterface::unbind () +{ + fgUntie("/position/latitude"); + fgUntie("/position/longitude"); + fgUntie("/position/altitude"); + fgUntie("/position/heading"); + fgUntie("/position/pitch"); + fgUntie("/position/roll"); + fgUntie("/velocities/airspeed"); + fgUntie("/velocities/speed-north"); + fgUntie("/velocities/speed-east"); + fgUntie("/velocities/speed-down"); + fgUntie("/velocities/uBody"); + fgUntie("/velocities/vBody"); + fgUntie("/velocities/wBody"); + fgUntie("/velocities/vertical-speed"); + fgUntie("/velocities/side-slip"); +} + +void +FGInterface::update () +{ + update(1); } diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 270ffaa11..7014f82d5 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -89,8 +89,11 @@ #include #include +#include #include +#include
+ FG_USING_STD(list); FG_USING_STD(vector); FG_USING_STD(string); @@ -160,7 +163,7 @@ typedef vector < FGEngInterface > engine_list; // This is based heavily on LaRCsim/ls_generic.h -class FGInterface { +class FGInterface : public FGSubsystem { private: @@ -258,6 +261,8 @@ private: SGTimeStamp next_stamp; // time this record is valid protected: + virtual bool init( double dt ); + void _busdump(void); void _updatePosition( double lat_geoc, double lon, double alt ); void _updateWeather( void ); @@ -417,7 +422,10 @@ public: FGInterface(void); virtual ~FGInterface(); - virtual bool init( double dt ); + virtual void init (); + virtual void bind (); + virtual void unbind (); + virtual void update (); virtual bool update( int multi_loop ); // Define the various supported flight models (many not yet implemented) @@ -454,15 +462,41 @@ public: virtual void set_Longitude(double lon); virtual void set_Altitude(double alt); // triggers re-calc of AGL altitude virtual void set_AltitudeAGL(double altagl); // and vice-versa + virtual void set_Latitude_deg (double lat) { + set_Latitude(lat * DEG_TO_RAD); + } + virtual void set_Longitude_deg (double lon) { + set_Longitude(lon * DEG_TO_RAD); + } // Speeds -- setting any of these will trigger a re-calc of the rest virtual void set_V_calibrated_kts(double vc); virtual void set_Mach_number(double mach); virtual void set_Velocities_Local( double north, double east, double down ); + inline void set_V_north (double north) { v_local_v[0] = north; } + inline void set_V_east (double east) { v_local_v[1] = east; } + inline void set_V_down (double down) { v_local_v[2] = down; } virtual void set_Velocities_Wind_Body( double u, double v, double w); + virtual void set_uBody (double uBody) { v_wind_body_v[0] = uBody; } + virtual void set_vBody (double vBody) { v_wind_body_v[1] = vBody; } + virtual void set_wBody (double wBody) { v_wind_body_v[2] = wBody; } // Euler angles virtual void set_Euler_Angles( double phi, double theta, double psi ); + virtual void set_Phi (double phi) { + set_Euler_Angles(phi, get_Theta(), get_Psi()); + } + virtual void set_Theta (double theta) { + set_Euler_Angles(get_Phi(), theta, get_Psi()); + } + virtual void set_Psi (double psi) { + set_Euler_Angles(get_Phi(), get_Theta(), psi); + } + virtual void set_Phi_deg (double phi) { set_Phi(phi * DEG_TO_RAD); } + virtual void set_Theta_deg (double theta) { + set_Theta(theta * DEG_TO_RAD); + } + virtual void set_Psi_deg (double psi) { set_Psi(psi * DEG_TO_RAD); } // Flight Path virtual void set_Climb_Rate( double roc); @@ -669,6 +703,9 @@ public: inline double get_V_north() const { return v_local_v[0]; } inline double get_V_east() const { return v_local_v[1]; } inline double get_V_down() const { return v_local_v[2]; } + inline double get_uBody () const { return v_wind_body_v[0]; } + inline double get_vBody () const { return v_wind_body_v[1]; } + inline double get_wBody () const { return v_wind_body_v[2]; } // inline double * get_V_local_rel_ground_v() { // return v_local_rel_ground_v; @@ -803,12 +840,22 @@ public: inline double get_Latitude() const { return geodetic_position_v[0]; } inline double get_Longitude() const { return geodetic_position_v[1]; } inline double get_Altitude() const { return geodetic_position_v[2]; } - inline double get_Altitude_AGL(void) { return altitude_agl; } + inline double get_Altitude_AGL(void) const { return altitude_agl; } + + inline double get_Latitude_deg () const { + return get_Latitude() * RAD_TO_DEG; + } + inline double get_Longitude_deg () const { + return get_Longitude() * RAD_TO_DEG; + } // inline double * get_Euler_angles_v() { return euler_angles_v; } inline double get_Phi() const { return euler_angles_v[0]; } inline double get_Theta() const { return euler_angles_v[1]; } inline double get_Psi() const { return euler_angles_v[2]; } + inline double get_Phi_deg () const { return get_Phi() * RAD_TO_DEG; } + inline double get_Theta_deg () const { return get_Theta() * RAD_TO_DEG; } + inline double get_Psi_deg () const { return get_Psi() * RAD_TO_DEG; } // ========== Miscellaneous quantities ========== diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index e9f2fe020..639a7bcae 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -212,16 +212,16 @@ FGBFI::init () fgTie("/sim/time/gmt-string", getGMTString); // Position - fgTie("/position/latitude", getLatitude, setLatitude); - fgTie("/position/longitude", getLongitude, setLongitude); - fgTie("/position/altitude", getAltitude, setAltitude); - fgTie("/position/altitude-agl", getAGL); +// fgTie("/position/latitude", getLatitude, setLatitude); +// fgTie("/position/longitude", getLongitude, setLongitude); +// fgTie("/position/altitude", getAltitude, setAltitude); +// fgTie("/position/altitude-agl", getAGL); // Orientation - fgTie("/orientation/heading", getHeading, setHeading); +// fgTie("/orientation/heading", getHeading, setHeading); fgTie("/orientation/heading-magnetic", getHeadingMag); - fgTie("/orientation/pitch", getPitch, setPitch); - fgTie("/orientation/roll", getRoll, setRoll); +// fgTie("/orientation/pitch", getPitch, setPitch); +// fgTie("/orientation/roll", getRoll, setRoll); // Engine fgTie("/engines/engine0/rpm", getRPM); @@ -230,12 +230,12 @@ FGBFI::init () fgTie("/engines/engine0/mp", getMP); // Velocities - fgTie("/velocities/airspeed", getAirspeed, setAirspeed); - fgTie("/velocities/side-slip", getSideSlip); - fgTie("/velocities/vertical-speed", getVerticalSpeed); - fgTie("/velocities/speed-north", getSpeedNorth); - fgTie("/velocities/speed-east", getSpeedEast); - fgTie("/velocities/speed-down", getSpeedDown); +// fgTie("/velocities/airspeed", getAirspeed, setAirspeed); +// fgTie("/velocities/side-slip", getSideSlip); +// fgTie("/velocities/vertical-speed", getVerticalSpeed); +// fgTie("/velocities/speed-north", getSpeedNorth); +// fgTie("/velocities/speed-east", getSpeedEast); +// fgTie("/velocities/speed-down", getSpeedDown); // Autopilot fgTie("/autopilot/locks/altitude", getAPAltitudeLock, setAPAltitudeLock); diff --git a/src/Main/bfi.hxx b/src/Main/bfi.hxx index 8238bca68..24b38ebe6 100644 --- a/src/Main/bfi.hxx +++ b/src/Main/bfi.hxx @@ -124,46 +124,6 @@ public: // static void setSpeedDown (double speed); -#if 0 - // Controls - static double getThrottle (); // 0.0:1.0 - static void setThrottle (double throttle); // 0.0:1.0 - - static double getMixture (); // 0.0:1.0 - static void setMixture (double mixture); // 0.0:1.0 - - static double getPropAdvance (); // 0.0:1.0 - static void setPropAdvance (double pitch); // 0.0:1.0 - - static double getFlaps (); // 0.0:1.0 - static void setFlaps (double flaps); // 0.0:1.0 - - static double getAileron (); // -1.0:1.0 - static void setAileron (double aileron); // -1.0:1.0 - - static double getRudder (); // -1.0:1.0 - static void setRudder (double rudder); // -1.0:1.0 - - static double getElevator (); // -1.0:1.0 - static void setElevator (double elevator); // -1.0:1.0 - - static double getElevatorTrim (); // -1.0:1.0 - static void setElevatorTrim (double trim); // -1.0:1.0 - - static double getBrakes (); // 0.0:1.0 - static void setBrakes (double brake); // 0.0:1.0 - - static double getLeftBrake (); // 0.0:1.0 - static void setLeftBrake (double brake); // 0.0:1.0 - - static double getRightBrake (); // 0.0:1.0 - static void setRightBrake (double brake); // 0.0:1.0 - - static double getCenterBrake (); // 0.0:1.0 - static void setCenterBrake (double brake); // 0.0:1.0 - -#endif - // Autopilot static bool getAPAltitudeLock (); static void setAPAltitudeLock (bool lock); diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index d81c9c9ca..565edd6d9 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -563,10 +563,10 @@ bool fgInitSubsystems( void ) { fgVelocityInit(); // Initial Orientation - cur_fdm_state-> - set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD, - fgGetDouble("/orientation/pitch") * DEG_TO_RAD, - fgGetDouble("/orientation/heading") * DEG_TO_RAD ); +// cur_fdm_state-> +// set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD, +// fgGetDouble("/orientation/pitch") * DEG_TO_RAD, +// fgGetDouble("/orientation/heading") * DEG_TO_RAD ); // Initialize the event manager global_events.Init(); @@ -692,12 +692,14 @@ bool fgInitSubsystems( void ) { // Initialize the flight model subsystem data structures base on // above values - if ( cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") ) ) { - // fdm init successful - } else { - FG_LOG( FG_GENERAL, FG_ALERT, "FDM init() failed! Cannot continue." ); - exit(-1); - } + cur_fdm_state->init(); + cur_fdm_state->bind(); +// if ( cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") ) ) { +// // fdm init successful +// } else { +// FG_LOG( FG_GENERAL, FG_ALERT, "FDM init() failed! Cannot continue." ); +// exit(-1); +// } // *ABCD* I'm just sticking this here for now, it should probably // move eventually @@ -810,10 +812,10 @@ void fgReInitSubsystems( void ) fgVelocityInit(); // Initial Orientation - cur_fdm_state-> - set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD, - fgGetDouble("/orientation/pitch") * DEG_TO_RAD, - fgGetDouble("/orientation/heading") * DEG_TO_RAD ); +// cur_fdm_state-> +// set_Euler_Angles( fgGetDouble("/orientation/roll") * DEG_TO_RAD, +// fgGetDouble("/orientation/pitch") * DEG_TO_RAD, +// fgGetDouble("/orientation/heading") * DEG_TO_RAD ); // Initialize view parameters FGViewerRPH *pilot_view = @@ -838,7 +840,9 @@ void fgReInitSubsystems( void ) FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << globals->get_current_view()->get_abs_view_pos()); - cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") ); + cur_fdm_state->init(); + cur_fdm_state->bind(); +// cur_fdm_state->init( 1.0 / fgGetInt("/sim/model-hz") ); scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER; -- 2.39.5