]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/LaRCsim.cxx
Add a link library needed by Irix.
[flightgear.git] / src / FDM / LaRCsim.cxx
index e8a08d1ff40508897d935a6bfc464f46c27f4bdf..1ef2fbb68f3d124196591f946c8e5deec2c79d2a 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
     Mass = 8.547270E+01;
     I_xx = 1.048000E+03;
     I_yy = 3.000000E+03;
     I_zz = 3.530000E+03;
     I_xz = 0.000000E+00;
-    //current_aircraft.fdm_state->set_Tank1Fuel(15.0);
-    //current_aircraft.fdm_state->set_Tank2Fuel(15.0);
-    //Tank1Fuel = 15.0;
-    //Tank2Fuel = 15.0;
-}
-
-FGLaRCsim::~FGLaRCsim(void) {
-    if(lsic != NULL) {
-       delete lsic;
-    }
-}    
-
-// Initialize the LaRCsim flight model, dt is the time increment for
-// each subsequent iteration through the EOM
-void FGLaRCsim::init() {
-
-    speed_up = fgGetValue("/sim/speed-up", true);
     
     ls_set_model_dt( get_delta_t() );
-    // Initialize our little engine that hopefully might
+    
+               // Initialize our little engine that hopefully might
     eng.init( get_delta_t() );
     // dcl - in passing dt to init rather than update I am assuming
     // that the LaRCsim dt is fixed at one value (yes it is 120hz CLO)
@@ -86,38 +74,29 @@ void FGLaRCsim::init() {
     set_Tank1Fuel(28.0);
     set_Tank2Fuel(28.0);  
 
-    // SG_LOG( SG_FLIGHT, SG_INFO, "FGLaRCsim::init()"  );
 
-    double save_alt = 0.0;
+}
 
-    if ( get_Altitude() < -9000.0 ) {
-       save_alt = get_Altitude();
-       set_Altitude( 0.0 );
+FGLaRCsim::~FGLaRCsim(void) {
+    if(lsic != NULL) {
+       delete lsic;
     }
+}    
 
-    // translate FG to LaRCsim structure
-    copy_to_LaRCsim();
-
-    // actual LaRCsim top level init
-    // ls_toplevel_init( dt, (char *)fgGetString("/sim/aircraft").c_str() );
-
-    SG_LOG( SG_FLIGHT, SG_INFO, "FG pos = " << 
-           get_Latitude() );
-
-    // translate LaRCsim back to FG structure
-    copy_from_LaRCsim();
+// Initialize the LaRCsim flight model, dt is the time increment for
+// each subsequent iteration through the EOM
+void FGLaRCsim::init() {
 
-    // but lets restore our original bogus altitude when we are done
-    if ( save_alt < -9000.0 ) {
-       set_Altitude( save_alt );
-    }
+               // Explicitly call the superclass's
+                               // init method first.
+    FGInterface::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 );
@@ -184,7 +163,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;
@@ -554,7 +533,7 @@ bool FGLaRCsim::copy_from_LaRCsim() {
     //        get_sin_longitude(), get_cos_longitude());
 
     _set_Climb_Rate( -1 * V_down );
-
+    // cout << "climb rate = " << -V_down * 60 << endl;
     return true;
 }