]> git.mxchange.org Git - flightgear.git/commitdiff
Sync. w. JSBSim CVS
authorehofman <ehofman>
Fri, 6 Feb 2009 19:53:51 +0000 (19:53 +0000)
committerTim Moore <timoore@redhat.com>
Fri, 6 Feb 2009 21:40:10 +0000 (22:40 +0100)
19 files changed:
src/FDM/JSBSim/FGJSBBase.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/initialization/FGTrim.cpp
src/FDM/JSBSim/initialization/FGTrim.h
src/FDM/JSBSim/models/FGFCS.cpp
src/FDM/JSBSim/models/FGFCS.h
src/FDM/JSBSim/models/FGGasCell.cpp
src/FDM/JSBSim/models/FGLGear.cpp
src/FDM/JSBSim/models/FGLGear.h
src/FDM/JSBSim/models/FGMassBalance.h
src/FDM/JSBSim/models/propulsion/FGEngine.cpp
src/FDM/JSBSim/models/propulsion/FGPiston.cpp
src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
src/FDM/JSBSim/models/propulsion/FGRocket.cpp
src/FDM/JSBSim/models/propulsion/FGTank.cpp
src/FDM/JSBSim/models/propulsion/FGThruster.cpp
src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp

index 8ec8e828bee9eb744f1b9892c47e41d1d7588ae3..c4d0542460c2b4637dd6b7fcd255fe2ebe75b550 100644 (file)
@@ -41,6 +41,7 @@ INCLUDES
 #include <float.h>
 #include <queue>
 #include <string>
+#include <sstream>
 #include <cmath>
 
 using std::fabs;
@@ -102,6 +103,27 @@ public:
     double dVal;
   };
 
+  /// First order, (low pass / lag) filter
+  class Filter {
+    double prev_in;
+    double prev_out;
+    double ca;
+    double cb;
+    public: Filter(void) {}
+    public: Filter(double coeff, double dt) {
+      prev_in = prev_out = 0.0;
+      double denom = 2.0 + coeff*dt;
+      ca = coeff*dt/denom;
+      cb = (2.0 - coeff*dt)/denom;
+    }
+    public: double execute(double in) {
+      double out = (in + prev_in)*ca + prev_out*cb;
+      prev_in = in;
+      prev_out = out;
+      return out;
+    }
+  };
+
   ///@name JSBSim console output highlighting terms.
   //@{
   /// highlights text
@@ -303,6 +325,15 @@ protected:
   static const string needed_cfg_version;
   static const string JSBSim_version;
 
+  static string CreateIndexedPropertyName(string Property, int index)
+  {
+    std::stringstream str;
+    str << index;
+    string tmp;
+    str >> tmp;
+    return Property + "[" + tmp + "]";
+  }
+
 public:
 /// Moments L, M, N
 enum {eL     = 1, eM,     eN    };
index cc6bbfa57477a3caa188db799cfb81773b8fc24c..5e659fc1e1e8d597b25e2e18c5fdaddc0cd4cd1f 100644 (file)
@@ -58,7 +58,7 @@ FGState::FGState(FGFDMExec* fdex)
   FDMExec = fdex;
 
   sim_time = 0.0;
-  dt = 1.0/120.0;
+  //dt = 1.0/120.0;
 
   Aircraft     = FDMExec->GetAircraft();
   Propagate    = FDMExec->GetPropagate();
index a13821d82b716a2a0c7f99b4f89544bb65437a21..ae53988be8b5b6a06a90d38881a8999d30a6e83c 100644 (file)
@@ -211,7 +211,7 @@ FGJSBsim::FGJSBsim( double dt )
       if (node->getChild("level-gal_us", 0, false) != 0) {
         Propulsion->GetTank(i)->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
       } else {
-        node->setDoubleValue("level-lb", Propulsion->GetTank(i)->GetContents());
+        node->setDoubleValue("level-lbs", Propulsion->GetTank(i)->GetContents());
         node->setDoubleValue("level-gal_us", Propulsion->GetTank(i)->GetContents() / 6.6);
       }
       node->setDoubleValue("capacity-gal_us",
@@ -626,7 +626,7 @@ bool FGJSBsim::copy_to_JSBsim()
       SGPropertyNode * node = fgGetNode("/consumables/fuel/tank", i, true);
       FGTank * tank = Propulsion->GetTank(i);
       tank->SetContents(node->getDoubleValue("level-gal_us") * 6.6);
-//       tank->SetContents(node->getDoubleValue("level-lb"));
+//       tank->SetContents(node->getDoubleValue("level-lbs"));
     }
 
     Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
@@ -866,7 +866,7 @@ bool FGJSBsim::copy_from_JSBsim()
         double contents = tank->GetContents();
         double temp = tank->GetTemperature_degC();
         node->setDoubleValue("level-gal_us", contents/6.6);
-        node->setDoubleValue("level-lb", contents);
+        node->setDoubleValue("level-lbs", contents);
         if (temp != -9999.0) node->setDoubleValue("temperature_degC", temp);
       }
     }
index 099ec495a32790a23677c6cb680b148481614d60..39e934f5bc3d84a9d0b212b22bec3e611db7fe79 100644 (file)
@@ -42,6 +42,7 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include <cstdlib>
+#include <iomanip>
 #include "FGTrim.h"
 #include <models/FGAtmosphere.h>
 #include "FGInitialCondition.h"
@@ -101,21 +102,19 @@ FGTrim::~FGTrim(void) {
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGTrim::TrimStats() {
-  char out[80];
   int run_sum=0;
   cout << endl << "  Trim Statistics: " << endl;
   cout << "    Total Iterations: " << total_its << endl;
-  if(total_its > 0) {
+  if( total_its > 0) {
     cout << "    Sub-iterations:" << endl;
-    for(current_axis=0; current_axis<TrimAxes.size(); current_axis++) {
-      run_sum+=TrimAxes[current_axis]->GetRunCount();
-      snprintf(out,80,"   %5s: %3.0f average: %5.2f  successful: %3.0f  stability: %5.2f\n",
-                  TrimAxes[current_axis]->GetStateName().c_str(),
-                  sub_iterations[current_axis],
-                  sub_iterations[current_axis]/double(total_its),
-                  successful[current_axis],
-                  TrimAxes[current_axis]->GetAvgStability() );
-      cout << out;
+    for (current_axis=0; current_axis<TrimAxes.size(); current_axis++) {
+      run_sum += TrimAxes[current_axis]->GetRunCount();
+      cout << "   " << setw(5) << TrimAxes[current_axis]->GetStateName().c_str()
+           << ": " << setprecision(3) << sub_iterations[current_axis]
+           << " average: " << setprecision(5) << sub_iterations[current_axis]/double(total_its)
+           << "  successful:  " << setprecision(3) << successful[current_axis]
+           << "  stability: " << setprecision(5) << TrimAxes[current_axis]->GetAvgStability()
+           << endl;
     }
     cout << "    Run Count: " << run_sum << endl;
   }
index 9fd38efbd2c87514e37346ddc685c6ed3ea0411d..420f3fda2be3eca0c99180a4fe85c9e72787b74f 100644 (file)
@@ -62,10 +62,6 @@ DEFINITIONS
 
 #define ID_TRIM "$Id$"
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-  #define snprintf _snprintf
-#endif
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 3d974bf6e74aa171023d8bdc0ae2236b459fe0e1..49c12f4352e9be12a49b19dd06f0395c8bf7a0fc 100644 (file)
@@ -41,6 +41,8 @@ INCLUDES
 #include <FGFDMExec.h>
 #include <input_output/FGPropertyManager.h>
 #include <fstream>
+#include <sstream>
+#include <iomanip>
 
 #include <models/flight_control/FGFilter.h>
 #include <models/flight_control/FGDeadBand.h>
@@ -58,10 +60,6 @@ namespace JSBSim {
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_FCS;
 
-#if defined(WIN32) && !defined(__CYGWIN__)
-#define snprintf _snprintf
-#endif
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -768,41 +766,37 @@ string FGFCS::GetComponentStrings(string delimeter)
 
 string FGFCS::GetComponentValues(string delimeter)
 {
+  std::ostringstream buf;
+
   unsigned int comp;
-  string CompValues = "";
-  char buffer[100];
   bool firstime = true;
   int total_count=0;
 
   for (unsigned int i=0; i<Systems.size(); i++) {
     if (firstime) firstime = false;
-    else          CompValues += delimeter;
+    else          buf << delimeter;
 
-    snprintf(buffer, 100, "%9.6f", Systems[i]->GetOutput());
-    CompValues += string(buffer);
+    buf << setprecision(9) << Systems[i]->GetOutput();
     total_count++;
   }
 
   for (comp = 0; comp < APComponents.size(); comp++) {
     if (firstime) firstime = false;
-    else          CompValues += delimeter;
+    else          buf << delimeter;
 
-    sprintf(buffer, "%9.6f", APComponents[comp]->GetOutput());
-    CompValues += string(buffer);
+    buf << setprecision(9) << APComponents[comp]->GetOutput();
     total_count++;
   }
 
   for (comp = 0; comp < FCSComponents.size(); comp++) {
     if (firstime) firstime = false;
-    else          CompValues += delimeter;
+    else          buf << delimeter;
 
-    sprintf(buffer, "%9.6f", FCSComponents[comp]->GetOutput());
-    CompValues += string(buffer);
+    buf << setprecision(9) << FCSComponents[comp]->GetOutput();
     total_count++;
   }
 
-  CompValues += "\0";
-  return CompValues;
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -898,35 +892,34 @@ void FGFCS::bind(void)
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 // Technically, this function should probably bind propulsion type specific controls
 // rather than mixture and prop-advance.
-//
 
 void FGFCS::bindThrottle(unsigned int num)
 {
-  char tmp[80];
+  string tmp;
 
-  snprintf(tmp, 80, "fcs/throttle-cmd-norm[%u]",num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetThrottleCmd,
+  tmp = CreateIndexedPropertyName("fcs/throttle-cmd-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetThrottleCmd,
                                         &FGFCS::SetThrottleCmd);
-  snprintf(tmp, 80, "fcs/throttle-pos-norm[%u]",num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetThrottlePos,
+  tmp = CreateIndexedPropertyName("fcs/throttle-pos-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetThrottlePos,
                                         &FGFCS::SetThrottlePos);
-  snprintf(tmp, 80, "fcs/mixture-cmd-norm[%u]",num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetMixtureCmd,
+  tmp = CreateIndexedPropertyName("fcs/mixture-cmd-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetMixtureCmd,
                                         &FGFCS::SetMixtureCmd);
-  snprintf(tmp, 80, "fcs/mixture-pos-norm[%u]",num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetMixturePos,
+  tmp = CreateIndexedPropertyName("fcs/mixture-pos-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetMixturePos,
                                         &FGFCS::SetMixturePos);
-  snprintf(tmp, 80, "fcs/advance-cmd-norm[%u]",num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetPropAdvanceCmd,
+  tmp = CreateIndexedPropertyName("fcs/advance-cmd-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropAdvanceCmd,
                                         &FGFCS::SetPropAdvanceCmd);
-  snprintf(tmp, 80, "fcs/advance-pos-norm[%u]", num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetPropAdvance,
+  tmp = CreateIndexedPropertyName("fcs/advance-pos-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropAdvance,
                                         &FGFCS::SetPropAdvance);
-  snprintf(tmp, 80, "fcs/feather-cmd-norm[%u]", num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetFeatherCmd,
+  tmp = CreateIndexedPropertyName("fcs/feather-cmd-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetFeatherCmd,
                                         &FGFCS::SetFeatherCmd);
-  snprintf(tmp, 80, "fcs/feather-pos-norm[%u]", num);
-  PropertyManager->Tie( tmp, this, num, &FGFCS::GetPropFeather,
+  tmp = CreateIndexedPropertyName("fcs/feather-pos-norm", num);
+  PropertyManager->Tie( tmp.c_str(), this, num, &FGFCS::GetPropFeather,
                                         &FGFCS::SetPropFeather);
 }
 
@@ -935,12 +928,12 @@ void FGFCS::bindThrottle(unsigned int num)
 void FGFCS::bindModel(void)
 {
   unsigned int i;
-  char tmp[80];
+  string tmp;
 
   for (i=0; i<SteerPosDeg.size(); i++) {
     if (GroundReactions->GetGearUnit(i)->GetSteerable()) {
-      snprintf(tmp,80,"fcs/steer-pos-deg[%u]",i);
-      PropertyManager->Tie( tmp, this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg);
+      tmp = CreateIndexedPropertyName("fcs/steer-pos-deg", i);
+      PropertyManager->Tie( tmp.c_str(), this, i, &FGFCS::GetSteerPosDeg, &FGFCS::SetSteerPosDeg);
     }
   }
 }
index 33d443e5b72f58852d0f970c727300391cab9c25..8aa9ca9ffc750ce63083663079a29b293bf9d84b 100644 (file)
@@ -206,31 +206,31 @@ public:
   //@{
   /** Gets the aileron command.
       @return aileron command in range from -1.0 - 1.0 */
-  inline double GetDaCmd(void) const { return DaCmd; }
+  double GetDaCmd(void) const { return DaCmd; }
 
   /** Gets the elevator command.
       @return elevator command in range from -1.0 - 1.0 */
-  inline double GetDeCmd(void) const { return DeCmd; }
+  double GetDeCmd(void) const { return DeCmd; }
 
   /** Gets the rudder command.
       @return rudder command in range from -1.0 - 1.0 */
-  inline double GetDrCmd(void) const { return DrCmd; }
+  double GetDrCmd(void) const { return DrCmd; }
 
   /** Gets the steering command.
       @return steering command in range from -1.0 - 1.0 */
-  inline double GetDsCmd(void) const { return DsCmd; }
+  double GetDsCmd(void) const { return DsCmd; }
 
   /** Gets the flaps command.
       @return flaps command in range from 0 to 1.0 */
-  inline double GetDfCmd(void) const { return DfCmd; }
+  double GetDfCmd(void) const { return DfCmd; }
 
   /** Gets the speedbrake command.
       @return speedbrake command in range from 0 to 1.0 */
-  inline double GetDsbCmd(void) const { return DsbCmd; }
+  double GetDsbCmd(void) const { return DsbCmd; }
 
   /** Gets the spoiler command.
       @return spoiler command in range from 0 to 1.0 */
-  inline double GetDspCmd(void) const { return DspCmd; }
+  double GetDspCmd(void) const { return DspCmd; }
 
   /** Gets the throttle command.
       @param engine engine ID number
@@ -240,73 +240,73 @@ public:
   /** Gets the mixture command.
       @param engine engine ID number
       @return mixture command in range from 0 - 1.0 for the given engine */
-  inline double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
+  double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
 
   /** Gets the prop pitch command.
       @param engine engine ID number
       @return pitch command in range from 0.0 - 1.0 for the given engine */
-  inline double GetPropAdvanceCmd(int engine) const { return PropAdvanceCmd[engine]; }
+  double GetPropAdvanceCmd(int engine) const { return PropAdvanceCmd[engine]; }
 
   /** Gets the prop feather command.
       @param engine engine ID number
       @return feather command for the given engine (on / off)*/
-  inline bool GetFeatherCmd(int engine) const { return PropFeatherCmd[engine]; }
+  bool GetFeatherCmd(int engine) const { return PropFeatherCmd[engine]; }
 
   /** Gets the pitch trim command.
       @return pitch trim command in range from -1.0 to 1.0 */
-  inline double GetPitchTrimCmd(void) const { return PTrimCmd; }
+  double GetPitchTrimCmd(void) const { return PTrimCmd; }
 
   /** Gets the rudder trim command.
       @return rudder trim command in range from -1.0 - 1.0 */
-  inline double GetYawTrimCmd(void) const { return YTrimCmd; }
+  double GetYawTrimCmd(void) const { return YTrimCmd; }
 
   /** Gets the aileron trim command.
       @return aileron trim command in range from -1.0 - 1.0 */
-  inline double GetRollTrimCmd(void) const { return RTrimCmd; }
+  double GetRollTrimCmd(void) const { return RTrimCmd; }
 
   /** Get the gear extend/retract command. 0 commands gear up, 1 down.
       defaults to down.
       @return the current value of the gear extend/retract command*/
-  inline double GetGearCmd(void) const { return GearCmd; }
+  double GetGearCmd(void) const { return GearCmd; }
   //@}
 
   /// @name Aerosurface position retrieval
   //@{
   /** Gets the left aileron position.
       @return aileron position in radians */
-  inline double GetDaLPos( int form = ofRad )
+  double GetDaLPos( int form = ofRad )
                          const { return DaLPos[form]; }
 
   /// @name Aerosurface position retrieval
   //@{
   /** Gets the right aileron position.
       @return aileron position in radians */
-  inline double GetDaRPos( int form = ofRad )
+  double GetDaRPos( int form = ofRad )
                          const { return DaRPos[form]; }
 
   /** Gets the elevator position.
       @return elevator position in radians */
-  inline double GetDePos( int form = ofRad )
+  double GetDePos( int form = ofRad )
                          const { return DePos[form]; }
 
   /** Gets the rudder position.
       @return rudder position in radians */
-  inline double GetDrPos( int form = ofRad )
+  double GetDrPos( int form = ofRad )
                          const { return DrPos[form]; }
 
   /** Gets the speedbrake position.
       @return speedbrake position in radians */
-  inline double GetDsbPos( int form = ofRad )
+  double GetDsbPos( int form = ofRad )
                          const { return DsbPos[form]; }
 
   /** Gets the spoiler position.
       @return spoiler position in radians */
-  inline double GetDspPos( int form = ofRad )
+  double GetDspPos( int form = ofRad )
                          const { return DspPos[form]; }
 
   /** Gets the flaps position.
       @return flaps position in radians */
-  inline double GetDfPos( int form = ofRad )
+  double GetDfPos( int form = ofRad )
                          const { return DfPos[form]; }
 
   /** Gets the throttle position.
@@ -317,7 +317,7 @@ public:
   /** Gets the mixture position.
       @param engine engine ID number
       @return mixture position for the given engine in range from 0 - 1.0 */
-  inline double GetMixturePos(int engine) const { return MixturePos[engine]; }
+  double GetMixturePos(int engine) const { return MixturePos[engine]; }
 
   /** Gets the steering position.
       @return steering position in degrees */
@@ -325,31 +325,31 @@ public:
 
   /** Gets the gear position (0 up, 1 down), defaults to down
       @return gear position (0 up, 1 down) */
-  inline double GetGearPos(void) const { return GearPos; }
+  double GetGearPos(void) const { return GearPos; }
 
   /** Gets the tailhook position (0 up, 1 down)
       @return tailhook position (0 up, 1 down) */
-  inline double GetTailhookPos(void) const { return TailhookPos; }
+  double GetTailhookPos(void) const { return TailhookPos; }
 
   /** Gets the wing fold position (0 unfolded, 1 folded)
       @return wing fold position (0 unfolded, 1 folded) */
-  inline double GetWingFoldPos(void) const { return WingFoldPos; }
+  double GetWingFoldPos(void) const { return WingFoldPos; }
 
   /** Gets the prop pitch position.
       @param engine engine ID number
       @return prop pitch position for the given engine in range from 0 - 1.0 */
-  inline double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
+  double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
 
   /** Gets the prop feather position.
       @param engine engine ID number
       @return prop fether for the given engine (on / off)*/
-  inline bool GetPropFeather(int engine) const { return PropFeather[engine]; }
+  bool GetPropFeather(int engine) const { return PropFeather[engine]; }
   //@}
 
   /** Retrieves the State object pointer.
       This is used by the FGFCS-owned components.
       @return pointer to the State object */
-  inline FGState* GetState(void) { return State; }
+  FGState* GetState(void) { return State; }
 
   /** Retrieves all component names for inclusion in output stream
       @param delimeter either a tab or comma string depending on output type
@@ -366,43 +366,43 @@ public:
   //@{
   /** Sets the aileron command
       @param cmd aileron command */
-  inline void SetDaCmd( double cmd ) { DaCmd = cmd; }
+  void SetDaCmd( double cmd ) { DaCmd = cmd; }
 
   /** Sets the elevator command
       @param cmd elevator command in percent*/
-  inline void SetDeCmd(double cmd ) { DeCmd = cmd; }
+  void SetDeCmd(double cmd ) { DeCmd = cmd; }
 
   /** Sets the rudder command
       @param cmd rudder command in percent*/
-  inline void SetDrCmd(double cmd) { DrCmd = cmd; }
+  void SetDrCmd(double cmd) { DrCmd = cmd; }
 
   /** Sets the steering command
       @param cmd steering command in percent*/
-  inline void SetDsCmd(double cmd) { DsCmd = cmd; }
+  void SetDsCmd(double cmd) { DsCmd = cmd; }
 
   /** Sets the flaps command
       @param cmd flaps command in percent*/
-  inline void SetDfCmd(double cmd) { DfCmd = cmd; }
+  void SetDfCmd(double cmd) { DfCmd = cmd; }
 
   /** Sets the speedbrake command
       @param cmd speedbrake command in percent*/
-  inline void SetDsbCmd(double cmd) { DsbCmd = cmd; }
+  void SetDsbCmd(double cmd) { DsbCmd = cmd; }
 
   /** Sets the spoilers command
       @param cmd spoilers command in percent*/
-  inline void SetDspCmd(double cmd) { DspCmd = cmd; }
+  void SetDspCmd(double cmd) { DspCmd = cmd; }
 
   /** Sets the pitch trim command
       @param cmd pitch trim command in percent*/
-  inline void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
+  void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
 
   /** Sets the rudder trim command
       @param cmd rudder trim command in percent*/
-  inline void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
+  void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
 
   /** Sets the aileron trim command
       @param cmd aileron trim command in percent*/
-  inline void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
+  void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
 
   /** Sets the throttle command for the specified engine
       @param engine engine ID number
@@ -433,31 +433,31 @@ public:
   //@{
   /** Sets the left aileron position
       @param cmd left aileron position in radians*/
-  inline void SetDaLPos( int form , double pos );
+  void SetDaLPos( int form , double pos );
 
   /** Sets the right aileron position
       @param cmd right aileron position in radians*/
-  inline void SetDaRPos( int form , double pos );
+  void SetDaRPos( int form , double pos );
 
   /** Sets the elevator position
       @param cmd elevator position in radians*/
-  inline void SetDePos( int form , double pos );
+  void SetDePos( int form , double pos );
 
   /** Sets the rudder position
       @param cmd rudder position in radians*/
-  inline void SetDrPos( int form , double pos );
+  void SetDrPos( int form , double pos );
 
    /** Sets the flaps position
       @param cmd flaps position in radians*/
-  inline void SetDfPos( int form , double pos );
+  void SetDfPos( int form , double pos );
 
   /** Sets the speedbrake position
       @param cmd speedbrake position in radians*/
-  inline void SetDsbPos( int form , double pos );
+  void SetDsbPos( int form , double pos );
 
   /** Sets the spoiler position
       @param cmd spoiler position in radians*/
-  inline void SetDspPos( int form , double pos );
+  void SetDspPos( int form , double pos );
 
   /** Sets the actual throttle setting for the specified engine
       @param engine engine ID number
index f876defd61f25f67a16b440bfa9db25bc7e18630..e6b32b6e00ec1ccd967d4f7b35397210a78653de 100644 (file)
@@ -196,29 +196,25 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, int num) : FGForce(exec)
   Mass = Contents * M_gas();
 
   // Bind relevant properties
-  char property_name[80];
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/max_volume-ft3",
-           CellNum);
-  PropertyManager->Tie( property_name, &MaxVolume );
+  string property_name, base_property_name;
+
+  base_property_name = CreateIndexedPropertyName("buoyant_forces/gas-cell", CellNum);
+
+  property_name = base_property_name + "/max_volume-ft3";
+  PropertyManager->Tie( property_name.c_str(), &MaxVolume );
   PropertyManager->SetWritable( property_name, false );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/temp-R",
-           CellNum);
-  PropertyManager->Tie( property_name, &Temperature );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/pressure-psf",
-           CellNum);
-  PropertyManager->Tie( property_name, &Pressure );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/volume-ft3",
-           CellNum);
-  PropertyManager->Tie( property_name, &Volume );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/buoyancy-lbs",
-           CellNum);
-  PropertyManager->Tie( property_name, &Buoyancy );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/contents-mol",
-           CellNum);
-  PropertyManager->Tie( property_name, &Contents );
-  snprintf(property_name, 80, "buoyant_forces/gas-cell[%d]/valve_open",
-           CellNum);
-  PropertyManager->Tie( property_name, &ValveOpen );
+  property_name = base_property_name + "/temp-R";
+  PropertyManager->Tie( property_name.c_str(), &Temperature );
+  property_name = base_property_name + "/pressure-psf";
+  PropertyManager->Tie( property_name.c_str(), &Pressure );
+  property_name = base_property_name + "/volume-ft3";
+  PropertyManager->Tie( property_name.c_str(), &Volume );
+  property_name = base_property_name + "/buoyancy-lbs";
+  PropertyManager->Tie( property_name.c_str(), &Buoyancy );
+  property_name = base_property_name + "/contents-mol";
+  PropertyManager->Tie( property_name.c_str(), &Contents );
+  property_name = base_property_name + "/valve_open";
+  PropertyManager->Tie( property_name.c_str(), &ValveOpen );
 
   Debug(0);
 
@@ -640,37 +636,27 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, int num, FGGasCell* parent)
   Volume = Contents * R * Temperature / Pressure;
 
   // Bind relevant properties
-  char property_name[80];
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/max_volume-ft3",
-           Parent->GetIndex(),
-           CellNum);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("buoyant_forces/gas-cell", Parent->GetIndex());
+  base_property_name = CreateIndexedPropertyName(base_property_name + "/ballonet", CellNum);
+
+  property_name = base_property_name + "/max_volume-ft3";
   PropertyManager->Tie( property_name, &MaxVolume );
   PropertyManager->SetWritable( property_name, false );
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/temp-R",
-           Parent->GetIndex(),
-           CellNum);
+
+  property_name = base_property_name + "/temp-R";
   PropertyManager->Tie( property_name, &Temperature );
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/pressure-psf",
-           Parent->GetIndex(),
-           CellNum);
+
+  property_name = base_property_name + "/pressure-psf";
   PropertyManager->Tie( property_name, &Pressure );
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/volume-ft3",
-           Parent->GetIndex(),
-           CellNum);
+
+  property_name = base_property_name + "/volume-ft3";
   PropertyManager->Tie( property_name, &Volume );
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/contents-mol",
-           Parent->GetIndex(),
-           CellNum);
+
+  property_name = base_property_name + "/contents-mol";
   PropertyManager->Tie( property_name, &Contents );
-  snprintf(property_name, 80,
-           "buoyant_forces/gas-cell[%d]/ballonet[%d]/valve_open",
-           Parent->GetIndex(),
-           CellNum);
+
+  property_name = base_property_name + "/valve_open";
   PropertyManager->Tie( property_name, &ValveOpen );
 
   Debug(0);
index 08011197629defd73c05bcd6c18e418a22b64d68..5d4ff071e56d47e2447ee7568fd6744b3aee6737 100644 (file)
@@ -190,6 +190,9 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
     }
   }
 
+  LongForceFilter = Filter(LongForceLagFilterCoeff, State->Getdt());
+  LatForceFilter = Filter(LatForceLagFilterCoeff, State->Getdt());
+
   WheelSlipLagFilterCoeff = 1/State->Getdt();
 
   Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
@@ -197,6 +200,8 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
     WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
   }
   
+  WheelSlipFilter = Filter(WheelSlipLagFilterCoeff, State->Getdt());
+
   GearUp = false;
   GearDown = true;
   GearPos  = 1.0;
@@ -241,9 +246,6 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) :
   SinWheel = 0.0;
   CosWheel = 0.0;
 
-  prevSlipIn  = 0.0;
-  prevSlipOut = 0.0;
-
   Debug(0);
 }
 
@@ -312,15 +314,14 @@ FGLGear::FGLGear(const FGLGear& lgear)
   ForceY_Table    = lgear.ForceY_Table;
   CosWheel        = lgear.CosWheel;
   SinWheel        = lgear.SinWheel;
-  prevOut         = lgear.prevOut;
-  prevIn          = lgear.prevIn;
-  prevSlipIn      = lgear.prevSlipIn;
-  prevSlipOut     = lgear.prevSlipOut;
   RFRV            = lgear.RFRV;
   SFRV            = lgear.SFRV;
   LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
   LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
   WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
+  WheelSlipFilter = lgear.WheelSlipFilter;
+  LongForceFilter = lgear.LongForceFilter;
+  LatForceFilter = lgear.LatForceFilter;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -385,40 +386,20 @@ FGColumnVector3& FGLGear::Force(void)
 
       vForce  = Propagate->GetTl2b() * vLocalForce;
 
-      // Lag and attenuate the XY-plane forces dependent on velocity
-
-      double ca, cb, denom;
-      FGColumnVector3 Output;
+      // Lag and attenuate the XY-plane forces dependent on velocity. This code
+      // uses a lag filter, C/(s + C) where "C" is the filter coefficient. When
+      // "C" is chosen at the frame rate (in Hz), the jittering is significantly
+      // reduced. This is because the jitter is present *at* the execution rate.
+      // If a coefficient is set to something equal to or less than zero, the
+      // filter is bypassed.
 
-      // This code implements a lag filter, C/(s + C) where
-      // "C" is the filter coefficient. When "C" is chosen at the 
-      // frame rate (in Hz), the jittering is significantly reduced. This is because
-      // the jitter is present *at* the execution rate.
-      // If a coefficient is set to something equal to or less than zero, the filter
-      // is bypassed.
-
-      if (LongForceLagFilterCoeff > 0) { 
-        denom = 2.00 + dT*LongForceLagFilterCoeff;
-        ca = dT*LongForceLagFilterCoeff / denom;
-        cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
-        Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
-        vForce(eX) = Output(eX);
-      }
-      if (LatForceLagFilterCoeff > 0) { 
-        denom = 2.00 + dT*LatForceLagFilterCoeff;
-        ca = dT*LatForceLagFilterCoeff / denom;
-        cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
-        Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
-        vForce(eY) = Output(eY);
-      }
-
-      prevIn = vForce;
-      prevOut = Output;
+      if (LongForceLagFilterCoeff > 0) vForce(eX) = LongForceFilter.execute(vForce(eX));
+      if (LatForceLagFilterCoeff > 0)  vForce(eY) = LatForceFilter.execute(vForce(eY));
 
       if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
       if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
 
-  // End section for attentuating gear jitter
+      // End section for attentuating gear jitter
 
       vMoment = vWhlBodyVec * vForce;
 
@@ -472,22 +453,10 @@ void FGLGear::ComputeSlipAngle(void)
   SideWhlVel    = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
 
   // Calculate tire slip angle.
-    WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
+  WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
 
   // Filter the wheel slip angle
-
-  double SlipOutput, ca, cb, denom;
-
-  if (WheelSlipLagFilterCoeff > 0) {
-    denom = 2.00 + dT*WheelSlipLagFilterCoeff;
-    ca = dT*WheelSlipLagFilterCoeff / denom;
-    cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
-
-    SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
-
-    prevSlipIn = WheelSlip;
-    WheelSlip = prevSlipOut = SlipOutput;
-  }
+  if (WheelSlipLagFilterCoeff > 0) WheelSlip = WheelSlipFilter.execute(WheelSlip);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -729,24 +698,26 @@ double FGLGear::GetGearUnitPos(void)
 
 void FGLGear::bind(void)
 {
-  char property_name[80];
+  string property_name;
+  string base_property_name;
+  base_property_name = CreateIndexedPropertyName("gear/unit", GearNumber);
   if (eContactType == ctBOGEY) {
-    snprintf(property_name, 80, "gear/unit[%d]/slip-angle-deg", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, &WheelSlip );
-    snprintf(property_name, 80, "gear/unit[%d]/WOW", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, &WOW );
-    snprintf(property_name, 80, "gear/unit[%d]/wheel-speed-fps", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, &RollingWhlVel );
-    snprintf(property_name, 80, "gear/unit[%d]/z-position", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, (FGLGear*)this,
+    property_name = base_property_name + "/slip-angle-deg";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), &WheelSlip );
+    property_name = base_property_name + "/WOW";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), &WOW );
+    property_name = base_property_name + "/wheel-speed-fps";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), &RollingWhlVel );
+    property_name = base_property_name + "/z-position";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), (FGLGear*)this,
                           &FGLGear::GetZPosition, &FGLGear::SetZPosition);
-    snprintf(property_name, 80, "gear/unit[%d]/compression-ft", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, &compressLength );
+    property_name = base_property_name + "/compression-ft";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), &compressLength );
   }
 
   if( isRetractable ) {
-    snprintf(property_name, 80, "gear/unit[%d]/pos-norm", GearNumber);
-    Exec->GetPropertyManager()->Tie( property_name, &GearPos );
+    property_name = base_property_name + "/pos-norm";
+    Exec->GetPropertyManager()->Tie( property_name.c_str(), &GearPos );
   }
 
 }
index 4de980edf1df2ab16785e8eca7bf5ef79394e944..11020158bd678c230785b2eec1b807654a458b79 100644 (file)
@@ -224,7 +224,6 @@ public:
   /// Destructor
   ~FGLGear();
 
-
   /// The Force vector for this gear
   FGColumnVector3& Force(void);
   /// The Moment vector for this gear
@@ -304,7 +303,6 @@ private:
   FGColumnVector3 vLocalForce;
   FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
   FGColumnVector3 normal, cvel;
-  FGColumnVector3 prevOut, prevIn;
   FGLocation contact, gearLoc;
   FGTable *ForceY_Table;
   double dT;
@@ -328,8 +326,6 @@ private:
   double SideWhlVel, RollingWhlVel;
   double RollingForce, SideForce, FCoeff;
   double WheelSlip;
-  double prevSlipIn;
-  double prevSlipOut;
   double TirePressureNorm;
   double SinWheel, CosWheel;
   double GearPos;
@@ -362,6 +358,10 @@ private:
   double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
   double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
 
+  Filter LongForceFilter;
+  Filter LatForceFilter;
+  Filter WheelSlipFilter;
+
   FGFDMExec*     Exec;
   FGState*       State;
   FGAircraft*    Aircraft;
index 64f09253deb797487b34b57588f106518f72fbce..34f6f9cd6bc127c59853993c72f77d033ac9362f 100644 (file)
@@ -50,10 +50,6 @@ DEFINITIONS
 
 #define ID_MASSBALANCE "$Id$"
 
-#if defined(WIN32) && !defined(__CYGWIN__)
-#define snprintf _snprintf
-#endif
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONSS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -177,7 +173,6 @@ private:
   FGMatrix33& CalculatePMInertias(void);
 
   struct PointMass {
-    char tmp[80];
     PointMass(double w, FGColumnVector3& vXYZ) {
       Weight = w;
       Location = vXYZ;
@@ -190,18 +185,18 @@ private:
     double GetPointMassWeight(void) const {return Weight;}
 
     void bind(FGPropertyManager* PropertyManager, int num) {
-      snprintf(tmp, 80, "inertia/pointmass-weight-lbs[%u]", num);
-      PropertyManager->Tie( tmp, this, &PointMass::GetPointMassWeight,
+      string tmp = CreateIndexedPropertyName("inertia/pointmass-weight-lbs", num);
+      PropertyManager->Tie( tmp.c_str(), this, &PointMass::GetPointMassWeight,
                                        &PointMass::SetPointMassWeight);
 
-      snprintf(tmp, 80, "inertia/pointmass-location-X-inches[%u]", num);
-      PropertyManager->Tie( tmp, this, eX, &PointMass::GetPointMassLocation,
+      tmp = CreateIndexedPropertyName("inertia/pointmass-location-X-inches", num);
+      PropertyManager->Tie( tmp.c_str(), this, eX, &PointMass::GetPointMassLocation,
                                            &PointMass::SetPointMassLocation);
-      snprintf(tmp, 80, "inertia/pointmass-location-Y-inches[%u]", num);
-      PropertyManager->Tie( tmp, this, eY, &PointMass::GetPointMassLocation,
+      tmp = CreateIndexedPropertyName("inertia/pointmass-location-Y-inches", num);
+      PropertyManager->Tie( tmp.c_str(), this, eY, &PointMass::GetPointMassLocation,
                                            &PointMass::SetPointMassLocation);
-      snprintf(tmp, 80, "inertia/pointmass-location-Z-inches[%u]", num);
-      PropertyManager->Tie( tmp, this, eZ, &PointMass::GetPointMassLocation,
+      tmp = CreateIndexedPropertyName("inertia/pointmass-location-Z-inches", num);
+      PropertyManager->Tie( tmp.c_str(), this, eZ, &PointMass::GetPointMassLocation,
                                            &PointMass::SetPointMassLocation);
     }
   };
index 49937ab8f2b34e9c913f59fad647bafd2eeb5736..d79f12c92cadbe34770000485925c45ca3a5204b 100644 (file)
@@ -115,13 +115,15 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number)
     cerr << "No feed tank specified in engine definition." << endl;
   }
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/set-running", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGEngine::GetRunning, &FGEngine::SetRunning );
-  snprintf(property_name, 80, "propulsion/engine[%u]/thrust-lbs", EngineNumber);
-  PropertyManager->Tie( property_name, Thruster, &FGThruster::GetThrust);
-  snprintf(property_name, 80, "propulsion/engine[%u]/fuel-flow-rate-pps", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGEngine::GetFuelFlowRate);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+
+  property_name = base_property_name + "/set-running";
+  PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetRunning, &FGEngine::SetRunning );
+  property_name = base_property_name + "/thrust-lbs";
+  PropertyManager->Tie( property_name.c_str(), Thruster, &FGThruster::GetThrust);
+  property_name = base_property_name + "/fuel-flow-rate-pps";
+  PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelFlowRate);
 
   Debug(0);
 }
index bac4eaa919591dd2e6c20ff921ccb2ff74c23218..a18a8624e099173140e97da57353c7312c95b4ff 100644 (file)
@@ -219,13 +219,14 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
       MaxManifoldPressure_Percent = MaxManifoldPressure_inHg / 29.92;
   }
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/power-hp", EngineNumber);
-  PropertyManager->Tie(property_name, &HP);
-  snprintf(property_name, 80, "propulsion/engine[%d]/bsfc-lbs_hphr", EngineNumber);
-  PropertyManager->Tie(property_name, &BSFC);
-  snprintf(property_name, 80, "propulsion/engine[%d]/volumetric-efficiency", EngineNumber);
-  PropertyManager->Tie(property_name, &volumetric_efficiency);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+  property_name = base_property_name + "/power-hp";
+  PropertyManager->Tie(property_name.c_str(), &HP);
+  property_name = base_property_name + "/bsfc-lbs_hphr";
+  PropertyManager->Tie(property_name.c_str(), &BSFC);
+  property_name = base_property_name + "/volumetric-efficiency";
+  PropertyManager->Tie(property_name.c_str(), &volumetric_efficiency);
   minMAP = MinManifoldPressure_inHg * inhgtopa;  // inHg to Pa
   maxMAP = MaxManifoldPressure_inHg * inhgtopa;
   StarterHP = sqrt(MaxHP) * 0.4;
index 55ea67ffe1f1726abc3dbe3ae5d94f30b1ab95cc..28ded401250c0611241ac950156c77b3cf9aa95c 100644 (file)
@@ -126,15 +126,16 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
   D4 = Diameter*Diameter*Diameter*Diameter;
   D5 = D4*Diameter;
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/advance-ratio", EngineNum);
-  PropertyManager->Tie( property_name, &J );
-  snprintf(property_name, 80, "propulsion/engine[%d]/blade-angle", EngineNum);
-  PropertyManager->Tie( property_name, &Pitch );
-  snprintf(property_name, 80, "propulsion/engine[%d]/thrust-coefficient", EngineNum);
-  PropertyManager->Tie( property_name, this, &FGPropeller::GetThrustCoefficient );
-  snprintf(property_name, 80, "propulsion/engine[%d]/propeller-rpm", EngineNum);
-  PropertyManager->Tie( property_name, this, &FGPropeller::GetRPM );
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
+  property_name = base_property_name + "/advance-ratio";
+  PropertyManager->Tie( property_name.c_str(), &J );
+  property_name = base_property_name + "/blade-angle";
+  PropertyManager->Tie( property_name.c_str(), &Pitch );
+  property_name = base_property_name + "/thrust-coefficient";
+  PropertyManager->Tie( property_name.c_str(), this, &FGPropeller::GetThrustCoefficient );
+  property_name = base_property_name + "/propeller-rpm";
+  PropertyManager->Tie( property_name.c_str(), this, &FGPropeller::GetRPM );
 
   Debug(0);
 }
@@ -236,8 +237,7 @@ double FGPropeller::GetPowerRequired(void)
           double dRPM = rpmReq - RPM;
           // The pitch of a variable propeller cannot be changed when the RPMs are
           // too low - the oil pump does not work.
-          if (RPM > 200) Pitch -= dRPM / 10;
-
+          if (RPM > 200) Pitch -= dRPM * deltaT;
           if (Pitch < MinPitch)       Pitch = MinPitch;
           else if (Pitch > MaxPitch)  Pitch = MaxPitch;
 
index b4edabfdd50f4ac3827685f0c2d480200a351a1e..f6716dca3fbd61c0c6622030e0bf23fc3ff1249c 100644 (file)
@@ -274,14 +274,15 @@ string FGRocket::GetEngineValues(string delimeter)
 //
 void FGRocket::bindmodel()
 {
-  char property_name[80];
-
-  snprintf(property_name, 80, "propulsion/engine[%u]/total-impulse", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGRocket::GetTotalImpulse);
-  snprintf(property_name, 80, "propulsion/engine[%u]/oxi-flow-rate-pps", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGRocket::GetOxiFlowRate);
-  snprintf(property_name, 80, "propulsion/engine[%u]/vacuum-thrust_lbs", EngineNumber);
-  PropertyManager->Tie( property_name, this, &FGRocket::GetVacThrust);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+
+  property_name = base_property_name + "/total-impulse";
+  PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetTotalImpulse);
+  property_name = base_property_name + "/oxi-flow-rate-pps";
+  PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetOxiFlowRate);
+  property_name = base_property_name + "/vacuum-thrust_lbs";
+  PropertyManager->Tie( property_name.c_str(), this, &FGRocket::GetVacThrust);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index af174d46db39deedbb45de50af11e33c35e4b82f..7b5e6729d6f695eac8d1961ffb38c27a509554bf 100644 (file)
@@ -137,19 +137,18 @@ FGTank::FGTank(FGFDMExec* exec, Element* el, int tank_number)
         exit(-1);
     }
     Density = (Contents*lbtoslug)/Volume; // slugs/in^3
-
+    CalculateInertias();
   }
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/tank[%d]/contents-lbs", TankNumber);
-  PropertyManager->Tie( property_name, (FGTank*)this, &FGTank::GetContents,
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/tank", TankNumber);
+  property_name = base_property_name + "/contents-lbs";
+  PropertyManager->Tie( property_name.c_str(), (FGTank*)this, &FGTank::GetContents,
                                        &FGTank::SetContents );
 
   if (Temperature != -9999.0)  InitialTemperature = Temperature = FahrenheitToCelsius(Temperature);
   Area = 40.0 * pow(Capacity/1975, 0.666666667);
 
-  CalculateInertias();
-
   Debug(0);
 }
 
@@ -265,7 +264,13 @@ void FGTank::CalculateInertias(void)
   double Mass = Contents*lbtoslug;
   double RadSumSqr;
   double Rad2 = Radius*Radius;
-  Volume = (Contents*lbtoslug)/Density; // in^3
+
+  if (Density > 0.0) {
+    Volume = (Contents*lbtoslug)/Density; // in^3
+  } else {
+    cerr << endl << "  Solid propellant grain density is zero!" << endl << endl;
+    exit(-1);
+  }
 
   switch (grainType) {
     case gtCYLINDRICAL:
index 9bbe8ed1c87a89da170032e0680212b077aca23d..48fb0692a4ba555639029ba8f065cb88935c1b3c 100644 (file)
@@ -79,17 +79,18 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
   SetLocation(location);
   SetAnglesToBody(orientation);
 
-  char property_name[80];
-  snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
-  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
-  snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
-  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNum);
+  property_name = base_property_name + "/pitch-angle-rad";
+  PropertyManager->Tie( property_name.c_str(), (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
+  property_name = base_property_name + "/yaw-angle-rad";
+  PropertyManager->Tie( property_name.c_str(), (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
 
   if (el->GetName() == "direct") // this is a direct thruster. At this time
                                  // only a direct thruster can be reversed.
   {
-    snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
-    PropertyManager->Tie( property_name, (FGThruster *)this, &FGThruster::GetReverserAngle,
+    property_name = base_property_name + "/reverser-angle-rad";
+    PropertyManager->Tie( property_name.c_str(), (FGThruster *)this, &FGThruster::GetReverserAngle,
                                                           &FGThruster::SetReverserAngle);
   }
 
index 16bc0fe1ea2dfe18a537324111ee12f69118c9f7..b713f56345fe51383f69f49f7f858736865f1419 100644 (file)
@@ -396,8 +396,8 @@ double FGTurbine::Seek(double *var, double target, double accel, double decel) {
 
 bool FGTurbine::Load(FGFDMExec* exec, Element *el)
 {
-  char property_prefix[80];
-  snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber);
+  string property_name, property_prefix;
+  property_prefix = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
 
   if (el->FindElement("milthrust"))
     MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
@@ -492,14 +492,14 @@ string FGTurbine::GetEngineValues(string delimeter)
 
 void FGTurbine::bindmodel()
 {
-  char property_name[80];
-
-  snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
-  PropertyManager->Tie( property_name, &N1);
-  snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
-  PropertyManager->Tie( property_name, &N2);
-  snprintf(property_name, 80, "propulsion/engine[%u]/injection_cmd", EngineNumber);
-  PropertyManager->Tie( property_name, (FGTurbine*)this, 
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+  property_name = base_property_name + "/n1";
+  PropertyManager->Tie( property_name.c_str(), &N1);
+  property_name = base_property_name + "/n2";
+  PropertyManager->Tie( property_name.c_str(), &N2);
+  property_name = base_property_name + "/injection_cmd";
+  PropertyManager->Tie( property_name.c_str(), (FGTurbine*)this, 
                         &FGTurbine::GetInjection, &FGTurbine::SetInjection);
 }
 
index be304747f74db764deca41b9c09af28ad063c15d..893c994e6bbcc2b5c427d633de787fb0350e53d3 100755 (executable)
@@ -76,9 +76,6 @@ FGTurboProp::~FGTurboProp()
 
 bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
 {
-  char property_prefix[80];
-  snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber);
-
   IdleFF=-1;
   MaxStartingTime = 999999; //very big timeout -> infinite
   Ielu_max_torque=-1;
@@ -493,7 +490,9 @@ string FGTurboProp::GetEngineValues(string delimeter)
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-int FGTurboProp::InitRunning(void) {
+
+int FGTurboProp::InitRunning(void)
+{
   State->SuspendIntegration();
   Cutoff=false;
   Running=true;  
@@ -503,19 +502,18 @@ int FGTurboProp::InitRunning(void) {
   return phase==tpRun;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGTurboProp::bindmodel()
 {
-  char property_name[80];
-
-// ToDo: Do a proper Tie here, this should be read only.
-
-  snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
-  PropertyManager->Tie( property_name, &N1);
-  snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
-  PropertyManager->Tie( property_name, &N2);
-  snprintf(property_name, 80, "propulsion/engine[%u]/reverser", EngineNumber);
-  PropertyManager->Tie( property_name, &Reversed);
-
+  string property_name, base_property_name;
+  base_property_name = CreateIndexedPropertyName("propulsion/engine", EngineNumber);
+  property_name = base_property_name + "/n1";
+  PropertyManager->Tie( property_name.c_str(), &N1);
+  property_name = base_property_name + "/n2";
+  PropertyManager->Tie( property_name.c_str(), &N2);
+  property_name = base_property_name + "/reverser";
+  PropertyManager->Tie( property_name.c_str(), &Reversed);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%