]> git.mxchange.org Git - flightgear.git/commitdiff
More property node optimizations.
authorcurt <curt>
Wed, 6 Jun 2001 19:12:24 +0000 (19:12 +0000)
committercurt <curt>
Wed, 6 Jun 2001 19:12:24 +0000 (19:12 +0000)
src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx
src/Controls/controls.cxx
src/Controls/controls.hxx
src/FDM/JSBSim.cxx
src/FDM/JSBSim.hxx
src/FDM/LaRCsim.cxx
src/FDM/LaRCsim.hxx

index 39159f43930bbc683f691c934e2323e3ae7954ad..720be75fe557340a144314ee2706e57c0faf3fee 100644 (file)
@@ -84,9 +84,9 @@ FGRadioStack::FGRadioStack() {
     nav2_radial = 0.0;
     nav2_dme_dist = 0.0;
     need_update = true;
-    longitudeVal = fgGetValue("/position/longitude");
-    latitudeVal = fgGetValue("/position/latitude");
-    altitudeVal = fgGetValue("/position/altitude");
+    lon_node = fgGetNode("/position/longitude");
+    lat_node = fgGetNode("/position/latitude");
+    alt_node = fgGetNode("/position/altitude");
 }
 
 
@@ -308,9 +308,9 @@ double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev,
 void 
 FGRadioStack::update() 
 {
-    double lon = longitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
-    double lat = latitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
-    double elev = altitudeVal->getDoubleValue() * SG_FEET_TO_METER;
+    double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+    double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+    double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
 
     need_update = false;
 
@@ -603,9 +603,9 @@ void FGRadioStack::search()
 {
     static FGMkrBeacon::fgMkrBeacType last_beacon = FGMkrBeacon::NOBEACON;
 
-    double lon = longitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
-    double lat = latitudeVal->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
-    double elev = altitudeVal->getDoubleValue() * SG_FEET_TO_METER;
+    double lon = lon_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+    double lat = lat_node->getDoubleValue() * SGD_DEGREES_TO_RADIANS;
+    double elev = alt_node->getDoubleValue() * SG_FEET_TO_METER;
 
     // nav1
     FGILS ils;
index 9a8f0f3db5c215d9822503ecc0e6552420d9e63e..cf88735233c351e318d6cc1e04416484e21810be 100644 (file)
@@ -48,9 +48,9 @@ class FGRadioStack : public FGSubsystem
     SGInterpTable *low_tbl;
     SGInterpTable *high_tbl;
 
-    SGValue * latitudeVal;
-    SGValue * longitudeVal;
-    SGValue * altitudeVal;
+    SGPropertyNode *lat_node;
+    SGPropertyNode *lon_node;
+    SGPropertyNode *alt_node;
 
     bool need_update;
 
index ed7fc2fa87e487db9e21f552d486ba1fbf9b460a..203aaea4b33c4d93ffd4563bd5b373b01aefebcb 100644 (file)
@@ -70,7 +70,7 @@ FGControls::init ()
         brake[wheel] = 0.0;
     }
 
-    auto_coordination = fgGetValue("/sim/auto-coordination", true);
+    auto_coordination = fgGetNode("/sim/auto-coordination", true);
 }
 
 
index 7f0019dec10770031fff9d8865099ae482855f0c..ba2a92d5bae1d8dbd2f1cdd5f514e6b3ea9e00a8 100644 (file)
@@ -66,7 +66,7 @@ private:
     double brake[MAX_WHEELS];
     bool throttle_idle;
 
-    SGValue * auto_coordination;
+    SGPropertyNode * auto_coordination;
 
     inline void CLAMP(double *x, double min, double max ) {
        if ( *x < min ) { *x = min; }
index 05fa4ec5d5d265eaabfbc957611ed36babc1c05b..301f60553ee0fb64144a4af3ef2ccc9c0b7628e5 100644 (file)
@@ -105,9 +105,15 @@ FGJSBsim::FGJSBsim( double dt )
     fgSetDouble("/fdm/trim/aileron",    FCS->GetDaCmd());
     fgSetDouble("/fdm/trim/rudder",     FCS->GetDrCmd());
 
-    trimmed = fgGetValue("/fdm/trim/trimmed",true);
+    startup_trim = fgGetNode("/sim/startup/trim", true);
+
+    trimmed = fgGetNode("/fdm/trim/trimmed", true);
     trimmed->setBoolValue(false);
 
+    pitch_trim = fgGetNode("/fdm/trim/pitch-trim", true );
+    throttle_trim = fgGetNode("/fdm/trim/throttle", true );
+    aileron_trim = fgGetNode("/fdm/trim/aileron", true );
+    rudder_trim = fgGetNode("/fdm/trim/rudder", true );
 }
 
 /******************************************************************************/
@@ -192,44 +198,44 @@ bool FGJSBsim::update( int multiloop ) {
 
     trimmed->setBoolValue(false);
 
-    if (needTrim && fgGetBool("/sim/startup/trim")) {
+    if ( needTrim && startup_trim->getBoolValue() ) {
 
-      //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
-      //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
+        //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
+        //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
 
-    FGTrim *fgtrim;
-    if(fgic->GetVcalibratedKtsIC() < 10 ) {
-        fgic->SetVcalibratedKtsIC(0.0);
-        fgtrim=new FGTrim(fdmex,fgic,tGround);
-    } else {
-        fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
-    }
-    if(!fgtrim->DoTrim()) {
-        fgtrim->Report();
-        fgtrim->TrimStats();
-    } else {
-        trimmed->setBoolValue(true);
-    }
-    fgtrim->ReportState();
-    delete fgtrim;
+        FGTrim *fgtrim;
+        if(fgic->GetVcalibratedKtsIC() < 10 ) {
+            fgic->SetVcalibratedKtsIC(0.0);
+            fgtrim=new FGTrim(fdmex,fgic,tGround);
+        } else {
+            fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
+        }
+        if(!fgtrim->DoTrim()) {
+            fgtrim->Report();
+            fgtrim->TrimStats();
+        } else {
+            trimmed->setBoolValue(true);
+        }
+        fgtrim->ReportState();
+        delete fgtrim;
 
-    needTrim=false;
+        needTrim=false;
 
-    fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
-    fgSetDouble("/fdm/trim/throttle",   FCS->GetThrottleCmd(0));
-    fgSetDouble("/fdm/trim/aileron",    FCS->GetDaCmd());
-    fgSetDouble("/fdm/trim/rudder",     FCS->GetDrCmd());
+        pitch_trim->setDoubleValue( FCS->GetPitchTrimCmd() );
+        throttle_trim->setDoubleValue( FCS->GetThrottleCmd(0) );
+        aileron_trim->setDoubleValue( FCS->GetDaCmd() );
+        rudder_trim->setDoubleValue( FCS->GetDrCmd() );
 
-    controls.set_elevator_trim(FCS->GetPitchTrimCmd());
-    controls.set_elevator(FCS->GetDeCmd());
-    controls.set_throttle(FGControls::ALL_ENGINES,
-                          FCS->GetThrottleCmd(0));
+        controls.set_elevator_trim(FCS->GetPitchTrimCmd());
+        controls.set_elevator(FCS->GetDeCmd());
+        controls.set_throttle(FGControls::ALL_ENGINES,
+                              FCS->GetThrottleCmd(0));
 
-    controls.set_aileron(FCS->GetDaCmd());
-    controls.set_rudder( FCS->GetDrCmd());
+        controls.set_aileron(FCS->GetDaCmd());
+        controls.set_rudder( FCS->GetDrCmd());
     
-    SG_LOG( SG_FLIGHT, SG_INFO, "  Trim complete" );
-    }  
+        SG_LOG( SG_FLIGHT, SG_INFO, "  Trim complete" );
+    }
   
     for( i=0; i<get_num_engines(); i++ ) {
       get_engine(i)->set_RPM( Propulsion->GetThruster(i)->GetRPM() );
index 06364c18ea5ce78ebde897e52aac79fdd7074006..bb6cdccbb9821770bb6c0a9c65660dffda3d5bfb 100644 (file)
@@ -50,6 +50,8 @@ DEFINITIONS
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <simgear/misc/props.hxx>
+
 #include <FDM/JSBSim/FGFDMExec.h>
 
 class FGState;
@@ -233,7 +235,12 @@ private:
     float trim_elev;
     float trim_throttle;
     
-    SGValue *trimmed;
+    SGPropertyNode *startup_trim;
+    SGPropertyNode *trimmed;
+    SGPropertyNode *pitch_trim;
+    SGPropertyNode *throttle_trim;
+    SGPropertyNode *aileron_trim;
+    SGPropertyNode *rudder_trim;
     
     void snap_shot(void);
 };
index e2cdc0b459d66e1c4192f2c0dd14def9558cef5a..39e012382ff9cf394ce55b604919942285062e95 100644 (file)
 FGLaRCsim::FGLaRCsim( double dt ) {
     set_delta_t( dt );
 
-    ls_toplevel_init( 0.0, 
-                     (char *)fgGetString("/sim/aircraft").c_str() );
+    speed_up = fgGetNode("/sim/speed-up", true);
+    aircraft = fgGetNode("/sim/aircraft", true);
+    
+    ls_toplevel_init( 0.0, (char *)(aircraft->getStringValue().c_str()) );
+
     lsic=new LaRCsimIC; //this needs to be brought up after LaRCsim is
     copy_to_LaRCsim(); // initialize all of LaRCsim's vars
     //this should go away someday -- formerly done in fg_init.cxx
@@ -71,8 +74,6 @@ void FGLaRCsim::init() {
                                // init method first.
     FGInterface::init();
 
-    speed_up = fgGetValue("/sim/speed-up", true);
-    
     ls_set_model_dt( get_delta_t() );
     // Initialize our little engine that hopefully might
     eng.init( get_delta_t() );
@@ -121,7 +122,7 @@ void FGLaRCsim::init() {
 // Run an iteration of the EOM (equations of motion)
 bool FGLaRCsim::update( int multiloop ) {
 
-    if ( fgGetString("/sim/aircraft") == "c172" ) {
+    if ( aircraft->getStringValue() == "c172" ) {
        // set control inputs
        // cout << "V_calibrated_kts = " << V_calibrated_kts << '\n';
        eng.set_IAS( V_calibrated_kts );
@@ -188,7 +189,7 @@ bool FGLaRCsim::update( int multiloop ) {
         speed_up->getIntValue();
     Flap_handle = 30.0 * controls.get_flaps();
 
-    if ( fgGetString("/sim/aircraft") == "c172" ) {
+    if ( aircraft->getStringValue() == "c172" ) {
        Use_External_Engine = 1;
     } else {
        Use_External_Engine = 0;
index ee884af87b36d28a1fe01d0da6cb0772d6d8c046..bc37e85a5932ac4d0cb202dc6f468c318fe6a0e2 100644 (file)
 
 class FGLaRCsim: public FGInterface {
 
+private:
+
     FGNewEngine eng;
     LaRCsimIC* lsic;
     void set_ls(void);
     void snap_shot(void);
     double time_step;
-    SGValue * speed_up;
+    SGPropertyNode *speed_up;
+    SGPropertyNode *aircraft;
     
 public:
+
     FGLaRCsim( double dt );
     ~FGLaRCsim(void);