From 4a948f5955238e91f1d71274ed7f65d8dc97741c Mon Sep 17 00:00:00 2001 From: James Turner Date: Sat, 26 Jun 2010 14:21:16 +0100 Subject: [PATCH] Remove uses of the global FDM interface in the cockpit/HUD code. --- src/Cockpit/cockpit.cxx | 180 +++++---------------------------------- src/Cockpit/hud.hxx | 40 --------- src/Cockpit/hud_ladr.cxx | 26 +++--- src/FDM/SP/ADA.cxx | 61 ++++++------- src/FDM/flight.cxx | 14 +++ src/FDM/flight.hxx | 13 --- 6 files changed, 79 insertions(+), 255 deletions(-) diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index 9e1457220..a959978fc 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -38,9 +38,7 @@ #include #include -#ifdef ENABLE_SP_FDM -#include -#endif + #include
#include
#include
@@ -51,10 +49,6 @@ #include "cockpit.hxx" #include "hud.hxx" -// ugly hack, make the raw FDM available here, to support some -// legacy accessor functions -extern FGInterface* evil_global_fdm_state; - // The following routines obtain information concerntin the aircraft's // current state and return it to calling instrument display routines. // They should eventually be member functions of the aircraft. @@ -265,235 +259,103 @@ float get_dme( void ) return dme_node->getFloatValue(); } -// $$$ begin - added, VS Renganathan 13 Oct 2K -// #ifdef FIGHTER_HUD -float get_Vx ( void ) -{ - // Curt dont comment this and return zero. - Ranga - // Please remove comments from get_V_..() function in flight.hxx - float Vxx = evil_global_fdm_state->get_V_north_rel_ground(); - return Vxx; -} - -float get_Vy ( void ) -{ - // Curt dont comment this and return zero. - Ranga - // Please remove comments from get_V_..() function in flight.hxx - float Vyy = evil_global_fdm_state->get_V_east_rel_ground(); - return Vyy; -} - -float get_Vz ( void ) -{ - // Curt dont comment this and return zero. - Ranga - // Please remove comments from get_V_..() function in flight.hxx - float Vzz = evil_global_fdm_state->get_V_down_rel_ground(); - return Vzz; -} - float get_Ax ( void ) { - float Ax = evil_global_fdm_state->get_V_dot_north(); - return Ax; -} - -float get_Ay ( void ) -{ - float Ay = evil_global_fdm_state->get_V_dot_east(); - return Ay; -} - -float get_Az ( void ) -{ - float Az = evil_global_fdm_state->get_V_dot_down(); - return Az; + return fgGetDouble("/accelerations/ned/north-accel-fps_sec", 0.0); } float get_anzg ( void ) { - float anzg = evil_global_fdm_state->get_N_Z_cg(); - return anzg; + return fgGetDouble("/accelerations/n-z-cg-fps_sec", 0.0); } #ifdef ENABLE_SP_FDM -int get_iaux1 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(1); -} - -int get_iaux2 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(2); -} - -int get_iaux3 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(3); -} - -int get_iaux4 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(4); -} - -int get_iaux5 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(5); -} - -int get_iaux6 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(6); -} - -int get_iaux7 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(7); -} - -int get_iaux8 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(8); -} - -int get_iaux9 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(9); -} - -int get_iaux10 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(10); -} - -int get_iaux11 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(11); -} - -int get_iaux12 (void) -{ - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_iaux(12); -} - float get_aux1 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(1); + return fgGetDouble("/fdm-ada/ship-lat", 0.0); } float get_aux2 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(2); + return fgGetDouble("/fdm-ada/ship-lon", 0.0); } float get_aux3 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(3); + return fgGetDouble("/fdm-ada/ship-alt", 0.0); } float get_aux4 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(4); + return fgGetDouble("/fdm-ada/skijump-dist", 0.0); } float get_aux5 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(5); + return fgGetDouble("/fdm-ada/aux5", 0.0); } float get_aux6 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(6); + return fgGetDouble("/fdm-ada/aux6", 0.0); } float get_aux7 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(7); + return fgGetDouble("/fdm-ada/aux7", 0.0); } float get_aux8 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_daux(8); -} + return fgGetDouble("/fdm-ada/aux8", 0.0);} float get_aux9 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(1); -} + return fgGetDouble("/fdm-ada/aux9", 0.0);} float get_aux10 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(2); + return fgGetDouble("/fdm-ada/aux10", 0.0); } float get_aux11 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(3); + return fgGetDouble("/fdm-ada/aux11", 0.0); } float get_aux12 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(4); + return fgGetDouble("/fdm-ada/aux12", 0.0); } float get_aux13 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(5); + return fgGetDouble("/fdm-ada/aux13", 0.0); } float get_aux14 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(6); + return fgGetDouble("/fdm-ada/aux14", 0.0); } float get_aux15 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(7); + return fgGetDouble("/fdm-ada/aux15", 0.0); } float get_aux16 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(8); + return fgGetDouble("/fdm-ada/aux16", 0.0); } float get_aux17 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(9); + return fgGetDouble("/fdm-ada/aux17", 0.0); } float get_aux18 (void) { - FGADA *fdm = (FGADA *)evil_global_fdm_state; - return fdm->get_faux(10); + return fgGetDouble("/fdm-ada/aux18", 0.0); } #endif diff --git a/src/Cockpit/hud.hxx b/src/Cockpit/hud.hxx index 3774767b6..0d727ccd3 100644 --- a/src/Cockpit/hud.hxx +++ b/src/Cockpit/hud.hxx @@ -134,46 +134,6 @@ extern float get_mach( void ); extern char *coord_format_lat(float); extern char *coord_format_lon(float); -// $$$ begin - added, VS Renganathan, 13 Oct 2K -extern float get_anzg (void); -extern float get_Vx (void); -extern float get_Vy (void); -extern float get_Vz (void); -extern float get_Ax (void); -extern float get_Ay (void); -extern float get_Az (void); -extern int get_iaux1 (void); -extern int get_iaux2 (void); -extern int get_iaux3 (void); -extern int get_iaux4 (void); -extern int get_iaux5 (void); -extern int get_iaux6 (void); -extern int get_iaux7 (void); -extern int get_iaux8 (void); -extern int get_iaux9 (void); -extern int get_iaux10 (void); -extern int get_iaux11 (void); -extern int get_iaux12 (void); -extern float get_aux1(void); -extern float get_aux2(void); -extern float get_aux3(void); -extern float get_aux4(void); -extern float get_aux5 (void); -extern float get_aux6 (void); -extern float get_aux7 (void); -extern float get_aux8(void); -extern float get_aux9(void); -extern float get_aux10(void); -extern float get_aux11(void); -extern float get_aux12(void); -extern float get_aux13(void); -extern float get_aux14(void); -extern float get_aux15(void); -extern float get_aux16(void); -extern float get_aux17(void); -extern float get_aux18(void); -// $$$ end - added, VS Renganathan, 13 Oct 2K - extern char *get_formated_gmt_time( void ); enum hudinstype{ HUDno_instr, diff --git a/src/Cockpit/hud_ladr.cxx b/src/Cockpit/hud_ladr.cxx index 34b58d0eb..d56315b06 100644 --- a/src/Cockpit/hud_ladr.cxx +++ b/src/Cockpit/hud_ladr.cxx @@ -96,11 +96,11 @@ void HudLadder::draw(void) #ifdef ENABLE_SP_FDM int lgear, wown, wowm, ilcanclaw, ihook; - ilcanclaw = get_iaux2(); - lgear = get_iaux3(); - wown = get_iaux4(); - wowm = get_iaux5(); - ihook = get_iaux6(); + ilcanclaw = fgGetInt("/fdm-ada/iaux2", 0); + lgear = fgGetInt("/fdm-ada/iaux3", 0); + wown = fgGetInt("/fdm-ada/iaux4", 0); + wowm = fgGetInt("/fdm-ada/iaux5", 0);; + ihook = fgGetInt("/fdm-ada/iaux6", 0); #endif float pitch_value = current_ch1() * SGD_RADIANS_TO_DEGREES; @@ -159,12 +159,12 @@ void HudLadder::draw(void) //**************************************************************** //velocity vector reticle - computations if (velocity_vector) { - Vxx = get_Vx(); - Vyy = get_Vy(); - Vzz = get_Vz(); - Axx = get_Ax(); - Ayy = get_Ay(); - Azz = get_Az(); + Vxx = fgGetDouble("/velocities/north-relground-fps", 0.0); + Vyy = fgGetDouble("/velocities/east-relground-fps", 0.0); + Vzz = fgGetDouble("/velocities/down-relground-fps", 0.0); + Axx = fgGetDouble("/accelerations/ned/north-accel-fps_sec", 0.0); + Ayy = fgGetDouble("/accelerations/ned/east-accel-fps_sec", 0.0); + Azz = fgGetDouble("/accelerations/ned/down-accel-fps_sec", 0.0); psi = get_heading(); if (psi > 180.0) @@ -597,8 +597,8 @@ void HudLadder::draw(void) fromwp_lon = get_longitude() * SGD_DEGREES_TO_RADIANS; fromwp_lat = get_latitude() * SGD_DEGREES_TO_RADIANS; - towp_lon = get_aux2() * SGD_DEGREES_TO_RADIANS; - towp_lat = get_aux1() * SGD_DEGREES_TO_RADIANS; + towp_lon = fgGetDouble("/fdm-ada/ship-lon", 0.0) * SGD_DEGREES_TO_RADIANS; + towp_lat = fgGetDouble("/fdm-ada/ship-lat", 0.0) * SGD_DEGREES_TO_RADIANS; dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat) * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon))); diff --git a/src/FDM/SP/ADA.cxx b/src/FDM/SP/ADA.cxx index 9aaa468fa..123856be0 100644 --- a/src/FDM/SP/ADA.cxx +++ b/src/FDM/SP/ADA.cxx @@ -261,14 +261,15 @@ bool FGADA::copy_from_FGADA() { _set_Velocities_Local( V_north, V_east, V_down ); //same as UVW_local in fps //Positions and attitude for ship - _set_daux(1,sixdof_to_visuals.aux1);//ship lat - _set_daux(2,sixdof_to_visuals.aux2);//ship lon - _set_daux(3,sixdof_to_visuals.aux3);//ship alt+heave - _set_daux(4,sixdof_to_visuals.aux4);//distance of a/c from ski-jump exit - _set_faux(1,sixdof_to_visuals.aux9);//ship pitch - _set_faux(2,sixdof_to_visuals.aux10);//ship roll - _set_faux(3,sixdof_to_visuals.aux11);//ship yaw - _set_iaux(1,sixdof_to_visuals.iaux1);//flag for drawing ship + + fgSetDouble("/fdm-ada/ship-lat", sixdof_to_visuals.aux1); + fgSetDouble("/fdm-ada/ship-lon", sixdof_to_visuals.aux2); + fgSetDouble("/fdm-ada/ship-alt", sixdof_to_visuals.aux3); + fgSetDouble("/fdm-ada/skijump-dist", sixdof_to_visuals.aux4); + fgSetDouble("/fdm-ada/ship-pitch", sixdof_to_visuals.aux9); // faux1 + fgSetDouble("/fdm-ada/ship-roll", sixdof_to_visuals.aux10); // faux2 + fgSetDouble("/fdm-ada/ship-yaw", sixdof_to_visuals.aux11); // faux3 + fgSetInt("/fdm-ada/draw-ship", sixdof_to_visuals.iaux1); // controls globals->get_controls()->set_throttle(0,throttle/131.0); @@ -284,30 +285,30 @@ bool FGADA::copy_from_FGADA() { _set_Mach_number( Machno); _set_Climb_Rate( W_local*SG_METER_TO_FEET ); //pressure alt in feet for lca(navy) - _set_iaux(2,sixdof_to_visuals.iaux2);//control law mode switch posn - _set_iaux(3,sixdof_to_visuals.iaux3);//ldg gear posn - _set_iaux(4,sixdof_to_visuals.iaux4);// wow nose status - _set_iaux(5,sixdof_to_visuals.iaux5);// wow main status - _set_iaux(6,sixdof_to_visuals.iaux6);// arrester hook posn - _set_iaux(7,sixdof_to_visuals.iaux7); - _set_iaux(8,sixdof_to_visuals.iaux8); - _set_iaux(9,sixdof_to_visuals.iaux9); - _set_iaux(10,sixdof_to_visuals.iaux10); - _set_iaux(11,sixdof_to_visuals.iaux11); - _set_iaux(12,sixdof_to_visuals.iaux12); + fgSetInt("/fdm-ada/iaux2", sixdof_to_visuals.iaux2); //control law mode switch posn + fgSetInt("/fdm-ada/iaux3", sixdof_to_visuals.iaux3); //ldg gear posn + fgSetInt("/fdm-ada/iaux4", sixdof_to_visuals.iaux4); // wow nose status + fgSetInt("/fdm-ada/iaux5", sixdof_to_visuals.iaux5); // wow main status + fgSetInt("/fdm-ada/iaux6", sixdof_to_visuals.iaux6); // arrester hook posn + fgSetInt("/fdm-ada/iaux7", sixdof_to_visuals.iaux7); + fgSetInt("/fdm-ada/iaux8", sixdof_to_visuals.iaux8); + fgSetInt("/fdm-ada/iaux9", sixdof_to_visuals.iaux9); + fgSetInt("/fdm-ada/iaux10", sixdof_to_visuals.iaux10); + fgSetInt("/fdm-ada/iaux11", sixdof_to_visuals.iaux11); + fgSetInt("/fdm-ada/iaux12", sixdof_to_visuals.iaux12); - _set_daux(5,sixdof_to_visuals.aux5); - _set_daux(6,sixdof_to_visuals.aux6); - _set_daux(7,sixdof_to_visuals.aux7); - _set_daux(8,sixdof_to_visuals.aux8); + fgSetDouble("/fdm-ada/aux5", sixdof_to_visuals.aux5); + fgSetDouble("/fdm-ada/aux6", sixdof_to_visuals.aux6); + fgSetDouble("/fdm-ada/aux7", sixdof_to_visuals.aux7); + fgSetDouble("/fdm-ada/aux8", sixdof_to_visuals.aux8); - _set_faux(4,sixdof_to_visuals.aux12); - _set_faux(5,sixdof_to_visuals.aux13); - _set_faux(6,sixdof_to_visuals.aux14); - _set_faux(7,sixdof_to_visuals.aux15); - _set_faux(8,sixdof_to_visuals.aux16); - _set_faux(9,sixdof_to_visuals.aux17); - _set_faux(10,sixdof_to_visuals.aux18); + fgSetDouble("/fdm-ada/aux12", sixdof_to_visuals.aux12); + fgSetDouble("/fdm-ada/aux13", sixdof_to_visuals.aux13); + fgSetDouble("/fdm-ada/aux14", sixdof_to_visuals.aux14); + fgSetDouble("/fdm-ada/aux15", sixdof_to_visuals.aux15); + fgSetDouble("/fdm-ada/aux16", sixdof_to_visuals.aux16); + fgSetDouble("/fdm-ada/aux17", sixdof_to_visuals.aux17); + fgSetDouble("/fdm-ada/aux18", sixdof_to_visuals.aux18); // Angular rates _set_Omega_Body( P_body, Q_body, R_body ); diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index cf4ab9e6a..6b6424089 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -337,6 +337,14 @@ FGInterface::bind () fgTie("/velocities/speed-down-fps", this, &FGInterface::get_V_down, &FGInterface::set_V_down); + fgTie("/velocities/north-relground-fps", this, + &FGInterface::get_V_north_rel_ground); + fgTie("/velocities/east-relground-fps", this, + &FGInterface::get_V_east_rel_ground); + fgTie("/velocities/down-relground-fps", this, + &FGInterface::get_V_down_rel_ground); + + // Relative wind // FIXME: temporarily archivable, until // the NED problem is fixed. @@ -387,6 +395,8 @@ FGInterface::bind () this, &FGInterface::get_A_Y_pilot, &FGInterface::set_A_Y_pilot); fgTie("/accelerations/pilot/z-accel-fps_sec", this, &FGInterface::get_A_Z_pilot, &FGInterface::set_A_Z_pilot); + + fgTie("/accelerations/n-z-cg-fps_sec", this, &FGInterface::get_N_Z_cg); } @@ -430,6 +440,9 @@ FGInterface::unbind () fgUntie("/velocities/speed-north-fps"); fgUntie("/velocities/speed-east-fps"); fgUntie("/velocities/speed-down-fps"); + fgUntie("/velocities/north-relground-fps"); + fgUntie("/velocities/east-relground-fps"); + fgUntie("/velocities/down-relground-fps"); fgUntie("/velocities/uBody-fps"); fgUntie("/velocities/vBody-fps"); fgUntie("/velocities/wBody-fps"); @@ -442,6 +455,7 @@ FGInterface::unbind () fgUntie("/accelerations/ned/north-accel-fps_sec"); fgUntie("/accelerations/ned/east-accel-fps_sec"); fgUntie("/accelerations/ned/down-accel-fps_sec"); + fgUntie("/accelerations/n-z-cg-fps_sec"); } /** diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 90859d921..6965d3098 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -187,10 +187,6 @@ private: double altitude_agl; double track; - double daux[16]; // auxilliary doubles - float faux[16]; // auxilliary floats - int iaux[16]; // auxilliary ints - // the ground cache object itself. FGGroundCache ground_cache; @@ -367,10 +363,6 @@ public: inline void _set_Runway_altitude( double alt ) { runway_altitude = alt; } inline void _set_Climb_Rate(double rate) { climb_rate = rate; } - inline void _set_daux( int n, double value ) { daux[n] = value; } - inline void _set_faux( int n, float value ) { faux[n] = value; } - inline void _set_iaux( int n, int value ) { iaux[n] = value; } - public: FGInterface(); @@ -651,11 +643,6 @@ public: inline double get_Climb_Rate() const { return climb_rate; } - // Auxilliary variables - inline double get_daux( int n ) const { return daux[n]; } - inline float get_faux( int n ) const { return faux[n]; } - inline int get_iaux( int n ) const { return iaux[n]; } - // Note that currently this is the "same" value runway altitude... inline double get_ground_elev_ft() const { return runway_altitude; }