]> git.mxchange.org Git - flightgear.git/commitdiff
Synchronized with JSBSim/CVS
authorbcoconni <bcoconni>
Sun, 24 Nov 2013 19:12:17 +0000 (20:12 +0100)
committerbcoconni <bcoconni>
Sun, 24 Nov 2013 19:12:17 +0000 (20:12 +0100)
84 files changed:
src/FDM/JSBSim/CMakeLists.txt
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGFDMExec.h
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/initialization/FGInitialCondition.cpp
src/FDM/JSBSim/initialization/FGInitialCondition.h
src/FDM/JSBSim/initialization/FGTrim.cpp
src/FDM/JSBSim/initialization/FGTrim.h
src/FDM/JSBSim/initialization/FGTrimAxis.cpp
src/FDM/JSBSim/initialization/FGTrimAxis.h
src/FDM/JSBSim/input_output/FGOutputFG.cpp
src/FDM/JSBSim/input_output/FGOutputFile.cpp
src/FDM/JSBSim/input_output/FGOutputSocket.cpp
src/FDM/JSBSim/input_output/FGOutputTextFile.cpp
src/FDM/JSBSim/input_output/FGOutputType.cpp
src/FDM/JSBSim/input_output/FGPropertyManager.h
src/FDM/JSBSim/input_output/FGScript.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/input_output/FGScript.h
src/FDM/JSBSim/input_output/FGXMLElement.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/input_output/FGXMLElement.h [changed mode: 0644->0755]
src/FDM/JSBSim/input_output/FGXMLFileRead.h [changed mode: 0644->0755]
src/FDM/JSBSim/input_output/FGXMLParse.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/input_output/net_fdm.hxx
src/FDM/JSBSim/input_output/string_utilities.h
src/FDM/JSBSim/math/FGFunction.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/math/FGLocation.cpp
src/FDM/JSBSim/math/FGLocation.h
src/FDM/JSBSim/math/FGModelFunctions.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/math/FGModelFunctions.h [changed mode: 0644->0755]
src/FDM/JSBSim/math/FGPropertyValue.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/math/FGPropertyValue.h [changed mode: 0644->0755]
src/FDM/JSBSim/math/FGQuaternion.h
src/FDM/JSBSim/models/FGAerodynamics.cpp
src/FDM/JSBSim/models/FGAerodynamics.h
src/FDM/JSBSim/models/FGAircraft.cpp
src/FDM/JSBSim/models/FGAircraft.h
src/FDM/JSBSim/models/FGBuoyantForces.cpp
src/FDM/JSBSim/models/FGBuoyantForces.h
src/FDM/JSBSim/models/FGExternalReactions.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/FGExternalReactions.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/FGFCS.cpp
src/FDM/JSBSim/models/FGFCS.h
src/FDM/JSBSim/models/FGFCSChannel.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/FGGroundReactions.cpp
src/FDM/JSBSim/models/FGGroundReactions.h
src/FDM/JSBSim/models/FGLGear.cpp
src/FDM/JSBSim/models/FGLGear.h
src/FDM/JSBSim/models/FGMassBalance.cpp
src/FDM/JSBSim/models/FGMassBalance.h
src/FDM/JSBSim/models/FGOutput.cpp
src/FDM/JSBSim/models/FGOutput.h
src/FDM/JSBSim/models/FGPropagate.cpp
src/FDM/JSBSim/models/FGPropulsion.cpp
src/FDM/JSBSim/models/FGPropulsion.h
src/FDM/JSBSim/models/flight_control/FGAccelerometer.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGAccelerometer.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGActuator.cpp
src/FDM/JSBSim/models/flight_control/FGActuator.h
src/FDM/JSBSim/models/flight_control/FGAngles.cpp
src/FDM/JSBSim/models/flight_control/FGDistributor.cpp [new file with mode: 0755]
src/FDM/JSBSim/models/flight_control/FGDistributor.h [new file with mode: 0755]
src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp
src/FDM/JSBSim/models/flight_control/FGFCSComponent.h
src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGFCSFunction.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGGyro.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGGyro.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGMagnetometer.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGMagnetometer.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGSensorOrientation.h [changed mode: 0644->0755]
src/FDM/JSBSim/models/flight_control/FGSwitch.cpp
src/FDM/JSBSim/models/flight_control/FGSwitch.h
src/FDM/JSBSim/models/propulsion/FGElectric.cpp
src/FDM/JSBSim/models/propulsion/FGElectric.h
src/FDM/JSBSim/models/propulsion/FGEngine.cpp
src/FDM/JSBSim/models/propulsion/FGEngine.h
src/FDM/JSBSim/models/propulsion/FGPiston.cpp
src/FDM/JSBSim/models/propulsion/FGRocket.cpp
src/FDM/JSBSim/models/propulsion/FGRocket.h
src/FDM/JSBSim/models/propulsion/FGRotor.cpp
src/FDM/JSBSim/models/propulsion/FGTransmission.cpp
src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp [changed mode: 0644->0755]
src/FDM/JSBSim/models/propulsion/FGTurboProp.h [changed mode: 0644->0755]

index 5449aa1fc9100a44fc53080e8b4e5ffb77e01494..c31b355ba99c245b4722f6b5a112c1afa2de79c6 100644 (file)
@@ -79,6 +79,7 @@ set(HEADERS
     models/flight_control/FGSummer.h
     models/flight_control/FGSwitch.h
     models/flight_control/FGWaypoint.h
+    models/flight_control/FGDistributor.h
     models/propulsion/FGElectric.h
     models/propulsion/FGEngine.h
     models/propulsion/FGForce.h
@@ -168,6 +169,7 @@ set(SOURCES
     models/flight_control/FGSummer.cpp
     models/flight_control/FGSwitch.cpp
     models/flight_control/FGWaypoint.cpp
+    models/flight_control/FGDistributor.cpp
     models/propulsion/FGElectric.cpp
     models/propulsion/FGEngine.cpp
     models/propulsion/FGForce.cpp
index 6f75b26c087d5464507654aa27a1c96e3fe60aaa..b61529229c40c3947ff50ab9792c1792907a8bb8 100644 (file)
@@ -68,12 +68,14 @@ INCLUDES
 #include "initialization/FGLinearization.h"
 #include "input_output/FGPropertyManager.h"
 #include "input_output/FGScript.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.148 2013/06/10 01:46:27 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFDMExec.cpp,v 1.150 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_FDMEXEC;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -160,6 +162,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr) : Root(root)
   instance->Tie("simulation/randomseed", this, (iPMF)0, &FGFDMExec::SRand, false);
   instance->Tie("simulation/terminate", (int *)&Terminate);
   instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
+  instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
   instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
   instance->Tie("simulation/frame", (int *)&Frame, false);
 
@@ -708,8 +711,9 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath)
   }
 
   int saved_debug_lvl = debug_lvl;
+  FGXMLFileRead XMLFileRead;
+  Element *document = XMLFileRead.LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
 
-  document = LoadXMLDocument(aircraftCfgFileName); // "document" is a class member
   if (document) {
     if (IsChild) debug_lvl = 0;
 
index 3ffef02419e66504ac35ee608f92a4866fb5a5b6..bf421552330cb51970af51a1179b133bc50db7ac 100644 (file)
@@ -47,7 +47,6 @@ INCLUDES
 #include "initialization/FGTrim.h"
 #include "FGJSBBase.h"
 #include "input_output/FGPropertyManager.h"
-#include "input_output/FGXMLFileRead.h"
 #include "models/FGPropagate.h"
 #include "math/FGColumnVector3.h"
 #include "models/FGOutput.h"
@@ -56,7 +55,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.83 2013/06/10 01:46:27 jberndt Exp $"
+#define ID_FDMEXEC "$Id: FGFDMExec.h,v 1.85 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -179,14 +178,14 @@ CLASS DOCUMENTATION
                                 property actually maps toa function call of DoTrim().
 
     @author Jon S. Berndt
-    @version $Revision: 1.83 $
+    @version $Revision: 1.85 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGFDMExec : public FGJSBBase, public FGXMLFileRead
+class FGFDMExec : public FGJSBBase
 {
   struct childData {
     FGFDMExec* exec;
index f6efc4b11f58da89c0405adc345f3cb458ae6474..d71d8fca2a8ccc62c5fcd5302430ed1ecbdcb949 100644 (file)
@@ -1261,6 +1261,8 @@ void FGJSBsim::do_trim(void)
     fgtrim = new FGTrim(fdmex,tFull);
   }
 
+  fdmex->RunIC();
+
   if ( !fgtrim->DoTrim() ) {
     fgtrim->Report();
     fgtrim->TrimStats();
index 21d4e8b40b922a5fa3c99b2deaf6031c5170f686..804a61ed8f092bc81aca600d137238fde6f08591 100644 (file)
@@ -58,12 +58,14 @@ INCLUDES
 #include "models/FGFCS.h"
 #include "input_output/FGPropertyManager.h"
 #include "input_output/string_utilities.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.87 2013/01/19 14:19:43 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGInitialCondition.cpp,v 1.89 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_INITIALCONDITION;
 
 //******************************************************************************
@@ -109,7 +111,7 @@ void FGInitialCondition::ResetIC(double u0, double v0, double w0,
 
   position.SetLongitude(lonRad0);
   position.SetLatitude(latRad0);
-  position.SetAltitudeAGL(altAGLFt0, fdmex->GetSimTime());
+  position.SetAltitudeAGL(altAGLFt0, 0.0);
 
   orientation = FGQuaternion(phi0, theta0, psi0);
   const FGMatrix33& Tb2l = orientation.GetTInv();
@@ -665,22 +667,22 @@ void FGInitialCondition::SetTerrainElevationFtIC(double elev)
 
 double FGInitialCondition::GetAltitudeAGLFtIC(void) const
 {
-  return position.GetAltitudeAGL(fdmex->GetSimTime());
+  return position.GetAltitudeAGL(0.0);
 }
 
 //******************************************************************************
 
 double FGInitialCondition::GetTerrainElevationFtIC(void) const
 {
-  return position.GetTerrainRadius(fdmex->GetSimTime())
-       - position.GetSeaLevelRadius();
+  return position.GetTerrainRadius(0.0) - position.GetSeaLevelRadius();
 }
 
 //******************************************************************************
 
 void FGInitialCondition::SetAltitudeAGLFtIC(double agl)
 {
-  double terrainElevation = position.GetTerrainRadius(fdmex->GetSimTime()) - position.GetSeaLevelRadius();
+  double terrainElevation = position.GetTerrainRadius(0.0)
+    - position.GetSeaLevelRadius();
   SetAltitudeASLFtIC(agl + terrainElevation);
   lastAltitudeSet = setagl;
 }
@@ -870,7 +872,8 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
     init_file_name = rstfile;
   }
 
-  document = LoadXMLDocument(init_file_name);
+  FGXMLFileRead XMLFileRead;
+  Element* document = XMLFileRead.LoadXMLDocument(init_file_name);
 
   // Make sure that the document is valid
   if (!document) {
@@ -887,14 +890,14 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
   bool result = false;
 
   if (version == HUGE_VAL) {
-    result = Load_v1(); // Default to the old version
+    result = Load_v1(document); // Default to the old version
   } else if (version >= 3.0) {
     cerr << "Only initialization file formats 1 and 2 are currently supported" << endl;
     exit (-1);
   } else if (version >= 2.0) {
-    result = Load_v2();
+    result = Load_v2(document);
   } else if (version >= 1.0) {
-    result = Load_v1();
+    result = Load_v1(document);
   }
 
   // Check to see if any engines are specified to be initialized in a running state
@@ -909,7 +912,7 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
 
 //******************************************************************************
 
-bool FGInitialCondition::Load_v1(void)
+bool FGInitialCondition::Load_v1(Element* document)
 {
   bool result = true;
 
@@ -995,7 +998,7 @@ bool FGInitialCondition::Load_v1(void)
 
 //******************************************************************************
 
-bool FGInitialCondition::Load_v2(void)
+bool FGInitialCondition::Load_v2(Element* document)
 {
   FGColumnVector3 vOrient;
   bool result = true;
@@ -1026,7 +1029,7 @@ bool FGInitialCondition::Load_v2(void)
           position.SetRadius(position_el->FindElementValueAsNumberConvertTo("radius", "FT"));
         } else if (position_el->FindElement("altitudeAGL")) {
           position.SetAltitudeAGL(position_el->FindElementValueAsNumberConvertTo("altitudeAGL", "FT"),
-                                  fdmex->GetSimTime());
+                                  0.0);
         } else if (position_el->FindElement("altitudeMSL")) {
           position.SetAltitudeASL(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT"));
         } else {
@@ -1042,7 +1045,7 @@ bool FGInitialCondition::Load_v2(void)
               double longitude = position.GetLongitude();
               double altitude = position.GetAltitudeASL();                 // SetPositionGeodetic() assumes altitude 
               position.SetPositionGeodetic(longitude, latitude, altitude); // is geodetic, but it's close enough for now.
-              position.SetAltitudeAGL(altitude, fdmex->GetSimTime());
+              position.SetAltitudeAGL(altitude, 0.0);
           } else {
             position.SetLatitude(latitude);
           }
index 5b3c96896b463a88760be529e832e6a3b8c2d50f..57c9533060550c6a56b2837bbc2f174b20cdd385 100644 (file)
@@ -47,7 +47,6 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "input_output/FGXMLFileRead.h"
 #include "math/FGLocation.h"
 #include "math/FGQuaternion.h"
 
@@ -55,7 +54,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.36 2013/01/19 14:19:43 bcoconni Exp $"
+#define ID_INITIALCONDITION "$Id: FGInitialCondition.h,v 1.39 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -67,6 +66,8 @@ class FGFDMExec;
 class FGMatrix33;
 class FGColumnVector3;
 class FGAtmosphere;
+class FGPropertyManager;
+class Element;
 
 typedef enum { setvt, setvc, setve, setmach, setuvw, setned, setvg } speedset;
 typedef enum { setasl, setagl} altitudeset;
@@ -216,14 +217,14 @@ CLASS DOCUMENTATION
    @property ic/r-rad_sec (read/write) Yaw rate initial condition in radians/second
 
    @author Tony Peden
-   @version "$Id: FGInitialCondition.h,v 1.36 2013/01/19 14:19:43 bcoconni Exp $"
+   @version "$Id: FGInitialCondition.h,v 1.39 2013/11/24 11:40:55 bcoconni Exp $"
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGInitialCondition : public FGJSBBase, public FGXMLFileRead
+class FGInitialCondition : public FGJSBBase
 {
 public:
   /// Constructor
@@ -682,8 +683,8 @@ private:
   FGPropertyManager *PropertyManager;
   FGAtmosphere* Atmosphere;
 
-  bool Load_v1(void);
-  bool Load_v2(void);
+  bool Load_v1(Element* document);
+  bool Load_v2(Element* document);
 
   void InitializeIC(void);
   void SetEulerAngleRadIC(int idx, double angle);
index d7446fa259018d1c3ed4bf1965850b402e1cd9a7..85de49462590790e546ba2aa8bb2c1a719109412 100644 (file)
@@ -45,6 +45,9 @@ INCLUDES
 #include "FGTrim.h"
 #include "models/FGGroundReactions.h"
 #include "models/FGInertial.h"
+#include "models/FGAccelerations.h"
+#include "models/FGMassBalance.h"
+#include "models/FGFCS.h"
 
 #if _MSC_VER
 #pragma warning (disable : 4786 4788)
@@ -54,7 +57,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGTrim.cpp,v 1.17 2012/09/05 21:49:19 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGTrim.cpp,v 1.18 2013/11/24 16:53:15 bcoconni Exp $";
 static const char *IdHdr = ID_TRIM;
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -225,6 +228,13 @@ bool FGTrim::DoTrim(void) {
 
   trim_failed=false;
   int i;
+  FGFCS *FCS = fdmex->GetFCS();
+  vector<double> throttle0 = FCS->GetThrottleCmd();
+  double elevator0 = FCS->GetDeCmd();
+  double aileron0 = FCS->GetDaCmd();
+  double rudder0 = FCS->GetDrCmd();
+  double PitchTrim0 = FCS->GetPitchTrimCmd();
+  FGInitialCondition fgic0 = *fgic;
 
   for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
     fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(false);
@@ -239,15 +249,21 @@ bool FGTrim::DoTrim(void) {
   fgic->SetQRadpsIC(0.0);
   fgic->SetRRadpsIC(0.0);
 
+  if (mode == tGround) {
+    trimOnGround();
+    double theta = fgic->GetThetaRadIC();
+    double phi = fgic->GetPhiRadIC();
+    // Take opportunity of the first approx. found by trimOnGround() to
+    // refine the control limits.
+    TrimAxes[0]->SetControlLimits(0., fgic->GetAltitudeAGLFtIC());
+    TrimAxes[1]->SetControlLimits(theta - 5.0 * degtorad, theta + 5.0 * degtorad);
+    TrimAxes[2]->SetControlLimits(phi - 30.0 * degtorad, phi + 30.0 * degtorad);
+  }
+
   //clear the sub iterations counts & zero out the controls
   for(current_axis=0;current_axis<TrimAxes.size();current_axis++) {
     //cout << current_axis << "  " << TrimAxes[current_axis]->GetStateName()
     //<< "  " << TrimAxes[current_axis]->GetControlName()<< endl;
-    if(TrimAxes[current_axis]->GetStateType() == tQdot) {
-      if(mode == tGround) {
-        TrimAxes[current_axis]->initTheta();
-      }
-    }
     xlo=TrimAxes[current_axis]->GetControlMin();
     xhi=TrimAxes[current_axis]->GetControlMax();
     TrimAxes[current_axis]->SetControl((xlo+xhi)/2);
@@ -258,7 +274,6 @@ bool FGTrim::DoTrim(void) {
     solution[current_axis]=false;
   }
 
-
   if(mode == tPullup ) {
     cout << "Setting pitch rate and nlf... " << endl;
     setupPullup();
@@ -297,7 +312,6 @@ bool FGTrim::DoTrim(void) {
       }
     }
 
-
     if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) {
       //cout << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << endl;
       //At this point we can check the input limits of the failed axis
@@ -338,24 +352,218 @@ bool FGTrim::DoTrim(void) {
     if(N > max_iterations)
       trim_failed=true;
   } while((axis_count < TrimAxes.size()) && (!trim_failed));
+
   if((!trim_failed) && (axis_count >= TrimAxes.size())) {
     total_its=N;
     if (debug_lvl > 0)
         cout << endl << "  Trim successful" << endl;
-  } else {
+  } else { // The trim has failed
     total_its=N;
+
+    // Restore the aircraft parameters to their initial values
+    *fgic = fgic0;
+    FCS->SetDeCmd(elevator0);
+    FCS->SetDaCmd(aileron0);
+    FCS->SetDrCmd(rudder0);
+    FCS->SetPitchTrimCmd(PitchTrim0);
+    for (unsigned int i=0; i < throttle0.size(); i++)
+      FCS->SetThrottleCmd(i, throttle0[i]);
+
+    // If WOW is true we must make sure there are no gears into the ground.
+    if (fdmex->GetGroundReactions()->GetWOW()) {
+      fdmex->Initialize(fgic);
+      fdmex->Run();
+      trimOnGround();
+    }
+
     if (debug_lvl > 0)
         cout << endl << "  Trim failed" << endl;
   }
+
   for(i=0;i < fdmex->GetGroundReactions()->GetNumGearUnits();i++){
     fdmex->GetGroundReactions()->GetGearUnit(i)->SetReport(true);
   }
+
   fdmex->SetTrimStatus(false);
   fdmex->ResumeIntegration();
   fdmex->EnableOutput();
   return !trim_failed;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// Trim the aircraft on the ground. The algorithm is looking for a stable
+// position of the aicraft. Assuming the aircaft is a rigid body and the ground
+// a plane: we need to find the translations and rotations of the aircraft that
+// will move 3 non-colinear points in contact with the ground.
+// The algorithm proceeds in three stages (one for each point):
+// 1. Look for the contact point closer to or deeper into the ground. Move the
+//    aircraft along the vertical direction so that only this contact point
+//    remains in contact with the ground.
+// 2. The forces applied on the aircraft (most likely the gravity) will generate
+//    a moment on the aircraft around the point in contact. The rotation axis is
+//    therefore the moment axis. The 2nd stage thus consists in determining the
+//    minimum rotation angle around the first point in contact that will place a
+//    second contact point on the ground.
+// 3. At this stage, 2 points are in contact with the ground: the rotation axis
+//    is therefore the vector generated by the 2 points. Like stage #2, the
+//    rotation direction will be driven by the moment around the axis formed by
+//    the 2 points in contact. The rotation angle is obtained similarly to stage
+//    #2: it is the minimum angle that will place a third contact point on the
+//    ground.
+// The calculations below do not account for the compression of the landing
+// gears meaning that the position found is close to the real position but not
+// strictly equal to it.
+
+void FGTrim::trimOnGround(void)
+{
+  FGGroundReactions* GroundReactions = fdmex->GetGroundReactions();
+  FGPropagate* Propagate = fdmex->GetPropagate();
+  FGMassBalance* MassBalance = fdmex->GetMassBalance();
+  FGAccelerations* Accelerations = fdmex->GetAccelerations();
+  vector<ContactPoints> contacts;
+  FGLocation CGLocation = Propagate->GetLocation();
+  FGMatrix33 Tec2b = Propagate->GetTec2b();
+  FGMatrix33 Tl2b = Propagate->GetTl2b();
+  double hmin = 1E+10;
+  int contactRef = -1;
+
+  // Build the list of the aircraft contact points and take opportunity of the
+  // loop to find which one is closer to (or deeper into) the ground.
+  for (int i = 0; i < GroundReactions->GetNumGearUnits(); i++) {
+    ContactPoints c;
+    FGLGear* gear = GroundReactions->GetGearUnit(i);
+    c.location = gear->GetLocalGear();
+    FGLocation gearLoc = CGLocation.LocalToLocation(c.location);
+    c.location = Tl2b * c.location;
+
+    FGColumnVector3 normal, vDummy;
+    FGLocation lDummy;
+    double height = gearLoc.GetContactPoint(fdmex->GetSimTime(), lDummy,
+                                            normal, vDummy, vDummy);
+    c.normal = Tec2b * normal;
+
+    contacts.push_back(c);
+
+    if (height < hmin) {
+      hmin = height;
+      contactRef = i;
+    }
+  }
+
+  // Remove the contact point that is closest to the ground from the list:
+  // the rotation axis will be going thru this point so we need to remove it
+  // to avoid divisions by zero that could result from the computation of
+  // the rotations.
+  FGColumnVector3 contact0 = contacts[contactRef].location;
+  contacts.erase(contacts.begin() + contactRef);
+
+  // Update the initial conditions: this should remove the forces generated
+  // by overcompressed landing gears
+  fgic->SetAltitudeASLFtIC(fgic->GetAltitudeASLFtIC() - hmin);
+  fdmex->Initialize(fgic);
+  fdmex->Run();
+
+  // Compute the rotation axis: it is obtained from the direction of the
+  // moment measured at the contact point 'contact0'
+  FGColumnVector3 force = MassBalance->GetMass() * Accelerations->GetUVWdot();
+  FGColumnVector3 moment = MassBalance->GetJ() * Accelerations->GetPQRdot()
+    + force * contact0;
+  FGColumnVector3 rotationAxis = moment.Normalize();
+
+  // Compute the rotation parameters: angle and the first point to come into
+  // contact with the ground when the rotation is applied.
+  RotationParameters rParam = calcRotation(contacts, rotationAxis, contact0);
+  FGQuaternion q0(rParam.angleMin, rotationAxis);
+
+  // Apply the computed rotation to all the contact points
+  FGMatrix33 rot = q0.GetTInv();
+  vector<ContactPoints>::iterator iter;
+  for (iter = contacts.begin(); iter != contacts.end(); iter++)
+    iter->location = contact0 + rot * (iter->location - contact0);
+
+  // Remove the second point to come in contact with the ground from the list.
+  // The reason is the same than above: avoid divisions by zero when the next
+  // rotation will be computed.
+  FGColumnVector3 contact1 = rParam.contactRef->location;
+  contacts.erase(rParam.contactRef);
+
+  // Compute the rotation axis: now there are 2 points in contact with the
+  // ground so the only option for the aircraft is to rotate around the axis
+  // generated by these 2 points.
+  rotationAxis = contact1 - contact0;
+  // Make sure that the rotation orientation is consistent with the moment.
+  if (DotProduct(rotationAxis, moment) < 0.0)
+    rotationAxis = contact0 - contact1;
+
+  rotationAxis.Normalize();
+
+  // Compute the rotation parameters
+  rParam = calcRotation(contacts, rotationAxis, contact0);
+  FGQuaternion q1(rParam.angleMin, rotationAxis);
+
+  // Update the aircraft orientation
+  FGColumnVector3 euler = (q0 * q1 * fgic->GetOrientation()).GetEuler();
+
+  fgic->SetPhiRadIC(euler(1));
+  fgic->SetThetaRadIC(euler(2));
+  fgic->SetPsiRadIC(euler(3));
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// Given a set of points and a rotation axis, this routine computes for each
+// point the rotation angle that would drive the point in contact with the
+// plane. It returns the minimum angle as well as the point with which this
+// angle has been obtained.
+// The rotation axis is defined by a vector 'u' and a point 'M0' on the axis.
+// Since we are in the body frame, the position if 'M0' is measured from the CG
+// hence the name 'GM0'.
+
+FGTrim::RotationParameters FGTrim::calcRotation(vector<ContactPoints>& contacts,
+                                                const FGColumnVector3& u,
+                                                const FGColumnVector3& GM0)
+{
+  RotationParameters rParam;
+  vector<ContactPoints>::iterator iter;
+
+  rParam.angleMin = 3.0 * M_PI;
+
+  for (iter = contacts.begin(); iter != contacts.end(); iter++) {
+    // Below the processed contact point is named 'M'
+    // Construct an orthonormal basis (u, v, t). The ground normal is obtained
+    // from iter->normal.
+    FGColumnVector3 t = u * iter->normal;
+    double length = t.Magnitude();
+    t /= length; // Normalize the tangent
+    FGColumnVector3 v = t * u;
+    FGColumnVector3 MM0 = GM0 - iter->location;
+    // d0 is the distance from the circle center 'C' to the reference point 'M0'
+    double d0 = DotProduct(MM0, u);
+    // Compute the square of the circle radius i.e. the square of the distance
+    // between 'C' and 'M'.
+    double sqrRadius = DotProduct(MM0, MM0) - d0 * d0;
+    // Compute the distance from the circle center 'C' to the line made by the
+    // intersection between the ground and the plane that contains the circle.
+    double DistPlane = d0 * DotProduct(u, iter->normal) / length;
+    // The coordinate of the point of intersection 'P' between the circle and
+    // the ground is (0, DistPlane, alpha) in the basis (u, v, t)
+    double alpha = sqrt(sqrRadius - DistPlane * DistPlane);
+    FGColumnVector3 CP = alpha * t + DistPlane * v;
+    // The transformation is now constructed: we can extract the angle using the
+    // classical formulas (cosine is obtained from the dot product and sine from
+    // the cross product).
+    double cosine = -DotProduct(MM0, CP) / sqrRadius;
+    double sine = DotProduct(MM0 * u, CP) / sqrRadius;
+    double angle = atan2(sine, cosine);
+    if (angle < 0.0) angle += 2.0 * M_PI;
+    if (angle < rParam.angleMin) {
+      rParam.angleMin = angle;
+      rParam.contactRef = iter;
+    }
+  }
+
+  return rParam;
+}
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGTrim::solve(void) {
@@ -645,7 +853,7 @@ void FGTrim::SetMode(TrimMode tt) {
           cout << "  Ground Trim" << endl;
         TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tWdot,tAltAGL ));
         TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tQdot,tTheta ));
-        //TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tPhi ));
+        TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tPdot,tPhi ));
         break;
       case tPullup:
         TrimAxes.push_back(new FGTrimAxis(fdmex,fgic,tNlf,tAlpha ));
index d40eaf24bf0880d2d56222e905c945029db41344..4ad5e056f2e9eb4a3261815e686672c9f602a65d 100644 (file)
@@ -60,7 +60,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_TRIM "$Id: FGTrim.h,v 1.8 2011/01/24 13:01:55 jberndt Exp $"
+#define ID_TRIM "$Id: FGTrim.h,v 1.10 2013/11/24 16:53:15 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -120,7 +120,7 @@ CLASS DOCUMENTATION
     @endcode
     
     @author Tony Peden
-    @version "$Id: FGTrim.h,v 1.8 2011/01/24 13:01:55 jberndt Exp $"
+    @version "$Id: FGTrim.h,v 1.10 2013/11/24 16:53:15 bcoconni Exp $"
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -178,6 +178,21 @@ private:
   void updateRates(void);
   void setDebug(void);
 
+  struct ContactPoints {
+    FGColumnVector3 location;
+    FGColumnVector3 normal;
+  };
+
+  struct RotationParameters {
+    double angleMin;
+    std::vector<ContactPoints>::iterator contactRef;
+  };
+
+  void trimOnGround(void);
+  RotationParameters calcRotation(std::vector<ContactPoints>& contacts,
+                                  const FGColumnVector3& rotationAxis,
+                                  const FGColumnVector3& contact0);
+
 public:
   /** Initializes the trimming class
       @param FDMExec pointer to a JSBSim executive object.
index 9d8ee207ae6865b014f5e886afeb272f5d7a6394..2fbaec8a28815f3b0a3cae76cf93f34b8aca505c 100644 (file)
@@ -56,7 +56,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGTrimAxis.cpp,v 1.14 2012/09/05 21:49:19 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGTrimAxis.cpp,v 1.15 2013/11/24 16:53:15 bcoconni Exp $";
 static const char *IdHdr = ID_TRIMAXIS;
 
 /*****************************************************************************/
@@ -243,155 +243,6 @@ void FGTrimAxis::setControl(void) {
   }
 }
 
-
-
-
-
-/*****************************************************************************/
-
-// the aircraft center of rotation is no longer the cg once the gear
-// contact the ground so the altitude needs to be changed when pitch
-// and roll angle are adjusted.  Instead of attempting to calculate the
-// new center of rotation, pick a gear unit as a reference and use its
-// location vector to calculate the new height change. i.e. new altitude =
-// earth z component of that vector (which is in body axes )
-void FGTrimAxis::SetThetaOnGround(double ff) {
-  int center,i,ref;
-
-  // favor an off-center unit so that the same one can be used for both
-  // pitch and roll.  An on-center unit is used (for pitch)if that's all
-  // that's in contact with the ground.
-  i=0; ref=-1; center=-1;
-  while( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
-    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) {
-      if(fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01)
-        ref=i;
-      else
-        center=i;
-    }
-    i++;
-  }
-  if((ref < 0) && (center >= 0)) {
-    ref=center;
-  }
-  cout << "SetThetaOnGround ref gear: " << ref << endl;
-  if(ref >= 0) {
-    double sp = fdmex->GetPropagate()->GetSinEuler(ePhi);
-    double cp = fdmex->GetPropagate()->GetCosEuler(ePhi);
-    double lx = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
-    double ly = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
-    double lz = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
-    double hagl = -1*lx*sin(ff) +
-                    ly*sp*cos(ff) +
-                    lz*cp*cos(ff);
-
-    fgic->SetAltitudeAGLFtIC(hagl);
-    cout << "SetThetaOnGround new alt: " << hagl << endl;
-  }
-  fgic->SetThetaRadIC(ff);
-  cout << "SetThetaOnGround new theta: " << ff << endl;
-}
-
-/*****************************************************************************/
-
-bool FGTrimAxis::initTheta(void) {
-  int i,N;
-  int iForward = 0;
-  int iAft = 1;
-  double zAft,zForward,zDiff,theta;
-  double xAft,xForward,xDiff;
-  bool level;
-  double saveAlt;
-
-  saveAlt=fgic->GetAltitudeAGLFtIC();
-  fgic->SetAltitudeAGLFtIC(100);
-
-
-  N=fdmex->GetGroundReactions()->GetNumGearUnits();
-
-  //find the first wheel unit forward of the cg
-  //the list is short so a simple linear search is fine
-  for( i=0; i<N; i++ ) {
-    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) > 0 ) {
-        iForward=i;
-        break;
-    }
-  }
-  //now find the first wheel unit aft of the cg
-  for( i=0; i<N; i++ ) {
-    if(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(1) < 0 ) {
-        iAft=i;
-        break;
-    }
-  }
-
-  // now adjust theta till the wheels are the same distance from the ground
-  xAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetBodyLocation(1);
-  xForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetBodyLocation(1);
-  xDiff = xForward - xAft;
-  zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3);
-  zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
-  zDiff = zForward - zAft;
-  level=false;
-  theta=fgic->GetThetaDegIC();
-  while(!level && (i < 100)) {
-    theta+=radtodeg*atan(zDiff/xDiff);
-    fgic->SetThetaDegIC(theta);
-    fdmex->Initialize(fgic);
-    fdmex->Run();
-    zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3);
-    zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3);
-    zDiff = zForward - zAft;
-    //cout << endl << theta << "  " << zDiff << endl;
-    //cout << "0: " << fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear() << endl;
-    //cout << "1: " << fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear() << endl;
-    if(fabs(zDiff ) < 0.1)
-        level=true;
-    i++;
-  }
-  //cout << i << endl;
-  if (debug_lvl > 0) {
-      cout << "    Initial Theta: " << fdmex->GetPropagate()->GetEuler(eTht)*radtodeg << endl;
-      cout << "    Used gear unit " << iAft << " as aft and " << iForward << " as forward" << endl;
-  }
-  control_min=(theta+5)*degtorad;
-  control_max=(theta-5)*degtorad;
-  fgic->SetAltitudeAGLFtIC(saveAlt);
-  if(i < 100)
-    return true;
-  else
-    return false;
-}
-
-/*****************************************************************************/
-
-void FGTrimAxis::SetPhiOnGround(double ff) {
-  int i,ref;
-
-  i=0; ref=-1;
-  //must have an off-center unit here
-  while ( (ref < 0) && (i < fdmex->GetGroundReactions()->GetNumGearUnits()) ) {
-    if ( (fdmex->GetGroundReactions()->GetGearUnit(i)->GetWOW()) &&
-      (fabs(fdmex->GetGroundReactions()->GetGearUnit(i)->GetBodyLocation(2)) > 0.01))
-        ref=i;
-    i++;
-  }
-  if (ref >= 0) {
-    double st = fdmex->GetPropagate()->GetSinEuler(eTht);
-    double ct = fdmex->GetPropagate()->GetCosEuler(eTht);
-    double lx = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(1);
-    double ly = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(2);
-    double lz = fdmex->GetGroundReactions()->GetGearUnit(ref)->GetBodyLocation(3);
-    double hagl = -1*lx*st +
-                    ly*sin(ff)*ct +
-                    lz*cos(ff)*ct;
-
-    fgic->SetAltitudeAGLFtIC(hagl);
-  }
-  fgic->SetPhiRadIC(ff);
-
-}
-
 /*****************************************************************************/
 
 void FGTrimAxis::Run(void) {
index e89825660b186bb2fd5e8273c4cef7f3d603349d..ebbd9db0370eb4fb82799b58bd8e7a1b83d57fd4 100644 (file)
@@ -48,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_TRIMAXIS "$Id: FGTrimAxis.h,v 1.5 2010/09/07 18:36:29 andgi Exp $"
+#define ID_TRIMAXIS "$Id: FGTrimAxis.h,v 1.7 2013/11/24 16:53:15 bcoconni Exp $"
 
 #define DEFAULT_TOLERANCE 0.001
 
@@ -140,14 +140,9 @@ public:
   inline int GetRunCount(void) { return total_stability_iterations; }
   double GetAvgStability( void );
   
-  void SetThetaOnGround(double ff);
-  void SetPhiOnGround(double ff);
-  
   inline void SetStateTarget(double target) { state_target=target; }
   inline double GetStateTarget(void) { return state_target; }
   
-  bool initTheta(void);
-  
   void AxisReport(void);
   
   bool InTolerance(void) { getState(); return (fabs(state_value) <= tolerance); }
index 873e3dcbd4febd80895fe0e562678a580b1bbb1b..b6a2964e1b05e2170267763aac4abb68174fc883 100644 (file)
@@ -71,7 +71,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutputFG.cpp,v 1.5 2012/12/15 16:13:57 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGOutputFG.cpp,v 1.6 2013/11/09 14:06:36 bcoconni Exp $";
 static const char *IdHdr = ID_OUTPUTFG;
 
 // (stolen from FGFS native_fdm.cxx)
@@ -159,9 +159,9 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
   net->v_east     = (float)(Propagate->GetVel(eEast));       // east vel in NED frame, fps
   net->v_down     = (float)(Propagate->GetVel(eDown));       // down vel in NED frame, fps
 //---ADD METHOD TO CALCULATE THESE TERMS---
-  net->v_wind_body_north = (float)(Propagate->GetVel(eNorth)); // north vel in NED relative to airmass, fps
-  net->v_wind_body_east = (float)(Propagate->GetVel(eEast)); // east vel in NED relative to airmass, fps
-  net->v_wind_body_down = (float)(Propagate->GetVel(eDown)); // down vel in NED relative to airmass, fps
+  net->v_body_u = (float)(Propagate->GetUVW(1)); // ECEF speed in body axis
+  net->v_body_v = (float)(Propagate->GetUVW(2)); // ECEF speed in body axis
+  net->v_body_w = (float)(Propagate->GetUVW(3)); // ECEF speed in body axis
 
   // Accelerations
   net->A_X_pilot   = (float)(Auxiliary->GetPilotAccel(1));    // X body accel, ft/s/s
@@ -282,9 +282,9 @@ void FGOutputFG::SocketDataFill(FGNetFDM* net)
     htonf(net->v_north);
     htonf(net->v_east);
     htonf(net->v_down);
-    htonf(net->v_wind_body_north);
-    htonf(net->v_wind_body_east);
-    htonf(net->v_wind_body_down);
+    htonf(net->v_body_u);
+    htonf(net->v_body_v);
+    htonf(net->v_body_w);
 
     htonf(net->A_X_pilot);
     htonf(net->A_Y_pilot);
index 700bee6c44d0a704f11636c7b96972835d8268c8..c1cfc7d32dd999ccd730227d9a5fbbefdf63c0dc 100644 (file)
@@ -41,12 +41,13 @@ INCLUDES
 #include <sstream>
 
 #include "FGOutputFile.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutputFile.cpp,v 1.3 2012/12/15 16:13:57 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGOutputFile.cpp,v 1.4 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_OUTPUTFILE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index f41cc21e153d2656d68cd234bb9dad2924c35df4..7e913ff66d1c0f0298348f4f2ebaaf7ca04487a3 100644 (file)
@@ -54,12 +54,13 @@ INCLUDES
 #include "models/FGGroundReactions.h"
 #include "models/FGFCS.h"
 #include "models/atmosphere/FGWinds.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutputSocket.cpp,v 1.5 2013/01/12 21:14:46 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGOutputSocket.cpp,v 1.6 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_OUTPUTSOCKET;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 35fe76c01a1c4d9aefd79a7d8aa1eb88e5638514..03c593bad42462b40df63c4d683b04df38b42fe2 100644 (file)
@@ -58,12 +58,13 @@ INCLUDES
 #include "models/FGBuoyantForces.h"
 #include "models/FGFCS.h"
 #include "models/atmosphere/FGWinds.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.6 2013/09/11 12:51:13 jberndt Exp $";
+static const char *IdSrc = "$Id: FGOutputTextFile.cpp,v 1.7 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_OUTPUTTEXTFILE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 1abae8bdb19d5e97c1581a8b0f49d5348201faf2..90b9c2c7a13fbe725dc2bf7195e661763ccc78bf 100644 (file)
@@ -46,7 +46,7 @@ INCLUDES
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutputType.cpp,v 1.6 2013/01/26 17:06:49 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGOutputType.cpp,v 1.7 2013/09/27 19:45:40 jberndt Exp $";
 static const char *IdHdr = ID_OUTPUTTYPE;
 
 using namespace std;
@@ -101,8 +101,7 @@ void FGOutputType::SetIdx(int idx)
 bool FGOutputType::Load(Element* element)
 {
   // Perform base class Load.
-  if(!FGModel::Load(element))
-    return false;
+//  if(!FGModel::Load(element)) return false;
 
   if (element->FindElementValue("simulation") == string("ON"))
     SubSystems += ssSimulation;
index 57b523cb81d0c39bf52fb952adc4bd47ceda9cf6..e3595941baa619785fa20b6143393a53e1ba6039 100644 (file)
@@ -53,7 +53,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_PROPERTYMANAGER "$Id: FGPropertyManager.h,v 1.26 2013/06/10 01:49:06 jberndt Exp $"
+#define ID_PROPERTYMANAGER "$Id: FGPropertyManager.h,v 1.28 2013/09/28 14:43:15 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -393,7 +393,12 @@ class FGPropertyManager
     { return root->GetNode(path, create); }
     FGPropertyNode* GetNode(const std::string &relpath, int index, bool create = false)
     { return root->GetNode(relpath, index, create); }
-    bool HasNode(const std::string& path) const { return root->HasNode(path); }
+    bool HasNode(const std::string& path) const
+    {
+      std::string newPath = path;
+      if (newPath[0] == '-') newPath.erase(0,1);
+      return root->HasNode(newPath);
+    }
 
     /** Property-ify a name
      *  replaces spaces with '-' and, optionally, makes name all lower case
old mode 100644 (file)
new mode 100755 (executable)
index 6ac660c..5a0e548
@@ -47,7 +47,7 @@ INCLUDES
 
 #include "FGScript.h"
 #include "input_output/FGXMLElement.h"
-#include "input_output/FGXMLParse.h"
+#include "input_output/FGXMLFileRead.h"
 #include "initialization/FGTrim.h"
 #include "models/FGInput.h"
 
@@ -55,7 +55,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGScript.cpp,v 1.52 2013/09/11 12:46:35 jberndt Exp $";
+static const char *IdSrc = "$Id: FGScript.cpp,v 1.53 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_FGSCRIPT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -114,7 +114,8 @@ bool FGScript::LoadScript(string script, double deltaT, const string initfile)
   struct event *newEvent;
   FGCondition *newCondition;
 
-  document = LoadXMLDocument(script);
+  FGXMLFileRead XMLFileRead;
+  Element* document = XMLFileRead.LoadXMLDocument(script);
 
   if (!document) {
     cerr << "File: " << script << " could not be loaded." << endl;
index 21323858d0234335072b82bdb6fcf4efbfb32e2a..81d4d9e541f88bb23192b58cd7e361cfaf17caff 100644 (file)
@@ -43,13 +43,12 @@ INCLUDES
 #include "FGJSBBase.h"
 #include "math/FGFunction.h"
 #include "math/FGCondition.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FGSCRIPT "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $"
+#define ID_FGSCRIPT "$Id: FGScript.h,v 1.27 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -158,14 +157,14 @@ CLASS DOCUMENTATION
     comes the &quot;run&quot; section, where the conditions are
     described in &quot;event&quot; clauses.</p>
     @author Jon S. Berndt
-    @version "$Id: FGScript.h,v 1.25 2013/09/11 12:46:35 jberndt Exp $"
+    @version "$Id: FGScript.h,v 1.27 2013/11/24 11:40:55 bcoconni Exp $"
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGScript : public FGJSBBase, public FGXMLFileRead
+class FGScript : public FGJSBBase
 {
 public:
   /// Default constructor
old mode 100644 (file)
new mode 100755 (executable)
index 72c4f17..4f7c9d5
@@ -31,6 +31,7 @@ INCLUDES
 #include <cmath>
 #include <cstdlib>
 #include <iostream>
+#include <sstream>
 
 #include "FGXMLElement.h"
 #include "string_utilities.h"
@@ -43,7 +44,7 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGXMLElement.cpp,v 1.39 2013/06/20 04:37:27 jberndt Exp $";
+static const char *IdSrc = "$Id: FGXMLElement.cpp,v 1.41 2013/11/16 14:51:20 bcoconni Exp $";
 static const char *IdHdr = ID_XMLELEMENT;
 
 bool Element::converterIsInitialized = false;
@@ -58,6 +59,7 @@ Element::Element(const string& nm)
   name   = nm;
   parent = 0L;
   element_index = 0;
+  line_number = -1;
 
   if (!converterIsInitialized) {
     converterIsInitialized = true;
@@ -279,8 +281,11 @@ double Element::GetAttributeValueAsNumber(const string& attr)
     double number=0;
     if (is_number(trim(attribute)))
       number = atof(attribute.c_str());
-    else
-      throw("Expecting numeric attribute value, but got: " + attribute);
+    else {
+      cerr << ReadFrom() << "Expecting numeric attribute value, but got: "
+           << attribute << endl;
+      exit(-1);
+    }
     
     return (number);
   }
@@ -329,14 +334,18 @@ double Element::GetDataAsNumber(void)
     double number=0;
     if (is_number(trim(data_lines[0])))
       number = atof(data_lines[0].c_str());
-    else
-      throw("Expected numeric value, but got: " + data_lines[0]);
+    else {
+      cerr << ReadFrom() << "Expected numeric value, but got: " << data_lines[0]
+           << endl;
+      exit(-1);
+    }
 
     return number;
   } else if (data_lines.size() == 0) {
     return HUGE_VAL;
   } else {
-    cerr << "Attempting to get single data value from multiple lines in element " << name << endl;
+    cerr << ReadFrom() << "Attempting to get single data value from multiple lines in element "
+         << name << endl;
     return HUGE_VAL;
   }
 }
@@ -404,8 +413,9 @@ double Element::FindElementValueAsNumber(const string& el)
     value = DisperseValue(element, value);
     return value;
   } else {
-    cerr << "Attempting to get single data value from multiple lines" << endl;
-    return 0;
+    cerr << ReadFrom() << "Attempting to get non-existent element " << el
+         << endl;
+    exit(-1);
   }
 }
 
@@ -428,27 +438,24 @@ double Element::FindElementValueAsNumberConvertTo(const string& el, const string
   Element* element = FindElement(el);
 
   if (!element) {
-    throw("Attempting to get the value of a non-existent element "+el);
-//    cerr << "Attempting to get non-existent element " << el << endl;
-//    exit(0);
+    cerr << ReadFrom() << "Attempting to get non-existent element " << el
+         << endl;
+    exit(-1);
   }
 
   string supplied_units = element->GetAttributeValue("unit");
 
   if (!supplied_units.empty()) {
     if (convert.find(supplied_units) == convert.end()) {
-      throw("Supplied unit: \"" + supplied_units + "\" does not exist (typo?). Add new unit"
-           + " conversion in FGXMLElement.cpp.");
-//      cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
-//           << " conversion in FGXMLElement.cpp." << endl;
-//      exit(-1);
+      cerr << element->ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" does not exist (typo?)." << endl;
+      exit(-1);
     }
     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
-      throw("Supplied unit: \"" + supplied_units + "\" cannot be converted to "
-                   + target_units + ". Add new unit conversion in FGXMLElement.cpp or fix typo");
-//      cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
-//                   << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
-//      exit(-1);
+      cerr << element->ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" cannot be converted to " << target_units
+           << endl;
+      exit(-1);
     }
   }
 
@@ -472,18 +479,19 @@ double Element::FindElementValueAsNumberConvertFromTo( const string& el,
 
   if (!element) {
     cerr << "Attempting to get non-existent element " << el << endl;
-    exit(0);
+    exit(-1);
   }
 
   if (!supplied_units.empty()) {
     if (convert.find(supplied_units) == convert.end()) {
-      cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
-           << " conversion in FGXMLElement.cpp." << endl;
+      cerr << element->ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" does not exist (typo?)." << endl;
       exit(-1);
     }
     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
-      cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
-                   << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
+      cerr << element->ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" cannot be converted to " << target_units
+           << endl;
       exit(-1);
     }
   }
@@ -509,13 +517,14 @@ FGColumnVector3 Element::FindElementTripletConvertTo( const string& target_units
 
   if (!supplied_units.empty()) {
     if (convert.find(supplied_units) == convert.end()) {
-      cerr << endl << "Supplied unit: \"" << supplied_units << "\" does not exist (typo?). Add new unit"
-           << " conversion in FGXMLElement.cpp." << endl;
+      cerr << ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" does not exist (typo?)." << endl;
       exit(-1);
     }
     if (convert[supplied_units].find(target_units) == convert[supplied_units].end()) {
-      cerr << endl << "Supplied unit: \"" << supplied_units << "\" cannot be converted to "
-                   << target_units << ". Add new unit conversion in FGXMLElement.cpp or fix typo" << endl;
+      cerr << ReadFrom() << "Supplied unit: \""
+           << supplied_units << "\" cannot be converted to " << target_units
+           << endl;
       exit(-1);
     }
   }
@@ -565,12 +574,22 @@ double Element::DisperseValue(Element *e, double val, const std::string supplied
     if (!supplied_units.empty()) disp *= convert[supplied_units][target_units];
     string attType = e->GetAttributeValue("type");
     if (attType == "gaussian") {
-      value = val + disp*GaussianRandomNumber();
+      double grn = GaussianRandomNumber();
+      value = val + disp*grn;
+/*      std::cout << "DISPERSION GAUSSIAN: Initial: " << val
+                << "  Dispersion: " << disp
+                << "  Gaussian Rand Num: " << grn
+                << "  Total Dispersed Value: " << value << endl; */
     } else if (attType == "uniform") {
-      value = val + disp * ((((double)rand()/RAND_MAX)-0.5)*2.0);
+      double urn = ((((double)rand()/RAND_MAX)-0.5)*2.0);
+      value = val + disp * urn;
+/*      std::cout << "DISPERSION UNIFORM: Initial: " << val
+                << "  Dispersion: " << disp
+                << "  Uniform Rand Num: " << urn
+                << "  Total Dispersed Value: " << value << endl; */
     } else {
-      std::cerr << "Unknown dispersion type" << endl;
-      throw("Unknown dispersion type");
+      cerr << ReadFrom() << "Unknown dispersion type" << attType << endl;
+      exit(-1);
     }
 
   }
@@ -649,4 +668,15 @@ void Element::AddData(string d)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+string Element::ReadFrom(void) const
+{
+  ostringstream message;
+
+  message << endl
+          << "In file " << GetFileName() << ": line " << GetLineNumber()
+          << endl;
+
+  return message.str();
+}
+
 } // end namespace JSBSim
old mode 100644 (file)
new mode 100755 (executable)
index f8b89c8..b4fa535
@@ -44,7 +44,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.17 2012/07/26 04:33:46 jberndt Exp $"
+#define ID_XMLELEMENT "$Id: FGXMLElement.h,v 1.18 2013/11/16 14:51:20 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -136,7 +136,7 @@ CLASS DOCUMENTATION
     - GAL = gallon (U.S. liquid) 
 
     @author Jon S. Berndt
-    @version $Id: FGXMLElement.h,v 1.17 2012/07/26 04:33:46 jberndt Exp $
+    @version $Id: FGXMLElement.h,v 1.18 2013/11/16 14:51:20 bcoconni Exp $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -218,6 +218,16 @@ public:
       @return a pointer to the parent Element, or 0 if this is the top level Element. */
   Element* GetParent(void) {return parent;}
 
+  /** Returns the line number at which the element has been defined.
+      @return the line number
+   */
+  int GetLineNumber(void) const { return line_number; }
+
+  /** Returns the name of the file in which the element has been read.
+      @return the file name
+  */
+  const std::string& GetFileName(void) const { return file_name; }
+
   /** Searches for a specified element.
       Finds the first element that matches the supplied string, or simply the first
       element if no search string is supplied. This function call resets the internal
@@ -331,6 +341,23 @@ public:
   *   @param d The tab level. A level corresponds to a single space. */
   void Print(unsigned int level=0);
 
+  /** Set the line number at which the element has been read.
+   *  @param line line number.
+   */
+  void SetLineNumber(int line) { line_number = line; }
+
+  /** Set the name of the file in which the element has been read.
+   *  @param name file name
+   */
+  void SetFileName(const std::string& name) { file_name = name; }
+
+  /** Return a string that contains a description of the location where the
+   *  current XML element was read from.
+   *  @return a string describing the file name and line number where the
+   *          element was read.
+   */
+  std::string ReadFrom(void) const;
+
 private:
   std::string name;
   std::map <std::string, std::string> attributes;
@@ -339,6 +366,8 @@ private:
   std::vector <std::string> attribute_key;
   Element *parent;
   unsigned int element_index;
+  std::string file_name;
+  int line_number;
   typedef std::map <std::string, std::map <std::string, double> > tMapConvert;
   static tMapConvert convert;
   static bool converterIsInitialized;
old mode 100644 (file)
new mode 100755 (executable)
index 09c889d..c921427
@@ -43,7 +43,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.7 2012/12/12 06:19:57 jberndt Exp $"
+#define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.8 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -56,13 +56,11 @@ public:
   FGXMLFileRead(void) {}
   ~FGXMLFileRead(void) {}
 
-protected:
-  Element* document;
   Element* LoadXMLDocument(std::string XML_filename, bool verbose=true)
   {
     return LoadXMLDocument(XML_filename, file_parser, true);
   }
-  
+
   Element* LoadXMLDocument(std::string XML_filename, FGXMLParse& fparse, bool verbose=true)
   {
     std::ifstream infile;
@@ -80,12 +78,12 @@ protected:
     }
 
     readXML(infile, fparse, XML_filename);
-    document = fparse.GetDocument();
+    Element* document = fparse.GetDocument();
     infile.close();
-    
+
     return document;
   }
-  
+
   void ResetParser(void) {file_parser.reset();}
 
 private:
old mode 100644 (file)
new mode 100755 (executable)
index 22d30a2..3710f14
@@ -40,7 +40,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.11 2010/09/28 02:54:03 jberndt Exp $";
+static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.12 2013/11/16 14:51:20 bcoconni Exp $";
 static const char *IdHdr = ID_XMLPARSE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -107,10 +107,14 @@ void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
   }
 
   if (current_element == 0L) {
-    cerr << "No current element read (no top-level element in XML file?)" << endl;
+    cerr << "In file " << getPath() << ": line " << getLine() << endl
+         << "No current element read (running out of memory?)" << endl;
     exit (-1);
   }
 
+  current_element->SetLineNumber(getLine());
+  current_element->SetFileName(getPath());
+
   for (int i=0; i<atts.size();i++) {
     current_element->AddAttribute(atts.getName(i), atts.getValue(i));
   }
index db9022a0b96fe17db77f7f258602d023b87800ad..600f9cf09dba3c11ff3ef27535874f39abd3d984 100644 (file)
@@ -6,7 +6,7 @@
 //
 // This file is in the Public Domain, and comes with no warranty.
 //
-// $Id: net_fdm.hxx,v 1.5 2011/11/10 12:06:14 jberndt Exp $
+// $Id: net_fdm.hxx,v 1.6 2013/11/09 14:06:36 bcoconni Exp $
 
 
 #ifndef _NET_FDM_HXX
@@ -61,12 +61,9 @@ public:
     float v_north;              // north velocity in local/body frame, fps
     float v_east;               // east velocity in local/body frame, fps
     float v_down;               // down/vertical velocity in local/body frame, fps
-    float v_wind_body_north;    // north velocity in local/body frame
-                                // relative to local airmass, fps
-    float v_wind_body_east;     // east velocity in local/body frame
-                                // relative to local airmass, fps
-    float v_wind_body_down;     // down/vertical velocity in local/body
-                                // frame relative to local airmass, fps
+    float v_body_u;             // ECEF velocity in body axis
+    float v_body_v;             // ECEF velocity in body axis
+    float v_body_w;             // ECEF velocity in body axis 
 
     // Accelerations
     float A_X_pilot;    // X accel in body frame ft/sec^2
index 1476e3eb1ce233815e459326ca812360ffef7bf7..aa64f64c40872a4a0d4da91808ad8d3e0daa73bc 100644 (file)
@@ -39,6 +39,8 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include <string>
+#include <sstream>
+#include <iostream>
 #include <vector>
 #include <stdio.h>
 
@@ -46,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.15 2012/11/17 19:31:26 bcoconni Exp $"
+#define ID_STRINGUTILS "$Id: string_utilities.h,v 1.16 2013/11/17 05:14:21 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -70,7 +72,10 @@ CLASS DECLARATION
   extern std::string& to_lower(std::string& str);
   extern bool is_number(const std::string& str);
   std::vector <std::string> split(std::string str, char d);
+/* Comment out to_string functions when they are defined already - C++ 11 defines these */
   extern std::string to_string(int);
+  extern std::string to_string(double);
+  extern std::string to_string(float);
   extern std::string replace(std::string str, const std::string& old, const std::string& newstr);
 #else
   #include <cctype>
@@ -153,7 +158,7 @@ CLASS DECLARATION
 
     return str_array;
   }
-
+/* Comment out to_string functions when they are defined already - C++ 11 defines these */
   string to_string(int i)
   {
     char buffer[32];
@@ -161,6 +166,20 @@ CLASS DECLARATION
     return string(buffer);
   }
 
+  string to_string(float x)
+  {
+    std::ostringstream o;\r
+    if (!(o << x)) cerr << "Bad float to string conversion" << endl;\r
+    return o.str();\r
+  }
+
+  string to_string(double x)
+  {
+    std::ostringstream o;\r
+    if (!(o << x)) cerr << "Bad double to string conversion" << endl;\r
+    return o.str();\r
+  }
+
   string replace(string str, const string& oldstr, const string& newstr)
   {
     int old_idx;
old mode 100644 (file)
new mode 100755 (executable)
index 0de0ecf..6beeedb
@@ -43,7 +43,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFunction.cpp,v 1.51 2013/09/11 12:49:36 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFunction.cpp,v 1.53 2013/09/27 19:42:08 jberndt Exp $";
 static const char *IdHdr = ID_FUNCTION;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -807,9 +807,10 @@ void FGFunction::bind(void)
     }
 
     if (PropertyManager->HasNode(tmp)) {
-      FGPropertyNode* property = PropertyManager->GetNode(tmp);
-      if (property->isTied()) {
-        cout << "Property " << tmp << " has already been successfully bound (late)." << endl;
+      FGPropertyNode* _property = PropertyManager->GetNode(tmp);
+      if (_property->isTied()) {
+      cout << "Property " << tmp << " has already been successfully bound (late)." << endl;
+        throw("Failed to bind the property to an existing already tied node.");
       }
     }
     PropertyManager->Tie( tmp, this, &FGFunction::GetValue);
index 57a4ad66dde3056379624e99c69c81cd8e16267f..12afdadde51f00371c4b068d192812c329d0788c 100644 (file)
@@ -44,11 +44,10 @@ INCLUDES
 #include <cmath>
 
 #include "FGLocation.h"
-#include "input_output/FGPropertyManager.h"
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGLocation.cpp,v 1.29 2012/04/14 12:14:37 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGLocation.cpp,v 1.30 2013/10/19 17:59:51 bcoconni Exp $";
 static const char *IdHdr = ID_LOCATION;
 using std::cerr;
 using std::endl;
index 8d2008215dddc14160bef59ab5207c4719b339ab..cc8a86b21199d4cb8f5306b10c6d8272b29615c0 100644 (file)
@@ -42,8 +42,9 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <iostream>
+
 #include "FGJSBBase.h"
-#include "input_output/FGPropertyManager.h"
 #include "FGColumnVector3.h"
 #include "FGMatrix33.h"
 #include "input_output/FGGroundCallback.h"
@@ -52,7 +53,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_LOCATION "$Id: FGLocation.h,v 1.31 2012/02/05 14:56:17 bcoconni Exp $"
+#define ID_LOCATION "$Id: FGLocation.h,v 1.32 2013/10/19 17:59:51 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -151,7 +152,7 @@ CLASS DOCUMENTATION
     @see W. C. Durham "Aircraft Dynamics & Control", section 2.2
 
     @author Mathias Froehlich
-    @version $Id: FGLocation.h,v 1.31 2012/02/05 14:56:17 bcoconni Exp $
+    @version $Id: FGLocation.h,v 1.32 2013/10/19 17:59:51 bcoconni Exp $
   */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 856f43a..200a67d
@@ -41,12 +41,13 @@ INCLUDES
 #include <sstream>
 #include <string>
 #include "FGModelFunctions.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGModelFunctions.cpp,v 1.6 2012/09/05 05:00:57 jberndt Exp $";
+static const char *IdSrc = "$Id: FGModelFunctions.cpp,v 1.7 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_MODELFUNCTIONS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 5950e4b..6b56e24
@@ -38,13 +38,12 @@ INCLUDES
 #include <vector>
 #include "math/FGFunction.h"
 #include "input_output/FGPropertyManager.h"
-#include "input_output/FGXMLElement.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.5 2012/04/13 13:25:52 jberndt Exp $"
+#define ID_MODELFUNCTIONS "$Id: FGModelFunctions.h,v 1.6 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
old mode 100644 (file)
new mode 100755 (executable)
index 1407a0c..f4b7591
@@ -34,7 +34,7 @@ INCLUDES
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPropertyValue.cpp,v 1.8 2013/01/26 17:06:49 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropertyValue.cpp,v 1.9 2013/09/27 19:42:53 jberndt Exp $";
 static const char *IdHdr = ID_PROPERTYVALUE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -44,13 +44,20 @@ CLASS IMPLEMENTATION
 FGPropertyValue::FGPropertyValue(FGPropertyNode* propNode)
   : PropertyManager(0L), PropertyNode(propNode)
 {
+  Sign = 1;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 FGPropertyValue::FGPropertyValue(std::string propName, FGPropertyManager* propertyManager)
-  : PropertyManager(propertyManager), PropertyNode(0L), PropertyName(propName)
+  : PropertyManager(propertyManager), PropertyNode(0L)
 {
+  Sign = 1;
+  if (propName[0] == '-') {
+    propName.erase(0,1);
+    Sign = -1;
+  }
+  PropertyName = propName;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -69,7 +76,7 @@ double FGPropertyValue::GetValue(void) const
     }
   }
 
-  return node->getDoubleValue();
+  return node->getDoubleValue()*Sign;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 4ea0e53..265b2fd
@@ -42,7 +42,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_PROPERTYVALUE "$Id: FGPropertyValue.h,v 1.10 2013/01/26 17:06:49 bcoconni Exp $"
+#define ID_PROPERTYVALUE "$Id: FGPropertyValue.h,v 1.11 2013/09/27 19:43:01 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -79,6 +79,7 @@ private:
   FGPropertyManager* PropertyManager; // Property root used to do late binding.
   FGPropertyNode_ptr PropertyNode;
   std::string PropertyName;
+  int Sign;
 };
 
 } // namespace JSBSim
index e52ccc549b5db4eddda75d7d5e54e6d958c3cb7f..3692dcc0d862bbbcb132e6b89cb34de02d2993d5 100644 (file)
@@ -48,7 +48,7 @@ SENTRY
   DEFINITIONS
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.25 2012/09/05 05:00:57 jberndt Exp $"
+#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.26 2013/11/24 16:53:15 bcoconni Exp $"
 
 namespace JSBSim {
 
@@ -149,6 +149,27 @@ public:
     }
   }
 
+  /** Initializer by a rotation axis and an angle.
+      Initialize the quaternion to represent the rotation around a given
+      angle and an arbitrary axis.
+      @param angle The angle in radians
+      @param axis  The rotation axis
+   */
+  FGQuaternion(double angle, const FGColumnVector3& axis)
+    : mCacheValid(false) {
+
+    double angle2 = 0.5 * angle;
+
+    double length = axis.Magnitude();
+    double Sangle2 = sin(angle2) / length;
+    double Cangle2 = cos(angle2);
+
+    data[0] = Cangle2;
+    data[1] = Sangle2 * axis(1);
+    data[2] = Sangle2 * axis(2);
+    data[3] = Sangle2 * axis(3);
+  }
+
   /** Initializer by matrix.
       Initialize the quaternion with the matrix representing a transform from one frame
       to another using the standard aerospace sequence, Yaw-Pitch-Roll (3-2-1).
index 02921c230828fc64b2a7b5927c9c2c236622c53c..494fa41ca7baf1d16d890daf144fae4c00414662 100644 (file)
@@ -43,12 +43,14 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGAerodynamics.h"
 #include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.48 2013/09/11 12:42:14 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAerodynamics.cpp,v 1.49 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_AERODYNAMICS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -284,11 +286,13 @@ bool FGAerodynamics::Load(Element *element)
   Element *temp_element, *axis_element, *function_element;
 
   string separator = "/";
+  FGXMLFileRead XMLFileRead;
+  Element* document;
 
   fname = element->GetAttributeValue("file");
   if (!fname.empty()) {
     file = FDMExec->GetFullAircraftPath() + separator + fname;
-    document = LoadXMLDocument(file);
+    document = XMLFileRead.LoadXMLDocument(file);
     if (document == 0L) return false;
   } else {
     document = element;
@@ -296,7 +300,7 @@ bool FGAerodynamics::Load(Element *element)
 
   FGModel::Load(document); // Perform base class Pre-Load
 
-  DetermineAxisSystem(); // Detemine if Lift/Side/Drag, etc. is used.
+  DetermineAxisSystem(document); // Detemine if Lift/Side/Drag, etc. is used.
 
   Debug(2);
 
@@ -370,7 +374,7 @@ bool FGAerodynamics::Load(Element *element)
 // This is OK, and the warning is due to the SIDE specifier used for both
 // the Lift/Drag and Axial/Normal axis systems.
 
-void FGAerodynamics::DetermineAxisSystem()
+void FGAerodynamics::DetermineAxisSystem(Element* document)
 {
   Element* axis_element = document->FindElement("axis");
   string axis;
index 5616a4779690dee90a35f69bbd6b7f18fed48344..da28d87b9fae589607d5968045ae5038b8efea92 100644 (file)
@@ -46,13 +46,12 @@ INCLUDES
 #include "math/FGFunction.h"
 #include "math/FGColumnVector3.h"
 #include "math/FGMatrix33.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.27 2013/09/11 12:42:14 jberndt Exp $"
+#define ID_AERODYNAMICS "$Id: FGAerodynamics.h,v 1.29 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -109,14 +108,14 @@ CLASS DOCUMENTATION
     Systems may NOT be combined, or a load error will occur.
 
     @author Jon S. Berndt, Tony Peden
-    @version $Revision: 1.27 $
+    @version $Revision: 1.29 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGAerodynamics : public FGModel, public FGXMLFileRead
+class FGAerodynamics : public FGModel
 {
 
 public:
@@ -252,7 +251,7 @@ private:
   double clsq, lod, qbar_area;
 
   typedef double (FGAerodynamics::*PMF)(int) const;
-  void DetermineAxisSystem(void);
+  void DetermineAxisSystem(Element* document);
   void bind(void);
 
   void Debug(int from);
index 34205ee8868a17b544282eef38eb3bf51701c434..fe46509df0e29ddfd20cefef191269d9be177f08 100644 (file)
@@ -46,6 +46,7 @@ INCLUDES
 #include "FGAircraft.h"
 #include "FGFDMExec.h"
 #include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
@@ -59,7 +60,7 @@ DEFINITIONS
 GLOBAL DATA
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.34 2012/09/15 17:00:56 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.35 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_AIRCRAFT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index c36f5accdf30061a1f28c6b75eddd8b6ff8f7d73..08f3a2da7a7a53f816636bba8e7a313c2f7db3be 100644 (file)
@@ -42,7 +42,6 @@ INCLUDES
 #include <vector>
 
 #include "FGModel.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 #include "math/FGMatrix33.h"
 
@@ -50,7 +49,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.20 2012/09/15 17:00:56 bcoconni Exp $"
+#define ID_AIRCRAFT "$Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -91,7 +90,7 @@ CLASS DOCUMENTATION
 @endcode
 
     @author Jon S. Berndt
-    @version $Id: FGAircraft.h,v 1.20 2012/09/15 17:00:56 bcoconni Exp $
+    @version $Id: FGAircraft.h,v 1.21 2013/11/24 11:40:55 bcoconni Exp $
     @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
      Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
      School, January 1994
index b5081760850183e647859ae7b12e9147b969d9d7..078acbd717205a61eec34b19c02f1ec0ad6c3fed 100644 (file)
@@ -36,16 +36,19 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <iostream>
+
 #include "FGBuoyantForces.h"
 #include "FGMassBalance.h"
 #include "input_output/FGPropertyManager.h"
-#include <iostream>
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.21 2011/10/31 14:54:41 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.22 2013/11/24 11:40:55 bcoconni Exp $";
 static const char *IdHdr = ID_BUOYANTFORCES;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -117,11 +120,13 @@ bool FGBuoyantForces::Load(Element *element)
   Debug(2);
 
   string separator = "/";
+  FGXMLFileRead XMLFileRead;
+  Element* document;
 
   fname = element->GetAttributeValue("file");
   if (!fname.empty()) {
     file = FDMExec->GetFullAircraftPath() + separator + fname;
-    document = LoadXMLDocument(file);
+    document = XMLFileRead.LoadXMLDocument(file);
   } else {
     document = element;
   }
index 098e9a49e86c2a52aff629cb883ec0b4125ee780..b63d90a846c3b026fe6975148269741e49170ade 100644 (file)
@@ -45,13 +45,12 @@ INCLUDES
 #include "FGModel.h"
 #include "FGGasCell.h"
 #include "math/FGColumnVector3.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $"
+#define ID_BUOYANTFORCES "$Id: FGBuoyantForces.h,v 1.18 2013/11/24 11:40:55 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -96,14 +95,14 @@ CLASS DOCUMENTATION
     See FGGasCell for the full configuration file format for gas cells.
 
     @author Anders Gidenstam, Jon S. Berndt
-    @version $Id: FGBuoyantForces.h,v 1.16 2011/10/31 14:54:41 bcoconni Exp $
+    @version $Id: FGBuoyantForces.h,v 1.18 2013/11/24 11:40:55 bcoconni Exp $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGBuoyantForces : public FGModel, public FGXMLFileRead
+class FGBuoyantForces : public FGModel
 {
 
 public:
old mode 100644 (file)
new mode 100755 (executable)
index f9e98f9..730b790
@@ -36,11 +36,13 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGExternalReactions.h"
-#include "input_output/FGXMLElement.h"
 #include <iostream>
 #include <string>
 
+#include "FGExternalReactions.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
+
 using namespace std;
 
 namespace JSBSim {
@@ -53,7 +55,7 @@ DEFINITIONS
 GLOBAL DATA
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-static const char *IdSrc = "$Id: FGExternalReactions.cpp,v 1.12 2011/07/20 12:16:34 jberndt Exp $";
+static const char *IdSrc = "$Id: FGExternalReactions.cpp,v 1.13 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_EXTERNALREACTIONS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -73,9 +75,11 @@ bool FGExternalReactions::Load(Element* el)
 {
   // check if a file attribute was specified
   string fname = el->GetAttributeValue("file");
+  FGXMLFileRead XMLFileRead;
+
   if (!fname.empty()) {
     string file = FDMExec->GetFullAircraftPath() + "/" + fname;
-    el = LoadXMLDocument(file);
+    el = XMLFileRead.LoadXMLDocument(file);
     if (el == 0L) return false;
   }
 
old mode 100644 (file)
new mode 100755 (executable)
index 7945abf..b6c39a7
@@ -41,14 +41,12 @@ INCLUDES
 #include <vector>
 #include "FGModel.h"
 #include "FGExternalForce.h"
-#include "input_output/FGXMLFileRead.h"
-
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $"
+#define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.15 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -117,7 +115,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGExternalReactions : public FGModel, public FGXMLFileRead
+class FGExternalReactions : public FGModel
 {
 public:
   /** Constructor.
index 855925e1cffe46e9a943c57c394e1145060e0c99..59deaafa2128bb8e09d44be7758b5e7d8091e24f 100644 (file)
@@ -45,6 +45,8 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGGroundReactions.h"
 #include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 #include "models/flight_control/FGFilter.h"
 #include "models/flight_control/FGDeadBand.h"
@@ -61,6 +63,7 @@ INCLUDES
 #include "models/flight_control/FGGyro.h"
 #include "models/flight_control/FGWaypoint.h"
 #include "models/flight_control/FGAngles.h"
+#include "models/flight_control/FGDistributor.h"
 
 #include "FGFCSChannel.h"
 
@@ -68,7 +71,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFCS.cpp,v 1.81 2013/06/20 04:37:27 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCS.cpp,v 1.83 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_FCS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -174,7 +177,10 @@ bool FGFCS::Run(bool Holding)
   }
 
   // Execute system channels in order
-  for (i=0; i<SystemChannels.size(); i++) SystemChannels[i]->Execute();
+  for (i=0; i<SystemChannels.size(); i++) {
+    if (debug_lvl & 4) cout << "    Executing System Channel: " << SystemChannels[i]->GetName() << endl;
+    SystemChannels[i]->Execute();
+  }
 
   RunPostFunctions();
 
@@ -485,6 +491,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
   string name, file, fname="", interface_property_string, parent_name;
   Element *component_element;
   Element *channel_element;
+  FGXMLFileRead XMLFileRead;
+  Element* document;
   
 // ToDo: The handling of name and file attributes could be improved, here,
 //       considering that a name can be in the external file, as well.
@@ -502,7 +510,7 @@ bool FGFCS::Load(Element* el, SystemType systype)
       cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl;
       return false;
     } else {
-      document = LoadXMLDocument(file);
+      document = XMLFileRead.LoadXMLDocument(file);
       if (!document) {
         cerr << "Error loading file " << file << endl;
         return false;
@@ -566,6 +574,7 @@ bool FGFCS::Load(Element* el, SystemType systype)
     FGFCSChannel* newChannel = 0;
 
     string sOnOffProperty = channel_element->GetAttributeValue("execute");
+    string sChannelName = channel_element->GetAttributeValue("name");
     FGPropertyNode* OnOffPropertyNode = 0;
     if (sOnOffProperty.length() > 0) {
       OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
@@ -576,10 +585,10 @@ bool FGFCS::Load(Element* el, SystemType systype)
              << "understood. The simulation will abort" << reset << endl;
         throw("Bad system definition");
       } else {
-        newChannel = new FGFCSChannel(OnOffPropertyNode);
+        newChannel = new FGFCSChannel(sChannelName, OnOffPropertyNode);
       }
     } else {
-      newChannel = new FGFCSChannel();
+      newChannel = new FGFCSChannel(sChannelName);
     }
 
     SystemChannels.push_back(newChannel);
@@ -631,6 +640,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
           newChannel->Add(new FGWaypoint(this, component_element));
         } else if (component_element->GetName() == string("angle")) {
           newChannel->Add(new FGAngles(this, component_element));
+        } else if (component_element->GetName() == string("distributor")) {
+          newChannel->Add(new FGDistributor(this, component_element));
         } else {
           cerr << "Unknown FCS component: " << component_element->GetName() << endl;
         }
@@ -646,8 +657,6 @@ bool FGFCS::Load(Element* el, SystemType systype)
 
   PostLoad(document, PropertyManager);
 
-  ResetParser();
-
   return true;
 }
 
index d67aea4088bdccc5f4d2b48529f2aa11b6654510..7a12f8d04db682ba0c7ead381d1a56ca84971c98 100644 (file)
@@ -45,13 +45,12 @@ INCLUDES
 #include "models/flight_control/FGFCSComponent.h"
 #include "models/FGModel.h"
 #include "models/FGLGear.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FCS "$Id: FGFCS.h,v 1.42 2013/06/20 04:37:27 jberndt Exp $"
+#define ID_FCS "$Id: FGFCS.h,v 1.45 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -169,7 +168,7 @@ CLASS DOCUMENTATION
     @property gear/tailhook-pos-norm
 
     @author Jon S. Berndt
-    @version $Revision: 1.42 $
+    @version $Revision: 1.45 $
     @see FGActuator
     @see FGDeadBand
     @see FGFCSFunction
@@ -184,13 +183,14 @@ CLASS DOCUMENTATION
     @see FGAngles
     @see FGFCSComponent
     @see Element
+    @see FGDistributor
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGFCS : public FGModel, public FGXMLFileRead
+class FGFCS : public FGModel
 {
 
 public:
old mode 100644 (file)
new mode 100755 (executable)
index fafd723..cb2686f
@@ -44,7 +44,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.2 2013/01/26 17:06:50 bcoconni Exp $"
+#define ID_FCSCHANNEL "$Id: FGFCSChannel.h,v 1.3 2013/09/27 19:44:45 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -70,8 +70,8 @@ typedef std::vector <FGFCSComponent*> FCSCompVec;
 class FGFCSChannel {
 public:
   /// Constructor
-  FGFCSChannel(FGPropertyNode* node=0) :
-  OnOffNode(node)
+  FGFCSChannel(string name, FGPropertyNode* node=0) :
+  OnOffNode(node), Name(name)
   {
   }
   /// Destructor
@@ -79,6 +79,9 @@ public:
     for (unsigned int i=0; i<FCSComponents.size(); i++) delete FCSComponents[i];
     FCSComponents.clear();
   }
+  /// Retrieves the name of the channel
+  string GetName() {return Name;}
+
   /// Adds a component to a channel
   void Add(FGFCSComponent* comp) {FCSComponents.push_back(comp);}
   /// Returns the number of components in the channel.
@@ -121,6 +124,7 @@ public:
   private:
     FCSCompVec FCSComponents;
     FGConstPropertyNode_ptr OnOffNode;
+    string Name;
 };
 
 }
index fe456dd08c06b9b6a2cf70ac746bee111dcfd3cc..1a0970af1ed2e58128c9289498035d53c22275ae 100644 (file)
@@ -42,12 +42,14 @@ INCLUDES
 #include "FGLGear.h"
 #include "FGAccelerations.h"
 #include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.42 2012/12/15 15:16:15 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.43 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_GROUNDREACTIONS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -130,11 +132,13 @@ bool FGGroundReactions::Load(Element* elem)
   int num=0;
   string fname="", file="";
   string separator = "/";
+  FGXMLFileRead XMLFileRead;
+  Element* document;
 
   fname = elem->GetAttributeValue("file");
   if (!fname.empty()) {
     file = FDMExec->GetFullAircraftPath() + separator + fname;
-    document = LoadXMLDocument(file);
+    document = XMLFileRead.LoadXMLDocument(file);
     if (document == 0L) return false;
   } else {
     document = elem;
index 8af49bda9f96a745bc0dc32cc8e0e202f0024923..0619a87717abd3ec88b0ebfabca2b4083fa3d941 100644 (file)
@@ -43,10 +43,8 @@ INCLUDES
 #include "FGModel.h"
 #include "FGLGear.h"
 #include "math/FGColumnVector3.h"
-#include "input_output/FGXMLElement.h"
-#include "input_output/FGXMLFileRead.h"
 
-#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.25 2012/12/12 06:19:57 jberndt Exp $"
+#define ID_GROUNDREACTIONS "$Id: FGGroundReactions.h,v 1.27 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -79,7 +77,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGGroundReactions : public FGModel, public FGXMLFileRead
+class FGGroundReactions : public FGModel
 {
 public:
   FGGroundReactions(FGFDMExec*);
index c31f4f2d4fb6c72d6ce292636a2ec79ff194a432..3796bffe320e67b81bc6fee62142ae9fd763ceee 100644 (file)
@@ -48,6 +48,7 @@ INCLUDES
 #include "input_output/FGPropertyManager.h"
 #include "models/FGGroundReactions.h"
 #include "math/FGTable.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
@@ -61,7 +62,7 @@ DEFINITIONS
 GLOBAL DATA
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-static const char *IdSrc = "$Id: FGLGear.cpp,v 1.104 2013/01/25 14:02:13 jberndt Exp $";
+static const char *IdSrc = "$Id: FGLGear.cpp,v 1.106 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_LGEAR;
 
 // Body To Structural (body frame is rotated 180 deg about Y and lengths are given in
@@ -723,6 +724,14 @@ void FGLGear::UpdateForces(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+void FGLGear::SetstaticFCoeff(double coeff)
+{
+  staticFCoeff = coeff;
+  Peak = coeff;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGLGear::bind(void)
 {
   string property_name;
@@ -749,7 +758,8 @@ void FGLGear::bind(void)
   property_name = base_property_name + "/compression-velocity-fps";
   PropertyManager->Tie( property_name.c_str(), &compressSpeed );
   property_name = base_property_name + "/static_friction_coeff";
-  PropertyManager->Tie( property_name.c_str(), &staticFCoeff );
+  PropertyManager->Tie( property_name.c_str(), (FGLGear*)this,
+                        &FGLGear::GetstaticFCoeff, &FGLGear::SetstaticFCoeff);
   property_name = base_property_name + "/dynamic_friction_coeff";
   PropertyManager->Tie( property_name.c_str(), &dynamicFCoeff );
 
index 83b039aaed42cfe9bc98f632d93d7b235cb334ba..45844e424fa3f711aea2d0e5799d4259ec704b2a 100644 (file)
@@ -48,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_LGEAR "$Id: FGLGear.h,v 1.56 2012/12/15 15:16:16 bcoconni Exp $"
+#define ID_LGEAR "$Id: FGLGear.h,v 1.58 2013/11/15 22:43:01 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -177,7 +177,7 @@ CLASS DOCUMENTATION
         </contact>
 @endcode
     @author Jon S. Berndt
-    @version $Id: FGLGear.h,v 1.56 2012/12/15 15:16:16 bcoconni Exp $
+    @version $Id: FGLGear.h,v 1.58 2013/11/15 22:43:01 bcoconni Exp $
     @see Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
      NASA-Ames", NASA CR-2497, January 1975
     @see Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
@@ -380,6 +380,7 @@ private:
   void ComputeGroundFrame(void);
   void ComputeJacobian(const FGColumnVector3& vWhlContactVec);
   void UpdateForces(void);
+  void SetstaticFCoeff(double coeff);
   void CrashDetect(void);
   void InitializeReporting(void);
   void ResetReporting(void);
index 446aaaca59b7098801f6b32136a738409bf9e942..0226cabd4c0fe06b3e0ffddecdb79ffdb97ac08c 100644 (file)
@@ -44,12 +44,14 @@ INCLUDES
 #include "FGMassBalance.h"
 #include "FGFDMExec.h"
 #include "input_output/FGPropertyManager.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.42 2012/12/12 06:19:57 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMassBalance.cpp,v 1.43 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_MASSBALANCE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -104,11 +106,13 @@ bool FGMassBalance::Load(Element* elem)
   double bixx, biyy, bizz, bixy, bixz, biyz;
   string fname="", file="";
   string separator = "/";
+  FGXMLFileRead XMLFileRead;
+  Element* document;
 
   fname = elem->GetAttributeValue("file");
   if (!fname.empty()) {
     file = FDMExec->GetFullAircraftPath() + separator + fname;
-    document = LoadXMLDocument(file);
+    document = XMLFileRead.LoadXMLDocument(file);
     if (document == 0L) return false;
   } else {
     document = elem;
index 947fdda08416de7690297194966874738776b7bd..833bb1a5418c3cecf44f6cca2fbd93402724e1bd 100644 (file)
@@ -43,14 +43,12 @@ INCLUDES
 #include "FGModel.h"
 #include "math/FGColumnVector3.h"
 #include "math/FGMatrix33.h"
-#include "input_output/FGXMLElement.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.28 2012/12/12 06:19:57 jberndt Exp $"
+#define ID_MASSBALANCE "$Id: FGMassBalance.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONSS
@@ -108,7 +106,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGMassBalance : public FGModel, public FGXMLFileRead
+class FGMassBalance : public FGModel
 {
 
 public:
index 221c9b7d398fe19c9e1a17cb830e42a79b63fdb6..1593621815d888e6726739399a4b49f80a329cd5 100644 (file)
@@ -44,12 +44,14 @@ INCLUDES
 #include "input_output/FGOutputSocket.h"
 #include "input_output/FGOutputTextFile.h"
 #include "input_output/FGOutputFG.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGOutput.cpp,v 1.73 2013/09/11 12:44:02 jberndt Exp $";
+static const char *IdSrc = "$Id: FGOutput.cpp,v 1.74 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_OUTPUT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -192,11 +194,10 @@ string FGOutput::GetOutputName(unsigned int idx) const
 
 bool FGOutput::SetDirectivesFile(const std::string& fname)
 {
-  Element* document = LoadXMLDocument(fname);
+  FGXMLFileRead XMLFile;
+  Element* document = XMLFile.LoadXMLDocument(fname);
   bool result = Load(document);
 
-  ResetParser();
-
   if (!result)
     cerr << endl << "Aircraft output element has problems in file " << fname << endl;
 
index 8336151fbf3b14fd4df89e862779487bc2e188d6..86e14c1ff437bf865c391753fbb8b4fcdaf51409 100644 (file)
@@ -42,13 +42,12 @@ INCLUDES
 
 #include "FGModel.h"
 #include "input_output/FGOutputType.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_OUTPUT "$Id: FGOutput.h,v 1.27 2013/01/26 17:06:50 bcoconni Exp $"
+#define ID_OUTPUT "$Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -122,14 +121,14 @@ CLASS DOCUMENTATION
 
     The class FGOutput is the manager of the outputs requested by the user. It
     manages a list of instances derived from the abstract class FGOutputType.
-    @version $Id: FGOutput.h,v 1.27 2013/01/26 17:06:50 bcoconni Exp $
+    @version $Id: FGOutput.h,v 1.29 2013/11/24 11:40:56 bcoconni Exp $
  */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGOutput : public FGModel, public FGXMLFileRead
+class FGOutput : public FGModel
 {
 public:
   FGOutput(FGFDMExec*);
index d1183a43b37c373e289ca267d59deeb7c3a3ff0f..12efa827acea3651a8424f28fb4e0e01aafa5cd2 100644 (file)
@@ -67,6 +67,7 @@ INCLUDES
 #include <cstdlib>
 #include <iostream>
 #include <iomanip>
+#include <fstream>
 
 #include "FGPropagate.h"
 #include "FGGroundReactions.h"
@@ -77,7 +78,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.115 2013/09/14 11:26:02 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGPropagate.cpp,v 1.119 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_PROPAGATE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -618,33 +619,43 @@ void FGPropagate::DumpState(void)
 
 void FGPropagate::WriteStateFile(int num)
 {
+  ofstream outfile;
+
+  if (num == 0) return;
+
   string filename = FDMExec->GetFullAircraftPath();
 
-  if (filename.empty())
-    filename = "initfile.xml";
-  else
-    filename.append("/initfile.xml");
-
-  ofstream outfile(filename.c_str());
-
-  if (outfile.is_open()) {
-    switch(num) {
-    case 1:
-    outfile << "<?xml version=\"1.0\"?>" << endl;
-    outfile << "<initialize name=\"reset00\">" << endl;
-    outfile << "  <ubody unit=\"FT/SEC\"> " << VState.vUVW(eU) << " </ubody> " << endl;
-    outfile << "  <vbody unit=\"FT/SEC\"> " << VState.vUVW(eV) << " </vbody> " << endl;
-    outfile << "  <wbody unit=\"FT/SEC\"> " << VState.vUVW(eW) << " </wbody> " << endl;
-    outfile << "  <phi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePhi)*radtodeg << " </phi>" << endl;
-    outfile << "  <theta unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(eTht)*radtodeg << " </theta>" << endl;
-    outfile << "  <psi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePsi)*radtodeg << " </psi>" << endl;
-    outfile << "  <longitude unit=\"DEG\"> " << VState.vLocation.GetLongitudeDeg() << " </longitude>" << endl;
-    outfile << "  <latitude unit=\"DEG\"> " << VState.vLocation.GetLatitudeDeg() << " </latitude>" << endl;
-    outfile << "  <altitude unit=\"FT\"> " << GetDistanceAGL() << " </altitude>" << endl;
-    outfile << "</initialize>" << endl;
-    outfile.close();
+  string sim_time = to_string((double)FDMExec->GetSimTime());
+  if (filename.empty()) filename = "initfile.";
+  else                  filename.append("/initfile.");
+
+  // Append sim time to the filename since there may be more than one created during a simulation run
+  filename += to_string((double)FDMExec->GetSimTime())+".xml";
+
+  switch(num) {
+  case 1:
+    outfile.open(filename.c_str());
+    if (outfile.is_open()) {
+      outfile << "<?xml version=\"1.0\"?>" << endl;
+      outfile << "<initialize name=\"reset00\">" << endl;
+      outfile << "  <ubody unit=\"FT/SEC\"> " << VState.vUVW(eU) << " </ubody> " << endl;
+      outfile << "  <vbody unit=\"FT/SEC\"> " << VState.vUVW(eV) << " </vbody> " << endl;
+      outfile << "  <wbody unit=\"FT/SEC\"> " << VState.vUVW(eW) << " </wbody> " << endl;
+      outfile << "  <phi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePhi)*radtodeg << " </phi>" << endl;
+      outfile << "  <theta unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(eTht)*radtodeg << " </theta>" << endl;
+      outfile << "  <psi unit=\"DEG\"> " << VState.qAttitudeLocal.GetEuler(ePsi)*radtodeg << " </psi>" << endl;
+      outfile << "  <longitude unit=\"DEG\"> " << VState.vLocation.GetLongitudeDeg() << " </longitude>" << endl;
+      outfile << "  <latitude unit=\"DEG\"> " << VState.vLocation.GetLatitudeDeg() << " </latitude>" << endl;
+      outfile << "  <altitude unit=\"FT\"> " << GetDistanceAGL() << " </altitude>" << endl;
+      outfile << "</initialize>" << endl;
+      outfile.close();
+    } else {
+      cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
+    }
     break;
-    case 2:
+  case 2:
+    outfile.open(filename.c_str());
+    if (outfile.is_open()) {
       outfile << "<?xml version=\"1.0\"?>" << endl;
       outfile << "<initialize name=\"IC File\" version=\"2.0\">" << endl;
       outfile << "" << endl;
@@ -674,13 +685,12 @@ void FGPropagate::WriteStateFile(int num)
       outfile << "" << endl;
       outfile << "</initialize>" << endl;
       outfile.close();
-    break;
-    default:
-      return; // Ignore other writes to the property, e.g. on FlightGear reset.
-      throw("When writing a state file, the supplied value must be 1 or 2 for the version number of the resulting IC file");
+    } else {
+      cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
     }
-  } else {
-    cerr << "Could not open and/or write the state to the initial conditions file: " << filename << endl;
+    break;
+  default:
+    cerr << "When writing a state file, the supplied value must be 1 or 2 for the version number of the resulting IC file" << endl;
   }
 }
 
index 372795790bc819056b0a73dc1c75ad5cdf4bd85a..8066846d6c4367dba56733c268e102e5dbc76b15 100644 (file)
@@ -59,14 +59,15 @@ INCLUDES
 #include "models/propulsion/FGTurboProp.h"
 #include "models/propulsion/FGTank.h"
 #include "input_output/FGPropertyManager.h"
-#include "input_output/FGXMLParse.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.70 2013/09/11 23:24:49 jentron Exp $";
+static const char *IdSrc = "$Id: FGPropulsion.cpp,v 1.71 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_PROPULSION;
 
 extern short debug_lvl;
@@ -376,6 +377,7 @@ bool FGPropulsion::Load(Element* elem)
   string type, engine_filename;
   string separator = "/";
   Element *el=0;
+  FGXMLFileRead XMLFileRead;
   FGXMLParse main_file_parser;
 
   Debug(2);
@@ -384,7 +386,7 @@ bool FGPropulsion::Load(Element* elem)
   fname = elem->GetAttributeValue("file");
   if (!fname.empty()) {
     file = FDMExec->GetFullAircraftPath() + separator + fname;
-    el = LoadXMLDocument(file, main_file_parser);
+    el = XMLFileRead.LoadXMLDocument(file, main_file_parser);
     if (el == 0L) return false;
   } else {
     el = elem;
@@ -421,7 +423,7 @@ bool FGPropulsion::Load(Element* elem)
       return false;
     }
 
-    document = LoadXMLDocument(engine_filename);
+    Element* document = XMLFileRead.LoadXMLDocument(engine_filename);
     document->SetParent(engine_element);
 
     type = document->GetName();
@@ -458,7 +460,7 @@ bool FGPropulsion::Load(Element* elem)
     numEngines++;
 
     engine_element = el->FindNextElement("engine");
-    ResetParser();
+    XMLFileRead.ResetParser();
   }
 
   CalculateTankInertias();
index 4be73b1698acb0814b0ce5e533a5445c45bc5c6d..cca5adf0003f4db613adfa0879b6d577709fff64 100644 (file)
@@ -44,13 +44,12 @@ INCLUDES
 #include "FGModel.h"
 #include "propulsion/FGEngine.h"
 #include "math/FGMatrix33.h"
-#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $"
+#define ID_PROPULSION "$Id: FGPropulsion.h,v 1.32 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -92,7 +91,7 @@ CLASS DOCUMENTATION
   @endcode
 
     @author Jon S. Berndt
-    @version $Id: FGPropulsion.h,v 1.31 2011/10/31 14:54:41 bcoconni Exp $
+    @version $Id: FGPropulsion.h,v 1.32 2013/11/24 11:40:56 bcoconni Exp $
     @see
     FGEngine
     FGTank
@@ -102,7 +101,7 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGPropulsion : public FGModel, public FGXMLFileRead
+class FGPropulsion : public FGModel
 {
 public:
   /// Constructor
old mode 100644 (file)
new mode 100755 (executable)
index 9f321a2..e4113aa
@@ -37,20 +37,21 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGAccelerometer.h"
 #include <iostream>
 #include <cstdlib>
 
+#include "FGAccelerometer.h"
 #include "models/FGPropagate.h"
 #include "models/FGAccelerations.h"
 #include "models/FGMassBalance.h"
 #include "models/FGInertial.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGAccelerometer.cpp,v 1.11 2012/11/17 18:03:19 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAccelerometer.cpp,v 1.12 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_ACCELEROMETER;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 44194bb..70aabd3
@@ -38,7 +38,6 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGSensor.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 #include "math/FGMatrix33.h"
 #include "FGSensorOrientation.h"
@@ -47,7 +46,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.6 2012/01/08 12:39:14 bcoconni Exp $"
+#define ID_ACCELEROMETER "$Id: FGAccelerometer.h,v 1.7 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -127,7 +126,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
 time.
 
 @author Jon S. Berndt
-@version $Revision: 1.6 $
+@version $Revision: 1.7 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index a335689c5c4282956d3be41af3e46b47608c14ed..1be3971b40bddf1a30ca239f10f917160e47192e 100644 (file)
@@ -38,12 +38,13 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGActuator.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGActuator.cpp,v 1.28 2013/06/10 02:04:50 jberndt Exp $";
+static const char *IdSrc = "$Id: FGActuator.cpp,v 1.29 2013/11/24 11:40:56 bcoconni Exp $";
 static const char *IdHdr = ID_ACTUATOR;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index a8e8d59328203a0ea87730d52cd1a061d30dffc7..6c3fff546497527731b859c5699780d35a6e1c23 100644 (file)
@@ -38,13 +38,12 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCSComponent.h"
-#include "input_output/FGXMLElement.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_ACTUATOR "$Id: FGActuator.h,v 1.15 2013/01/26 17:06:50 bcoconni Exp $"
+#define ID_ACTUATOR "$Id: FGActuator.h,v 1.16 2013/11/24 11:40:56 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -120,7 +119,7 @@ Example:
 @endcode
 
 @author Jon S. Berndt
-@version $Revision: 1.15 $
+@version $Revision: 1.16 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index f9287c50686791b31311f182711cf7ede2ddc560..fea7f68a377f6755a3b5fb75627ae898234d3c2d 100755 (executable)
@@ -1,4 +1,5 @@
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Module:       FGAngles.cpp
  Author:       Jon S. Berndt
  Date started: 6/2013
@@ -73,7 +74,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGAngles.cpp,v 1.1 2013/06/20 04:37:28 jberndt Exp $";
+static const char *IdSrc = "$Id: FGAngles.cpp,v 1.2 2013/09/27 19:36:28 jberndt Exp $";
 static const char *IdHdr = ID_ANGLES;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/FDM/JSBSim/models/flight_control/FGDistributor.cpp b/src/FDM/JSBSim/models/flight_control/FGDistributor.cpp
new file mode 100755 (executable)
index 0000000..da16ddb
--- /dev/null
@@ -0,0 +1,177 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module:       FGDistributor.cpp
+ Author:       Jon S. Berndt
+ Date started: 9/2013
+
+ ------------- Copyright (C) 2013 -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA  02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+FUNCTIONAL DESCRIPTION
+--------------------------------------------------------------------------------
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES,  and NOTES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+Also, see the header file (FGDistributor.h) for further details.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <iostream>
+#include "FGDistributor.h"
+#include "input_output/FGXMLElement.h"
+
+using namespace std;
+
+namespace JSBSim {
+
+static const char *IdSrc = "$Id: FGDistributor.cpp,v 1.3 2013/11/24 11:40:56 bcoconni Exp $";
+static const char *IdHdr = ID_DISTRIBUTOR;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGDistributor::FGDistributor(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
+{
+  Element *case_element=0;
+  Element* test_element=0;
+  Element* prop_val_element=0;
+  string type_string;
+  Case* current_case=0;
+
+  FGFCSComponent::bind(); // Bind() this component here in case it is used
+                          // in its own definition for a sample-and-hold
+
+  type_string = element->GetAttributeValue("type");
+  if (type_string == "inclusive") Type = eInclusive;
+  else if (type_string == "exclusive") Type = eExclusive;
+  else {
+    throw("Not a known Distributor type, "+type_string);
+  }
+
+  case_element = element->FindElement("case");
+  while (case_element) {
+    current_case = new struct Case;
+    test_element = case_element->FindElement("test");
+    if (test_element) current_case->SetTest(new FGCondition(test_element, PropertyManager));
+    prop_val_element = case_element->FindElement("property");
+    while (prop_val_element) {
+      string value_string = prop_val_element->GetAttributeValue("value");
+      string property_string = prop_val_element->GetDataLine();
+      current_case->AddPropValPair(new PropValPair(property_string, value_string, PropertyManager));
+      prop_val_element = case_element->FindNextElement("property");
+    }
+    Cases.push_back(current_case);
+    case_element = element->FindNextElement("case");
+  }
+
+  Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGDistributor::~FGDistributor()
+{
+
+  Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGDistributor::Run(void )
+{
+  bool completed = false;
+  for (unsigned int ctr=0; ctr<Cases.size(); ctr++) { // Loop through all Cases
+    if (Cases[ctr]->HasTest()) {                      
+      if (Cases[ctr]->GetTestResult() && !((Type == eExclusive) && completed)) {
+        Cases[ctr]->SetPropValPairs();
+        completed = true;
+      }
+    } else {                                          // If no test present, execute always
+      Cases[ctr]->SetPropValPairs();
+    }
+  }
+
+//  if (delay != 0) Delay();
+//  Clip();
+//  if (IsOutput) SetOutput();
+
+  return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGDistributor::Debug(int from)
+{
+  string comp, scratch;
+  string indent = "        ";
+  //bool first = false;
+
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+    if (from == 0) { // Constructor
+
+    }
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGDistributor" << endl;
+    if (from == 1) cout << "Destroyed:    FGDistributor" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
+
+} //namespace JSBSim
+
diff --git a/src/FDM/JSBSim/models/flight_control/FGDistributor.h b/src/FDM/JSBSim/models/flight_control/FGDistributor.h
new file mode 100755 (executable)
index 0000000..55f8c7a
--- /dev/null
@@ -0,0 +1,215 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header:       FGDistributor.h
+ Author:       Jon S. Berndt
+ Date started: 09/27/2013
+
+ ------------- Copyright (C) 2013 jon@jsbsim.org  -------------
+
+ This program is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free Software
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA  02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
+HISTORY
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGDISTRIBUTOR_H
+#define FGDISTRIBUTOR_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <iostream>
+#include <cstdlib>
+
+#include "FGFCSComponent.h"
+#include "math/FGCondition.h"
+#include "math/FGPropertyValue.h"
+#include "math/FGRealValue.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_DISTRIBUTOR "$Id: FGDistributor.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Encapsulates a distributor for the flight control system.
+
+The distributor component models a distributor - 
+
+Within a test, additional tests can be specified, which allows for
+complex groupings of logical comparisons. Each test contains
+additional conditions, as well as possibly additional tests.
+
+@code
+<distributor name="name/is/irrelevant" type="exclusive|inclusive">
+
+  <case>
+    [<test logic="{AND|OR}" value="{property|value}">
+      {property} {conditional} {property|value}
+      <test logic="{AND|OR}">
+        {property} {conditional} {property|value}
+        ...
+      </test>
+      ...
+    </test>] <!-- Optional <test> one time. A <case> without a <test> is always executed -->
+    <property value="number|property"> property_name </property>
+    ...
+  </case>
+
+  ... <!-- Additional cases -->
+
+</distributor>
+@endcode
+
+Here's an example:
+
+@code
+
+@endcode
+
+Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.
+
+@author Jon S. Berndt
+@version $Id: FGDistributor.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGDistributor  : public FGFCSComponent
+{
+public:
+  /** Constructor
+      @param fcs a pointer to the parent FGFCS class
+      @param element a pointer to the Element (from the config file XML tree)
+             that represents this distributor component */
+  FGDistributor(FGFCS* fcs, Element* element);
+
+  /// Destructor
+  ~FGDistributor();
+
+  /** Executes the distributor logic.
+      @return true - always*/
+  bool Run(void);
+
+private:
+
+  enum eType {eInclusive=0, eExclusive} Type;
+
+  class PropValPair {
+  public:
+    PropValPair(std::string prop, std::string val, FGPropertyManager* propMan) {
+      PropMan = propMan;
+      sign = 1;
+      Val = 0;
+      ValString = val;
+      FGPropertyNode *node = propMan->GetNode(prop, false);
+      if (node) PropNode = node;
+      else PropNode = 0;
+      PropName = prop;
+      if (is_number(ValString)) {
+        Val = new FGRealValue(atof(ValString.c_str()));
+      } else {
+        // "value" must be a property if execution passes to here.
+        if (ValString[0] == '-') {
+          sign = -1;
+          ValString.erase(0,1);
+        }
+        node = propMan->GetNode(ValString, false);
+        if (node) Val = new FGPropertyValue(node);
+      }
+    }
+
+    ~PropValPair() {
+      delete PropNode;
+      delete PropMan;
+    }
+    
+    void SetPropToValue() {
+      if (PropNode == 0) {
+        if (PropMan->HasNode(PropName)) {
+          PropNode = PropMan->GetNode(PropName);
+        } else {
+          throw(PropName+" in distributor component is not known");
+        }
+      }
+      if (Val == 0) {
+        if (PropMan->HasNode(ValString)) {
+          FGPropertyNode* node = PropMan->GetNode(ValString, false);
+          if (node) Val = new FGPropertyValue(node);
+        } else {
+          throw(ValString+" in distributor component is not known. Check spelling.");
+        }
+      }
+      PropNode->setDoubleValue(Val->GetValue()*sign);
+    }
+
+  private:
+    std::string PropName;
+    FGPropertyNode* PropNode;
+    FGPropertyManager* PropMan;
+    FGParameter* Val;
+    std::string ValString;
+    int sign;
+  };
+
+  class Case {
+  public:
+    Case() {
+      Test = 0;
+    }
+
+    ~Case() {
+      for (unsigned int i=0; i<PropValPairs.size(); i++) delete PropValPairs[i];
+      PropValPairs.clear();
+    }
+
+    void SetTest(FGCondition* test) {Test = test;}
+    void AddPropValPair(PropValPair* pvPair) {PropValPairs.push_back(pvPair);}
+    void SetPropValPairs() {
+      for (unsigned int i=0; i<PropValPairs.size(); i++) PropValPairs[i]->SetPropToValue();
+    }
+    bool HasTest() {return (Test != 0);}
+    bool GetTestResult() { return Test->Evaluate(); }
+
+  private:
+    FGCondition* Test;
+    std::vector <PropValPair*> PropValPairs;
+  };
+
+  std::vector <Case*> Cases;
+
+  void Debug(int from);
+};
+}
+#endif
index 198ad689fbdfce89e31f3d7999563edeb7013081..630f5cb8c38afb4a74ac044be2bf8fd263f21090 100644 (file)
@@ -48,7 +48,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.36 2013/06/20 04:37:28 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCSComponent.cpp,v 1.37 2013/09/27 19:38:36 jberndt Exp $";
 static const char *IdHdr = ID_FCSCOMPONENT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -57,14 +57,14 @@ CLASS IMPLEMENTATION
 
 FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
 {
-  Element *input_element, *clip_el;
+  Element *input_element,*init_element, *clip_el;
   Input = Output = clipmin = clipmax = delay_time = 0.0;
   treenode = 0;
   delay = index = 0;
   ClipMinPropertyNode = ClipMaxPropertyNode = 0;
   clipMinSign = clipMaxSign = 1.0;
   IsOutput   = clip = false;
-  string input, clip_string;
+  string input,init, clip_string;
   dt = fcs->GetDt();
 
   PropertyManager = fcs->GetPropertyManager();
@@ -112,12 +112,36 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
     Type = "WAYPOINT_DISTANCE";
   } else if (element->GetName() == string("angle")) {
     Type = "ANGLE";
+  } else if (element->GetName() == string("distributor")) {
+    Type = "DISTRIBUTOR";
   } else { // illegal component in this channel
     Type = "UNKNOWN";
   }
 
   Name = element->GetAttributeValue("name");
 
+  init_element = element->FindElement("init");
+  while (init_element) {
+    init = init_element->GetDataLine();
+    if (init[0] == '-') {
+      InitSigns.push_back(-1.0);
+      init.erase(0,1);
+    } else {
+      InitSigns.push_back( 1.0);
+    }
+    FGPropertyNode* node = 0L;
+    if (PropertyManager->HasNode(init)) {
+      node = PropertyManager->GetNode(init);
+      InitNodes.push_back(new FGPropertyValue( node ));
+    } else {
+      InitNodes.push_back(new FGPropertyValue( init,
+                                                PropertyManager ));
+    }
+    InitNames.push_back( init );
+
+    init_element = element->FindNextElement("init");
+  }
+  
   input_element = element->FindElement("input");
   while (input_element) {
     input = input_element->GetDataLine();
index 1c0c03ef93f609ff24b97f0b2800fbb0f377202f..77b014095eabd3118a6f92df33386a333e111983 100644 (file)
@@ -46,7 +46,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.22 2013/06/20 04:37:28 jberndt Exp $"
+#define ID_FCSCOMPONENT "$Id: FGFCSComponent.h,v 1.23 2013/09/27 19:38:44 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -82,7 +82,7 @@ CLASS DOCUMENTATION
     - FGAngle
 
     @author Jon S. Berndt
-    @version $Id: FGFCSComponent.h,v 1.22 2013/06/20 04:37:28 jberndt Exp $
+    @version $Id: FGFCSComponent.h,v 1.23 2013/09/27 19:38:44 jberndt Exp $
     @see Documentation for the FGFCS class, and for the configuration file class
 */
 
@@ -112,6 +112,9 @@ protected:
   std::vector <FGPropertyNode_ptr> OutputNodes;
   FGPropertyNode_ptr ClipMinPropertyNode;
   FGPropertyNode_ptr ClipMaxPropertyNode;
+  std::vector <FGPropertyValue*> InitNodes;
+  std::vector <std::string> InitNames;
+  std::vector <float> InitSigns;
   std::vector <FGPropertyValue*> InputNodes;
   std::vector <std::string> InputNames;
   std::vector <float> InputSigns;
old mode 100644 (file)
new mode 100755 (executable)
index 28032d3..6d21a05
@@ -37,15 +37,17 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGFCSFunction.h"
 #include <cstdlib>
 #include <iostream>
 
+#include "FGFCSFunction.h"
+#include "input_output/FGXMLElement.h"
+
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGFCSFunction.cpp,v 1.12 2012/11/17 18:03:19 jberndt Exp $";
+static const char *IdSrc = "$Id: FGFCSFunction.cpp,v 1.13 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_FCSFUNCTION;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 779014c..f5fa524
@@ -38,14 +38,13 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFCSComponent.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGFunction.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $"
+#define ID_FCSFUNCTION "$Id: FGFCSFunction.h,v 1.9 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -105,7 +104,7 @@ a function (from an aero specification):
 </function>
 @endcode
 
-    @version $Id: FGFCSFunction.h,v 1.8 2011/11/10 12:06:14 jberndt Exp $
+    @version $Id: FGFCSFunction.h,v 1.9 2013/11/24 11:40:57 bcoconni Exp $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 19d8de2..cc5ce53
@@ -37,16 +37,17 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGGyro.h"
 #include <iostream>
 
+#include "FGGyro.h"
 #include "models/FGAccelerations.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGGyro.cpp,v 1.7 2012/11/17 18:03:19 jberndt Exp $";
+static const char *IdSrc = "$Id: FGGyro.cpp,v 1.8 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_GYRO;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 39db505..a339908
@@ -38,7 +38,6 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGSensor.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 #include "math/FGMatrix33.h"
 #include "FGSensorOrientation.h"
@@ -47,7 +46,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_GYRO "$Id: FGGyro.h,v 1.6 2011/07/17 13:51:23 jberndt Exp $"
+#define ID_GYRO "$Id: FGGyro.h,v 1.7 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -104,7 +103,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
 time.
 
 @author Jon S. Berndt
-@version $Revision: 1.6 $
+@version $Revision: 1.7 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index e0a54a7..8eefb8c
@@ -37,17 +37,19 @@ COMMENTS, REFERENCES,  and NOTES
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGMagnetometer.h"
-#include "simgear/magvar/coremag.hxx"
 #include <ctime>
 #include <cstdlib>
 #include <iostream>
 
+#include "FGMagnetometer.h"
+#include "simgear/magvar/coremag.hxx"
+#include "input_output/FGXMLElement.h"
+
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGMagnetometer.cpp,v 1.6 2012/11/17 18:03:19 jberndt Exp $";
+static const char *IdSrc = "$Id: FGMagnetometer.cpp,v 1.7 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_MAGNETOMETER;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index c7a850a..c0dac14
@@ -38,7 +38,6 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGSensor.h"
-#include "input_output/FGXMLElement.h"
 #include "models/FGPropagate.h"
 #include "models/FGMassBalance.h"
 #include "models/FGInertial.h"
@@ -50,7 +49,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_MAGNETOMETER "$Id: FGMagnetometer.h,v 1.4 2009/12/11 06:03:06 jberndt Exp $"
+#define ID_MAGNETOMETER "$Id: FGMagnetometer.h,v 1.5 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -118,7 +117,7 @@ even varying all the way from 0.95 to 1.05 in adjacent frames - whatever the del
 time.
 
 @author Jon S. Berndt
-@version $Revision: 1.4 $
+@version $Revision: 1.5 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 99f5d13..f5bdafa
@@ -48,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.3 2009/10/24 22:59:30 jberndt Exp $"
+#define ID_SensorOrientation "$Id: FGSensorOrientation.h,v 1.5 2013/11/17 05:12:57 jberndt Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -65,7 +65,7 @@ CLASS DOCUMENTATION
 Syntax:
 
 @author Jon S. Berndt
-@version $Revision: 1.3 $
+@version $Revision: 1.5 $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -79,7 +79,7 @@ public:
   {
     Element* orient_element = element->FindElement("orientation");
     if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD");
-    else { std::cerr << "No orientation given for this sensor. " << std::endl;}
+
 
     Element* axis_element = element->FindElement("axis");
     if (axis_element) {
index fa28935d9a1a8392a8f1782d77ff53a37c64f9ae..4d91a30d89601a4c5738c117af6ece700afb8264 100644 (file)
@@ -61,14 +61,16 @@ Also, see the header file (FGSwitch.h) for further details.
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include "FGSwitch.h"
 #include <iostream>
 
+#include "FGSwitch.h"
+#include "input_output/FGXMLElement.h"
+
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.25 2012/12/02 12:59:19 bcoconni Exp $";
+static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.27 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_SWITCH;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -95,6 +97,11 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
     value = test_element->GetAttributeValue("value");
     current_test->setTestValue(value, Name, PropertyManager);
     current_test->Default = true;
+    if (delay > 0 && is_number(value)) {        // If there is a delay, initialize the
+      for (unsigned int i=0; i<delay-1; i++) {  // delay buffer to the default value
+        output_array[i] = atof(value.c_str());  // for the switch if that value is a number.
+      }
+    }
     tests.push_back(current_test);
   }
 
index 5dd2949ce4f2c8490a369a9a9430ef875e388057..ff5fe0c40bac967059b8fc25816badf270835518 100644 (file)
@@ -39,8 +39,8 @@ INCLUDES
 
 #include <iostream>
 #include <cstdlib>
+
 #include "FGFCSComponent.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGCondition.h"
 #include "math/FGPropertyValue.h"
 
@@ -48,7 +48,7 @@ INCLUDES
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_SWITCH "$Id: FGSwitch.h,v 1.16 2013/01/26 17:06:50 bcoconni Exp $"
+#define ID_SWITCH "$Id: FGSwitch.h,v 1.18 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -127,7 +127,7 @@ ap/attitude_hold takes the value 1), the value of the switch component will be
 whatever value fcs/roll-ap-error-summer is.
 
 @author Jon S. Berndt
-@version $Id: FGSwitch.h,v 1.16 2013/01/26 17:06:50 bcoconni Exp $
+@version $Id: FGSwitch.h,v 1.18 2013/11/24 11:40:57 bcoconni Exp $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -171,7 +171,9 @@ private:
       sign       = 1.0;
     }
 
-    void setTestValue(std::string value, std::string Name, FGPropertyManager* propMan) {
+    void setTestValue(std::string value, std::string Name,
+                      FGPropertyManager* propMan)
+    {
       if (value.empty()) {
         std::cerr << "No VALUE supplied for switch component: " << Name << std::endl;
       } else {
index c591ceb63ec5e69217d6bcb31a1948c14b91b0a9..088a41993372e822edc27a258a673954c40e69fb 100644 (file)
@@ -44,12 +44,13 @@ INCLUDES
 
 #include "FGElectric.h"
 #include "FGPropeller.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGElectric.cpp,v 1.13 2011/08/03 03:21:06 jberndt Exp $";
+static const char *IdSrc = "$Id: FGElectric.cpp,v 1.14 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_ELECTRIC;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index f35be2186728cdb9b7f1e19483b85b8632172bec..cfbdf167895d2ec3b3f0941aeb70cd7167ccec90 100644 (file)
@@ -39,13 +39,12 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGEngine.h"
-#include "input_output/FGXMLElement.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_ELECTRIC "$Id: FGElectric.h,v 1.11 2011/07/28 12:48:19 jberndt Exp $";
+#define ID_ELECTRIC "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $";
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -65,7 +64,7 @@ CLASS DOCUMENTATION
     there is no battery model available, so this motor does not consume any
     energy.  There is no internal friction.
     @author David Culp
-    @version "$Id: FGElectric.h,v 1.11 2011/07/28 12:48:19 jberndt Exp $"
+    @version "$Id: FGElectric.h,v 1.12 2013/11/24 11:40:57 bcoconni Exp $"
   */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index e4a9cb77e0bb608cf7a2630b1c4d47b3bf9f2aee..62917a7bcb26ed73a4d3a3df1e4fdd0657d329b5 100644 (file)
@@ -46,14 +46,15 @@ INCLUDES
 #include "FGPropeller.h"
 #include "FGNozzle.h"
 #include "FGRotor.h"
-#include "input_output/FGXMLParse.h"
+#include "input_output/FGXMLFileRead.h"
+#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGEngine.cpp,v 1.52 2013/01/12 19:24:45 jberndt Exp $";
+static const char *IdSrc = "$Id: FGEngine.cpp,v 1.54 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_ENGINE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -83,7 +84,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number,
 
   Name = engine_element->GetAttributeValue("name");
 
-  Load(engine_element, PropertyManager, ::to_string(EngineNumber)); // Call ModelFunctions loader
+  Load(engine_element, PropertyManager, to_string((int)EngineNumber)); // Call ModelFunctions loader
 
 // Find and set engine location
 
@@ -133,7 +134,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number,
   property_name = base_property_name + "/fuel-used-lbs";
   PropertyManager->Tie( property_name.c_str(), this, &FGEngine::GetFuelUsedLbs);
 
-  PostLoad(engine_element, PropertyManager, ::to_string(EngineNumber));
+  PostLoad(engine_element, PropertyManager, to_string((int)EngineNumber));
 
   Debug(0);
 }
@@ -268,7 +269,8 @@ bool FGEngine::LoadThruster(Element *thruster_element)
     return false;
   }
 
-  document = LoadXMLDocument(thruster_fullpathname);
+  FGXMLFileRead XMLFileRead;
+  Element *document = XMLFileRead.LoadXMLDocument(thruster_fullpathname);
   document->SetParent(thruster_element);
 
   thrType = document->GetName();
index aeb243f6e7f6240ed0ebc52cde70cfe2487677c9..a275833954b2b3ff32575e09336242b9b9144cc1 100644 (file)
@@ -47,15 +47,13 @@ INCLUDES
 #include <string>
 
 #include "math/FGModelFunctions.h"
-#include "input_output/FGXMLFileRead.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGColumnVector3.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_ENGINE "$Id: FGEngine.h,v 1.36 2012/07/29 12:04:09 bcoconni Exp $"
+#define ID_ENGINE "$Id: FGEngine.h,v 1.38 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -113,14 +111,14 @@ CLASS DOCUMENTATION
   documentation for engine and thruster classes.
 </pre>     
     @author Jon S. Berndt
-    @version $Id: FGEngine.h,v 1.36 2012/07/29 12:04:09 bcoconni Exp $
+    @version $Id: FGEngine.h,v 1.38 2013/11/24 11:40:57 bcoconni Exp $
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGEngine : public FGModelFunctions, public FGXMLFileRead
+class FGEngine : public FGModelFunctions
 {
 public:
   struct Inputs {
index ae563404c48f4e93c11008008a101a21400750c3..10e43820e5a42e505dde0ad2ed7ffc87779f5268 100644 (file)
@@ -45,12 +45,13 @@ INCLUDES
 
 #include "FGPiston.h"
 #include "FGPropeller.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPiston.cpp,v 1.71 2012/04/07 01:50:54 jentron Exp $";
+static const char *IdSrc = "$Id: FGPiston.cpp,v 1.72 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_PISTON;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index b17cf31e2fd411b3b7036477b2ead93eaf89fa4f..6d4123ab35b1f9bd9317ef9c25273a5ba5e4bfba 100644 (file)
@@ -40,14 +40,16 @@ INCLUDES
 
 #include <iostream>
 #include <sstream>
+
 #include "FGRocket.h"
 #include "FGThruster.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGRocket.cpp,v 1.30 2013/06/10 02:00:11 jberndt Exp $";
+static const char *IdSrc = "$Id: FGRocket.cpp,v 1.31 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_ROCKET;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 8b9a3334e159ab50a26abf2b90d238f25492a996..b93f1519346bc0a9e83617eb68a58cee3969f410 100644 (file)
@@ -41,13 +41,12 @@ INCLUDES
 #include "FGEngine.h"
 #include "math/FGTable.h"
 #include "math/FGFunction.h"
-#include "input_output/FGXMLElement.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_ROCKET "$Id: FGRocket.h,v 1.19 2012/09/17 12:29:13 jberndt Exp $"
+#define ID_ROCKET "$Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -119,7 +118,7 @@ for the rocket engine to be throttle up to 1. At that time, the solid rocket
 fuel begins burning and thrust is provided.
 
     @author Jon S. Berndt
-    $Id: FGRocket.h,v 1.19 2012/09/17 12:29:13 jberndt Exp $
+    $Id: FGRocket.h,v 1.20 2013/11/24 11:40:57 bcoconni Exp $
     @see FGNozzle,
     FGThruster,
     FGForce,
index 19100ea2f8676cfb9d1a3ba691d2aa23c7cdae7b..977c96726215f811d185435a9749a4e5fdab9a31 100644 (file)
@@ -48,6 +48,7 @@ INCLUDES
 #include "FGRotor.h"
 #include "models/FGMassBalance.h"
 #include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor
+#include "input_output/FGXMLElement.h"
 
 using std::cerr;
 using std::cout;
@@ -56,7 +57,7 @@ using std::ostringstream;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGRotor.cpp,v 1.20 2012/03/18 15:48:36 jentron Exp $";
+static const char *IdSrc = "$Id: FGRotor.cpp,v 1.21 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_ROTOR;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 97bad3f81da7ffc90b9b7beb9d1af4489708c480..a887dcd3ee81159689c8cf7e6083a15082a51aae 100644 (file)
@@ -42,13 +42,13 @@ INCLUDES
 
 #include "FGTransmission.h"
 
+using std::string;
 using std::cout;
 using std::endl;
-using std::string;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGTransmission.cpp,v 1.1 2012/02/25 14:37:02 jentron Exp $";
+static const char *IdSrc = "$Id: FGTransmission.cpp,v 1.2 2013/11/15 22:43:03 bcoconni Exp $";
 static const char *IdHdr = ID_TRANSMISSION;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 21880d73ab649b00835b84af1a3b83a9bbba51ab..d48439103c08c45990257f81eca8997502b9cdd8 100644 (file)
@@ -44,12 +44,13 @@ INCLUDES
 
 #include "FGTurbine.h"
 #include "FGThruster.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.37 2012/11/17 19:38:43 jberndt Exp $";
+static const char *IdSrc = "$Id: FGTurbine.cpp,v 1.38 2013/11/24 11:40:57 bcoconni Exp $";
 static const char *IdHdr = ID_TURBINE;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index c0bb279..fa3109c
@@ -48,12 +48,13 @@ INCLUDES
 #include "FGTurboProp.h"
 #include "FGPropeller.h"
 #include "FGRotor.h"
+#include "input_output/FGXMLElement.h"
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.24 2011/09/25 23:56:11 jentron Exp $";
+static const char *IdSrc = "$Id: FGTurboProp.cpp,v 1.26 2013/11/24 14:22:22 bcoconni Exp $";
 static const char *IdHdr = ID_TURBOPROP;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -62,7 +63,7 @@ CLASS IMPLEMENTATION
 
 FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number, struct Inputs& input)
   : FGEngine(exec, el, engine_number, input),
-    ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL)
+    ITT_N1(NULL), EnginePowerRPM_N1(NULL), EnginePowerVC(NULL), CombustionEfficiency_N1(NULL)
 {
   SetDefaults();
   thrusterType = Thruster->GetType();
@@ -79,6 +80,7 @@ FGTurboProp::~FGTurboProp()
   delete ITT_N1;
   delete EnginePowerRPM_N1;
   delete EnginePowerVC;
+  delete CombustionEfficiency_N1;
   Debug(1);
 }
 
@@ -86,7 +88,6 @@ FGTurboProp::~FGTurboProp()
 
 bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
 {
-  IdleFF=-1;
   MaxStartingTime = 999999; //very big timeout -> infinite
   Ielu_max_torque=-1;
 
@@ -110,8 +111,10 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
 
   if (el->FindElement("maxpower"))
     MaxPower = el->FindElementValueAsNumber("maxpower");
-  if (el->FindElement("idlefuelflow"))
-    IdleFF = el->FindElementValueAsNumber("idlefuelflow");
+  if (el->FindElement("idlefuelflow")) {
+    cerr << el->ReadFrom() << "Note: 'idlefuelflow' is obsolete, "
+         << "use the 'CombustionEfficiency_N1' table instead." << endl;
+  }
   if (el->FindElement("psfc"))
     PSFC = el->FindElementValueAsNumber("psfc");
   if (el->FindElement("n1idle_max_delay"))
@@ -139,9 +142,11 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
       EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element);
     } else if (name == "ITT_N1") {
       ITT_N1 = new FGTable(PropertyManager, table_element);
+    } else if (name == "CombustionEfficiency_N1") {
+      CombustionEfficiency_N1 = new FGTable(PropertyManager, table_element);
     } else {
-      cerr << "Unknown table type: " << name << " in turbine definition." <<
-      endl;
+      cerr << el->ReadFrom() << "Unknown table type: " << name
+           << " in turboprop definition." << endl;
     }
   }
 
@@ -151,9 +156,19 @@ bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
   N1_factor = MaxN1 - IdleN1;
   N2_factor = MaxN2 - IdleN2;
   OilTemp_degK = in.TAT_c + 273.0;
-  if (IdleFF==-1) IdleFF = pow(MilThrust, 0.2) * 107.0;  // just an estimate
 
-  // cout << "ENG POWER:" << EnginePowerRPM_N1->GetValue(1200,90) << endl;
+  // default table based on '9.333 - (N1)/12.0' approximation
+  // gives 430%Fuel at 60%N1
+  if (! CombustionEfficiency_N1) {
+    CombustionEfficiency_N1 = new FGTable(6);
+    *CombustionEfficiency_N1 <<  60.0 << 12.0/52.0;
+    *CombustionEfficiency_N1 <<  82.0 << 12.0/30.0;
+    *CombustionEfficiency_N1 <<  96.0 << 12.0/16.0;
+    *CombustionEfficiency_N1 << 100.0 << 1.0;
+    *CombustionEfficiency_N1 << 104.0 << 1.5;
+    *CombustionEfficiency_N1 << 110.0 << 6.0;
+  }
+  
 
   return true;
 }
@@ -294,7 +309,9 @@ double FGTurboProp::Off(void)
 
 double FGTurboProp::Run(void)
 {
-  double thrust = 0.0, EngPower_HP, eff_coef;
+  double thrust = 0.0;
+  double EngPower_HP;
+
   Running = true; Starter = false; EngStarting = false;
 
 //---
@@ -305,8 +322,8 @@ double FGTurboProp::Run(void)
   EngPower_HP *= EnginePowerVC->GetValue();
   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
 
-  eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
-  FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
+  CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
+  FuelFlow_pph = PSFC / CombustionEfficiency * EngPower_HP;
 
   Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
   double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
@@ -368,7 +385,6 @@ double FGTurboProp::SpinUp(void)
 double FGTurboProp::Start(void)
 {
   double EngPower_HP = 0.0;
-  double eff_coef;
 
   EngStarting = false;
   if ((N1 > 15.0) && !Starved) {       // minimum 15% N2 needed for start
@@ -379,8 +395,8 @@ double FGTurboProp::Start(void)
       EngPower_HP *= EnginePowerVC->GetValue();
       if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
       N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4);
-      eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
-      FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
+      CombustionEfficiency = CombustionEfficiency_N1->GetValue(N1);
+      FuelFlow_pph = PSFC / CombustionEfficiency * EngPower_HP;
       Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
       double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
       Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
@@ -477,6 +493,7 @@ void FGTurboProp::SetDefaults(void)
   ITT_Delay = 0.05;
   ReverseMaxPower = 0.0;
   BetaRangeThrottleEnd = 0.0;
+  CombustionEfficiency = 1.0;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -541,6 +558,8 @@ void FGTurboProp::bindmodel()
   PropertyManager->Tie( property_name.c_str(), &Eng_Temperature);
   property_name = base_property_name + "/ielu_intervent";
   PropertyManager->Tie( property_name.c_str(), &Ielu_intervent);
+  property_name = base_property_name + "/combustion_efficiency";
+  PropertyManager->Tie( property_name.c_str(), &CombustionEfficiency);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
old mode 100644 (file)
new mode 100755 (executable)
index 330a726..bb70f86
@@ -44,10 +44,9 @@ INCLUDES
 
 #include <vector>
 #include "FGEngine.h"
-#include "input_output/FGXMLElement.h"
 #include "math/FGTable.h"
 
-#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.16 2011/08/04 13:45:42 jberndt Exp $"
+#define ID_TURBOPROP "$Id: FGTurboProp.h,v 1.18 2013/11/24 14:22:22 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -160,7 +159,6 @@ private:
   double N2;               ///< N2
   double MaxN1;            ///< N1 at 100% throttle
   double MaxN2;            ///< N2 at 100% throttle
-  double IdleFF;           ///< Idle Fuel Flow (lbm/hr)
   double delay;            ///< Inverse spool-up time from idle to 100% (seconds)
   double N1_factor;        ///< factor to tie N1 and throttle
   double N2_factor;        ///< factor to tie N2 and throttle
@@ -195,6 +193,7 @@ private:
   double Velocity;
   double rho;
   double PSFC;                 // Power specific fuel comsumption [lb/(HP*hr)] at best efficiency
+  double CombustionEfficiency;
 
   double HP;                   // engine power output
 
@@ -222,6 +221,7 @@ private:
   FGTable* ITT_N1;             // ITT temperature depending on throttle command
   FGTable* EnginePowerRPM_N1;
   FGTable* EnginePowerVC;
+  FGTable* CombustionEfficiency_N1;
 };
 }
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%