1
0
Fork 0

Allow a "fuel" attribute in the approach and cruise tags to have

values other than the defaults (20% and 50%, respectively)
This commit is contained in:
andy 2004-02-17 23:24:36 +00:00
parent a6129a38d0
commit 500b081ca5
3 changed files with 12 additions and 16 deletions

View file

@ -170,27 +170,23 @@ void Airplane::updateGearState()
} }
} }
void Airplane::setApproach(float speed, float altitude) void Airplane::setApproach(float speed, float altitude, float aoa, float fuel)
{
// The zero AoA will become a calculated stall AoA in compile()
setApproach(speed, altitude, 0);
}
void Airplane::setApproach(float speed, float altitude, float aoa)
{ {
_approachSpeed = speed; _approachSpeed = speed;
_approachP = Atmosphere::getStdPressure(altitude); _approachP = Atmosphere::getStdPressure(altitude);
_approachT = Atmosphere::getStdTemperature(altitude); _approachT = Atmosphere::getStdTemperature(altitude);
_approachAoA = aoa; _approachAoA = aoa;
_approachFuel = fuel;
} }
void Airplane::setCruise(float speed, float altitude) void Airplane::setCruise(float speed, float altitude, float fuel)
{ {
_cruiseSpeed = speed; _cruiseSpeed = speed;
_cruiseP = Atmosphere::getStdPressure(altitude); _cruiseP = Atmosphere::getStdPressure(altitude);
_cruiseT = Atmosphere::getStdTemperature(altitude); _cruiseT = Atmosphere::getStdTemperature(altitude);
_cruiseAoA = 0; _cruiseAoA = 0;
_tailIncidence = 0; _tailIncidence = 0;
_cruiseFuel = fuel;
} }
void Airplane::setElevatorControl(int control) void Airplane::setElevatorControl(int control)
@ -780,8 +776,7 @@ void Airplane::runCruise()
Math::mul3(-1, _cruiseState.v, wind); Math::mul3(-1, _cruiseState.v, wind);
Math::vmul33(_cruiseState.orient, wind, wind); Math::vmul33(_cruiseState.orient, wind, wind);
// Cruise is by convention at 50% tank capacity setFuelFraction(_cruiseFuel);
setFuelFraction(0.5);
// Set up the thruster parameters and iterate until the thrust // Set up the thruster parameters and iterate until the thrust
// stabilizes. // stabilizes.
@ -824,7 +819,7 @@ void Airplane::runApproach()
Math::vmul33(_approachState.orient, wind, wind); Math::vmul33(_approachState.orient, wind, wind);
// Approach is by convention at 20% tank capacity // Approach is by convention at 20% tank capacity
setFuelFraction(0.2f); setFuelFraction(_approachFuel);
// Run the thrusters until they get to a stable setting. FIXME: // Run the thrusters until they get to a stable setting. FIXME:
// this is lots of wasted work. // this is lots of wasted work.

View file

@ -48,9 +48,8 @@ public:
int addWeight(float* pos, float size); int addWeight(float* pos, float size);
void setWeight(int handle, float mass); void setWeight(int handle, float mass);
void setApproach(float speed, float altitude); void setApproach(float speed, float altitude, float aoa, float fuel);
void setApproach(float speed, float altitude, float aoa); void setCruise(float speed, float altitude, float fuel);
void setCruise(float speed, float altitude);
void setElevatorControl(int control); void setElevatorControl(int control);
void addApproachControl(int control, float val); void addApproachControl(int control, float val);
@ -134,6 +133,7 @@ private:
float _cruiseT; float _cruiseT;
float _cruiseSpeed; float _cruiseSpeed;
float _cruiseWeight; float _cruiseWeight;
float _cruiseFuel;
Vector _approachControls; Vector _approachControls;
State _approachState; State _approachState;
@ -142,6 +142,7 @@ private:
float _approachSpeed; float _approachSpeed;
float _approachAoA; float _approachAoA;
float _approachWeight; float _approachWeight;
float _approachFuel;
int _solutionIterations; int _solutionIterations;
float _dragFactor; float _dragFactor;

View file

@ -118,12 +118,12 @@ void FGFDM::startElement(const char* name, const XMLAttributes &atts)
float spd = attrf(a, "speed") * KTS2MPS; float spd = attrf(a, "speed") * KTS2MPS;
float alt = attrf(a, "alt", 0) * FT2M; float alt = attrf(a, "alt", 0) * FT2M;
float aoa = attrf(a, "aoa", 0) * DEG2RAD; float aoa = attrf(a, "aoa", 0) * DEG2RAD;
_airplane.setApproach(spd, alt, aoa); _airplane.setApproach(spd, alt, aoa, attrf(a, "fuel", 0.2));
_cruiseCurr = false; _cruiseCurr = false;
} else if(eq(name, "cruise")) { } else if(eq(name, "cruise")) {
float spd = attrf(a, "speed") * KTS2MPS; float spd = attrf(a, "speed") * KTS2MPS;
float alt = attrf(a, "alt") * FT2M; float alt = attrf(a, "alt") * FT2M;
_airplane.setCruise(spd, alt); _airplane.setCruise(spd, alt, attrf(a, "fuel", 0.5));
_cruiseCurr = true; _cruiseCurr = true;
} else if(eq(name, "cockpit")) { } else if(eq(name, "cockpit")) {
v[0] = attrf(a, "x"); v[0] = attrf(a, "x");