From 500b081ca5ce88055da642f0c8ec93d014577c13 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 17 Feb 2004 23:24:36 +0000 Subject: [PATCH] Allow a "fuel" attribute in the approach and cruise tags to have values other than the defaults (20% and 50%, respectively) --- src/FDM/YASim/Airplane.cpp | 17 ++++++----------- src/FDM/YASim/Airplane.hpp | 7 ++++--- src/FDM/YASim/FGFDM.cpp | 4 ++-- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/FDM/YASim/Airplane.cpp b/src/FDM/YASim/Airplane.cpp index 09707c7f7..bb95ae9ba 100644 --- a/src/FDM/YASim/Airplane.cpp +++ b/src/FDM/YASim/Airplane.cpp @@ -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. diff --git a/src/FDM/YASim/Airplane.hpp b/src/FDM/YASim/Airplane.hpp index 16f0ca714..bc35a9b30 100644 --- a/src/FDM/YASim/Airplane.hpp +++ b/src/FDM/YASim/Airplane.hpp @@ -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; diff --git a/src/FDM/YASim/FGFDM.cpp b/src/FDM/YASim/FGFDM.cpp index 7f3077fce..f1d489708 100644 --- a/src/FDM/YASim/FGFDM.cpp +++ b/src/FDM/YASim/FGFDM.cpp @@ -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"); -- 2.39.5