1
0
Fork 0

Sync. with JSBSim CVS again. This fixes some small issues.

This commit is contained in:
ehofman 2004-06-27 19:35:54 +00:00
parent 25ac349fe4
commit 5c685b34de
18 changed files with 93 additions and 52 deletions

View file

@ -50,12 +50,12 @@ static const char *IdHdr = ID_ELECTRIC;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGElectric::FGElectric(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
FGElectric::FGElectric(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number)
: FGEngine(exec, engine_number)
{
string token;
Type = etElectric;
EngineNumber = 0;
PowerWatts = 745.7;
hptowatts = 745.7;

View file

@ -74,7 +74,7 @@ class FGElectric : public FGEngine
{
public:
/// Constructor
FGElectric(FGFDMExec* exec, FGConfigFile* Eng_cfg);
FGElectric(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number);
/// Destructor
~FGElectric();

View file

@ -68,7 +68,7 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGEngine::FGEngine(FGFDMExec* exec)
FGEngine::FGEngine(FGFDMExec* exec, int engine_number) : EngineNumber(engine_number)
{
Name = "";
Type = etUnknown;
@ -84,7 +84,6 @@ FGEngine::FGEngine(FGFDMExec* exec)
FuelNeed = OxidizerNeed = 0.0;
Starved = Running = Cranking = false;
PctPower = 0.0;
EngineNumber = -1;
TrimMode = false;
FuelFlow_gph = 0.0;
FuelFlow_pph = 0.0;
@ -124,7 +123,7 @@ void FGEngine::ConsumeFuel(void)
if (TrimMode) return;
Fshortage = Oshortage = TanksWithFuel = 0.0;
// count how many assigned tanks have fuel
for (unsigned int i=0; i<SourceTanks.size(); i++) {
Tank = Propulsion->GetTank(SourceTanks[i]);

View file

@ -107,7 +107,7 @@ CLASS DECLARATION
class FGEngine : public FGJSBBase
{
public:
FGEngine(FGFDMExec* exec);
FGEngine(FGFDMExec* exec, int engine_number);
virtual ~FGEngine();
enum EngineType {etUnknown, etRocket, etPiston, etTurbine, etElectric};
@ -164,9 +164,6 @@ public:
/// Sets engine placement information
virtual void SetPlacement(double x, double y, double z, double pitch, double yaw);
/// Sets the engine number
virtual void SetEngineNumber(int nn) {EngineNumber = nn;}
virtual double GetPowerAvailable(void) {return 0.0;};
virtual bool GetTrimMode(void) {return TrimMode;}
@ -184,6 +181,7 @@ public:
protected:
FGPropertyManager* PropertyManager;
string Name;
const int EngineNumber;
EngineType Type;
double X, Y, Z;
double EnginePitch;
@ -199,7 +197,6 @@ protected:
double FuelNeed;
double OxidizerNeed;
double PctPower;
int EngineNumber;
bool Starter;
bool Starved;
bool Running;

View file

@ -747,7 +747,6 @@ void FGFCS::bindModel(void)
unsigned i;
char tmp[80];
for (i=0; i<ThrottleCmd.size(); i++) {
snprintf(tmp,80,"fcs/throttle-cmd-norm[%u]",i);
PropertyManager->Tie( tmp,this,i,

View file

@ -384,18 +384,22 @@ vector <string> FGFDMExec::EnumerateFDMs(void)
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model)
bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model,
bool addModelToPath)
{
FGFDMExec::AircraftPath = AircraftPath;
FGFDMExec::EnginePath = EnginePath;
return LoadModel(model);
return LoadModel(model, addModelToPath);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bool FGFDMExec::LoadModel(string model)
bool FGFDMExec::LoadModel(string model, bool addModelToPath)
{
bool result = true;
string token;
string aircraftCfgFileName;
@ -406,10 +410,13 @@ bool FGFDMExec::LoadModel(string model)
return false;
}
aircraftCfgFileName = AircraftPath;
# ifndef macintosh
aircraftCfgFileName = AircraftPath + "/" + model + ".xml";
if (addModelToPath) aircraftCfgFileName += "/" + model;
aircraftCfgFileName += "/" + model + ".xml";
# else
aircraftCfgFileName = AircraftPath + ";" + model + ".xml";
if (addModelToPath) aircraftCfgFileName += ";" + model;
aircraftCfgFileName += ";" + model + ".xml";
# endif
FGConfigFile AC_cfg(aircraftCfgFileName);

View file

@ -152,8 +152,11 @@ public:
be looked for in the directory specified in the AircraftPath variable,
and in turn under the directory with the same name as the model. For
instance: "aircraft/x15/x15.xml"
@param addModelToPath set to true to add the model name to the
AircraftPath, defaults to true
@return true if successful*/
bool LoadModel(string AircraftPath, string EnginePath, string model);
bool LoadModel(string AircraftPath, string EnginePath, string model,
bool addModelToPath = true);
/** Loads an aircraft model. The paths to the aircraft and engine
@ -163,8 +166,10 @@ public:
be looked for in the directory specified in the AircraftPath variable,
and in turn under the directory with the same name as the model. For
instance: "aircraft/x15/x15.xml"
@param addModelToPath set to true to add the model name to the
AircraftPath, defaults to true
@return true if successful*/
bool LoadModel(string model);
bool LoadModel(string model, bool addModelToPath = true);
/** Sets the path to the engine config file directories.

View file

@ -199,7 +199,6 @@ public:
return celsius * 1.8 + 32.0;
}
/** Finite precision comparison.
@param a first value to compare
@param b second value to compare

View file

@ -353,9 +353,9 @@ FGColumnVector3& FGLGear::Force(void)
if (RollingWhlVel == 0.0 && SideWhlVel == 0.0) {
WheelSlip = 0.0;
} else if (fabs(RollingWhlVel) < 1.0) {
WheelSlip = 0.05*radtodeg*atan2(SideWhlVel, RollingWhlVel) + 0.95*WheelSlip;
WheelSlip = 0.05*radtodeg*atan2(SideWhlVel, fabs(RollingWhlVel)) + 0.95*WheelSlip;
} else {
WheelSlip = radtodeg*atan2(SideWhlVel, RollingWhlVel);
WheelSlip = radtodeg*atan2(SideWhlVel, fabs(RollingWhlVel));
}
/*
double maxdeltaSlip = 0.5*deltaT;

View file

@ -54,7 +54,8 @@ static const char *IdHdr = ID_PISTON;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec),
FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number)
: FGEngine(exec, engine_number),
R_air(287.3),
rho_fuel(800), // estimate
calorific_value_fuel(47.3e6),
@ -65,7 +66,6 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec),
Type = etPiston;
crank_counter = 0;
EngineNumber = 0;
OilTemp_degK = 298;
MinManifoldPressure_inHg = 6.5;
MaxManifoldPressure_inHg = 28.5;

View file

@ -142,7 +142,7 @@ class FGPiston : public FGEngine
{
public:
/// Constructor
FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg);
FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number);
/// Destructor
~FGPiston();

View file

@ -108,7 +108,7 @@ bool FGPropulsion::Run(void)
for (unsigned int i=0; i<numTanks; i++) {
Tanks[i]->Calculate( dt * rate );
}
}
if (refuel) DoRefuel( dt * rate );
@ -231,20 +231,20 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
ThrottleAdded = true;
if (engType == "FG_ROCKET") {
Engines.push_back(new FGRocket(FDMExec, Cfg_ptr));
Engines.push_back(new FGRocket(FDMExec, Cfg_ptr, numEngines));
} else if (engType == "FG_PISTON") {
Engines.push_back(new FGPiston(FDMExec, Cfg_ptr));
Engines.push_back(new FGPiston(FDMExec, Cfg_ptr, numEngines));
} else if (engType == "FG_TURBINE") {
Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr));
Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr, numEngines));
} else if (engType == "FG_SIMTURBINE") {
cerr << endl;
cerr << "The FG_SIMTURBINE engine type has been renamed to FG_TURBINE." << endl;
cerr << "To fix this problem, simply replace the FG_SIMTURBINE name " << endl;
cerr << "in your engine file to FG_TURBINE." << endl;
cerr << endl;
Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr));
Engines.push_back(new FGTurbine(FDMExec, Cfg_ptr, numEngines));
} else if (engType == "FG_ELECTRIC") {
Engines.push_back(new FGElectric(FDMExec, Cfg_ptr));
Engines.push_back(new FGElectric(FDMExec, Cfg_ptr, numEngines));
} else {
cerr << fgred << " Unrecognized engine type: " << underon << engType
<< underoff << " found in config file." << fgdef << endl;
@ -281,7 +281,6 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
}
Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw);
Engines[numEngines]->SetEngineNumber(numEngines);
numEngines++;
} else {
@ -328,7 +327,7 @@ string FGPropulsion::GetPropulsionStrings(void)
if (firstime) firstime = false;
else PropulsionStrings += ", ";
PropulsionStrings += Engines[i]->GetEngineLabels() + ", ";
PropulsionStrings += Engines[i]->GetEngineLabels();
}
return PropulsionStrings;
@ -345,7 +344,7 @@ string FGPropulsion::GetPropulsionValues(void)
if (firstime) firstime = false;
else PropulsionValues += ", ";
PropulsionValues += Engines[i]->GetEngineValues() + ", ";
PropulsionValues += Engines[i]->GetEngineValues();
}
return PropulsionValues;
@ -494,7 +493,7 @@ void FGPropulsion::DoRefuel(double time_slice)
if (Tanks[i]->GetPctFull() < 99.99)
Transfer(-1, i, fillrate/TanksNotFull);
}
}
}
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -51,7 +51,8 @@ static const char *IdHdr = ID_ROCKET;
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number)
: FGEngine(exec, engine_number)
{
string token;
@ -73,7 +74,6 @@ FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
Debug(0);
EngineNumber = 0;
Type = etRocket;
Flameout = false;
@ -105,6 +105,10 @@ double FGRocket::Calculate(void)
} else {
PctPower = Throttle / MaxThrottle;
PC = maxPC*PctPower * (1.0 + Variance * ((double)rand()/(double)RAND_MAX - 0.5));
// The Cf (below) is CF from Eqn. 3-30, "Rocket Propulsion Elements", Fifth Edition,
// George P. Sutton. Note that the thruster function GetPowerRequired() might
// be better called GetResistance() or something; this function returns the
// nozzle exit pressure.
Cf = sqrt(kFactor*(1 - pow(Thruster->GetPowerRequired()/(PC), (SHR-1)/SHR)));
Flameout = false;
}

View file

@ -103,8 +103,9 @@ class FGRocket : public FGEngine
public:
/** Constructor.
@param exec pointer to JSBSim parent object, the FDM Executive.
@param Eng_cfg pointer to the config file object. */
FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg);
@param Eng_cfg pointer to the config file object.
@param engine_number engine number */
FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg, int engine_number);
/** Destructor */
~FGRocket(void);

View file

@ -54,7 +54,8 @@ CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGTurbine::FGTurbine(FGFDMExec* exec, FGConfigFile* cfg) : FGEngine(exec)
FGTurbine::FGTurbine(FGFDMExec* exec, FGConfigFile* cfg, int engine_number)
: FGEngine(exec, engine_number)
{
SetDefaults();
@ -66,6 +67,7 @@ FGTurbine::FGTurbine(FGFDMExec* exec, FGConfigFile* cfg) : FGEngine(exec)
FGTurbine::~FGTurbine()
{
unbind();
Debug(1);
}
@ -183,14 +185,16 @@ double FGTurbine::Run(void)
NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
}
if ((AugmentCmd > 0.0) && (AugMethod == 2)) {
Augmentation = true;
double tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust;
thrust += (tdiff * AugmentCmd);
FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
} else {
Augmentation = false;
if (AugMethod == 2) {
if (AugmentCmd > 0.0) {
Augmentation = true;
double tdiff = (MaxThrust * ThrustTables[2]->TotalValue()) - thrust;
thrust += (tdiff * AugmentCmd);
FuelFlow_pph = Seek(&FuelFlow_pph, thrust * ATSFC, 5000.0, 10000.0);
NozzlePosition = Seek(&NozzlePosition, 1.0, 0.8, 0.8);
} else {
Augmentation = false;
}
}
if ((Injected == 1) && Injection)
@ -402,6 +406,7 @@ bool FGTurbine::Load(FGConfigFile *Eng_cfg)
OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
IdleFF = pow(MilThrust, 0.2) * 107.0; // just an estimate
bindmodel();
return true;
}
@ -431,6 +436,30 @@ string FGTurbine::GetEngineValues(void)
return buf.str();
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTurbine::bindmodel()
{
char property_name[80];
snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber);
PropertyManager->Tie( property_name, &N1);
snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber);
PropertyManager->Tie( property_name, &N2);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGTurbine::unbind()
{
char property_name[80];
snprintf(property_name, 80, "propulsion/n1[%u]", EngineNumber);
PropertyManager->Untie(property_name);
snprintf(property_name, 80, "propulsion/n2[%u]", EngineNumber);
PropertyManager->Untie(property_name);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// The bitmasked value choices are as follows:
// unset: In this case (the default) JSBSim would only print

View file

@ -139,8 +139,9 @@ class FGTurbine : public FGEngine
public:
/** Constructor
@param Executive pointer to executive structure
@param Eng_cfg pointer to engine config file instance */
FGTurbine(FGFDMExec* Executive, FGConfigFile* Eng_cfg);
@param Eng_cfg pointer to engine config file instance
@param engine_number engine number*/
FGTurbine(FGFDMExec* Executive, FGConfigFile* Eng_cfg, int engine_number);
/// Destructor
~FGTurbine();
@ -241,6 +242,8 @@ private:
void SetDefaults(void);
bool Load(FGConfigFile *ENG_cfg);
void bindmodel(void);
void unbind(void);
void Debug(int from);
};

View file

@ -133,7 +133,7 @@ FGJSBsim::FGJSBsim( double dt )
result = fdmex->LoadModel( aircraft_path.str(),
engine_path.str(),
fgGetString("/sim/aero") );
fgGetString("/sim/aero"), false );
if (result) {
SG_LOG( SG_FLIGHT, SG_INFO, " loaded aero.");

View file

@ -165,7 +165,6 @@ bool FGFilter::Run(void)
} else if (Trigger != 0) {
test = Trigger->getIntValue();
if (test < 0) {
Output = PreviousOutput1 = PreviousOutput2 = 0.0;
Input = PreviousInput1 = PreviousInput2 = 0.0;
} else {
Output = PreviousOutput1 = PreviousOutput2 = 0.0;