X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGFCS.cpp;h=f5bbba07d885103ff29cb796df7993f3df08bd34;hb=9da9364a98383bfb6c49cb7366def490ee7b0c7f;hp=e1b7b9fb42e6a29aa2f790c9d6288bda5cf68798;hpb=a6db6d89ff41a619569e6433409e8bf62ff98499;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index e1b7b9fb4..f5bbba07d 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -38,28 +38,32 @@ INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ #include "FGFCS.h" -#include -#include +#include "FGFDMExec.h" +#include "FGGroundReactions.h" +#include "input_output/FGPropertyManager.h" #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "models/flight_control/FGFilter.h" +#include "models/flight_control/FGDeadBand.h" +#include "models/flight_control/FGGain.h" +#include "models/flight_control/FGPID.h" +#include "models/flight_control/FGSwitch.h" +#include "models/flight_control/FGSummer.h" +#include "models/flight_control/FGKinemat.h" +#include "models/flight_control/FGFCSFunction.h" +#include "models/flight_control/FGSensor.h" +#include "models/flight_control/FGActuator.h" +#include "models/flight_control/FGAccelerometer.h" +#include "models/flight_control/FGMagnetometer.h" +#include "models/flight_control/FGGyro.h" + +using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id$"; +static const char *IdSrc = "$Id: FGFCS.cpp,v 1.68 2010/03/18 13:21:24 jberndt Exp $"; static const char *IdHdr = ID_FCS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -194,6 +198,8 @@ bool FGFCS::Run(void) if (FGModel::Run()) return true; // fast exit if nothing to do if (FDMExec->Holding()) return false; + RunPreFunctions(); + for (i=0; iRun(); + RunPostFunctions(); + return false; } @@ -525,19 +533,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; @@ -643,6 +649,8 @@ bool FGFCS::Load(Element* el, SystemType systype) Components->push_back(new FGSensor(this, component_element)); } else if (component_element->GetName() == string("accelerometer")) { Components->push_back(new FGAccelerometer(this, component_element)); + } else if (component_element->GetName() == string("magnetometer")) { + Components->push_back(new FGMagnetometer(this, component_element)); } else if (component_element->GetName() == string("gyro")) { Components->push_back(new FGGyro(this, component_element)); } else { @@ -682,49 +690,55 @@ double FGFCS::GetBrake(FGLGear::BrakeGroup bg) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::FindSystemFullPathname(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(fullpath + system_filename).c_str()); if ( !system_file.is_open()) { - system_file.open(string(localpath + system_filename + ".xml").c_str()); + system_file.open(string(localpath + 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(localpath + system_filename); } } - return string(fullpath + system_filename + ".xml"); + return string(fullpath + system_filename); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ifstream* FGFCS::FindSystemFile(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(fullpath + system_filename).c_str()); if ( !system_file->is_open()) { - system_file->open(string(localpath + system_filename + ".xml").c_str()); + system_file->open(string(localpath + system_filename).c_str()); if ( !system_file->is_open()) { cerr << " Could not open system file: " << system_filename << " in path " << fullpath << " or " << localpath << endl; @@ -735,7 +749,7 @@ ifstream* FGFCS::FindSystemFile(string system_filename) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentStrings(string delimeter) +string FGFCS::GetComponentStrings(const string& delimiter) { unsigned int comp; string CompStrings = ""; @@ -744,7 +758,7 @@ string FGFCS::GetComponentStrings(string delimeter) for (unsigned int i=0; iGetName(); total_count++; @@ -753,7 +767,7 @@ string FGFCS::GetComponentStrings(string delimeter) for (comp = 0; comp < APComponents.size(); comp++) { if (firstime) firstime = false; - else CompStrings += delimeter; + else CompStrings += delimiter; CompStrings += APComponents[comp]->GetName(); total_count++; @@ -761,7 +775,7 @@ string FGFCS::GetComponentStrings(string delimeter) for (comp = 0; comp < FCSComponents.size(); comp++) { if (firstime) firstime = false; - else CompStrings += delimeter; + else CompStrings += delimiter; CompStrings += FCSComponents[comp]->GetName(); total_count++; @@ -772,7 +786,7 @@ string FGFCS::GetComponentStrings(string delimeter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentValues(string delimeter) +string FGFCS::GetComponentValues(const string& delimiter) { std::ostringstream buf; @@ -782,7 +796,7 @@ string FGFCS::GetComponentValues(string delimeter) for (unsigned int i=0; iGetOutput(); total_count++; @@ -790,7 +804,7 @@ string FGFCS::GetComponentValues(string delimeter) for (comp = 0; comp < APComponents.size(); comp++) { if (firstime) firstime = false; - else buf << delimeter; + else buf << delimiter; buf << setprecision(9) << APComponents[comp]->GetOutput(); total_count++; @@ -798,7 +812,7 @@ string FGFCS::GetComponentValues(string delimeter) for (comp = 0; comp < FCSComponents.size(); comp++) { if (firstime) firstime = false; - else buf << delimeter; + else buf << delimiter; buf << setprecision(9) << FCSComponents[comp]->GetOutput(); total_count++;