]> git.mxchange.org Git - flightgear.git/commitdiff
Sync. with JSBSim CVS again. This fixes some small issues.
authorehofman <ehofman>
Sun, 27 Jun 2004 19:35:54 +0000 (19:35 +0000)
committerehofman <ehofman>
Sun, 27 Jun 2004 19:35:54 +0000 (19:35 +0000)
18 files changed:
src/FDM/JSBSim/FGElectric.cpp
src/FDM/JSBSim/FGElectric.h
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGEngine.h
src/FDM/JSBSim/FGFCS.cpp
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGFDMExec.h
src/FDM/JSBSim/FGJSBBase.h
src/FDM/JSBSim/FGLGear.cpp
src/FDM/JSBSim/FGPiston.cpp
src/FDM/JSBSim/FGPiston.h
src/FDM/JSBSim/FGPropulsion.cpp
src/FDM/JSBSim/FGRocket.cpp
src/FDM/JSBSim/FGRocket.h
src/FDM/JSBSim/FGTurbine.cpp
src/FDM/JSBSim/FGTurbine.h
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/filtersjb/FGFilter.cpp

index c8a075fdaab8afe009d2419b6cb9cc74b0d87429..4cc12f006612d60868aa3895a3ed377aede29e51 100644 (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;
 
index cef8a0f872af73b7b8a62e15fc416e1eb9712953..7e865e2dbe6f6ddd8ac544389aeacb25d72268fa 100644 (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();
 
index b3a1b39294346a2e4107299447537d3b8517b1b7..1983708ef3cc4f34f7a627c3284102541cb0f33b 100644 (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]);
index e0d070dd508154b6543fb36f8b5010f0e35e3faa..a4d63c2d1bb26b99144e79922e4a767451da6c61 100644 (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;
index cf1b8628fe57dbdb5801df73d9a71e305c8480c2..b6a961a684b7bda461b0ad3f0709a7c13820d161 100644 (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,
index 3002ec56bdc2f44175b5eeba46acd7ccbaef58ac..dac9eedacb1701d38a4963e597feea5c2c557ac1 100644 (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);
index fefe6cd37544e425e307af2c6402549e947b0796..9e2d0a093b1d0d446ea1618dd3dd8d296cae1eed 100644 (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.
index d0f24e59154690890096a86383e2edfb6885b6bf..9e51d2456ce76b42a43d70aaf665999dbc7adfee 100644 (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
index dd0325b109ff9251ecd689b46725dc9cda460a8e..6c9d6b209c32aedde3f38a109b0c86c7882a14dc 100644 (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;
index aa3cef21d6b38e03b44ad8c1692c8a267c7054e9..dde46eea41ac7981339d5174103707fb38575362 100644 (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;
index b2e65b5fcb3aedc017183b67326199cc828f15dc..197f36cc42fb8c16c9f5f385e3174321df476849 100644 (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();
 
index a7a31a38b4f4e7415863a55098ab4f261f6fe84b..09cf080c8b3f799266ca4d827ca34707a1420a12 100644 (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);
     }
-  }      
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index dc99191921c92de3b2227ef2fd84f8d62cb9563c..0d0497b99713c98eed0737a113d176c6ff6d6def 100644 (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;
   }
index 9d64c6ad4e9e0e513a50b7cb09faefd1e99f7abd..a4d237e8b297a198ce309f5fc6cc88e2dda1f3b2 100644 (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);
index 437b04917e10ba085dcc502429972b5c546dd53b..69afe4778064bb46c66e6c3e5372e5d1e4457ba9 100644 (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
index 8361595c7d6f1bcc1f598aa522e39763cb695daf..fc87e2eeb3763b65aa019bca1877de7726f42af8 100644 (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);
 
 };
index ec9eb014b18b1420cc219ab0dbda688306659688..ff1f163c0d37a7055ca1b923e480987e47fce598 100644 (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.");
index d2c2dd88ac5d4d8de0672e41f2acfe74212b04de..a7fa9c5a3abbcaf0ea741dbc6689643cdcc8172d 100644 (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;