]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/YASim/FGFDM.cpp
Constant-speed props were seeking to engine speed, not prop speed.
[flightgear.git] / src / FDM / YASim / FGFDM.cpp
index 57d95c041571e5e58d2b296c7d922f31f80f655c..cc332d34d0299a7b535e8491fb9b5012e51c37d1 100644 (file)
@@ -104,7 +104,7 @@ void FGFDM::iterate(float dt)
     } 
     _airplane.calcFuelWeights();
     
-    setOutputProperties();
+    setOutputProperties(dt);
 }
 
 Airplane* FGFDM::getAirplane()
@@ -241,6 +241,8 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
         g->setSpring(attrf(a, "spring", 1));
         g->setDamping(attrf(a, "damp", 1));
        _airplane.addGear(g);
+    } else if(eq(name, "hook")) {
+    } else if(eq(name, "launchbar")) {
     } else if(eq(name, "fuselage")) {
        float b[3];
        v[0] = attrf(a, "ax");
@@ -391,7 +393,19 @@ void FGFDM::getExternalInput(float dt)
     }
 }
 
-void FGFDM::setOutputProperties()
+// Linearly "seeks" a property by the specified fraction of the way to
+// the target value.  Used to emulate "slowly changing" output values.
+static void moveprop(SGPropertyNode* node, const char* prop,
+                    float target, float frac)
+{
+    float val = node->getFloatValue(prop);
+    if(frac > 1) frac = 1;
+    if(frac < 0) frac = 0;
+    val += (target - val) * frac;
+    node->setFloatValue(prop, val);
+}
+
+void FGFDM::setOutputProperties(float dt)
 {
     // char buf[256];
     int i;
@@ -483,6 +497,15 @@ void FGFDM::setOutputProperties()
             node->setFloatValue("epr", j->getEPR());
             node->setFloatValue("egr-degf",
                                 j->getEGT() * K2DEGF + K2DEGFOFFSET);
+
+            // These are "unmodeled" values that are still needed for
+            // many cockpits.  Tie them all to the N1 speed, but
+            // normalize the numbers to the range [0:1] so the
+            // cockpit code can scale them to the right values.
+            float pnorm = j->getPerfNorm();
+            moveprop(node, "oilp-norm", pnorm, dt/3); // 3s seek time
+            moveprop(node, "oilt-norm", pnorm, dt/30); // 30s 
+            moveprop(node, "itt-norm", pnorm, dt/1); // 1s
         }
     }
 }
@@ -696,6 +719,9 @@ void FGFDM::parsePropeller(XMLAttributes* a)
        thruster->setVariableProp(min, max);
     }
 
+    if(attrb(a, "contra"))
+        thruster->setContraPair(true);
+
     if(a->hasAttribute("manual-pitch")) {
        prop->setManualPitch();
     }
@@ -748,6 +774,8 @@ int FGFDM::parseOutput(const char* name)
     if(eq(name, "BRAKE"))     return ControlMap::BRAKE;
     if(eq(name, "STEER"))     return ControlMap::STEER;
     if(eq(name, "EXTEND"))    return ControlMap::EXTEND;
+    if(eq(name, "HEXTEND"))   return ControlMap::HEXTEND;
+    if(eq(name, "LEXTEND"))   return ControlMap::LEXTEND;
     if(eq(name, "INCIDENCE")) return ControlMap::INCIDENCE;
     if(eq(name, "FLAP0"))     return ControlMap::FLAP0;
     if(eq(name, "FLAP1"))     return ControlMap::FLAP1;