Sync with latest JSBSim.
This commit is contained in:
parent
a69e2cc976
commit
bc391fb54e
6 changed files with 241 additions and 228 deletions
|
@ -133,28 +133,28 @@ bool FGAircraft::Load(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
string token;
|
string token;
|
||||||
|
|
||||||
ReadPrologue(AC_cfg);
|
if (!ReadPrologue(AC_cfg)) return false;
|
||||||
|
|
||||||
while ((AC_cfg->GetNextConfigLine() != string("EOF")) &&
|
while ((AC_cfg->GetNextConfigLine() != string("EOF")) &&
|
||||||
(token = AC_cfg->GetValue()) != string("/FDM_CONFIG")) {
|
(token = AC_cfg->GetValue()) != string("/FDM_CONFIG")) {
|
||||||
if (token == "METRICS") {
|
if (token == "METRICS") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Metrics" << fgdef << endl;
|
||||||
ReadMetrics(AC_cfg);
|
if (!ReadMetrics(AC_cfg)) return false;
|
||||||
} else if (token == "AERODYNAMICS") {
|
} else if (token == "AERODYNAMICS") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Aerodynamics" << fgdef << endl;
|
||||||
ReadAerodynamics(AC_cfg);
|
if (!ReadAerodynamics(AC_cfg)) return false;
|
||||||
} else if (token == "UNDERCARRIAGE") {
|
} else if (token == "UNDERCARRIAGE") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Landing Gear" << fgdef << endl;
|
||||||
ReadUndercarriage(AC_cfg);
|
if (!ReadUndercarriage(AC_cfg)) return false;
|
||||||
} else if (token == "PROPULSION") {
|
} else if (token == "PROPULSION") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Propulsion" << fgdef << endl;
|
||||||
ReadPropulsion(AC_cfg);
|
if (!ReadPropulsion(AC_cfg)) return false;
|
||||||
} else if (token == "FLIGHT_CONTROL") {
|
} else if (token == "FLIGHT_CONTROL") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Flight Control" << fgdef << endl;
|
||||||
ReadFlightControls(AC_cfg);
|
if (!ReadFlightControls(AC_cfg)) return false;
|
||||||
} else if (token == "OUTPUT") {
|
} else if (token == "OUTPUT") {
|
||||||
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
|
if (debug_lvl > 0) cout << fgcyan << "\n Reading Output directives" << fgdef << endl;
|
||||||
ReadOutput(AC_cfg);
|
if (!ReadOutput(AC_cfg)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ float FGAircraft::GetNlf(void)
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
string token = AC_cfg->GetValue();
|
string token = AC_cfg->GetValue();
|
||||||
string scratch;
|
string scratch;
|
||||||
|
@ -226,12 +226,14 @@ void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg)
|
||||||
" RESULTS WILL BE UNPREDICTABLE !!" << endl;
|
" RESULTS WILL BE UNPREDICTABLE !!" << endl;
|
||||||
cerr << "Current version needed is: " << needed_cfg_version << endl;
|
cerr << "Current version needed is: " << needed_cfg_version << endl;
|
||||||
cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
|
cerr << " You have version: " << CFGVersion << endl << fgdef << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
string token = "";
|
string token = "";
|
||||||
string parameter;
|
string parameter;
|
||||||
|
@ -317,52 +319,62 @@ void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
|
||||||
vbarv = VTailArm*VTailArea / (cbar*WingArea);
|
vbarv = VTailArm*VTailArea / (cbar*WingArea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadPropulsion(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
if (!Propulsion->Load(AC_cfg)) {
|
if (!Propulsion->Load(AC_cfg)) {
|
||||||
cerr << "Propulsion not successfully loaded" << endl;
|
cerr << " Propulsion not successfully loaded" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
if (!FCS->Load(AC_cfg)) {
|
if (!FCS->Load(AC_cfg)) {
|
||||||
cerr << "Flight Controls not successfully loaded" << endl;
|
cerr << " Flight Controls not successfully loaded" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
if (!Aerodynamics->Load(AC_cfg)) {
|
if (!Aerodynamics->Load(AC_cfg)) {
|
||||||
cerr << "Aerodynamics not successfully loaded" << endl;
|
cerr << " Aerodynamics not successfully loaded" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadUndercarriage(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
if (!GroundReactions->Load(AC_cfg)) {
|
if (!GroundReactions->Load(AC_cfg)) {
|
||||||
cerr << "Ground Reactions not successfully loaded" << endl;
|
cerr << " Ground Reactions not successfully loaded" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
void FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
|
bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg)
|
||||||
{
|
{
|
||||||
if (!Output->Load(AC_cfg)) {
|
if (!Output->Load(AC_cfg)) {
|
||||||
cerr << "Output not successfully loaded" << endl;
|
cerr << " Output not successfully loaded" << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
|
@ -225,13 +225,13 @@ private:
|
||||||
string CFGVersion;
|
string CFGVersion;
|
||||||
string AircraftName;
|
string AircraftName;
|
||||||
|
|
||||||
void ReadMetrics(FGConfigFile*);
|
bool ReadMetrics(FGConfigFile*);
|
||||||
void ReadPropulsion(FGConfigFile*);
|
bool ReadPropulsion(FGConfigFile*);
|
||||||
void ReadFlightControls(FGConfigFile*);
|
bool ReadFlightControls(FGConfigFile*);
|
||||||
void ReadAerodynamics(FGConfigFile*);
|
bool ReadAerodynamics(FGConfigFile*);
|
||||||
void ReadUndercarriage(FGConfigFile*);
|
bool ReadUndercarriage(FGConfigFile*);
|
||||||
void ReadPrologue(FGConfigFile*);
|
bool ReadPrologue(FGConfigFile*);
|
||||||
void ReadOutput(FGConfigFile*);
|
bool ReadOutput(FGConfigFile*);
|
||||||
void Debug(void);
|
void Debug(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -395,13 +395,13 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
modelLoaded = true;
|
modelLoaded = true;
|
||||||
|
if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n";
|
||||||
} else {
|
} else {
|
||||||
cerr << fgred
|
cerr << fgred
|
||||||
<< "FGFDMExec: Failed to load aircraft and/or engine model"
|
<< " FGFDMExec: Failed to load aircraft and/or engine model"
|
||||||
<< fgdef << endl;
|
<< fgdef << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n";
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ const double FGJSBBase::ktstofps = 1.68781;
|
||||||
const double FGJSBBase::inchtoft = 0.08333333;
|
const double FGJSBBase::inchtoft = 0.08333333;
|
||||||
const double FGJSBBase::Reng = 1716.0;
|
const double FGJSBBase::Reng = 1716.0;
|
||||||
const double FGJSBBase::SHRatio = 1.40;
|
const double FGJSBBase::SHRatio = 1.40;
|
||||||
const string FGJSBBase::needed_cfg_version = "1.55";
|
const string FGJSBBase::needed_cfg_version = "1.56";
|
||||||
const string FGJSBBase::JSBSim_version = "0.9.1";
|
const string FGJSBBase::JSBSim_version = "0.9.1";
|
||||||
|
|
||||||
queue <FGJSBBase::Message*> FGJSBBase::Messages;
|
queue <FGJSBBase::Message*> FGJSBBase::Messages;
|
||||||
|
|
|
@ -226,7 +226,9 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
|
||||||
} else if (engType == "FG_TURBOPROP") {
|
} else if (engType == "FG_TURBOPROP") {
|
||||||
Engines.push_back(new FGTurboProp(FDMExec, &Eng_cfg));
|
Engines.push_back(new FGTurboProp(FDMExec, &Eng_cfg));
|
||||||
} else {
|
} else {
|
||||||
cerr << " Unrecognized engine type: " << engType << " found in config file.\n";
|
cerr << fgred << " Unrecognized engine type: " << underon << engType
|
||||||
|
<< underoff << " found in config file." << fgdef << endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AC_cfg->GetNextConfigLine();
|
AC_cfg->GetNextConfigLine();
|
||||||
|
@ -259,8 +261,8 @@ bool FGPropulsion::Load(FGConfigFile* AC_cfg)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
cerr << "Could not read engine config file: " << fullpath
|
cerr << fgred << "\n Could not read engine config file: " << underon <<
|
||||||
+ engineFileName + ".xml" << endl;
|
fullpath + engineFileName + ".xml" << underoff << fgdef << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,19 +348,20 @@ string FGPropulsion::GetPropulsionStrings(void)
|
||||||
{
|
{
|
||||||
string PropulsionStrings = "";
|
string PropulsionStrings = "";
|
||||||
bool firstime = true;
|
bool firstime = true;
|
||||||
|
char buffer[5];
|
||||||
|
|
||||||
for (unsigned int i=0;i<Engines.size();i++) {
|
for (unsigned int i=0;i<Engines.size();i++) {
|
||||||
if (!firstime) {
|
if (firstime) firstime = false;
|
||||||
PropulsionStrings += ", ";
|
else PropulsionStrings += ", ";
|
||||||
firstime = false;
|
|
||||||
}
|
sprintf(buffer, "%d", i);
|
||||||
|
|
||||||
switch(Engines[i]->GetType()) {
|
switch(Engines[i]->GetType()) {
|
||||||
case FGEngine::etPiston:
|
case FGEngine::etPiston:
|
||||||
PropulsionStrings += (Engines[i]->GetName() + "_PwrAvail");
|
PropulsionStrings += (Engines[i]->GetName() + "_PwrAvail[" + buffer + "]");
|
||||||
break;
|
break;
|
||||||
case FGEngine::etRocket:
|
case FGEngine::etRocket:
|
||||||
PropulsionStrings += (Engines[i]->GetName() + "_ChamberPress");
|
PropulsionStrings += (Engines[i]->GetName() + "_ChamberPress[" + buffer + "]");
|
||||||
break;
|
break;
|
||||||
case FGEngine::etTurboJet:
|
case FGEngine::etTurboJet:
|
||||||
case FGEngine::etTurboProp:
|
case FGEngine::etTurboProp:
|
||||||
|
@ -373,14 +376,14 @@ string FGPropulsion::GetPropulsionStrings(void)
|
||||||
|
|
||||||
switch(Thrusters[i]->GetType()) {
|
switch(Thrusters[i]->GetType()) {
|
||||||
case FGThruster::ttNozzle:
|
case FGThruster::ttNozzle:
|
||||||
PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust");
|
PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "]");
|
||||||
break;
|
break;
|
||||||
case FGThruster::ttRotor:
|
case FGThruster::ttRotor:
|
||||||
break;
|
break;
|
||||||
case FGThruster::ttPropeller:
|
case FGThruster::ttPropeller:
|
||||||
PropulsionStrings += (Thrusters[i]->GetName() + "_Torque, ");
|
PropulsionStrings += (Thrusters[i]->GetName() + "_Torque[" + buffer + "], ");
|
||||||
PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust, ");
|
PropulsionStrings += (Thrusters[i]->GetName() + "_Thrust[" + buffer + "], ");
|
||||||
PropulsionStrings += (Thrusters[i]->GetName() + "_RPM");
|
PropulsionStrings += (Thrusters[i]->GetName() + "_RPM[" + buffer + "]");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PropulsionStrings += "INVALID THRUSTER TYPE";
|
PropulsionStrings += "INVALID THRUSTER TYPE";
|
||||||
|
@ -400,10 +403,8 @@ string FGPropulsion::GetPropulsionValues(void)
|
||||||
bool firstime = true;
|
bool firstime = true;
|
||||||
|
|
||||||
for (unsigned int i=0;i<Engines.size();i++) {
|
for (unsigned int i=0;i<Engines.size();i++) {
|
||||||
if (!firstime) {
|
if (firstime) firstime = false;
|
||||||
PropulsionValues += ", ";
|
else PropulsionValues += ", ";
|
||||||
firstime = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(Engines[i]->GetType()) {
|
switch(Engines[i]->GetType()) {
|
||||||
case FGEngine::etPiston:
|
case FGEngine::etPiston:
|
||||||
|
|
|
@ -141,7 +141,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
} else { // form jsbsim <acname> <resetfile>
|
} else { // form jsbsim <acname> <resetfile>
|
||||||
if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
|
if ( ! FDMExec->LoadModel("aircraft", "engine", string(argv[1]))) {
|
||||||
cerr << "JSBSim could not be started" << endl;
|
cerr << " JSBSim could not be started" << endl << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue