]> git.mxchange.org Git - flightgear.git/commitdiff
Allow a "fuel" attribute in the approach and cruise tags to have
authorandy <andy>
Tue, 17 Feb 2004 23:24:36 +0000 (23:24 +0000)
committerandy <andy>
Tue, 17 Feb 2004 23:24:36 +0000 (23:24 +0000)
values other than the defaults (20% and 50%, respectively)

src/FDM/YASim/Airplane.cpp
src/FDM/YASim/Airplane.hpp
src/FDM/YASim/FGFDM.cpp

index 09707c7f7bc6fa2fc25f638d643f1a4f2ff65fca..bb95ae9bada26178b5d591789988e679551cec43 100644 (file)
@@ -170,27 +170,23 @@ void Airplane::updateGearState()
     }
 }
 
-void Airplane::setApproach(float speed, float altitude)
-{
-    // The zero AoA will become a calculated stall AoA in compile()
-    setApproach(speed, altitude, 0);
-}
-
-void Airplane::setApproach(float speed, float altitude, float aoa)
+void Airplane::setApproach(float speed, float altitude, float aoa, float fuel)
 {
     _approachSpeed = speed;
     _approachP = Atmosphere::getStdPressure(altitude);
     _approachT = Atmosphere::getStdTemperature(altitude);
     _approachAoA = aoa;
+    _approachFuel = fuel;
 }
  
-void Airplane::setCruise(float speed, float altitude)
+void Airplane::setCruise(float speed, float altitude, float fuel)
 {
     _cruiseSpeed = speed;
     _cruiseP = Atmosphere::getStdPressure(altitude);
     _cruiseT = Atmosphere::getStdTemperature(altitude);
     _cruiseAoA = 0;
     _tailIncidence = 0;
+    _cruiseFuel = fuel;
 }
 
 void Airplane::setElevatorControl(int control)
@@ -780,8 +776,7 @@ void Airplane::runCruise()
     Math::mul3(-1, _cruiseState.v, wind);
     Math::vmul33(_cruiseState.orient, wind, wind);
  
-    // Cruise is by convention at 50% tank capacity
-    setFuelFraction(0.5);
+    setFuelFraction(_cruiseFuel);
    
     // Set up the thruster parameters and iterate until the thrust
     // stabilizes.
@@ -824,7 +819,7 @@ void Airplane::runApproach()
     Math::vmul33(_approachState.orient, wind, wind);
     
     // Approach is by convention at 20% tank capacity
-    setFuelFraction(0.2f);
+    setFuelFraction(_approachFuel);
 
     // Run the thrusters until they get to a stable setting.  FIXME:
     // this is lots of wasted work.
index 16f0ca714fc97da975ad308886be53112da7ed81..bc35a9b30b939a5dcf3d1b1935bfe2030a7cdcd9 100644 (file)
@@ -48,9 +48,8 @@ public:
     int addWeight(float* pos, float size);
     void setWeight(int handle, float mass);
 
-    void setApproach(float speed, float altitude);
-    void setApproach(float speed, float altitude, float aoa); 
-    void setCruise(float speed, float altitude);
+    void setApproach(float speed, float altitude, float aoa, float fuel);
+    void setCruise(float speed, float altitude, float fuel);
 
     void setElevatorControl(int control);
     void addApproachControl(int control, float val);
@@ -134,6 +133,7 @@ private:
     float _cruiseT;
     float _cruiseSpeed;
     float _cruiseWeight;
+    float _cruiseFuel;
 
     Vector _approachControls;
     State _approachState;
@@ -142,6 +142,7 @@ private:
     float _approachSpeed;
     float _approachAoA;
     float _approachWeight;
+    float _approachFuel;
 
     int _solutionIterations;
     float _dragFactor;
index 7f3077fce9ccfd5c45233265a587de912fa089a9..f1d489708fad02ab07130e577935cf7179e9e3af 100644 (file)
@@ -118,12 +118,12 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
        float spd = attrf(a, "speed") * KTS2MPS;
        float alt = attrf(a, "alt", 0) * FT2M;
        float aoa = attrf(a, "aoa", 0) * DEG2RAD;
-       _airplane.setApproach(spd, alt, aoa);
+       _airplane.setApproach(spd, alt, aoa, attrf(a, "fuel", 0.2));
        _cruiseCurr = false;
     } else if(eq(name, "cruise")) {
        float spd = attrf(a, "speed") * KTS2MPS;
        float alt = attrf(a, "alt") * FT2M;
-       _airplane.setCruise(spd, alt);
+       _airplane.setCruise(spd, alt, attrf(a, "fuel", 0.5));
        _cruiseCurr = true;
     } else if(eq(name, "cockpit")) {
        v[0] = attrf(a, "x");