X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGFCS.cpp;h=3f659831f5c03944085cc9eb75ae589ed4e657db;hb=642735ab18421db87a07d6841dd720fd4615bfff;hp=f5bbba07d885103ff29cb796df7993f3df08bd34;hpb=10366f4f1b91bfb037060a3f02d5c4056edac6c5;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGFCS.cpp b/src/FDM/JSBSim/models/FGFCS.cpp index f5bbba07d..3f659831f 100644 --- a/src/FDM/JSBSim/models/FGFCS.cpp +++ b/src/FDM/JSBSim/models/FGFCS.cpp @@ -37,13 +37,14 @@ HISTORY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include +#include +#include + #include "FGFCS.h" #include "FGFDMExec.h" #include "FGGroundReactions.h" #include "input_output/FGPropertyManager.h" -#include -#include -#include #include "models/flight_control/FGFilter.h" #include "models/flight_control/FGDeadBand.h" @@ -63,7 +64,7 @@ using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id: FGFCS.cpp,v 1.68 2010/03/18 13:21:24 jberndt Exp $"; +static const char *IdSrc = "$Id: FGFCS.cpp,v 1.77 2011/09/25 14:05:40 bcoconni Exp $"; static const char *IdHdr = ID_FCS; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -78,7 +79,7 @@ FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0; PTrimCmd = YTrimCmd = RTrimCmd = 0.0; GearCmd = GearPos = 1; // default to gear down - LeftBrake = RightBrake = CenterBrake = 0.0; + BrakePos.resize(FGLGear::bgNumBrakeGroups); TailhookPos = WingFoldPos = 0.0; bind(); @@ -123,8 +124,6 @@ bool FGFCS::InitModel(void) { unsigned int i; - if (!FGModel::InitModel()) return false; - for (i=0; iHolding()) return false; + if (FGModel::Run(Holding)) return true; // fast exit if nothing to do + if (Holding) return false; RunPreFunctions(); @@ -207,7 +206,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() ); } @@ -666,6 +665,8 @@ bool FGFCS::Load(Element* el, SystemType systype) channel_element = document->FindNextElement("channel"); } + PostLoad(document, PropertyManager); + ResetParser(); return true; @@ -675,17 +676,7 @@ bool FGFCS::Load(Element* el, SystemType systype) double FGFCS::GetBrake(FGLGear::BrakeGroup bg) { - switch (bg) { - case FGLGear::bgLeft: - return LeftBrake; - case FGLGear::bgRight: - return RightBrake; - case FGLGear::bgCenter: - return CenterBrake; - default: - cerr << "GetBrake asked to return a bogus brake value" << endl; - } - return 0.0; + return BrakePos[bg]; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -705,18 +696,18 @@ string FGFCS::FindSystemFullPathname(const string& sysfilename) system_filename.append(".xml"); } - system_file.open(string(fullpath + system_filename).c_str()); + system_file.open(string(localpath + system_filename).c_str()); if ( !system_file.is_open()) { - system_file.open(string(localpath + system_filename).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); + return string(fullpath + system_filename); } } - return string(fullpath + system_filename); + return string(localpath + system_filename); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -736,9 +727,9 @@ ifstream* FGFCS::FindSystemFile(const string& sysfilename) system_filename.append(".xml"); } - system_file->open(string(fullpath + system_filename).c_str()); + system_file->open(string(localpath + system_filename).c_str()); if ( !system_file->is_open()) { - system_file->open(string(localpath + system_filename).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; @@ -749,7 +740,7 @@ ifstream* FGFCS::FindSystemFile(const string& sysfilename) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentStrings(const string& delimiter) +string FGFCS::GetComponentStrings(const string& delimiter) const { unsigned int comp; string CompStrings = ""; @@ -786,7 +777,7 @@ string FGFCS::GetComponentStrings(const string& delimiter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGFCS::GetComponentValues(const string& delimiter) +string FGFCS::GetComponentValues(const string& delimiter) const { std::ostringstream buf; @@ -840,9 +831,10 @@ void FGFCS::AddThrottle(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -void FGFCS::AddGear(void) +void FGFCS::AddGear(unsigned int NumGear) { - SteerPosDeg.push_back(0.0); + SteerPosDeg.clear(); + for (unsigned int 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); }