1
0
Fork 0

More property manager interface updates.

This commit is contained in:
curt 2001-01-16 20:21:03 +00:00
parent 576432ec75
commit f7b844f4d6
6 changed files with 179 additions and 73 deletions

View file

@ -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);

View file

@ -31,6 +31,7 @@
#include <Scenery/scenery.hxx>
#include <FDM/LaRCsim/ls_interface.h>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#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);
}

View file

@ -89,8 +89,11 @@
#include <vector>
#include <string>
#include <simgear/constants.h>
#include <simgear/timing/timestamp.hxx>
#include <Main/fgfs.hxx>
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 ==========

View file

@ -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);

View file

@ -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);

View file

@ -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;