X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGFCS.cpp;h=f0b77007d23cbabd0b344cf67fdde1e14bd4d791;hb=4f364af6d178d947eae1a5a751e3a9542b270069;hp=477890295478671424b026873c20664dfeb362fb;hpb=b61f8fba3353b8b77dd1866e230922ccb78daf71;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index 477890295..f0b77007d 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -63,7 +63,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id$"; +static const char *IdSrc = "$Id: FGFCS.cpp,v 1.72 2010/11/18 12:38:06 jberndt Exp $"; static const char *IdHdr = ID_FCS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -183,6 +183,17 @@ bool FGFCS::InitModel(void) return true; } +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +void FGFCS::LateBind(void) +{ + unsigned int i; + + for (i=0; iLateBind(); + for (i=0; iLateBind(); + for (i=0; iLateBind(); +} + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Notes: In this logic the default engine commands are set. This is simply a // sort of safe-mode method in case the user has not defined control laws for @@ -207,7 +218,7 @@ bool FGFCS::Run(void) // Set the default steering angle for (i=0; iGetGearUnit(i); + FGLGear* gear = FDMExec->GetGroundReactions()->GetGearUnit(i); SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() ); } @@ -533,19 +544,17 @@ bool FGFCS::Load(Element* el, SystemType systype) Components=0; - string separator = "/"; - // ToDo: The handling of name and file attributes could be improved, here, // considering that a name can be in the external file, as well. name = el->GetAttributeValue("name"); - if (name.empty()) { + if (name.empty() || !el->GetAttributeValue("file").empty()) { fname = el->GetAttributeValue("file"); if (systype == stSystem) { file = FindSystemFullPathname(fname); } else { - file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml"; + file = FDMExec->GetFullAircraftPath() + "/" + fname + ".xml"; } if (fname.empty()) { cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl; @@ -692,49 +701,55 @@ double FGFCS::GetBrake(FGLGear::BrakeGroup bg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::FindSystemFullPathname(const string& system_filename) +string FGFCS::FindSystemFullPathname(const string& sysfilename) { string fullpath, localpath; + string system_filename = sysfilename; string systemPath = FDMExec->GetSystemsPath(); string aircraftPath = FDMExec->GetFullAircraftPath(); ifstream system_file; - string separator = "/"; + fullpath = systemPath + "/"; + localpath = aircraftPath + "/Systems/"; - fullpath = systemPath + separator; - localpath = aircraftPath + separator + "Systems" + separator; + if (system_filename.length() <=4 || system_filename.substr(system_filename.length()-4, 4) != ".xml") { + system_filename.append(".xml"); + } - system_file.open(string(fullpath + system_filename + ".xml").c_str()); + system_file.open(string(localpath + system_filename).c_str()); if ( !system_file.is_open()) { - system_file.open(string(localpath + system_filename + ".xml").c_str()); + system_file.open(string(fullpath + system_filename).c_str()); if ( !system_file.is_open()) { cerr << " Could not open system file: " << system_filename << " in path " << fullpath << " or " << localpath << endl; return string(""); } else { - return string(localpath + system_filename + ".xml"); + return string(fullpath + system_filename); } } - return string(fullpath + system_filename + ".xml"); + return string(localpath + system_filename); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ifstream* FGFCS::FindSystemFile(const string& system_filename) +ifstream* FGFCS::FindSystemFile(const string& sysfilename) { string fullpath, localpath; + string system_filename = sysfilename; string systemPath = FDMExec->GetSystemsPath(); string aircraftPath = FDMExec->GetFullAircraftPath(); ifstream* system_file = new ifstream(); - string separator = "/"; + fullpath = systemPath + "/"; + localpath = aircraftPath + "/Systems/"; - fullpath = systemPath + separator; - localpath = aircraftPath + separator + "Systems" + separator; + if (system_filename.substr(system_filename.length()-4, 4) != ".xml") { + system_filename.append(".xml"); + } - system_file->open(string(fullpath + system_filename + ".xml").c_str()); + system_file->open(string(localpath + system_filename).c_str()); if ( !system_file->is_open()) { - system_file->open(string(localpath + system_filename + ".xml").c_str()); + system_file->open(string(fullpath + system_filename).c_str()); if ( !system_file->is_open()) { cerr << " Could not open system file: " << system_filename << " in path " << fullpath << " or " << localpath << endl; @@ -745,7 +760,7 @@ ifstream* FGFCS::FindSystemFile(const string& system_filename) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentStrings(const string& delimiter) +string FGFCS::GetComponentStrings(const string& delimiter) const { unsigned int comp; string CompStrings = ""; @@ -782,7 +797,7 @@ string FGFCS::GetComponentStrings(const string& delimiter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentValues(const string& delimiter) +string FGFCS::GetComponentValues(const string& delimiter) const { std::ostringstream buf; @@ -949,7 +964,7 @@ void FGFCS::bindModel(void) string tmp; for (i=0; iGetGearUnit(i)->GetSteerable()) { + if (FDMExec->GetGroundReactions()->GetGearUnit(i)->GetSteerable()) { tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", i); PropertyManager->Tie( tmp.c_str(), this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg); }