]> git.mxchange.org Git - flightgear.git/commitdiff
Sync. w. JSB CVS as of 15/01/2007
authorehofman <ehofman>
Mon, 15 Jan 2007 12:48:54 +0000 (12:48 +0000)
committerehofman <ehofman>
Mon, 15 Jan 2007 12:48:54 +0000 (12:48 +0000)
127 files changed:
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGFDMExec.h
src/FDM/JSBSim/FGJSBBase.cpp
src/FDM/JSBSim/FGJSBBase.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGState.h
src/FDM/JSBSim/JSBSim.cxx
src/FDM/JSBSim/JSBSim.hxx
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/FGGroundCallback.cpp
src/FDM/JSBSim/input_output/FGGroundCallback.h
src/FDM/JSBSim/input_output/FGPropertyManager.cpp
src/FDM/JSBSim/input_output/FGPropertyManager.h
src/FDM/JSBSim/input_output/FGScript.cpp
src/FDM/JSBSim/input_output/FGScript.h
src/FDM/JSBSim/input_output/FGXMLElement.cpp
src/FDM/JSBSim/input_output/FGXMLElement.h
src/FDM/JSBSim/input_output/FGXMLParse.cpp
src/FDM/JSBSim/input_output/FGXMLParse.h
src/FDM/JSBSim/input_output/FGfdmSocket.cpp
src/FDM/JSBSim/input_output/FGfdmSocket.h
src/FDM/JSBSim/math/FGColumnVector3.cpp
src/FDM/JSBSim/math/FGColumnVector3.h
src/FDM/JSBSim/math/FGCondition.cpp [new file with mode: 0644]
src/FDM/JSBSim/math/FGCondition.h [new file with mode: 0644]
src/FDM/JSBSim/math/FGFunction.cpp
src/FDM/JSBSim/math/FGFunction.h
src/FDM/JSBSim/math/FGLocation.cpp
src/FDM/JSBSim/math/FGLocation.h
src/FDM/JSBSim/math/FGMatrix33.cpp
src/FDM/JSBSim/math/FGMatrix33.h
src/FDM/JSBSim/math/FGParameter.h
src/FDM/JSBSim/math/FGPropertyValue.cpp
src/FDM/JSBSim/math/FGPropertyValue.h
src/FDM/JSBSim/math/FGQuaternion.cpp
src/FDM/JSBSim/math/FGQuaternion.h
src/FDM/JSBSim/math/FGRealValue.cpp
src/FDM/JSBSim/math/FGRealValue.h
src/FDM/JSBSim/math/FGTable.cpp
src/FDM/JSBSim/math/FGTable.h
src/FDM/JSBSim/math/Makefile.am
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/FGAtmosphere.cpp
src/FDM/JSBSim/models/FGAtmosphere.h
src/FDM/JSBSim/models/FGAuxiliary.cpp
src/FDM/JSBSim/models/FGAuxiliary.h
src/FDM/JSBSim/models/FGFCS.cpp
src/FDM/JSBSim/models/FGFCS.h
src/FDM/JSBSim/models/FGGroundReactions.cpp
src/FDM/JSBSim/models/FGGroundReactions.h
src/FDM/JSBSim/models/FGInertial.cpp
src/FDM/JSBSim/models/FGInertial.h
src/FDM/JSBSim/models/FGInput.cpp
src/FDM/JSBSim/models/FGInput.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/FGModel.cpp
src/FDM/JSBSim/models/FGModel.h
src/FDM/JSBSim/models/FGOutput.cpp
src/FDM/JSBSim/models/FGOutput.h
src/FDM/JSBSim/models/FGPropagate.cpp
src/FDM/JSBSim/models/FGPropagate.h
src/FDM/JSBSim/models/FGPropulsion.cpp
src/FDM/JSBSim/models/FGPropulsion.h
src/FDM/JSBSim/models/atmosphere/FGMSIS.cpp
src/FDM/JSBSim/models/atmosphere/FGMSIS.h
src/FDM/JSBSim/models/atmosphere/FGMars.cpp
src/FDM/JSBSim/models/atmosphere/FGMars.h
src/FDM/JSBSim/models/flight_control/FGCondition.cpp [deleted file]
src/FDM/JSBSim/models/flight_control/FGCondition.h [deleted file]
src/FDM/JSBSim/models/flight_control/FGDeadBand.cpp
src/FDM/JSBSim/models/flight_control/FGDeadBand.h
src/FDM/JSBSim/models/flight_control/FGFCSComponent.cpp
src/FDM/JSBSim/models/flight_control/FGFCSComponent.h
src/FDM/JSBSim/models/flight_control/FGFCSFunction.cpp
src/FDM/JSBSim/models/flight_control/FGFCSFunction.h
src/FDM/JSBSim/models/flight_control/FGFilter.cpp
src/FDM/JSBSim/models/flight_control/FGFilter.h
src/FDM/JSBSim/models/flight_control/FGGain.cpp
src/FDM/JSBSim/models/flight_control/FGGain.h
src/FDM/JSBSim/models/flight_control/FGGradient.cpp
src/FDM/JSBSim/models/flight_control/FGGradient.h
src/FDM/JSBSim/models/flight_control/FGKinemat.cpp
src/FDM/JSBSim/models/flight_control/FGKinemat.h
src/FDM/JSBSim/models/flight_control/FGPID.cpp [new file with mode: 0755]
src/FDM/JSBSim/models/flight_control/FGPID.h [new file with mode: 0755]
src/FDM/JSBSim/models/flight_control/FGSensor.cpp
src/FDM/JSBSim/models/flight_control/FGSensor.h
src/FDM/JSBSim/models/flight_control/FGSummer.cpp
src/FDM/JSBSim/models/flight_control/FGSummer.h
src/FDM/JSBSim/models/flight_control/FGSwitch.cpp
src/FDM/JSBSim/models/flight_control/FGSwitch.h
src/FDM/JSBSim/models/flight_control/Makefile.am
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/FGForce.cpp
src/FDM/JSBSim/models/propulsion/FGForce.h
src/FDM/JSBSim/models/propulsion/FGNozzle.cpp
src/FDM/JSBSim/models/propulsion/FGNozzle.h
src/FDM/JSBSim/models/propulsion/FGPiston.cpp
src/FDM/JSBSim/models/propulsion/FGPiston.h
src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
src/FDM/JSBSim/models/propulsion/FGPropeller.h
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/FGRotor.h
src/FDM/JSBSim/models/propulsion/FGTank.cpp
src/FDM/JSBSim/models/propulsion/FGTank.h
src/FDM/JSBSim/models/propulsion/FGThruster.cpp
src/FDM/JSBSim/models/propulsion/FGThruster.h
src/FDM/JSBSim/models/propulsion/FGTurbine.cpp
src/FDM/JSBSim/models/propulsion/FGTurbine.h
src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
src/FDM/JSBSim/models/propulsion/FGTurboProp.h

index 54e3194d03058ed4203aa6b4ed86c7daf1ecba60..f5b920900c6f9fc20161f3cd05a727ae77a12f39 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -72,6 +72,7 @@ INCLUDES
 #include <models/FGOutput.h>
 #include <initialization/FGInitialCondition.h>
 #include <input_output/FGPropertyManager.h>
+#include <input_output/FGScript.h>
 
 namespace JSBSim {
 
@@ -128,13 +129,12 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root) : Root(root)
   Input           = 0;
   IC              = 0;
   Trim            = 0;
+  Script          = 0;
 
-  terminate = false;
   modelLoaded = false;
   IsSlave = false;
   holding = false;
 
-
   // Multiple FDM's are stopped for now.  We need to ensure that
   // the "user" instance always gets the zeroeth instance number,
   // because there may be instruments or scripts tied to properties
@@ -188,6 +188,8 @@ FGFDMExec::~FGFDMExec()
   for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
   SlaveFDMList.clear();
 
+  //ToDo remove property catalog.
+
   Debug(1);
 }
 
@@ -291,11 +293,9 @@ bool FGFDMExec::DeAllocate(void)
   delete Propagate;
   delete Auxiliary;
   delete State;
+  delete Script;
 
-  for (int i=0; i<Outputs.size(); i++) {
-    if (Outputs[i]) delete Outputs[i];
-  }
-
+  for (unsigned i=0; i<Outputs.size(); i++) delete Outputs[i];
   Outputs.clear();
 
   delete IC;
@@ -354,6 +354,7 @@ int FGFDMExec::Schedule(FGModel* model, int rate)
 
 bool FGFDMExec::Run(void)
 {
+  bool success;
   FGModel* model_iterator;
 
   model_iterator = FirstModel;
@@ -366,6 +367,8 @@ bool FGFDMExec::Run(void)
 //    SlaveFDMList[i]->exec->Run();
   }
 
+  if (Script != 0) success = Script->RunScript(); // returns true if success
+                                                  // false if complete
   while (model_iterator != 0L) {
     model_iterator->Run();
     model_iterator = model_iterator->NextModel;
@@ -373,7 +376,7 @@ bool FGFDMExec::Run(void)
 
   frame = Frame++;
   if (!Holding()) State->IncrTime();
-  return true;
+  return (success);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -393,13 +396,26 @@ bool FGFDMExec::RunIC(void)
 
 void FGFDMExec::SetGroundCallback(FGGroundCallback* p)
 {
-  if (GroundCallback) delete GroundCallback;
-
+  delete GroundCallback;
   GroundCallback = p;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+double FGFDMExec::GetSimTime(void)
+{
+  return (State->Getsim_time());
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+double FGFDMExec::GetDeltaT(void)
+{
+  return (State->Getdt());
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 vector <string> FGFDMExec::EnumerateFDMs(void)
 {
   vector <string> FDMList;
@@ -415,6 +431,18 @@ vector <string> FGFDMExec::EnumerateFDMs(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+bool FGFDMExec::LoadScript(string script)
+{
+  bool result;
+
+  Script = new FGScript(this);
+  result = Script->LoadScript(script);
+
+  return result;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model,
                 bool addModelToPath)
 {
@@ -442,9 +470,9 @@ bool FGFDMExec::LoadModel(string model, bool addModelToPath)
     return false;
   }
 
-  aircraftCfgFileName = AircraftPath;
-  if (addModelToPath) aircraftCfgFileName += separator + model;
-  aircraftCfgFileName += separator + model + ".xml";
+  FullAircraftPath = AircraftPath;
+  if (addModelToPath) FullAircraftPath += separator + model;
+  aircraftCfgFileName = FullAircraftPath + separator + model + ".xml";
 
   FGXMLParse *XMLParse = new FGXMLParse();
   Element* element = 0L;
@@ -545,7 +573,7 @@ void FGFDMExec::BuildPropertyCatalog(struct PropertyCatalogStructure* pcs)
 string FGFDMExec::QueryPropertyCatalog(string in)
 {
   string results="";
-  for (int i=0; i<PropertyCatalog.size(); i++) {
+  for (unsigned i=0; i<PropertyCatalog.size(); i++) {
     if (PropertyCatalog[i].find(in) != string::npos) results += PropertyCatalog[i] + "\n";
   }
   if (results.empty()) return "No matches found\n";
@@ -554,6 +582,18 @@ string FGFDMExec::QueryPropertyCatalog(string in)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+void FGFDMExec::PrintPropertyCatalog(void)
+{
+  cout << endl;
+  cout << "  " << fgblue << highint << underon << "Property Catalog for "
+       << modelName << reset << endl << endl;
+  for (unsigned i=0; i<PropertyCatalog.size(); i++) {
+    cout << "    " << PropertyCatalog[i] << endl;
+  }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 bool FGFDMExec::ReadFileHeader(Element* el)
 {
   bool result = true; // true for success
@@ -649,7 +689,7 @@ bool FGFDMExec::ReadSlave(Element* el)
 
   SlaveFDMList.push_back(new slaveData);
   SlaveFDMList.back()->exec = new FGFDMExec();
-  SlaveFDMList.back()->exec->SetSlave();
+  SlaveFDMList.back()->exec->SetSlave(true);
 /*
   string AircraftName = AC_cfg->GetValue("file");
 
@@ -704,7 +744,7 @@ FGTrim* FGFDMExec::GetTrim(void)
 
 void FGFDMExec::DisableOutput(void)
 {
-  for (int i=0; i<Outputs.size(); i++) {
+  for (unsigned i=0; i<Outputs.size(); i++) {
     Outputs[i]->Disable();
   }
 }
@@ -713,13 +753,33 @@ void FGFDMExec::DisableOutput(void)
 
 void FGFDMExec::EnableOutput(void)
 {
-  for (int i=0; i<Outputs.size(); i++) {
+  for (unsigned i=0; i<Outputs.size(); i++) {
     Outputs[i]->Enable();
   }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+bool FGFDMExec::SetOutputDirectives(string fname)
+{
+  bool result=true; // for now always return true
+
+  if (Outputs.size() == 0) {
+    FGOutput* Output = new FGOutput(this);
+    Output->InitModel();
+    Schedule(Output,       1);
+    Output->SetDirectivesFile(fname);
+    Output->Load(0);
+    Outputs.push_back(Output);
+  } else { // Outputs > 1
+    cerr << "First output file being overridden" << endl;
+    Outputs[0]->SetDirectivesFile(fname);
+  }
+  return result;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGFDMExec::DoTrim(int mode)
 {
   double saved_time;
@@ -792,7 +852,7 @@ void FGFDMExec::Debug(int from)
     if (from == 0) { // Constructor
       cout << "\n\n     " << highint << underon << "JSBSim Flight Dynamics Model v"
                                      << JSBSim_version << underoff << normint << endl;
-      cout << halfint << "            [cfg file spec v" << needed_cfg_version << "]\n\n";
+      cout << halfint << "            [JSBSim-ML v" << needed_cfg_version << "]\n\n";
       cout << normint << "JSBSim startup beginning ...\n\n";
     } else if (from == 3) {
       cout << "\n\nJSBSim startup complete\n\n";
index 5d4d473e1e3590ac44332917ce2519dab8b7c739..6ae678cfd9a66811f0ef0f3d96b581cca7857cfa 100644 (file)
@@ -2,24 +2,25 @@
  Header:       FGFDMExec.h
  Author:       Jon Berndt
  Date started: 11/17/98
+ file The header file for the JSBSim executive.
 
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -65,6 +66,8 @@ FORWARD DECLARATIONS
 
 namespace JSBSim {
 
+class FGScript;
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -121,11 +124,9 @@ CLASS DOCUMENTATION
 
     @code
     FDMExec = new JSBSim::FGFDMExec();
-    Script = new JSBSim::FGScript( \85 );
-    Script->LoadScript( ScriptName ); // the script loads the aircraft and ICs
+    FDMExec->LoadScript( ScriptName ); // the script loads the aircraft and ICs
     result = FDMExec->Run();
     while (result) { // cyclic execution
-      if (Scripted) if (!Script->RunScript()) break; // execute script
       result = FDMExec->Run(); // execute JSBSim
     }
     @endcode
@@ -235,6 +236,11 @@ public:
       @return true if successful*/
   bool LoadModel(string model, bool addModelToPath = true);
 
+  /** Loads a script
+      @param Script the full path name and file name for the script to be loaded.
+      @return true if successfully loadsd; false otherwise. */
+  bool LoadScript(string Script);
+
   /** Sets the path to the engine config file directories.
       @param path path to the directory under which engine config
       files are kept, for instance "engine"  */
@@ -284,16 +290,70 @@ public:
   inline string GetEnginePath(void)          {return EnginePath;}
   /// Retrieves the aircraft path.
   inline string GetAircraftPath(void)        {return AircraftPath;}
+  /// Retrieves the full aircraft path name.
+  inline string GetFullAircraftPath(void)    {return FullAircraftPath;}
+
+  /** Retrieves the value of a property.
+      @param property the name of the property
+      @result the value of the specified property */
+  inline double GetPropertyValue(string property) {return instance->GetDouble(property);}
+
+  /** Sets a property value.
+      @param property the property to be set
+      @param value the value to set the property to */
+  inline void SetPropertyValue(string property, double value) {
+    instance->SetDouble(property, value);
+  }
 
   /// Returns the model name.
   string GetModelName(void) { return modelName; }
 
+  /// Returns the current time.
+  double GetSimTime(void);
+
+  /// Returns the current frame time (delta T).
+  double GetDeltaT(void);
+
   /// Returns a pointer to the property manager object.
   FGPropertyManager* GetPropertyManager(void);
   /// Returns a vector of strings representing the names of all loaded models (future)
   vector <string> EnumerateFDMs(void);
   /// Marks this instance of the Exec object as a "slave" object.
-  void SetSlave(void) {IsSlave = true;}
+  void SetSlave(bool s) {IsSlave = s;}
+
+  /** Sets the output (logging) mechanism for this run.
+      Calling this function passes the name of an output directives file to
+      the FGOutput object associated with this run. The call to this function
+      should be made prior to loading an aircraft model. This call results in an
+      FGOutput object being built as the first Output object in the FDMExec-managed
+      list of Output objects that may be created for an aircraft model. If this call
+      is made after an aircraft model is loaded, there is no effect. Any Output
+      objects added by the aircraft model itself (in an &lt;output> element) will be
+      added after this one. Care should be taken not to refer to the same file
+      name.
+      An output directives file contains an &lt;output> &lt;/output> element, within
+      which should be specified the parameters or parameter groups that should
+      be logged.
+      @param fname the filename of an output directives file.
+    */
+  bool SetOutputDirectives(string fname);
+
+  /** Sets (or overrides) the output filename
+      @param fname the name of the file to output data to
+      @return true if successful, false if there is no output specified for the flight model */
+  bool SetOutputFileName(string fname) {
+    if (Outputs.size() > 0) Outputs[0]->SetOutputFileName(fname);
+    else return false;
+    return true;
+  }
+
+  /** Retrieves the current output filename.
+      @return the name of the output file for the first output specified by the flight model.
+              If none is specified, the empty string is returned. */
+  string GetOutputFileName(void) {
+    if (Outputs.size() > 0) return Outputs[0]->GetOutputFileName();
+    else return string("");
+  }
 
   /** Executes trimming in the selected mode.
   *   @param mode Specifies how to trim:
@@ -316,6 +376,8 @@ public:
   void Resume(void) {holding = false;}
   /// Returns true if the simulation is Holding (i.e. simulation time is not moving).
   bool Holding(void) {return holding;}
+  /// Sets the debug level.
+  void SetDebugLevel(int level) {debug_lvl = level;}
 
   struct PropertyCatalogStructure {
     /// Name of the property.
@@ -338,6 +400,9 @@ public:
   *               in the catalog.  */
   string QueryPropertyCatalog(string check);
 
+  // Print the contents of the property catalog for the loaded aircraft.
+  void PrintPropertyCatalog(void);
+
   /// Use the MSIS atmosphere model.
   void UseAtmosphereMSIS(void);
 
@@ -345,22 +410,20 @@ public:
   void UseAtmosphereMars(void);
 
 private:
-  FGModel* FirstModel;
-
-  bool terminate;
-  bool holding;
-  bool Constructing;
-  int  Error;
+  static unsigned int FDMctr;
+  int Error;
   unsigned int Frame;
   unsigned int IdFDM;
-  FGPropertyManager* Root;
-  static unsigned int FDMctr;
+  bool holding;
+  bool Constructing;
   bool modelLoaded;
-  string modelName;
   bool IsSlave;
-  static FGPropertyManager *master;
-  FGPropertyManager *instance;
-  vector <string> PropertyCatalog;
+  string modelName;
+  string AircraftPath;
+  string FullAircraftPath;
+  string EnginePath;
+  string CFGVersion;
+  string Release;
 
   struct slaveData {
     FGFDMExec* exec;
@@ -381,41 +444,41 @@ private:
     }
   };
 
-  string AircraftPath;
-  string EnginePath;
-
-  string CFGVersion;
-  string Release;
-
-  FGGroundCallback*  GroundCallback;
-  FGState*           State;
-  FGAtmosphere*      Atmosphere;
-  FGFCS*             FCS;
-  FGPropulsion*      Propulsion;
-  FGMassBalance*     MassBalance;
-  FGAerodynamics*    Aerodynamics;
-  FGInertial*        Inertial;
-  FGGroundReactions* GroundReactions;
-  FGAircraft*        Aircraft;
-  FGPropagate*       Propagate;
-  FGAuxiliary*       Auxiliary;
-  FGInput*           Input;
-  vector <FGOutput*> Outputs;
+  static FGPropertyManager *master;
 
+  FGModel*            FirstModel;
+  FGGroundCallback*   GroundCallback;
+  FGState*            State;
+  FGAtmosphere*       Atmosphere;
+  FGFCS*              FCS;
+  FGPropulsion*       Propulsion;
+  FGMassBalance*      MassBalance;
+  FGAerodynamics*     Aerodynamics;
+  FGInertial*         Inertial;
+  FGGroundReactions*  GroundReactions;
+  FGAircraft*         Aircraft;
+  FGPropagate*        Propagate;
+  FGAuxiliary*        Auxiliary;
+  FGInput*            Input;
+  FGScript*           Script;
   FGInitialCondition* IC;
-  FGTrim *Trim;
+  FGTrim*             Trim;
 
+  FGPropertyManager* Root;
+  FGPropertyManager* instance;
+
+  vector <string> PropertyCatalog;
+  vector <FGOutput*> Outputs;
   vector <slaveData*> SlaveFDMList;
 
   bool ReadFileHeader(Element*);
   bool ReadSlave(Element*);
   bool ReadPrologue(Element*);
-
   bool Allocate(void);
   bool DeAllocate(void);
+
   void Debug(int from);
 };
 }
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif
-
index c6fcc0f6caad39b0b7e7a9c276963bc2bc27dad9..bda88a1f8a415bbb1206a941e8b9eb3215713229 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -94,7 +94,7 @@ const double FGJSBBase::slugtolb = 32.174049;
 const double FGJSBBase::lbtoslug = 1.0/slugtolb;
 
 const string FGJSBBase::needed_cfg_version = "2.0";
-const string FGJSBBase::JSBSim_version = "0.9.10.111805";
+const string FGJSBBase::JSBSim_version = "0.9.12 "__DATE__" "__TIME__;
 
 std::queue <FGJSBBase::Message*> FGJSBBase::Messages;
 FGJSBBase::Message FGJSBBase::localMsg;
index c09104c9a39a32e51a238cd49d6163fbc6b01d06..1fda8afc7e364d815127d07e8fbdbf74e5ca5cd9 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -218,6 +218,13 @@ public:
     return (rankine - 491.67)/1.8;
   }
 
+  /** Converts from degrees Rankine to degrees Kelvin.
+  *   @param rankine The temperature in degrees Rankine.
+  *   @return The temperature in Kelvin. */
+  static double RankineToKelvin (double rankine) {
+    return rankine/1.8;
+  }
+
   /** Converts from degrees Fahrenheit to degrees Celsius.
   *   @param fahrenheit The temperature in degrees Fahrenheit.
   *   @return The temperature in Celsius. */
index 73c3529e4e5897ee39736b01052925f66f0c61f8..8945abdd47a1aba23678565a23899afaee87c55d 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 9e5f9703941f99591714038c0f474f58d7171a90..aad679f378a9d8a2b6bf16cd5bc3bbed58d351ac 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 44c99315b0d1b0e1cea15582604885659a126de5..80ee3ee03e559cc45aca1df6cf22a9ae6b7aaa0e 100644 (file)
@@ -262,6 +262,8 @@ FGJSBsim::FGJSBsim( double dt )
     wind_from_east = fgGetNode("/environment/wind-from-east-fps" ,true);
     wind_from_down = fgGetNode("/environment/wind-from-down-fps" ,true);
 
+    slaved = fgGetNode("/sim/slaved/enabled", true);
+
     for (unsigned int i = 0; i < Propulsion->GetNumEngines(); i++) {
       SGPropertyNode * node = fgGetNode("engines/engine", i, true);
       Propulsion->GetEngine(i)->GetThruster()->SetRPM(node->getDoubleValue("rpm") /
@@ -601,6 +603,7 @@ bool FGJSBsim::copy_to_JSBsim()
     SGPropertyNode* node = fgGetNode("/systems/refuel", true);
     Propulsion->SetRefuel(node->getDoubleValue("contact"));
     Propulsion->SetFuelFreeze((fgGetNode("/sim/freeze/fuel",true))->getBoolValue());
+    fdmex->SetSlave(slaved->getBoolValue());
 
     return true;
 }
index 3f4d33465e0656f74c1d9c3373d459a8ae77a900..098cc38e354b653d8837fa802859b2c07d2d55bf 100644 (file)
@@ -226,40 +226,42 @@ private:
     double trim_elev;
     double trim_throttle;
 
-    SGPropertyNode_ptr startup_trim;
-    SGPropertyNode_ptr trimmed;
-    SGPropertyNode_ptr pitch_trim;
-    SGPropertyNode_ptr throttle_trim;
-    SGPropertyNode_ptr aileron_trim;
-    SGPropertyNode_ptr rudder_trim;
-    SGPropertyNode_ptr stall_warning;
-
-    /* SGPropertyNode_ptr elevator_pos_deg;
-    SGPropertyNode_ptr left_aileron_pos_deg;
-    SGPropertyNode_ptr right_aileron_pos_deg;
-    SGPropertyNode_ptr rudder_pos_deg;
-    SGPropertyNode_ptr flap_pos_deg; */
-
-
-    SGPropertyNode_ptr elevator_pos_pct;
-    SGPropertyNode_ptr left_aileron_pos_pct;
-    SGPropertyNode_ptr right_aileron_pos_pct;
-    SGPropertyNode_ptr rudder_pos_pct;
-    SGPropertyNode_ptr flap_pos_pct;
-    SGPropertyNode_ptr speedbrake_pos_pct;
-    SGPropertyNode_ptr spoilers_pos_pct;
-
-    SGPropertyNode_ptr gear_pos_pct;
-
-    SGPropertyNode_ptr temperature;
-    SGPropertyNode_ptr pressure;
-    SGPropertyNode_ptr density;
-    SGPropertyNode_ptr turbulence_gain;
-    SGPropertyNode_ptr turbulence_rate;
-
-    SGPropertyNode_ptr wind_from_north;
-    SGPropertyNode_ptr wind_from_east;
-    SGPropertyNode_ptr wind_from_down;
+    SGPropertyNode *startup_trim;
+    SGPropertyNode *trimmed;
+    SGPropertyNode *pitch_trim;
+    SGPropertyNode *throttle_trim;
+    SGPropertyNode *aileron_trim;
+    SGPropertyNode *rudder_trim;
+    SGPropertyNode *stall_warning;
+
+    /* SGPropertyNode *elevator_pos_deg;
+    SGPropertyNode *left_aileron_pos_deg;
+    SGPropertyNode *right_aileron_pos_deg;
+    SGPropertyNode *rudder_pos_deg;
+    SGPropertyNode *flap_pos_deg; */
+
+
+    SGPropertyNode *elevator_pos_pct;
+    SGPropertyNode *left_aileron_pos_pct;
+    SGPropertyNode *right_aileron_pos_pct;
+    SGPropertyNode *rudder_pos_pct;
+    SGPropertyNode *flap_pos_pct;
+    SGPropertyNode *speedbrake_pos_pct;
+    SGPropertyNode *spoilers_pos_pct;
+
+    SGPropertyNode *gear_pos_pct;
+
+    SGPropertyNode *temperature;
+    SGPropertyNode *pressure;
+    SGPropertyNode *density;
+    SGPropertyNode *turbulence_gain;
+    SGPropertyNode *turbulence_rate;
+
+    SGPropertyNode *wind_from_north;
+    SGPropertyNode *wind_from_east;
+    SGPropertyNode *wind_from_down;
+
+    SGPropertyNode *slaved;
 
     void init_gear(void);
     void update_gear(void);
index 02262b092ecba16a3fc69237cd1cd58ad19e3e73..9ee9d094edc640c1439107a13d0af520d5d39841 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -731,7 +731,7 @@ double FGInitialCondition::GetWindDirDegIC(void) const {
 
 bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
 {
-  string resetDef, acpath;
+  string resetDef;
   ifstream initialization_file;
   FGXMLParse initialization_file_parser;
   Element *document, *el;
@@ -739,12 +739,11 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
 
   string sep = "/";
 # ifdef macintosh
-   string sep = ";";
+   sep = ";";
 # endif
 
   if( useStoredPath ) {
-    acpath = fdmex->GetAircraftPath() + sep + fdmex->GetModelName();
-    resetDef = acpath + sep + rstfile + ".xml";
+    resetDef = fdmex->GetFullAircraftPath() + sep + rstfile + ".xml";
   } else {
     resetDef = rstfile;
   }
@@ -773,20 +772,6 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
     SetLatitudeDegIC(document->FindElementValueAsNumberConvertTo("latitude", "DEG"));
   if (document->FindElement("longitude"))
     SetLongitudeDegIC(document->FindElementValueAsNumberConvertTo("longitude", "DEG"));
-  if (document->FindElement("phi"))
-    SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG"));
-  if (document->FindElement("theta"))
-    SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG"));
-  if (document->FindElement("psi"))
-    SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG"));
-  if (document->FindElement("alpha"))
-    SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG"));
-  if (document->FindElement("beta"))
-    SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG"));
-  if (document->FindElement("gamma"))
-    SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG"));
-  if (document->FindElement("roc"))
-    SetClimbRateFpmIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC"));
   if (document->FindElement("altitude"))
     SetAltitudeFtIC(document->FindElementValueAsNumberConvertTo("altitude", "FT"));
   if (document->FindElement("winddir"))
@@ -801,6 +786,20 @@ bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
     SetVcalibratedKtsIC(document->FindElementValueAsNumberConvertTo("vc", "FT/SEC"));
   if (document->FindElement("mach"))
     SetMachIC(document->FindElementValueAsNumber("mach"));
+  if (document->FindElement("phi"))
+    SetPhiDegIC(document->FindElementValueAsNumberConvertTo("phi", "DEG"));
+  if (document->FindElement("theta"))
+    SetThetaDegIC(document->FindElementValueAsNumberConvertTo("theta", "DEG"));
+  if (document->FindElement("psi"))
+    SetPsiDegIC(document->FindElementValueAsNumberConvertTo("psi", "DEG"));
+  if (document->FindElement("alpha"))
+    SetAlphaDegIC(document->FindElementValueAsNumberConvertTo("alpha", "DEG"));
+  if (document->FindElement("beta"))
+    SetBetaDegIC(document->FindElementValueAsNumberConvertTo("beta", "DEG"));
+  if (document->FindElement("gamma"))
+    SetFlightPathAngleDegIC(document->FindElementValueAsNumberConvertTo("gamma", "DEG"));
+  if (document->FindElement("roc"))
+    SetClimbRateFpsIC(document->FindElementValueAsNumberConvertTo("roc", "FT/SEC"));
   if (document->FindElement("vground"))
     SetVgroundKtsIC(document->FindElementValueAsNumberConvertTo("vground", "FT/SEC"));
   if (document->FindElement("running")) {
index 67a94e343f10360487723d9124c8aa4c823440d1..077f001f7e15c8f02a396437a6ec9544371f898e 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
  HISTORY
@@ -70,7 +70,8 @@ typedef enum { setwned, setwmd, setwhc } windset;
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/** Takes a set of initial conditions and provide a kinematically consistent set
+/** Initializes the simulation run.
+    Takes a set of initial conditions (IC) and provide a kinematically consistent set
     of body axis velocity components, euler angles, and altitude.  This class
     does not attempt to trim the model i.e. the sim will most likely start in a
     very dynamic state (unless, of course, you have chosen your IC's wisely, or
@@ -449,11 +450,11 @@ public:
   inline double GetWindNFpsIC(void) const { return wnorth; }
 
   /** Gets the initial wind velocity in local frame.
-      @return Initial wind velocity toward north in feet/second */
+      @return Initial wind velocity eastwards in feet/second */
   inline double GetWindEFpsIC(void) const { return weast; }
 
   /** Gets the initial wind velocity in local frame.
-      @return Initial wind velocity toward north in feet/second */
+      @return Initial wind velocity downwards in feet/second */
   inline double GetWindDFpsIC(void) const { return wdown; }
 
   /** Gets the initial total wind velocity in feet/sec.
index c5d42cc7c0fc26b0145e726709f733084184dac2..854519c618ac820374d3779f0fd9cd530deb9583 100644 (file)
@@ -7,20 +7,20 @@
  --------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) ---------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
index d41708d4b8111444361d618d5812db28f87bbda1..9fd38efbd2c87514e37346ddc685c6ed3ea0411d 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -79,7 +79,7 @@ typedef enum { tLongitudinal=0, tFull, tGround, tPullup,
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/** FGTrim -- the trimming routine for JSBSim.
+/** The trimming routine for JSBSim.
     FGTrim finds the aircraft attitude and control settings needed to maintain
     the steady state described by the FGInitialCondition object .  It does this
     iteratively by assigning a control to each state and adjusting that control
@@ -122,6 +122,7 @@ CLASS DOCUMENTATION
     }
     fgt.Report();
     @endcode
+    
     @author Tony Peden
     @version "$Id$"
 */
index c7b692a3775df2cfed913a002682b13cb56e12f8..8557adc89904b3ce0e296474b3a677756a032f27 100644 (file)
@@ -7,20 +7,20 @@
  --------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) ---------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -181,8 +181,8 @@ void FGTrimAxis::getState(void) {
 void FGTrimAxis::getControl(void) {
   switch(control) {
   case tThrottle:  control_value=fdmex->GetFCS()->GetThrottleCmd(0); break;
-  case tBeta:      control_value=fdmex->GetAuxiliary()->Getalpha(); break;
-  case tAlpha:     control_value=fdmex->GetAuxiliary()->Getbeta();  break;
+  case tBeta:      control_value=fdmex->GetAuxiliary()->Getbeta(); break;
+  case tAlpha:     control_value=fdmex->GetAuxiliary()->Getalpha();  break;
   case tPitchTrim: control_value=fdmex->GetFCS() -> GetPitchTrimCmd(); break;
   case tElevator:  control_value=fdmex->GetFCS() -> GetDeCmd(); break;
   case tRollTrim:
index e0754a03ce22ba8cc5c0c21800bcee3434e6bc74..ac3d45f8f308b947a100c3edd892df3444ff97d9 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
  
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
  
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
  
  HISTORY
@@ -89,12 +89,20 @@ enum Control { tThrottle, tBeta, tAlpha, tElevator, tAileron, tRudder, tAltAGL,
 class FGTrimAxis : public FGJSBBase
 {
 public:
+  /**  Constructor for Trim Axis class.
+       @param fdmex FGFDMExec pointer
+       @param IC pointer to initial conditions instance
+       @param state a State type (enum)
+       @param control a Control type (enum) */
   FGTrimAxis(FGFDMExec* fdmex, 
-             FGInitialCondition *ic, 
-             State st,
-             Control ctrl );
+             FGInitialCondition *IC, 
+             State state,
+             Control control );
+  /// Destructor
   ~FGTrimAxis();
 
+  /** This function iterates through a call to the FGFDMExec::RunIC() 
+      function until the desired trimming condition falls inside a tolerance.*/
   void Run(void);
  
   double GetState(void) { getState(); return state_value; }
index 8b9a5674b05f5826c331a27d7e18a228339b5096..a0236a2d7c70500a3d3a4d49915ea2cc79280f8d 100644 (file)
@@ -7,20 +7,20 @@
  ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 8abffcff38ed8984b98bfdb67f72cd2ab997442d..0a5a7af67aa70a9911e9ca14179cf65e1c2ae3ea 100644 (file)
@@ -7,20 +7,20 @@
  ------ Copyright (C) 2004 Mathias Froehlich (Mathias.Froehlich@web.de) -------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 63bc5895107afcbd6373a244a39526d80a838457..61aed893f163e2a951e67fb525c3aa5710c9be43 100755 (executable)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2002 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 284c747619ff00144c868b488abd2ee1da6e2621..001d16db487183bb3a72258e348e69cd1b631ad3 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2002 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -78,7 +78,7 @@ class FGPropertyManager : public SGPropertyNode, public FGJSBBase
     /// Constructor
     FGPropertyManager(void) {suppress_warning = false;}
     /// Destructor
-    ~FGPropertyManager(void) {}
+    virtual ~FGPropertyManager(void) {}
 
     /** Property-ify a name
      *  replaces spaces with '-' and, optionally, makes name all lower case
index 83e87f752fa94bc1941f160e6ff319a3e6e5e64a..797a5bf497c3028a23f70150fe89cdfec042f86d 100755 (executable)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -55,7 +55,7 @@ INCLUDES
 #endif
 
 #include "FGScript.h"
-#include "FGXMLParse.h"
+#include <input_output/FGXMLParse.h>
 #include <initialization/FGTrim.h>
 
 namespace JSBSim {
@@ -84,6 +84,14 @@ FGScript::FGScript(FGFDMExec* fgex) : FDMExec(fgex)
 
 FGScript::~FGScript()
 {
+  int i;
+  for (i=0; i<local_properties.size(); i++)
+    PropertyManager->Untie(local_properties[i]->title);
+  
+  for (i=0; i<local_properties.size(); i++)
+    delete local_properties[i];
+
+  local_properties.clear();
   Debug(1);
 }
 
@@ -92,12 +100,16 @@ FGScript::~FGScript()
 bool FGScript::LoadScript( string script )
 {
   string aircraft="", initialize="", comparison = "", prop_name="";
-  Element *document=0, *element=0, *run_element=0, *when_element=0;
-  Element *parameter_element=0, *set_element=0;
+  string notifyPropertyName="";
+  Element *document=0, *element=0, *run_element=0, *event_element=0;
+  Element *condition_element=0, *set_element=0, *delay_element=0;
+  Element *notify_element = 0L, *notify_property_element = 0L;
+  Element *property_element = 0L;
   bool result = false;
   double dt = 0.0, value = 0.0;
   FGXMLParse script_file_parser;
-  struct condition *newCondition;
+  struct event *newEvent;
+  FGCondition *newCondition;
   ifstream script_file(script.c_str());
 
   if ( !script_file ) return false;
@@ -110,6 +122,25 @@ bool FGScript::LoadScript( string script )
     return false;
   }
 
+  ScriptName = document->GetAttributeValue("name");
+
+ // First, find "run" element and set delta T
+
+  run_element = document->FindElement("run");
+
+  if (!run_element) {
+    cerr << "No \"run\" element found in script." << endl;
+    return false;
+  }
+
+  // Set sim timing
+
+  StartTime = run_element->GetAttributeValueAsNumber("start");
+  State->Setsim_time(StartTime);
+  EndTime   = run_element->GetAttributeValueAsNumber("end");
+  dt        = run_element->GetAttributeValueAsNumber("dt");
+  State->Setdt(dt);
+
   // read aircraft and initialization files
 
   element = document->FindElement("use");
@@ -119,88 +150,108 @@ bool FGScript::LoadScript( string script )
       result = FDMExec->LoadModel(aircraft);
       if (!result) return false;
     } else {
-      cerr << "Aircraft must be specified first in script file." << endl;
+      cerr << "Aircraft must be specified in use element." << endl;
       return false;
     }
 
-    element = document->FindNextElement("use");
     initialize = element->GetAttributeValue("initialize");
+    if (initialize.empty()) {
+      cerr << "Initialization file must be specified in use element." << endl;
+      return false;
+    }
 
   } else {
     cerr << "No \"use\" directives in the script file." << endl;
     return false;
   }
 
-  run_element = document->FindElement("run");
-
-  if (!run_element) {
-    cerr << "No \"run\" element found in script." << endl;
-    return false;
+  // Read local property declarations
+  property_element = run_element->FindElement("property");
+  while (property_element) {
+    LocalProps *localProp = new LocalProps();
+    localProp->title = property_element->GetDataLine();
+    local_properties.push_back(localProp);
+    PropertyManager->Tie(localProp->title, (local_properties.back())->value);
+    property_element = run_element->FindNextElement("property");
   }
 
-  // Set sim timing
+  // Read "events" from script
 
-  StartTime = run_element->GetAttributeValueAsNumber("start");
-  State->Setsim_time(StartTime);
-  EndTime   = run_element->GetAttributeValueAsNumber("end");
-  dt        = run_element->GetAttributeValueAsNumber("dt");
-  State->Setdt(dt);
+  event_element = run_element->FindElement("event");
+  while (event_element) { // event processing
+
+    // Create the event structure
+    newEvent = new struct event();
+
+    // Retrieve the event name if given
+    newEvent->Name = event_element->GetAttributeValue("name");
 
-  // read "when" tests from script
-
-  when_element = run_element->FindElement("when");
-  while (when_element) { // "when" processing
-    newCondition = new struct condition();
-
-    // read parameters
-    parameter_element = when_element->FindElement("parameter");
-    while (parameter_element) {
-      prop_name = parameter_element->GetAttributeValue("name");
-      newCondition->TestParam.push_back( PropertyManager->GetNode(prop_name) );
-      value = parameter_element->GetAttributeValueAsNumber("value");
-      newCondition->TestValue.push_back(value);
-      comparison = parameter_element->GetAttributeValue("comparison");
-      newCondition->Comparison.push_back(comparison);
-      parameter_element = when_element->FindNextElement("parameter");
+    // Is this event persistent? That is, does it execute repeatedly as long as the
+    // condition is true, or does it execute as a one-shot event, only?
+    if (event_element->GetAttributeValue("persistent") == string("true")) {
+      newEvent->Persistent = true;
     }
 
-    // read set definitions
-    set_element = when_element->FindElement("set");
+    // Process the conditions
+    condition_element = event_element->FindElement("condition");
+    if (condition_element != 0) {
+      newCondition = new FGCondition(condition_element, PropertyManager);
+      newEvent->Condition = newCondition;
+    } else {
+      cerr << "No condition specified in script event " << newEvent->Name << endl;
+      return false;
+    }
+
+    // Is there a delay between the time this event is triggered, and when the event
+    // actions are executed?
+
+    delay_element = event_element->FindElement("delay");
+    if (delay_element) newEvent->Delay = event_element->FindElementValueAsNumber("delay");
+    else newEvent->Delay = 0.0;
+
+    // Notify about when this event is triggered?
+    if ((notify_element = event_element->FindElement("notify")) != 0) {
+      newEvent->Notify = true;
+      notify_property_element = notify_element->FindElement("property");
+      while (notify_property_element) {
+        notifyPropertyName = notify_property_element->GetDataLine();
+        newEvent->NotifyProperties.push_back( PropertyManager->GetNode(notifyPropertyName) );
+        notify_property_element = notify_element->FindNextElement("property");
+      }
+    }
+
+    // Read set definitions (these define the actions to be taken when the event is triggered).
+    set_element = event_element->FindElement("set");
     while (set_element) {
       prop_name = set_element->GetAttributeValue("name");
-      newCondition->SetParam.push_back( PropertyManager->GetNode(prop_name) );
+      newEvent->SetParam.push_back( PropertyManager->GetNode(prop_name) );
       value = set_element->GetAttributeValueAsNumber("value");
-      newCondition->SetValue.push_back(value);
-      newCondition->Triggered.push_back(false);
-      newCondition->OriginalValue.push_back(0.0);
-      newCondition->newValue.push_back(0.0);
-      newCondition->StartTime.push_back(0.0);
-      newCondition->EndTime.push_back(0.0);
+      newEvent->SetValue.push_back(value);
+      newEvent->OriginalValue.push_back(0.0);
+      newEvent->newValue.push_back(0.0);
+      newEvent->ValueSpan.push_back(0.0);
       string tempCompare = set_element->GetAttributeValue("type");
-      if      (tempCompare == "FG_DELTA") newCondition->Type.push_back(FG_DELTA);
-      else if (tempCompare == "FG_BOOL")  newCondition->Type.push_back(FG_BOOL);
-      else if (tempCompare == "FG_VALUE") newCondition->Type.push_back(FG_VALUE);
-      else                                newCondition->Type.push_back(FG_VALUE); // DEFAULT
+      if      (tempCompare == "FG_DELTA") newEvent->Type.push_back(FG_DELTA);
+      else if (tempCompare == "FG_BOOL")  newEvent->Type.push_back(FG_BOOL);
+      else if (tempCompare == "FG_VALUE") newEvent->Type.push_back(FG_VALUE);
+      else                                newEvent->Type.push_back(FG_VALUE); // DEFAULT
       tempCompare = set_element->GetAttributeValue("action");
-      if      (tempCompare == "FG_RAMP") newCondition->Action.push_back(FG_RAMP);
-      else if (tempCompare == "FG_STEP") newCondition->Action.push_back(FG_STEP);
-      else if (tempCompare == "FG_EXP")  newCondition->Action.push_back(FG_EXP);
-      else                               newCondition->Action.push_back(FG_STEP); // DEFAULT
-
-      if (set_element->GetAttributeValue("persistent") == "true")
-        newCondition->Persistent.push_back(true);
-      else
-        newCondition->Persistent.push_back(false); // DEFAULT
+      if      (tempCompare == "FG_RAMP") newEvent->Action.push_back(FG_RAMP);
+      else if (tempCompare == "FG_STEP") newEvent->Action.push_back(FG_STEP);
+      else if (tempCompare == "FG_EXP")  newEvent->Action.push_back(FG_EXP);
+      else                               newEvent->Action.push_back(FG_STEP); // DEFAULT
 
       if (!set_element->GetAttributeValue("tc").empty())
-        newCondition->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
+        newEvent->TC.push_back(set_element->GetAttributeValueAsNumber("tc"));
       else
-        newCondition->TC.push_back(1.0); // DEFAULT
+        newEvent->TC.push_back(1.0); // DEFAULT
 
-      set_element = when_element->FindNextElement("set");
+      newEvent->Transiting.push_back(false);
+
+      set_element = event_element->FindNextElement("set");
     }
-    Conditions.push_back(*newCondition);
-    when_element = run_element->FindNextElement("when");
+    Events.push_back(*newEvent);
+    event_element = run_element->FindNextElement("event");
   }
 
   Debug(4);
@@ -218,89 +269,90 @@ bool FGScript::LoadScript( string script )
 
 bool FGScript::RunScript(void)
 {
-  vector <struct condition>::iterator iC = Conditions.begin();
-  bool truth = false;
-  bool WholeTruth = false;
-  unsigned i;
+  vector <struct event>::iterator iEvent = Events.begin();
+  unsigned i, j;
+  unsigned event_ctr = 0;
 
   double currentTime = State->Getsim_time();
   double newSetValue = 0;
 
-  if (currentTime > EndTime) return false;
-
-  while (iC < Conditions.end()) {
-    // determine whether the set of conditional tests for this condition equate
-    // to true
-    for (i=0; i<iC->TestValue.size(); i++) {
-           if (iC->Comparison[i] == "lt")
-              truth = iC->TestParam[i]->getDoubleValue() <  iC->TestValue[i];
-      else if (iC->Comparison[i] == "le")
-              truth = iC->TestParam[i]->getDoubleValue() <= iC->TestValue[i];
-      else if (iC->Comparison[i] == "eq")
-              truth = iC->TestParam[i]->getDoubleValue() == iC->TestValue[i];
-      else if (iC->Comparison[i] == "ge")
-              truth = iC->TestParam[i]->getDoubleValue() >= iC->TestValue[i];
-      else if (iC->Comparison[i] == "gt")
-              truth = iC->TestParam[i]->getDoubleValue() >  iC->TestValue[i];
-      else if (iC->Comparison[i] == "ne")
-              truth = iC->TestParam[i]->getDoubleValue() != iC->TestValue[i];
-      else
-              cerr << "Bad comparison" << endl;
-
-      if (i == 0) WholeTruth = truth;
-      else        WholeTruth = WholeTruth && truth;
-
-      if (!truth && iC->Persistent[i] && iC->Triggered[i]) iC->Triggered[i] = false;
-    }
+  if (currentTime > EndTime) return false; //Script done!
 
-    // if the conditions are true, do the setting of the desired parameters
+  // Iterate over all events.
+  while (iEvent < Events.end()) {
+    iEvent->PrevTriggered = iEvent->Triggered;
+    // Determine whether the set of conditional tests for this condition equate
+    // to true and should cause the event to execute.
+    if (iEvent->Condition->Evaluate()) {
+      if (!iEvent->Triggered) {
 
-    if (WholeTruth) {
-      for (i=0; i<iC->SetValue.size(); i++) {
-        if ( ! iC->Triggered[i]) {
-          iC->OriginalValue[i] = iC->SetParam[i]->getDoubleValue();
-          switch (iC->Type[i]) {
+        // The conditions are true, do the setting of the desired Event parameters
+        for (i=0; i<iEvent->SetValue.size(); i++) {
+          iEvent->OriginalValue[i] = iEvent->SetParam[i]->getDoubleValue();
+          switch (iEvent->Type[i]) {
           case FG_VALUE:
-            iC->newValue[i] = iC->SetValue[i];
+          case FG_BOOL:
+            iEvent->newValue[i] = iEvent->SetValue[i];
             break;
           case FG_DELTA:
-            iC->newValue[i] = iC->OriginalValue[i] + iC->SetValue[i];
-            break;
-          case FG_BOOL:
-            iC->newValue[i] = iC->SetValue[i];
+            iEvent->newValue[i] = iEvent->OriginalValue[i] + iEvent->SetValue[i];
             break;
           default:
             cerr << "Invalid Type specified" << endl;
             break;
           }
-          iC->Triggered[i] = true;
-          iC->StartTime[i] = currentTime;
+          iEvent->StartTime = currentTime + iEvent->Delay;
+          iEvent->ValueSpan[i] = iEvent->newValue[i] - iEvent->OriginalValue[i];
+          iEvent->Transiting[i] = true;
         }
+      }
+      iEvent->Triggered = true;
+    } else if (iEvent->Persistent) {
+      iEvent->Triggered = false; // Reset the trigger for persistent events
+    }
 
-        double time_span = currentTime - iC->StartTime[i];
-        double value_span = iC->newValue[i] - iC->OriginalValue[i];
-
-        switch (iC->Action[i]) {
-        case FG_RAMP:
-          if (time_span <= iC->TC[i])
-            newSetValue = time_span/iC->TC[i] * value_span + iC->OriginalValue[i];
-          else
-            newSetValue = iC->newValue[i];
-          break;
-        case FG_STEP:
-          newSetValue = iC->newValue[i];
-          break;
-        case FG_EXP:
-          newSetValue = (1 - exp( -time_span/iC->TC[i] )) * value_span + iC->OriginalValue[i];
-          break;
-        default:
-          cerr << "Invalid Action specified" << endl;
-          break;
+    if ((currentTime >= iEvent->StartTime) && iEvent->Triggered) {
+
+      if (iEvent->Notify && iEvent->PrevTriggered != iEvent->Triggered) {
+        cout << endl << "  Event " << event_ctr << " (" << iEvent->Name << ")"
+             << " executed at time: " << currentTime << endl;
+        for (j=0; j<iEvent->NotifyProperties.size();j++) {
+          cout << "    " << iEvent->NotifyProperties[j]->GetName()
+               << " = " << iEvent->NotifyProperties[j]->getDoubleValue() << endl;
+        }
+        cout << endl;
+      }
+
+      for (i=0; i<iEvent->SetValue.size(); i++) {
+        if (iEvent->Transiting[i]) {
+          iEvent->TimeSpan = currentTime - iEvent->StartTime;
+          switch (iEvent->Action[i]) {
+          case FG_RAMP:
+            if (iEvent->TimeSpan <= iEvent->TC[i]) {
+              newSetValue = iEvent->TimeSpan/iEvent->TC[i] * iEvent->ValueSpan[i] + iEvent->OriginalValue[i];
+            } else {
+              newSetValue = iEvent->newValue[i];
+              iEvent->Transiting[i] = false;
+            }
+            break;
+          case FG_STEP:
+            newSetValue = iEvent->newValue[i];
+            iEvent->Transiting[i] = false;
+            break;
+          case FG_EXP:
+            newSetValue = (1 - exp( -iEvent->TimeSpan/iEvent->TC[i] )) * iEvent->ValueSpan[i] + iEvent->OriginalValue[i];
+            break;
+          default:
+            cerr << "Invalid Action specified" << endl;
+            break;
+          }
+          iEvent->SetParam[i]->setDoubleValue(newSetValue);
         }
-        iC->SetParam[i]->setDoubleValue(newSetValue);
       }
     }
-    iC++;
+
+    iEvent++;
+    event_ctr++;
   }
   return true;
 }
@@ -326,80 +378,67 @@ bool FGScript::RunScript(void)
 
 void FGScript::Debug(int from)
 {
-  unsigned int i;
-
   if (debug_lvl <= 0) return;
 
   if (debug_lvl & 1) { // Standard console startup message output
     if (from == 0) { // Constructor
     } else if (from == 3) {
     } else if (from == 4)  { // print out script data
-      vector <struct condition>::iterator iterConditions = Conditions.begin();
-      int count=0;
+      cout << endl;
+      cout << "Script: \"" << ScriptName << "\"" << endl;
+      cout << "  begins at " << StartTime << " seconds and runs to " << EndTime
+           << " seconds with dt = " << State->Getdt() << endl;
+      cout << endl;
 
-      cout << "\n  Script goes from " << StartTime << " to " << EndTime
-           << " with dt = " << State->Getdt() << endl << endl;
+      for (unsigned i=0; i<Events.size(); i++) {
+        cout << "Event " << i;
+        if (!Events[i].Name.empty()) cout << " (" << Events[i].Name << ")";
+        cout << ":" << endl;
 
-      while (iterConditions < Conditions.end()) {
-        cout << "  Condition: " << count++ << endl;
-        cout << "    if (";
+        if (Events[i].Persistent)
+          cout << "  " << "Always executes";
+        else
+          cout << "  " << "Executes once";
 
-        for (i=0; i<iterConditions->TestValue.size(); i++) {
-          if (i>0) cout << " and" << endl << "        ";
-          cout << "(" << iterConditions->TestParam[i]->GetName()
-                      << " " << iterConditions->Comparison[i] << " "
-                      << iterConditions->TestValue[i] << ")";
-        }
-        cout << ") then {";
+        Events[i].Condition->PrintCondition();
 
-        for (i=0; i<iterConditions->SetValue.size(); i++) {
-          cout << endl << "      set " << iterConditions->SetParam[i]->GetName()
-               << " to " << iterConditions->SetValue[i];
+        cout << endl << "  Actions taken:" << endl << "    {";
+        for (unsigned j=0; j<Events[i].SetValue.size(); j++) {
+          cout << endl << "      set " << Events[i].SetParam[j]->GetName()
+               << " to " << Events[i].SetValue[j];
 
-          switch (iterConditions->Type[i]) {
+          switch (Events[i].Type[j]) {
           case FG_VALUE:
+          case FG_BOOL:
             cout << " (constant";
             break;
           case FG_DELTA:
             cout << " (delta";
             break;
-          case FG_BOOL:
-            cout << " (boolean";
-            break;
           default:
             cout << " (unspecified type";
           }
 
-          switch (iterConditions->Action[i]) {
+          switch (Events[i].Action[j]) {
           case FG_RAMP:
             cout << " via ramp";
             break;
           case FG_STEP:
-            cout << " via step";
+            cout << " via step)";
             break;
           case FG_EXP:
             cout << " via exponential approach";
             break;
           default:
-            cout << " via unspecified action";
+            cout << " via unspecified action)";
           }
 
-          if (!iterConditions->Persistent[i]) cout << endl
-                             << "                              once";
-          else cout << endl
-                             << "                              repeatedly";
-
-          if (iterConditions->Action[i] == FG_RAMP ||
-              iterConditions->Action[i] == FG_EXP) cout << endl
-                             << "                              with time constant "
-                             << iterConditions->TC[i];
+          if (Events[i].Action[j] == FG_RAMP || Events[i].Action[j] == FG_EXP)
+            cout << " with time constant " << Events[i].TC[j] << ")";
         }
-        cout << ")" << endl << "    }" << endl << endl;
+        cout << endl << "    }" << endl << endl;
 
-        iterConditions++;
       }
-
-      cout << endl;
     }
   }
   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
index 7b4587a92f770dad1f5cb7ae2dd9960fc5276959..903057a1de69d41b8366f2e3b6b8c2b8388097d6 100644 (file)
@@ -6,20 +6,20 @@
  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -40,6 +40,7 @@ INCLUDES
 #include "FGJSBBase.h"
 #include "FGState.h"
 #include "FGFDMExec.h"
+#include <math/FGCondition.h>
 #include <vector>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -61,65 +62,100 @@ CLASS DOCUMENTATION
 /** Encapsulates the JSBSim scripting capability.
     <h4>Scripting support provided via FGScript.</h4>
 
-    <p>There is simple scripting support provided in the FGScript
-    class. Commands are specified using the <em>Simple Scripting
-    Directives for JSBSim</em> (SSDJ). The script file is in XML
-    format. A test condition (or conditions) can be set up in the
+    <p>There is support for scripting provided in the FGScript
+    class. Commands are specified using the <em>Scripting
+    Directives for JSBSim</em>. The script file is in XML
+    format. A test condition (or conditions) can be set up in an event in a
     script and when the condition evaluates to true, the specified
-    action[s] is/are taken. A test condition can be <em>persistent</em>,
-    meaning that if a test condition evaluates to true, then passes
-    and evaluates to false, the condition is reset and may again be
-    triggered. When the set of tests evaluates to true for a given
-    condition, an item may be set to another value. This value might
-    be a boolean, a value, or a delta value, and the change from the
+    action[s] is/are taken. An event can be <em>persistent</em>,
+    meaning that at all times when the test condition evaluates to true
+    the specified <em>set</em> actions take place. When the set of
+    tests evaluates to true for a given
+    condition, an item may be set to another value. This value may
+    be a value, or a delta value, and the change from the
     current value to the new value can be either via a step function,
     a ramp, or an exponential approach. The speed of a ramp or
-    approach is specified via the time constant. Here is the format
-    of the script file:</p>
-
-    <pre><strong>&lt;?xml version=&quot;1.0&quot;?&gt;
-    &lt;runscript name=&quot;C172-01A&quot;&gt;
-
-    &lt;!--
-    This run is for testing C172 runs
-    --&gt;
-
-    &lt;use aircraft=&quot;c172&quot;&gt;
-    &lt;use initialize=&quot;reset00&quot;&gt;
-
-    &lt;run start=&quot;0.0&quot; end=&quot;4.5&quot; dt=&quot;0.05&quot;&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.25&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;0.50&quot;&gt;
-        &lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_VALUE&quot; value=&quot;0.25&quot;
-        action=&quot;FG_STEP&quot; persistent=&quot;false&quot; tc =&quot;0.25&quot;&gt;
-      &lt;/when&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;0.5&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;1.5&quot;&gt;
-        &lt;set name=&quot;FG_AILERON_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
-        action=&quot;FG_EXP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
-      &lt;/when&gt;
-      &lt;when&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;ge&quot; value=&quot;1.5&quot;&gt;
-        &lt;parameter name=&quot;FG_TIME&quot; comparison=&quot;le&quot; value=&quot;2.5&quot;&gt;
-        &lt;set name=&quot;FG_RUDDER_CMD&quot; type=&quot;FG_DELTA&quot; value=&quot;0.5&quot;
-        action=&quot;FG_RAMP&quot; persistent=&quot;false&quot; tc =&quot;0.5&quot;&gt;
-      &lt;/when&gt;
-    &lt;/run&gt;
-
-    &lt;/runscript&gt;</strong></pre>
-
-    <p>The first line must always be present. The second line
+    approach is specified via the time constant. Here is an example
+    illustrating the format of the script file:
+
+    @code
+<?xml version="1.0"?>
+<runscript name="C172-01A takeoff run">
+  <!--
+    This run is for testing the C172 altitude hold autopilot
+  -->
+
+  <use aircraft="c172x"/>
+  <use initialize="reset00"/>
+  <run start="0.0" end="3000" dt="0.0083333">
+
+    <event name="engine start">
+      <notify/>
+      <condition>
+        sim-time-sec >= 0.25
+      </condition>
+      <set name="fcs/throttle-cmd-norm" value="1.0" action="FG_RAMP" tc ="0.5"/>
+      <set name="fcs/mixture-cmd-norm" value="0.87" action="FG_RAMP" tc ="0.5"/>
+      <set name="propulsion/magneto_cmd" value="3"/>
+      <set name="propulsion/starter_cmd" value="1"/>
+    </event>
+
+    <event name="set heading hold">
+      <!-- Set Heading when reach 5 ft -->
+      <notify/>
+      <condition>
+        position/h-agl-ft >= 5
+      </condition>
+      <set name="ap/heading_setpoint" value="200"/>
+      <set name="ap/attitude_hold" value="0"/>
+      <set name="ap/heading_hold" value="1"/>
+    </event>
+
+    <event name="set autopilot">
+      <!-- Set Autopilot for 20 ft -->
+      <notify/>
+      <condition>
+        aero/qbar-psf >= 4
+      </condition>
+      <set name="ap/altitude_setpoint" value="100.0" action="FG_EXP" tc ="2.0"/>
+      <set name="ap/altitude_hold" value="1"/>
+      <set name="fcs/flap-cmd-norm" value=".33"/>
+    </event>
+
+    <event name="set autopilot 2" persistent="true">
+      <!-- Set Autopilot for 6000 ft -->
+      <notify/>
+      <condition>
+        aero/qbar-psf > 5
+      </condition>
+      <set name="ap/altitude_setpoint" value="6000.0"/>
+    </event>
+
+    <event name="Time Notify">
+      <notify/>
+      <condition> sim-time-sec >= 500 </condition>
+    </event>
+
+    <event name="Time Notify">
+      <notify/>
+      <condition> sim-time-sec >= 1000 </condition>
+    </event>
+
+  </run>
+
+</runscript>
+    @endcode
+
+    The first line must always be present - it identifies the file
+    as an XML format file. The second line
     identifies this file as a script file, and gives a descriptive
     name to the script file. Comments are next, delineated by the
     &lt;!-- and --&gt; symbols. The aircraft and initialization files
     to be used are specified in the &quot;use&quot; lines. Next,
     comes the &quot;run&quot; section, where the conditions are
-    described in &quot;when&quot; clauses.</p>
+    described in &quot;event&quot; clauses.</p>
     @author Jon S. Berndt
     @version "$Id$"
-
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -136,13 +172,13 @@ public:
   ~FGScript();
 
   /** Loads a script to drive JSBSim (usually in standalone mode).
-      The language is the Simple Script Directives for JSBSim (SSDJ).
+      The language is the Script Directives for JSBSim.
       @param script the filename (including path name, if any) for the script.
       @return true if successful */
   bool LoadScript( string script );
 
   /** This function is called each pass through the executive Run() method IF
-      scripting is enabled. 
+      scripting is enabled.
       @return false if script should exit (i.e. if time limits are violated */
   bool RunScript(void);
 
@@ -159,32 +195,53 @@ private:
     FG_BOOL  = 3
   };
 
-  struct condition {
-    vector <FGPropertyManager*>  TestParam;
+  struct event {
+    FGCondition     *Condition;
+    bool             Persistent;
+    bool             Triggered;
+    bool             PrevTriggered;
+    bool             Notify;
+    double           Delay;
+    double           StartTime;
+    double           TimeSpan;
+    string           Name;
     vector <FGPropertyManager*>  SetParam;
-    vector <double>  TestValue;
-    vector <double>  SetValue;
-    vector <string>  Comparison;
-    vector <double>  TC;
-    vector <bool>    Persistent;
+    vector <FGPropertyManager*>  NotifyProperties;
     vector <eAction> Action;
     vector <eType>   Type;
-    vector <bool>    Triggered;
+    vector <double>  SetValue;
+    vector <double>  TC;
     vector <double>  newValue;
     vector <double>  OriginalValue;
-    vector <double>  StartTime;
-    vector <double>  EndTime;
-
-    condition() {
+    vector <double>  ValueSpan;
+    vector <bool>    Transiting;
+
+    event() {
+      Triggered = false;
+      PrevTriggered = false;
+      Persistent = false;
+      Delay = 0.0;
+      Notify = false;
+      Name = "";
+      StartTime = 0.0;
+      TimeSpan = 0.0;
     }
   };
 
-  bool Scripted;
+  struct LocalProps {
+    double *value;
+    string title;
+    LocalProps() {
+      value = new double(0.0);
+      title = "";
+    }
+  };
 
   string  ScriptName;
   double  StartTime;
   double  EndTime;
-  vector <struct condition> Conditions;
+  vector <struct event> Events;
+  vector <LocalProps*> local_properties;
 
   FGFDMExec* FDMExec;
   FGState* State;
index 5b19704412309d9bc2083235d1ed80937ddf759c..64d2a38ed6938a0ecd931304c3b25cb87c392484 100755 (executable)
@@ -5,6 +5,25 @@
  Purpose:      XML element class
  Called by:    FGXMLParse
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -78,6 +97,8 @@ Element::Element(string nm)
   convert["FT/SEC"]["KTS"] = 1.0/convert["KTS"]["FT/SEC"];
   convert["FT*LBS"]["N*M"] = 1.35581795;
   convert["N*M"]["FT*LBS"] = 1/convert["FT*LBS"]["N*M"];
+  convert["IN"]["M"] = convert["IN"]["FT"] * convert["FT"]["M"];
+  convert["M"]["IN"] = convert["M"]["FT"] * convert["FT"]["IN"];
 
   convert["M"]["M"] = 1.00;
   convert["FT"]["FT"] = 1.00;
@@ -113,7 +134,7 @@ Element::Element(string nm)
 
 Element::~Element(void)
 {
-  for (int i=0; i<children.size(); i++) delete children[i];
+  for (unsigned int i=0; i<children.size(); i++) delete children[i];
   data_lines.clear();
   attributes.clear();
   attribute_key.clear();
@@ -124,7 +145,7 @@ Element::~Element(void)
 string Element::GetAttributeValue(string attr)
 {
   int select=-1;
-  for (int i=0; i<attribute_key.size(); i++) {
+  for (unsigned int i=0; i<attribute_key.size(); i++) {
     if (attribute_key[i] == attr) select = i;
   }
   if (select < 0) return string("");
@@ -143,7 +164,7 @@ double Element::GetAttributeValueAsNumber(string attr)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-Element* Element::GetElement(int el)
+Element* Element::GetElement(unsigned int el)
 {
   if (children.size() > el) {
     element_index = el;
@@ -170,7 +191,7 @@ Element* Element::GetNextElement(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string Element::GetDataLine(int i)
+string Element::GetDataLine(unsigned int i)
 {
   if (data_lines.size() > 0) return data_lines[i];
   else return string("");
@@ -183,15 +204,16 @@ double Element::GetDataAsNumber(void)
   if (data_lines.size() == 1) {
     return atof(data_lines[0].c_str());
   } else {
-    return 99e99;
+    cerr << "Attempting to get single data value from multiple lines" << endl;
+    return 0;
   }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-int Element::GetNumElements(string element_name)
+unsigned int Element::GetNumElements(string element_name)
 {
-  int number_of_elements=0;
+  unsigned int number_of_elements=0;
   Element* el=FindElement(element_name);
   while (el) {
     number_of_elements++;
@@ -208,7 +230,7 @@ Element* Element::FindElement(string el)
     element_index = 1;
     return children[0];
   }
-  for (int i=0; i<children.size(); i++) {
+  for (unsigned int i=0; i<children.size(); i++) {
     if (el == children[i]->GetName()) {
       element_index = i+1;
       return children[i];
@@ -230,7 +252,7 @@ Element* Element::FindNextElement(string el)
       return 0L;
     }
   }
-  for (int i=element_index; i<children.size(); i++) {
+  for (unsigned int i=element_index; i<children.size(); i++) {
     if (el == children[i]->GetName()) {
       element_index = i+1;
       return children[i];
@@ -248,7 +270,8 @@ double Element::FindElementValueAsNumber(string el)
   if (element) {
     return element->GetDataAsNumber();
   } else {
-    return 99e99;
+    cerr << "Attempting to get single data value from multiple lines" << endl;
+    return 0;
   }
 }
 
@@ -291,7 +314,8 @@ double Element::FindElementValueAsNumberConvertTo(string el, string target_units
        }
      }
   } else {
-    return 99e99;
+    cerr << "Attempting to get get non-existent element " << el << endl;
+    return 0;
   }
   return value;
 }
@@ -323,7 +347,8 @@ double Element::FindElementValueAsNumberConvertFromTo( string el,
        }
      }
   } else {
-    return 99e99;
+    cerr << "Attempting to get get non-existent element " << el << endl;
+    return 0;
   }
   return value;
 }
@@ -375,9 +400,9 @@ FGColumnVector3 Element::FindElementTripletConvertTo( string target_units)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void Element::Print(int level)
+void Element::Print(unsigned int level)
 {
-  int i, spaces;
+  unsigned int i, spaces;
 
   level+=2;
   for (spaces=0; spaces<=level; spaces++) cout << " "; // format output
@@ -407,7 +432,7 @@ void Element::AddAttribute(string name, string value)
 
 void Element::AddData(string d)
 {
-  int string_start = d.find_first_not_of(" \t");
+  unsigned int string_start = (unsigned int)d.find_first_not_of(" \t");
   if (string_start > 0) {
     d.erase(0,string_start);
   }
index 8248fb8f5d614f3141d006dd5a18abfa2d3aa808..ce3711aed1e1a42e442bbb7d3bfc9f2484d6c80b 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2004  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -183,16 +183,16 @@ public:
       @param i the index of the data line to return (0 by default).
       @return a string representing the data line requested, or the empty string
               if none exists.*/
-  string GetDataLine(int i=0);
+  string GetDataLine(unsigned int i=0);
 
   /// Returns the number of lines of data stored
-  int GetNumDataLines(void) {return data_lines.size();}
+  unsigned int GetNumDataLines(void) {return (unsigned int)data_lines.size();}
 
   /// Returns the number of child elements for this element.
-  int GetNumElements(void) {return children.size();}
+  unsigned int GetNumElements(void) {return (unsigned int)children.size();}
 
   /// Returns the number of named child elements for this element.
-  int GetNumElements(string);
+  unsigned int GetNumElements(string);
 
   /** Converts the element data to a number.
       This function attempts to convert the first (and presumably only) line of
@@ -208,7 +208,7 @@ public:
       GetNextElement() will return NULL.
       @param el the index of the requested element (0 by default)
       @return a pointer to the Element, or 0 if no valid element exists. */
-  Element* GetElement(int el=0);
+  Element* GetElement(unsigned int el=0);
 
   /** Returns a pointer to the next element in the list.
       The function GetElement() must be called first to be sure that this
@@ -333,7 +333,7 @@ public:
   /** Prints the element.
   *   Prints this element and calls the Print routine for child elements.
   *   @param d The tab level. A level corresponds to a single space. */
-  void Print(int level=0);
+  void Print(unsigned int level=0);
 
 private:
   string name;
@@ -342,7 +342,7 @@ private:
   vector <Element*> children;
   vector <string> attribute_key;
   Element *parent;
-  int element_index;
+  unsigned int element_index;
   typedef map <string, map <string, double> > tMapConvert;
   tMapConvert convert;
 };
index ec051f8d027efef1802714e96a9c6f18da80d46d..d00d074c74209dadaded96eff4eaaad3ec47fdd0 100755 (executable)
@@ -1,11 +1,30 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
- Header:       FGXMLParse.h
+ Header:       FGXMLParse.cpp
  Author:       Jon Berndt
  Date started: 08/20/2004
  Purpose:      Config file read-in class and XML parser
  Called by:    Various
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -36,7 +55,7 @@ FGXMLParse::FGXMLParse(void)
 
 FGXMLParse::~FGXMLParse(void)
 {
-  if (document) delete document;
+  delete document;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -49,7 +68,7 @@ void FGXMLParse::startXML(void)
 
 void FGXMLParse::reset(void)
 {
-  if (document) delete document;
+  delete document;
   first_element_read = false;
   current_element = document = 0L;
 }
index a86cd6e862fbf710a0d6062290837aa0380e893f..2d58acf447939821597b92ecd0632a3e56abc0d9 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2004  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index c9db20f9486d9e7fc62169ae7e635c1a9b5261e6..37f29336ea310350aaeb2dca63b43b9694f93c27 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -82,13 +82,13 @@ FGfdmSocket::FGfdmSocket(string address, int port)
       memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
       int len = sizeof(struct sockaddr_in);
       if (connect(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
-        cout << "Successfully connected to socket ..." << endl;
+        cout << "Successfully connected to socket for output ..." << endl;
         connected = true;
       } else {                // unsuccessful
-        cout << "Could not connect to socket ..." << endl;
+        cout << "Could not connect to socket for output ..." << endl;
       }
     } else {          // unsuccessful
-      cout << "Could not create socket for FDM, error = " << errno << endl;
+      cout << "Could not create socket for FDM output, error = " << errno << endl;
     }
   }
   Debug(0);
@@ -116,10 +116,9 @@ FGfdmSocket::FGfdmSocket(int port)
     memset(&scktName, 0, sizeof(struct sockaddr_in));
     scktName.sin_family = AF_INET;
     scktName.sin_port = htons(port);
-//    memcpy(&scktName.sin_addr, host->h_addr_list[0], host->h_length);
     int len = sizeof(struct sockaddr_in);
     if (bind(sckt, (struct sockaddr*)&scktName, len) == 0) {   // successful
-      cout << "Successfully bound to socket ..." << endl;
+      cout << "Successfully bound to socket for input on port " << port << endl;
       if (listen(sckt, 5) >= 0) { // successful listen()
         #if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__MINGW32__)
           ioctlsocket(sckt, FIONBIO, &NoBlock);
@@ -133,10 +132,10 @@ FGfdmSocket::FGfdmSocket(int port)
       }
       connected = true;
     } else {                // unsuccessful
-      cerr << "Could not bind to socket ..." << endl;
+      cerr << "Could not bind to socket for input ..." << endl;
     }
   } else {          // unsuccessful
-    cerr << "Could not create socket for FDM, error = " << errno << endl;
+    cerr << "Could not create socket for FDM input, error = " << errno << endl;
   }
 
   Debug(0);
index 7eed2fe36cfa79bc5a61e52108d79135a32b4124..f1d41ef1bb8a4d6d38d4d1c2e8132c04d7134823 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -75,6 +75,12 @@ INCLUDES
   #include <sys/ioctl.h>
 #endif
 
+#ifdef _MSC_VER
+
+#pragma comment (lib,"WSock32.lib")
+
+#endif
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -91,7 +97,9 @@ namespace JSBSim {
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/** Encapsulates a socket object.
+/** Encapsulates an object that enables JSBSim to communicate via socket (input
+    and/or output).
+    
   */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 0b0fa0351c77a4b34b183aa5c848eb3ef317ab8b..dfbbca6e014b851b891c29a483b266f1eaaa1a82 100644 (file)
@@ -1,11 +1,30 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 Module: FGColumnVector3.cpp
-Author: Originally by Tony Peden [formatted here (and broken??) by JSB]
+Author: Originally by Tony Peden [formatted here by JSB]
 Date started: 1998
 Purpose: FGColumnVector3 class
 Called by: Various
 
+ ------------- Copyright (C) 1998 Tony Peden and Jon S. Berndt (jsb@hal-pc.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.
+
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
 
index e0d01bf7a0fb7e504faf59e9ee188ae06294fc79..a17c53561d1cd5fdb83d00f4731213cbe42664e5 100644 (file)
@@ -4,6 +4,25 @@ Header: FGColumnVector3.h
 Author: Originally by Tony Peden [formatted and adapted here by Jon Berndt]
 Date started: Unknown
 
+ ------------- Copyright (C) 2001 by Tony Peden and Jon S. Berndt (jsb@hal-pc.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
 --------------------------------------------------------------------------------
 ??/??/???? ??   Initial version and more.
diff --git a/src/FDM/JSBSim/math/FGCondition.cpp b/src/FDM/JSBSim/math/FGCondition.cpp
new file mode 100644 (file)
index 0000000..e5cebbc
--- /dev/null
@@ -0,0 +1,306 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module:       FGCondition.cpp
+ Author:       Jon S. Berndt
+ Date started: 1/2/2003
+
+ -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.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
+--------------------------------------------------------------------------------
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES,  and NOTES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGCondition.h"
+
+namespace JSBSim {
+
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_CONDITION;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+string FGCondition::indent = "        ";
+
+// This constructor is called when tests are inside an element
+FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
+  PropertyManager(PropertyManager), isGroup(true)
+{
+  string property1, property2, logic;
+  Element* condition_element;
+
+  InitializeConditionals();
+
+  TestParam1  = TestParam2 = 0L;
+  TestValue   = 0.0;
+  Comparison  = ecUndef;
+  Logic       = elUndef;
+  conditions.clear();
+
+  logic = element->GetAttributeValue("logic");
+  if (!logic.empty()) {
+    if (logic == "OR") Logic = eOR;
+    else if (logic == "AND") Logic = eAND;
+    else { // error
+      cerr << "Unrecognized LOGIC token " << logic << endl;
+    }
+  } else {
+    Logic = eAND; // default
+  }
+
+  condition_element = element->GetElement();
+  while (condition_element) {
+    conditions.push_back(FGCondition(condition_element, PropertyManager));
+    condition_element = element->GetNextElement();
+  }
+  for (unsigned int i=0; i<element->GetNumDataLines(); i++) {
+    string data = element->GetDataLine(i);
+    conditions.push_back(FGCondition(data, PropertyManager));
+  }
+
+  Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//This constructor is called when there are no nested test groups inside the
+// condition
+
+FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) :
+  PropertyManager(PropertyManager), isGroup(false)
+{
+  string property1, property2, compare_string;
+
+  InitializeConditionals();
+
+  TestParam1  = TestParam2 = 0L;
+  TestValue   = 0.0;
+  Comparison  = ecUndef;
+  Logic       = elUndef;
+  conditions.clear();
+
+  unsigned int start = 0, end = 0;
+  start = test.find_first_not_of(" ");
+  end = test.find_first_of(" ", start+1);
+  property1 = test.substr(start,end-start);
+  start = test.find_first_not_of(" ",end);
+  end = test.find_first_of(" ",start+1);
+  conditional = test.substr(start,end-start);
+  start = test.find_first_not_of(" ",end);
+  end = test.find_first_of(" ",start+1);
+  property2 = test.substr(start,end-start);
+
+  TestParam1 = PropertyManager->GetNode(property1, true);
+  Comparison = mComparison[conditional];
+  if (property2.find_first_not_of("-.0123456789eE") == string::npos) {
+    TestValue = atof(property2.c_str());
+  } else {
+    TestParam2 = PropertyManager->GetNode(property2, true);
+  }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::InitializeConditionals(void)
+{
+  mComparison["EQ"] = eEQ;
+  mComparison["NE"] = eNE;
+  mComparison["GT"] = eGT;
+  mComparison["GE"] = eGE;
+  mComparison["LT"] = eLT;
+  mComparison["LE"] = eLE;
+  mComparison["eq"] = eEQ;
+  mComparison["ne"] = eNE;
+  mComparison["gt"] = eGT;
+  mComparison["ge"] = eGE;
+  mComparison["lt"] = eLT;
+  mComparison["le"] = eLE;
+  mComparison["=="] = eEQ;
+  mComparison["!="] = eNE;
+  mComparison[">"]  = eGT;
+  mComparison[">="] = eGE;
+  mComparison["<"]  = eLT;
+  mComparison["<="] = eLE;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGCondition::~FGCondition(void)
+{
+  Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGCondition::Evaluate(void )
+{
+  vector <FGCondition>::iterator iConditions;
+  bool pass = false;
+  double compareValue;
+
+  if (TestParam1 == 0L) {
+
+    if (Logic == eAND) {
+
+      iConditions = conditions.begin();
+      pass = true;
+      while (iConditions < conditions.end()) {
+        if (!iConditions->Evaluate()) pass = false;
+        *iConditions++;
+      }
+
+    } else { // Logic must be eOR
+
+      pass = false;
+      while (iConditions < conditions.end()) {
+        if (iConditions->Evaluate()) pass = true;
+        *iConditions++;
+      }
+
+    }
+
+  } else {
+
+    if (TestParam2 != 0L) compareValue = TestParam2->getDoubleValue();
+    else compareValue = TestValue;
+
+    switch (Comparison) {
+    case ecUndef:
+      cerr << "Undefined comparison operator." << endl;
+      break;
+    case eEQ:
+      pass = TestParam1->getDoubleValue() == compareValue;
+      break;
+    case eNE:
+      pass = TestParam1->getDoubleValue() != compareValue;
+      break;
+    case eGT:
+      pass = TestParam1->getDoubleValue() > compareValue;
+      break;
+    case eGE:
+      pass = TestParam1->getDoubleValue() >= compareValue;
+      break;
+    case eLT:
+      pass = TestParam1->getDoubleValue() < compareValue;
+      break;
+    case eLE:
+      pass = TestParam1->getDoubleValue() <= compareValue;
+      break;
+    default:
+     cerr << "Unknown comparison operator." << endl;
+    }
+  }
+
+  return pass;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGCondition::PrintCondition(void )
+{
+  vector <FGCondition>::iterator iConditions;
+  string scratch;
+
+  if (isGroup) {
+    switch(Logic) {
+    case (elUndef):
+      scratch = " UNSET";
+      cerr << "unset logic for test condition" << endl;
+      break;
+    case (eAND):
+      scratch = " if all of the following are true:";
+      break;
+    case (eOR):
+      scratch = " if any of the following are true:";
+      break;
+    default:
+      scratch = " UNKNOWN";
+      cerr << "Unknown logic for test condition" << endl;
+    }
+
+    iConditions = conditions.begin();
+    cout << scratch << endl;
+    while (iConditions < conditions.end()) {
+      iConditions->PrintCondition();
+      *iConditions++;
+    }
+  } else {
+    if (TestParam2 != 0L)
+      cout << "    " << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
+    else
+      cout << "    " << TestParam1->GetName() << " " << conditional << " " << TestValue;
+  }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    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 FGCondition::Debug(int from)
+{
+  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: FGCondition" << endl;
+    if (from == 1) cout << "Destroyed:    FGCondition" << 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/math/FGCondition.h b/src/FDM/JSBSim/math/FGCondition.h
new file mode 100644 (file)
index 0000000..c778e0f
--- /dev/null
@@ -0,0 +1,99 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header:       FGCondition.h
+ Author:       Jon S. Berndt
+ Date started: 1/02/2003
+
+ ------------- Copyright (C)  -------------
+
+ 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 FGCONDITION_H
+#define FGCONDITION_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include <map>
+#include <FGJSBBase.h>
+#include <input_output/FGXMLElement.h>
+#include <input_output/FGPropertyManager.h>
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_CONDITION "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Encapsulates a condition, which is used in parts of JSBSim including switches
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGCondition : public FGJSBBase
+{
+public:
+  FGCondition(Element* element, FGPropertyManager* PropertyManager);
+  FGCondition(string test, FGPropertyManager* PropertyManager);
+  ~FGCondition(void);
+
+  bool Evaluate(void);
+  void PrintCondition(void);
+
+private:
+  enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
+  enum eLogic {elUndef=0, eAND, eOR};
+  map <string, eComparison> mComparison;
+  eLogic Logic;
+
+  FGPropertyManager *TestParam1, *TestParam2, *PropertyManager;
+  double TestValue;
+  eComparison Comparison;
+  bool isGroup;
+  string conditional;
+
+  static string indent;
+
+  vector <FGCondition> conditions;
+  void InitializeConditionals(void);
+
+  void Debug(int from);
+};
+}
+#endif
+
index b655d3b374d854332e863272cdfc9b90a19c6a23..0625d4d6bd3fcec66c359b67f4f28d52b4a99d26 100755 (executable)
@@ -5,6 +5,25 @@ Author: Jon Berndt
 Date started: 8/25/2004
 Purpose: Stores various parameter types for functions
 
+ ------------- Copyright (C) 2004  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -37,9 +56,9 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
 
   Name = el->GetAttributeValue("name");
   operation = el->GetName();
+
   if (operation == string("function")) {
     Type = eTopLevel;
-    bind();
   } else if (operation == string("product")) {
     Type = eProduct;
   } else if (operation == string("difference")) {
@@ -54,6 +73,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
     Type = eAbs;
   } else if (operation == string("sin")) {
     Type = eSin;
+  } else if (operation == string("exp")) {
+    Type = eExp;
   } else if (operation == string("cos")) {
     Type = eCos;
   } else if (operation == string("tan")) {
@@ -94,6 +115,7 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
                operation == string("sum") ||
                operation == string("quotient") ||
                operation == string("pow") ||
+               operation == string("exp") ||
                operation == string("abs") ||
                operation == string("sin") ||
                operation == string("cos") ||
@@ -110,6 +132,8 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
     element = el->GetNextElement();
   }
 
+  bind(); // Allow any function to save its value
+
   Debug(0);
 }
 
@@ -117,8 +141,14 @@ FGFunction::FGFunction(FGPropertyManager* propMan, Element* el, string prefix)
 
 FGFunction::~FGFunction(void)
 {
-  string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case
-  PropertyManager->Untie(tmp);
+  if (!Name.empty()) {
+    string tmp = PropertyManager->mkPropertyName(Prefix + Name, false); // Allow upper case
+    PropertyManager->Untie(tmp);
+  }
+
+  for (int i=0; i<Parameters.size(); i++) {
+    delete Parameters[i];
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -161,6 +191,9 @@ double FGFunction::GetValue(void) const
   case ePow:
     temp = pow(temp,Parameters[1]->GetValue());
     break;
+  case eExp:
+    temp = exp(temp);
+    break;
   case eAbs:
     temp = fabs(temp);
     break;
@@ -245,8 +278,8 @@ void FGFunction::Debug(int from)
     }
   }
   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
-    if (from == 0) cout << "Instantiated: FGGroundReactions" << endl;
-    if (from == 1) cout << "Destroyed:    FGGroundReactions" << endl;
+    if (from == 0) cout << "Instantiated: FGFunction" << endl;
+    if (from == 1) cout << "Destroyed:    FGFunction" << endl;
   }
   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
   }
index 3c4fddf73ac1ea5df084425f35dec0788b69dba1..47bc1ccc38f4d236e780785eb490567e5da9113b 100755 (executable)
@@ -4,6 +4,25 @@ Header: FGFunction.h
 Author: Jon Berndt
 Date started: August 25 2004
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -37,9 +56,82 @@ namespace JSBSim {
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-  /** Represents various types of parameters.
-      @author Jon Berndt
-  */
+/** Represents a mathematical function.
+The FGFunction class is a powerful and versatile resource that allows
+algebraic functions to be defined in a JSBSim configuration file. It is
+similar in concept to MathML (Mathematical Markup Language, www.w3.org/Math/),
+but simpler and more terse.
+A function definition consists of an operation, a value, a table, or a property
+(which evaluates to a value). The currently supported operations are:
+- sum (takes n args)
+- difference (takes n args)
+- product (takes n args)
+- quotient (takes 2 args)
+- pow (takes 2 args)
+- exp (takes 2 args)
+- abs (takes n args)
+- sin (takes 1 arg)
+- cos (takes 1 arg)
+- tan (takes 1 arg)
+- asin (takes 1 arg)
+- acos (takes 1 arg)
+- atan (takes 1 arg)
+- atan2 (takes 2 args)
+
+An operation is defined in the configuration file as in the following example:
+
+@code
+  <sum>
+    <value> 3.14159 </value>
+    <property> velocities/qbar </property>
+    <product>
+      <value> 0.125 </value>
+      <property> metrics/wingarea </property>
+    </product>
+  </sum>
+@endcode
+
+A full function definition, such as is used in the aerodynamics section of a
+configuration file includes the function element, and other elements. It should
+be noted that there can be only one non-optional (non-documentation) element -
+that is, one operation element - in the top-level function definition.
+Multiple value and/or property elements cannot be immediate child
+members of the function element. Almost always, the first operation within the
+function element will be a product or sum. For example:
+
+@code
+<function name="aero/coefficient/Clr">
+    <description>Roll moment due to yaw rate</description>
+    <product>
+        <property>aero/qbar-area</property>
+        <property>metrics/bw-ft</property>
+        <property>aero/bi2vel</property>
+        <property>velocities/r-aero-rad_sec</property>
+        <table>
+            <independentVar>aero/alpha-rad</independentVar>
+            <tableData>
+                 0.000  0.08
+                 0.094  0.19
+            </tableData>
+        </table>
+    </product>
+</function>
+@endcode
+
+The "lowest level" in a function is always a value or a property, which cannot
+itself contain another element. As shown, operations can contain values,
+properties, tables, or other operations. In the first above example, the sum
+element contains all three. What is evaluated is written algebraically as:
+
+@code 3.14159 + qbar + (0.125 * wingarea) @endcode
+
+Some operations can take only a single argument. That argument, however, can be
+an operation (such as sum) which can contain other items. The point to keep in
+mind is that it evaluates to a single value - which is just what the trigonometric
+functions require (except atan2, which takes two arguments).
+
+@author Jon Berndt
+*/
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DECLARATION: FGFunction
@@ -49,13 +141,43 @@ class FGFunction : public FGParameter
 {
 public:
 
-  FGFunction(FGPropertyManager* propMan, Element* el, string prefix="");
-  ~FGFunction();
-
+/** Constructor.
+    When this constructor is called, the XML element pointed to in memory by the
+    element argument is traversed. If other FGParameter-derived objects (values,
+    functions, properties, or tables) are encountered, this instance of the
+    FGFunction object will store a pointer to the found object and pass the relevant
+    Element pointer to the constructor for the new object. In other words, each
+    FGFunction object maintains a list of "child" FGParameter-derived objects which
+    in turn may each contain its own list, and so on. At runtime, each object
+    evaluates its child parameters, which each may have its own child parameters to
+    evaluate.
+    @param PropertyManager a pointer to the property manager instance.
+    @param element a pointer to the Element object containing the function definition.
+    @param prefix an optional prefix to prepend to the name given to the property
+           that represents this function (if given).
+*/
+  FGFunction(FGPropertyManager* PropertyManager, Element* element, string prefix="");
+  /// Destructor.
+  virtual ~FGFunction();
+
+/** Retrieves the value of the function object.
+    @return the total value of the function. */
   double GetValue(void) const;
+
+/** The value that the function evaluates to, as a string.
+  @return the value of the function as a string. */
   string GetValueAsString(void) const;
+
+/// Retrieves the name of the function.
   string GetName(void) const {return Name;}
-  void cacheValue(bool);
+
+/** Specifies whether to cache the value of the function, so it is calculated only
+    once per frame.
+    If shouldCache is true, then the value of the function is calculated, and
+    a flag is set so further calculations done this frame will use the cached value.
+    In order to turn off caching, cacheValue must be called with a false argument.
+    @param shouldCache specifies whether the function should cache the computed value. */
+  void cacheValue(bool shouldCache);
 
 private:
   vector <FGParameter*> Parameters;
@@ -64,7 +186,7 @@ private:
   string Prefix;
   double cachedValue;
   enum functionType {eTopLevel=0, eProduct, eDifference, eSum, eQuotient, ePow,
-                     eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type;
+                     eExp, eAbs, eSin, eCos, eTan, eASin, eACos, eATan, eATan2} Type;
   string Name;
   void bind(void);
   void Debug(int from);
index 995c89e409fa486a267556d22390ccf578bd9c5b..f9a9b52b3a5d7212abafdaf4b340cd0e52eba9e4 100644 (file)
@@ -9,20 +9,20 @@
  -------           (C) 2004  Mathias Froehlich (Mathias.Froehlich@web.de) ----
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 44aa96969489c54c55ae08046b47adc656e2d69f..5f9553059ac0ad1a5a9aeabc19b6715bfde8131d 100644 (file)
@@ -8,20 +8,20 @@
  -------           (C) 2004  Mathias Froehlich (Mathias.Froehlich@web.de) ----
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 0d42129f17c849d6ff8de3fd5ec2a0ebfefd5f76..9b4ce123103196d3f730bec674d97394b768b924 100644 (file)
@@ -6,6 +6,25 @@ Date started: 1998
 Purpose: FGMatrix33 class
 Called by: Various
 
+ ------------- Copyright (C) 1998 by the authors above -------------
+
+ 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
 --------------------------------------------------------------------------------
 
index dc68b73584733c4a4f9ae1542296e76679854e22..60b1ff885dd5702abcc5bc09ed9445874181b98a 100644 (file)
@@ -4,6 +4,25 @@ Header: FGMatrix33.h
 Author: Tony Peden, Jon Berndt, Mathias Frolich
 Date started: Unknown
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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
 --------------------------------------------------------------------------------
 ??/??/??   TP   Created
index c970f7ef445aca4aa429547c007d71a514058e76..3e235affa4ee0cb77498588c1bfad874faa57738 100755 (executable)
@@ -4,6 +4,25 @@ Header: FGParameter.h
 Author: Jon Berndt
 Date started: August 25 2004
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -44,7 +63,7 @@ DECLARATION: FGParameter
 class FGParameter : public FGJSBBase
 {
 public:
-
+  virtual ~FGParameter(void) {};
   virtual double GetValue(void) const = 0;
 
 protected:
index b0ae33eed215598896f09f409100135b0245e9be..dd24aaa939094fe5152e2cf910302d19167dd613 100755 (executable)
@@ -5,6 +5,25 @@ Author: Jon Berndt
 Date started: 12/10/2004
 Purpose: Stores property values
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index afce3911fddbb37d289ab2d79f4700300f14511e..b9bc6e2b614feba797fd342d8278edd835e721ca 100755 (executable)
@@ -4,6 +4,25 @@ Header: FGPropertyValue.h
 Author: Jon Berndt
 Date started: December 10 2004
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 55edcf88ef81a0f499ca27feb5830a09f8c8d3da..38e7e76e986c8d89283058ae2c238aa3103befaa 100644 (file)
@@ -8,20 +8,20 @@
  -------           (C) 2004  Mathias Froehlich (Mathias.Froehlich@web.de) ----
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index a23ced79a6c7782be5a275fbd914ceefa7240d7f..832f109184575b5c7e52f267fd5530a0376651bb 100644 (file)
@@ -8,20 +8,20 @@
  -------           (C) 2004  Mathias Froehlich (Mathias.Froehlich@web.de) ----
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index d1f97cd72f3efb829bf72ddeba5324e0b1c17227..313d5d646c2388f0cd5d4ef61091930886e662f7 100755 (executable)
@@ -5,6 +5,25 @@ Author: Jon Berndt
 Date started: 12/10/2004
 Purpose: Stores real values
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 334bf8433f31c6c49bcf13c9db9edd66019b6dac..36b3408ae9463f91b52ca47f57c59003005050ad 100755 (executable)
@@ -4,6 +4,25 @@ Header: FGRealValue.h
 Author: Jon Berndt
 Date started: December 10 2004
 
+ ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.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.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 584d57fb9a839386956d4bb4d39b5e9910fca5f0..5d57628b0ed5d29183e5d851f97b2c56702a3bf5 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -80,6 +80,10 @@ FGTable::FGTable(const FGTable& t) : PropertyManager(t.PropertyManager)
   nTables = t.nTables;
   dimension = t.dimension;
   internal = t.internal;
+  Name = t.Name;
+  lookupProperty[0] = t.lookupProperty[0];
+  lookupProperty[1] = t.lookupProperty[1];
+  lookupProperty[2] = t.lookupProperty[2];
 
   Tables = t.Tables;
   Data = Allocate();
@@ -117,6 +121,7 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
   // Is this an internal lookup table?
 
   internal = false;
+  Name = el->GetAttributeValue("name"); // Allow this table to be named with a property
   call_type = el->GetAttributeValue("type");
   if (call_type == string("internal")) {
     parent_element = el->GetParent();
@@ -271,6 +276,9 @@ FGTable::FGTable(FGPropertyManager* propMan, Element* el) : PropertyManager(prop
     cout << "No dimension given" << endl;
     break;
   }
+
+  bind();
+
   if (debug_lvl & 1) Print();
 }
 
@@ -292,13 +300,18 @@ double** FGTable::Allocate(void)
 
 FGTable::~FGTable()
 {
+  if (!Name.empty() && !internal) {
+    string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper case
+    PropertyManager->Untie(tmp);
+  }
+
   if (nTables > 0) {
-cout << "nTables = " << nTables << endl;
     for (int i=0; i<nTables; i++) delete Tables[i];
     Tables.clear();
   }
-  for (int r=0; r<=nRows; r++) if (Data[r]) delete[] Data[r];
-  if (Data) delete[] Data;
+  for (int r=0; r<=nRows; r++) delete[] Data[r];
+  delete[] Data;
+
   Debug(1);
 }
 
@@ -562,6 +575,16 @@ void FGTable::Print(void)
   cout.setf(flags); // reset
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGTable::bind(void)
+{
+  typedef double (FGTable::*PMF)(void) const;
+  if ( !Name.empty() && !internal) {
+    string tmp = PropertyManager->mkPropertyName(Name, false); // Allow upper
+    PropertyManager->Tie( tmp, this, (PMF)&FGTable::GetValue);
+  }
+}
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 //    The bitmasked value choices are as follows:
 //    unset: In this case (the default) JSBSim would only print
index be6e3b8d9e221c65e292bcecfe1064a5a1c245ec..e70684095d49d9cae05928ac373e0c03a8ec7906 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -64,138 +64,177 @@ CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 /** Lookup table class.
-    Models a one, two, or three dimensional lookup table for use in FGCoefficient,
-    FGPropeller, etc.  A one-dimensional table is called a "VECTOR" in a coefficient
-    definition. For example:
-<pre>
-    \<COEFFICIENT NAME="{short name}" TYPE="VECTOR">
-      {name}
-      {number of rows}
-      {row lookup property}
-      {non-dimensionalizing properties}
-      {row_1_key} {col_1_data}
-      {row_2_key} {...       }
-      { ...     } {...       }
-      {row_n_key} {...       }
-    \</COEFFICIENT>
-</pre>
-    A "real life" example is as shown here:
-<pre>
-    \<COEFFICIENT NAME="CLDf" TYPE="VECTOR">
-      Delta_lift_due_to_flap_deflection
-      4
-      fcs/flap-pos-deg
-      aero/qbar-psf | metrics/Sw-sqft
-      0   0
-      10  0.20
-      20  0.30
-      30  0.35
-    \</COEFFICIENT>
-</pre>
-    The first column in the data table represents the lookup index (or "key").  In
-    this case, the lookup index is fcs/flap-pos-deg (flap extension in degrees).
-    If the flap position is 10 degrees, the value returned from the lookup table
-    would be 0.20.  This value would be multiplied by qbar (aero/qbar-psf) and wing
-    area (metrics/Sw-sqft) to get the total lift force that is a result of flap
-    deflection (measured in pounds force).  If the value of the flap-pos-deg property
-    was 15 (degrees), the value output by the table routine would be 0.25 - an
-    interpolation.  If the flap position in degrees ever went below 0.0, or above
-    30 (degrees), the output from the table routine would be 0 and 0.35, respectively.
-    That is, there is no _extrapolation_ to values outside the range of the lookup
-    index.  This is why it is important to chose the data for the table wisely.
-
-    The definition for a 2D table - referred to simply as a TABLE, is as follows:
-<pre>
-    \<COEFFICIENT NAME="{short name}" TYPE="TABLE">
-      {name}
-      {number of rows}
-      {number of columns}
-      {row lookup property}
-      {column lookup property}
-      {non-dimensionalizing}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
-    \</COEFFICIENT>
-</pre>
-    A "real life" example is as shown here:
-<pre>
-    \<COEFFICIENT NAME="CYb" TYPE="TABLE">
-      Side_force_due_to_beta
-      3
-      2
-      aero/beta-rad
-      fcs/flap-pos-deg
-      aero/qbar-psf | metrics/Sw-sqft
-               0     30
-      -0.349   0.137  0.106
-       0       0      0
-       0.349  -0.137 -0.106
-    \</COEFFICIENT>
-</pre>
-    The definition for a 3D table in a coefficient would be (for example):
-<pre>
-    \<COEFFICIENT NAME="{short name}" TYPE="TABLE3D">
-      {name}
-      {number of rows}
-      {number of columns}
-      {number of tables}
-      {row lookup property}
-      {column lookup property}
-      {table lookup property}
-      {non-dimensionalizing}
-      {first table key}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
-
-      {second table key}
-                  {col_1_key   col_2_key   ...  col_n_key }
-      {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
-      {row_2_key} {...         ...         ...  ...       }
-      { ...     } {...         ...         ...  ...       }
-      {row_n_key} {...         ...         ...  ...       }
-
-      ...
-
-    \</COEFFICIENT>
-</pre>
-    [At the present time, all rows and columns for each table must have the
-    same dimension.]
-
-    In addition to using a Table for something like a coefficient, where all the
-    row and column elements are read in from a file, a Table could be created
-    and populated completely within program code:
-<pre>
-    // First column is thi, second is neta (combustion efficiency)
-    Lookup_Combustion_Efficiency = new FGTable(12);
-    *Lookup_Combustion_Efficiency << 0.00 << 0.980;
-    *Lookup_Combustion_Efficiency << 0.90 << 0.980;
-    *Lookup_Combustion_Efficiency << 1.00 << 0.970;
-    *Lookup_Combustion_Efficiency << 1.05 << 0.950;
-    *Lookup_Combustion_Efficiency << 1.10 << 0.900;
-    *Lookup_Combustion_Efficiency << 1.15 << 0.850;
-    *Lookup_Combustion_Efficiency << 1.20 << 0.790;
-    *Lookup_Combustion_Efficiency << 1.30 << 0.700;
-    *Lookup_Combustion_Efficiency << 1.40 << 0.630;
-    *Lookup_Combustion_Efficiency << 1.50 << 0.570;
-    *Lookup_Combustion_Efficiency << 1.60 << 0.525;
-    *Lookup_Combustion_Efficiency << 2.00 << 0.345;
-</pre>
-    The first column in the table, above, is thi (the lookup index, or key). The
-    second column is the output data - in this case, "neta" (the Greek letter
-    referring to combustion efficiency). Later on, the table is used like this:
-
-    combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
-
-    @author Jon S. Berndt
-    @version $Id$
-    @see FGCoefficient
-    @see FGPropeller
+Models a one, two, or three dimensional lookup table for use in aerodynamics
+and function definitions.
+
+For a single "vector" lookup table, the format is as follows:
+
+@code
+<table name="property_name">
+  <independentVar lookup="row"> property_name </independentVar>
+  <tableData>
+    key_1 value_1
+    key_2 value_2
+    ...  ...
+    key_n value_n
+  </tableData>
+</table>
+@endcode
+
+The lookup="row" attribute in the independentVar element is option in this case;
+it is assumed that the independentVar is a row variable.
+
+A "real life" example is as shown here:
+
+@code
+<table>
+  <independentVar lookup="row"> aero/alpha-rad </independentVar>
+  <tableData>
+   -1.57  1.500
+   -0.26  0.033
+    0.00  0.025
+    0.26  0.033
+    1.57  1.500
+  </tableData>
+</table>
+@endcode
+
+The first column in the data table represents the lookup index (or "key").  In
+this case, the lookup index is aero/alpha-rad (angle of attack in radians).
+If alpha is 0.26 radians, the value returned from the lookup table
+would be 0.033.
+
+The definition for a 2D table, is as follows:
+
+@code
+<table name="property_name">
+  <independentVar lookup="row"> property_name </independentVar>
+  <independentVar lookup="column"> property_name </independentVar>
+  <tableData>
+                {col_1_key   col_2_key   ...  col_n_key }
+    {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
+    {row_2_key} {...         ...         ...  ...       }
+    { ...     } {...         ...         ...  ...       }
+    {row_n_key} {...         ...         ...  ...       }
+  </tableData>
+</table>
+@endcode
+
+The data is in a gridded format.
+
+A "real life" example is as shown below. Alpha in radians is the row lookup (alpha
+breakpoints are arranged in the first column) and flap position in degrees is
+
+@code
+<table>
+  <independentVar lookup="row">aero/alpha-rad</independentVar>
+  <independentVar lookup="column">fcs/flap-pos-deg</independentVar>
+  <tableData>
+                0.0         10.0        20.0         30.0
+    -0.0523599  8.96747e-05 0.00231942  0.0059252    0.00835082
+    -0.0349066  0.000313268 0.00567451  0.0108461    0.0140545
+    -0.0174533  0.00201318  0.0105059   0.0172432    0.0212346
+     0.0        0.0051894   0.0168137   0.0251167    0.0298909
+     0.0174533  0.00993967  0.0247521   0.0346492    0.0402205
+     0.0349066  0.0162201   0.0342207   0.0457119    0.0520802
+     0.0523599  0.0240308   0.0452195   0.0583047    0.0654701
+     0.0698132  0.0333717   0.0577485   0.0724278    0.0803902
+     0.0872664  0.0442427   0.0718077   0.088081     0.0968405
+  </tableData>
+</table>
+@endcode
+
+The definition for a 3D table in a coefficient would be (for example):
+
+@code
+<table name="property_name">
+  <independentVar lookup="row"> property_name </independentVar>
+  <independentVar lookup="column"> property_name </independentVar>
+  <tableData breakpoint="table_1_key">
+                {col_1_key   col_2_key   ...  col_n_key }
+    {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
+    {row_2_key} {...         ...         ...  ...       }
+    { ...     } {...         ...         ...  ...       }
+    {row_n_key} {...         ...         ...  ...       }
+  </tableData>
+  <tableData breakpoint="table_2_key">
+                {col_1_key   col_2_key   ...  col_n_key }
+    {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
+    {row_2_key} {...         ...         ...  ...       }
+    { ...     } {...         ...         ...  ...       }
+    {row_n_key} {...         ...         ...  ...       }
+  </tableData>
+  ...
+  <tableData breakpoint="table_n_key">
+                {col_1_key   col_2_key   ...  col_n_key }
+    {row_1_key} {col_1_data  col_2_data  ...  col_n_data}
+    {row_2_key} {...         ...         ...  ...       }
+    { ...     } {...         ...         ...  ...       }
+    {row_n_key} {...         ...         ...  ...       }
+  </tableData>
+</table>
+@endcode
+
+[Note the "breakpoint" attribute in the tableData element, above.]
+
+Here's an example:
+
+@code
+<table>
+  <independentVar lookup="row">fcs/row-value</independentVar>
+  <independentVar lookup="column">fcs/column-value</independentVar>
+  <independentVar lookup="table">fcs/table-value</independentVar>
+  <tableData breakPoint="-1.0">
+           -1.0     1.0
+    0.0     1.0000  2.0000
+    1.0     3.0000  4.0000
+  </tableData>
+  <tableData breakPoint="0.0000">
+            0.0     10.0
+    2.0     1.0000  2.0000
+    3.0     3.0000  4.0000
+  </tableData>
+  <tableData breakPoint="1.0">
+           0.0     10.0     20.0
+     2.0   1.0000   2.0000   3.0000
+     3.0   4.0000   5.0000   6.0000
+    10.0   7.0000   8.0000   9.0000
+  </tableData>
+</table>
+@endcode
+
+In addition to using a Table for something like a coefficient, where all the
+row and column elements are read in from a file, a Table could be created
+and populated completely within program code:
+
+@code
+// First column is thi, second is neta (combustion efficiency)
+Lookup_Combustion_Efficiency = new FGTable(12);
+
+*Lookup_Combustion_Efficiency << 0.00 << 0.980;
+*Lookup_Combustion_Efficiency << 0.90 << 0.980;
+*Lookup_Combustion_Efficiency << 1.00 << 0.970;
+*Lookup_Combustion_Efficiency << 1.05 << 0.950;
+*Lookup_Combustion_Efficiency << 1.10 << 0.900;
+*Lookup_Combustion_Efficiency << 1.15 << 0.850;
+*Lookup_Combustion_Efficiency << 1.20 << 0.790;
+*Lookup_Combustion_Efficiency << 1.30 << 0.700;
+*Lookup_Combustion_Efficiency << 1.40 << 0.630;
+*Lookup_Combustion_Efficiency << 1.50 << 0.570;
+*Lookup_Combustion_Efficiency << 1.60 << 0.525;
+*Lookup_Combustion_Efficiency << 2.00 << 0.345;
+@endcode
+
+The first column in the table, above, is thi (the lookup index, or key). The
+second column is the output data - in this case, "neta" (the Greek letter
+referring to combustion efficiency). Later on, the table is used like this:
+
+@code
+combustion_efficiency = Lookup_Combustion_Efficiency->GetValue(equivalence_ratio);
+@endcode
+
+@author Jon S. Berndt
+@version $Id$
 */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -266,6 +305,8 @@ private:
   mutable int lastRowIndex, lastColumnIndex, lastTableIndex;
   double** Allocate(void);
   FGPropertyManager* const PropertyManager;
+  string Name;
+  void bind(void);
 
   void Debug(int from);
 };
index 107e29f29f831a6cea7678badc269ef0257ba543..afcedd6cc11a19e62464190aba7fe8e4efd82d93 100644 (file)
@@ -1,9 +1,11 @@
 noinst_LIBRARIES = libMath.a
 
 libMath_a_SOURCES = FGColumnVector3.cpp FGFunction.cpp FGLocation.cpp FGMatrix33.cpp \
-                    FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp
+                    FGPropertyValue.cpp FGQuaternion.cpp FGRealValue.cpp FGTable.cpp \
+                    FGCondition.cpp
 
 noinst_HEADERS = FGColumnVector3.h FGFunction.h FGLocation.h FGMatrix33.h \
-                 FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h 
+                 FGParameter.h FGPropertyValue.h FGQuaternion.h FGRealValue.h FGTable.h \
+                 FGCondition.h
 
 INCLUDES = -I$(top_srcdir)/src/FDM/JSBSim
index 63f00754d2335fb68f5acd541690bdaca14050f8..8e75ce0588b4bf9fc1e07c7a74eaa1c3bf418cd1 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -76,6 +76,9 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec)
   clsq = lod = 0.0;
   alphaw = 0.0;
   bi2vel = ci2vel = 0.0;
+  AeroRPShift = 0;
+  vDeltaRP.InitMatrix();
+
   bind();
 
   Debug(0);
@@ -87,8 +90,6 @@ FGAerodynamics::~FGAerodynamics()
 {
   unsigned int i,j;
 
-  unbind();
-
   for (i=0; i<6; i++)
     for (j=0; j<Coeff[i].size(); j++)
       delete Coeff[i][j];
@@ -98,6 +99,10 @@ FGAerodynamics::~FGAerodynamics()
   for (i=0; i<variables.size(); i++)
     delete variables[i];
 
+  if (AeroRPShift) delete AeroRPShift;
+
+  unbind();
+
   Debug(1);
 }
 
@@ -153,6 +158,11 @@ bool FGAerodynamics::Run(void)
     }
   }
 
+  // Calculate aerodynamic reference point shift, if any
+  if (AeroRPShift) {
+    vDeltaRP(eX) = AeroRPShift->GetValue()*Aircraft->Getcbar()*12.0;
+  }
+
   // calculate lift coefficient squared
   if ( Auxiliary->Getqbar() > 0) {
     clsq = vFs(eLift) / (Aircraft->GetWingArea()*Auxiliary->Getqbar());
@@ -170,7 +180,7 @@ bool FGAerodynamics::Run(void)
   // transform stability axis forces into body axes
   vForces = State->GetTs2b()*vFs;
 
-  vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp());
+  vDXYZcg = MassBalance->StructuralToBody(Aircraft->GetXYZrp() + vDeltaRP);
 
   vMoments = vDXYZcg*vForces; // M = r X F
 
@@ -202,6 +212,11 @@ bool FGAerodynamics::Load(Element *element)
     alphahystmax = temp_element->FindElementValueAsNumberConvertTo("max", "DEG");
   }
 
+  if (temp_element = element->FindElement("aero_ref_pt_shift_x")) {
+    function_element = temp_element->FindElement("function");
+    AeroRPShift = new FGFunction(PropertyManager, function_element);
+  }
+
   function_element = element->FindElement("function");
   while (function_element) {
     variables.push_back( new FGFunction(PropertyManager, function_element) );
@@ -243,7 +258,11 @@ string FGAerodynamics::GetCoefficientStrings(string delimeter)
 
   for (axis = 0; axis < 6; axis++) {
     for (sd = 0; sd < Coeff[axis].size(); sd++) {
-      CoeffStrings += delimeter;
+      if (firstime) {
+        firstime = false;
+      } else {
+        CoeffStrings += delimeter;
+      }
       CoeffStrings += Coeff[axis][sd]->GetName();
     }
   }
@@ -269,7 +288,11 @@ string FGAerodynamics::GetCoefficientValues(string delimeter)
 
   for (unsigned int axis = 0; axis < 6; axis++) {
     for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
-      SDValues += delimeter;
+      if (firstime) {
+        firstime = false;
+      } else {
+        SDValues += delimeter;
+      }
       SDValues += Coeff[axis][sd]->GetValueAsString();
     }
   }
index 2874461616fa4150f55b9cbd48b8ea0e4060b492..91c19d122f5debc9a9ba1a1be9759743c0de0594 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -75,7 +75,8 @@ CLASS DOCUMENTATION
 /** Encapsulates the aerodynamic calculations.
     This class owns and contains the list of force/coefficients that define the
     aerodynamic properties of an aircraft. Here also, such unique phenomena
-    as ground effect and maximum lift curve tailoff are handled.
+    as ground effect, aerodynamic reference point shift, and maximum lift curve
+    tailoff are handled.
 
     @code
     <aerodynamics>
@@ -133,17 +134,24 @@ public:
               similar call to GetForces(int n).*/
   double GetMoments(int n) const {return vMoments(n);}
 
-  FGColumnVector3& GetvLastFs(void) { return vLastFs; }
-  double GetvLastFs(int axis) const { return vLastFs(axis); }
+  /** Retrieves the aerodynamic forces in the stability axes.
+      @return a reference to a column vector containing the stability axis forces. */
   FGColumnVector3& GetvFs(void) { return vFs; }
+
+  /** Retrieves the aerodynamic forces in the stability axes, given an axis.
+      @param axis the axis to return the force for (eX, eY, eZ).
+      @return a reference to a column vector containing the requested stability
+      axis force. */
   double GetvFs(int axis) const { return vFs(axis); }
+
+  /** Retrieves the lift over drag ratio */
   inline double GetLoD(void) const { return lod; }
+
+  /** Retrieves the square of the lift coefficient. */
   inline double GetClSquared(void) const { return clsq; }
   inline double GetAlphaCLMax(void) const { return alphaclmax; }
   inline double GetAlphaCLMin(void) const { return alphaclmin; }
 
-  inline double GetAlphaHystMax(void) const { return alphahystmax; }
-  inline double GetAlphaHystMin(void) const { return alphahystmin; }
   inline double GetHysteresisParm(void) const { return stall_hyst; }
   inline double GetStallWarn(void) const { return impending_stall; }
   double GetAlphaW(void) const { return alphaw; }
@@ -168,6 +176,7 @@ public:
 private:
   typedef map<string,int> AxisIndex;
   AxisIndex AxisIdx;
+  FGFunction* AeroRPShift;
   vector <FGFunction*> variables;
   typedef vector <FGFunction*> CoeffArray;
   CoeffArray* Coeff;
@@ -176,6 +185,7 @@ private:
   FGColumnVector3 vMoments;
   FGColumnVector3 vLastFs;
   FGColumnVector3 vDXYZcg;
+  FGColumnVector3 vDeltaRP;
   double alphaclmax, alphaclmin;
   double alphahystmax, alphahystmin;
   double impending_stall, stall_hyst;
index fd6f9fce36f3a7336b6ce3648a49b5b47efc268f..4e4b6536089f2541f2cda8c164069bd16176258c 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -125,10 +125,8 @@ bool FGAircraft::Run(void)
   vMoments += Propulsion->GetMoments();
   vMoments += GroundReactions->GetMoments();
 
-//  printf("%s:%i\n", __FILE__, __LINE__);
   vBodyAccel = vForces/MassBalance->GetMass();
 
-//  printf("%s:%i\n", __FILE__, __LINE__);
   vNcg = vBodyAccel/Inertial->gravity();
 
   vNwcg = State->GetTb2s() * vNcg;
index 29d555df54fdc8ba30e194206a399daebb1ade64..6a882e11a5e91cfe4a5f31bd345dd6f9552c8207 100644 (file)
@@ -1,32 +1,32 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Header:       FGAircraft.h
  Author:       Jon S. Berndt
  Date started: 12/12/98
+
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
- You should have received a copy of the GNU General Public License along with
+
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
+
 HISTORY
 --------------------------------------------------------------------------------
 12/12/98   JSB   Created
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -102,7 +102,7 @@ public:
   /** Constructor
       @param Executive a pointer to the parent executive object */
   FGAircraft(FGFDMExec *Executive);
-  
+
   /// Destructor
   ~FGAircraft();
 
@@ -110,17 +110,17 @@ public:
       @see JSBSim.cpp documentation
       @return false if no error */
   bool Run(void);
-  
+
   /** Loads the aircraft.
       The executive calls this method to load the aircraft into JSBSim.
       @param el a pointer to the element tree
       @return true if successful */
   bool Load(Element* el);
-  
+
   /** Gets the aircraft name
       @return the name of the aircraft as a string type */
   inline string GetAircraftName(void) { return AircraftName; }
-  
+
   /// Gets the wing area
   double GetWingArea(void) const { return WingArea; }
   /// Gets the wing span
@@ -152,6 +152,8 @@ public:
   inline double GetXYZep(int idx) const { return vXYZep(idx); }
   inline void SetAircraftName(string name) {AircraftName = name;}
 
+  void SetXYZrp(int idx, double value) {vXYZrp(idx) = value;}
+
   double GetNlf(void);
 
   inline FGColumnVector3& GetNwcg(void) { return vNwcg; }
index 2441f843f7a1ac21a473b07c445e8fb7659b8723..5da2bb0b569cf6e2bcf21cfcb4c478ef2858d8cb 100644 (file)
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 788d04c19c49bf2ec23817ba3109cd1a201f9be3..06f32a812ac58b1e30d6268a8e2285901c04140b 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 056c1c07e061a83dfd040f35a13fdbc341c073f8..bb637c9d02871effe70cad899c3b4d5f61747dc5 100755 (executable)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -107,7 +107,8 @@ bool FGAuxiliary::Run()
   const FGColumnVector3& vUVWdot = Propagate->GetUVWdot();
   const FGColumnVector3& vVel = Propagate->GetVel();
 
-  if (FGModel::Run()) return true;
+  if (FGModel::Run()) return true; // return true if error returned from base class
+
   if (FDMExec->Holding()) return false;
 
   p = Atmosphere->GetPressure();
@@ -118,13 +119,14 @@ bool FGAuxiliary::Run()
 // Rotation
 
   double cTht = Propagate->GetCosEuler(eTht);
+  double sTht = Propagate->GetSinEuler(eTht);
   double cPhi = Propagate->GetCosEuler(ePhi);
   double sPhi = Propagate->GetSinEuler(ePhi);
 
   vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
   if (cTht != 0.0) {
     vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht;
-    vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sPhi;
+    vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht;
   }
 
 // 12/16/2005, JSB: For ground handling purposes, at this time, let's ramp
@@ -185,11 +187,12 @@ bool FGAuxiliary::Run()
 
   if (psigt < 0.0) psigt += 2*M_PI;
 
-  if (Vt != 0) {
-    hdot_Vt = -vVel(eDown)/Vt;
-    if (fabs(hdot_Vt) <= 1) gamma = asin(hdot_Vt);
+  if (Vground == 0.0) {
+    if (vVel(eDown) == 0.0) gamma = 0.0;
+    else if (vVel(eDown) < 0.0) gamma = 90.0*degtorad;
+    else gamma = -90.0*degtorad;
   } else {
-    gamma = 0.0;
+    gamma = atan2(-vVel(eDown), Vground);
   }
 
   tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
@@ -275,14 +278,14 @@ void FGAuxiliary::bind(void)
 {
   typedef double (FGAuxiliary::*PMF)(int) const;
   typedef double (FGAuxiliary::*PF)(void) const;
+  PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
+  PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
+  PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
   PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
   PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
   PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
   PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
   PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
-  PropertyManager->Tie("velocities/tat-r", this, &FGAuxiliary::GetTotalTemperature);
-  PropertyManager->Tie("velocities/tat-c", this, &FGAuxiliary::GetTAT_C);
-  PropertyManager->Tie("velocities/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
   PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);
   PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);
   PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);
@@ -327,17 +330,18 @@ void FGAuxiliary::bind(void)
 
 void FGAuxiliary::unbind(void)
 {
+  PropertyManager->Untie("propulsion/tat-r");
+  PropertyManager->Untie("propulsion/tat-c");
+  PropertyManager->Untie("propulsion/pt-lbs_sqft");
+
   PropertyManager->Untie("velocities/vc-fps");
   PropertyManager->Untie("velocities/vc-kts");
   PropertyManager->Untie("velocities/ve-fps");
   PropertyManager->Untie("velocities/ve-kts");
   PropertyManager->Untie("velocities/machU");
-  PropertyManager->Untie("velocities/tat-r");
-  PropertyManager->Untie("velocities/tat-c");
   PropertyManager->Untie("velocities/p-aero-rad_sec");
   PropertyManager->Untie("velocities/q-aero-rad_sec");
   PropertyManager->Untie("velocities/r-aero-rad_sec");
-  PropertyManager->Untie("velocities/pt-lbs_sqft");
   PropertyManager->Untie("velocities/phidot-rad_sec");
   PropertyManager->Untie("velocities/thetadot-rad_sec");
   PropertyManager->Untie("velocities/psidot-rad_sec");
index 297b3a0cc0ea62c9031663900dcbabde3d497702..0428ff9eb60f51a9d938cafdc770f69b00e44fef 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 0c106cefa1887505aab3276c5d1292e0447d0421..d6732a379f99002ed0cd40ba7ab2790e23606bb4 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -45,6 +45,7 @@ INCLUDES
 #include <models/flight_control/FGFilter.h>
 #include <models/flight_control/FGDeadBand.h>
 #include <models/flight_control/FGGain.h>
+#include <models/flight_control/FGPID.h>
 #include <models/flight_control/FGGradient.h>
 #include <models/flight_control/FGSwitch.h>
 #include <models/flight_control/FGSummer.h>
@@ -453,10 +454,9 @@ void FGFCS::SetPropFeather(int engineNum, bool setting)
 
 bool FGFCS::Load(Element* el)
 {
-  string name, file, fname, comp_name, interface_property_string;
-  unsigned i;
+  string name, file, fname, interface_property_string;
   vector <FGFCSComponent*> *Components;
-  Element *FCS_cfg, *document, *component_element, *property_element, *sensor_element;
+  Element *document, *component_element, *property_element, *sensor_element;
   Element *channel_element;
   ifstream* controls_file = new ifstream();
   FGXMLParse controls_file_parser;
@@ -474,7 +474,7 @@ bool FGFCS::Load(Element* el)
 
   if (name.empty()) {
     fname = el->GetAttributeValue("file");
-    file = FDMExec->GetAircraftPath() + separator + FDMExec->GetModelName() + separator + fname + ".xml";
+    file = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
     if (fname.empty()) {
       cerr << "FCS/Autopilot does not appear to be defined inline nor in a file" << endl;
       return false;
@@ -527,60 +527,42 @@ bool FGFCS::Load(Element* el)
 
   channel_element = document->FindElement("channel");
   while (channel_element) {
-    component_element = channel_element->FindElement("component");
-    if (component_element) {
-      cout << "This form of the component specification is being deprecated" << endl;
-    } else {
-      component_element = channel_element->GetElement();
-    }
+    component_element = channel_element->GetElement();
     while (component_element) {
-      comp_name = component_element->GetAttributeValue("type");
       try {
-        if ((comp_name == "LAG_FILTER") ||
-            (comp_name == "LEAD_LAG_FILTER") ||
-            (comp_name == "SECOND_ORDER_FILTER") ||
-            (comp_name == "WASHOUT_FILTER") ||
-            (comp_name == "INTEGRATOR") ||
-            (component_element->GetName() == string("lag_filter")) ||
+        if ((component_element->GetName() == string("lag_filter")) ||
             (component_element->GetName() == string("lead_lag_filter")) ||
             (component_element->GetName() == string("washout_filter")) ||
             (component_element->GetName() == string("second_order_filter")) ||
             (component_element->GetName() == string("integrator")) )
         {
           Components->push_back(new FGFilter(this, component_element));
-        } else if ((comp_name == "PURE_GAIN") ||
-                   (comp_name == "SCHEDULED_GAIN") ||
-                   (comp_name == "AEROSURFACE_SCALE") ||
-                   (component_element->GetName() == string("pure_gain")) ||
+        } else if ((component_element->GetName() == string("pure_gain")) ||
                    (component_element->GetName() == string("scheduled_gain")) ||
                    (component_element->GetName() == string("aerosurface_scale")))
         {
           Components->push_back(new FGGain(this, component_element));
-        } else if ((comp_name == "SUMMER") || (component_element->GetName() == string("summer"))) {
+        } else if (component_element->GetName() == string("summer")) {
           Components->push_back(new FGSummer(this, component_element));
-        } else if ((comp_name == "DEADBAND") || (component_element->GetName() == string("deadband"))) {
+        } else if (component_element->GetName() == string("deadband")) {
           Components->push_back(new FGDeadBand(this, component_element));
-        } else if (comp_name == "GRADIENT") {
-          Components->push_back(new FGGradient(this, component_element));
-        } else if ((comp_name == "SWITCH") || (component_element->GetName() == string("switch"))) {
+        } else if (component_element->GetName() == string("switch")) {
           Components->push_back(new FGSwitch(this, component_element));
-        } else if ((comp_name == "KINEMAT") || (component_element->GetName() == string("kinematic"))) {
+        } else if (component_element->GetName() == string("kinematic")) {
           Components->push_back(new FGKinemat(this, component_element));
-        } else if ((comp_name == "FUNCTION") || (component_element->GetName() == string("fcs_function"))) {
+        } else if (component_element->GetName() == string("fcs_function")) {
           Components->push_back(new FGFCSFunction(this, component_element));
+        } else if (component_element->GetName() == string("pid")) {
+          Components->push_back(new FGPID(this, component_element));
         } else {
-          cerr << "Unknown FCS component: " << comp_name << endl;
+          cerr << "Unknown FCS component: " << component_element->GetName() << endl;
         }
       } catch(string s) {
         cerr << highint << fgred << endl << "  " << s << endl;
         cerr << reset << endl;
         return false;
       }
-      if (comp_name.empty()) { // comp_name will be empty if using new format
-        component_element = channel_element->GetNextElement();
-      } else {
-        component_element = channel_element->FindNextElement("component");
-      }
+      component_element = channel_element->GetNextElement();
     }
     channel_element = document->FindNextElement("channel");
   }
@@ -635,7 +617,7 @@ string FGFCS::GetComponentValues(string delimeter)
 {
   unsigned int comp;
   string CompValues = "";
-  char buffer[12];
+  char buffer[17];
   bool firstime = true;
 
   for (comp = 0; comp < FCSComponents.size(); comp++) {
@@ -651,6 +633,7 @@ string FGFCS::GetComponentValues(string delimeter)
     CompValues += string(buffer);
   }
 
+  CompValues += "\0";
   return CompValues;
 }
 
@@ -667,7 +650,7 @@ void FGFCS::AddThrottle(void)
   PropFeatherCmd.push_back(false);
   PropFeather.push_back(false);
 
-  unsigned int num = ThrottleCmd.size()-1;
+  unsigned int num = (unsigned int)ThrottleCmd.size()-1;
   bindThrottle(num);
 }
 
@@ -685,14 +668,12 @@ void FGFCS::bind(void)
   PropertyManager->Tie("fcs/aileron-cmd-norm", this, &FGFCS::GetDaCmd, &FGFCS::SetDaCmd);
   PropertyManager->Tie("fcs/elevator-cmd-norm", this, &FGFCS::GetDeCmd, &FGFCS::SetDeCmd);
   PropertyManager->Tie("fcs/rudder-cmd-norm", this, &FGFCS::GetDrCmd, &FGFCS::SetDrCmd);
-  PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd);
   PropertyManager->Tie("fcs/flap-cmd-norm", this, &FGFCS::GetDfCmd, &FGFCS::SetDfCmd);
   PropertyManager->Tie("fcs/speedbrake-cmd-norm", this, &FGFCS::GetDsbCmd, &FGFCS::SetDsbCmd);
   PropertyManager->Tie("fcs/spoiler-cmd-norm", this, &FGFCS::GetDspCmd, &FGFCS::SetDspCmd);
   PropertyManager->Tie("fcs/pitch-trim-cmd-norm", this, &FGFCS::GetPitchTrimCmd, &FGFCS::SetPitchTrimCmd);
   PropertyManager->Tie("fcs/roll-trim-cmd-norm", this, &FGFCS::GetRollTrimCmd, &FGFCS::SetRollTrimCmd);
   PropertyManager->Tie("fcs/yaw-trim-cmd-norm", this, &FGFCS::GetYawTrimCmd, &FGFCS::SetYawTrimCmd);
-  PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd);
 
   PropertyManager->Tie("fcs/left-aileron-pos-rad", this, ofRad, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
   PropertyManager->Tie("fcs/left-aileron-pos-deg", this, ofDeg, &FGFCS::GetDaLPos, &FGFCS::SetDaLPos);
@@ -729,6 +710,11 @@ void FGFCS::bind(void)
   PropertyManager->Tie("fcs/mag-spoiler-pos-rad", this, ofMag, &FGFCS::GetDspPos);
 
   PropertyManager->Tie("gear/gear-pos-norm", this, &FGFCS::GetGearPos, &FGFCS::SetGearPos);
+  PropertyManager->Tie("gear/gear-cmd-norm", this, &FGFCS::GetGearCmd, &FGFCS::SetGearCmd);
+  PropertyManager->Tie("fcs/left-brake-cmd-norm", this, &FGFCS::GetLBrake, &FGFCS::SetLBrake);
+  PropertyManager->Tie("fcs/right-brake-cmd-norm", this, &FGFCS::GetRBrake, &FGFCS::SetRBrake);
+  PropertyManager->Tie("fcs/center-brake-cmd-norm", this, &FGFCS::GetCBrake, &FGFCS::SetCBrake);
+  PropertyManager->Tie("fcs/steer-cmd-norm", this, &FGFCS::GetDsCmd, &FGFCS::SetDsCmd);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 450d2b95100a0a5082e70799b6ef4854cb0448ff..10c582d1032705495fd2fbc70b63ce227718f011 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -501,6 +501,18 @@ public:
       @param bg which brakegroup to retrieve the command for
       @return the brake setting for the supplied brake group argument */
   double GetBrake(FGLGear::BrakeGroup bg);
+
+  /** Gets the left brake.
+      @return the left brake setting. */
+  double GetLBrake(void) const {return LeftBrake;}
+
+  /** Gets the right brake.
+      @return the right brake setting. */
+  double GetRBrake(void) const {return RightBrake;}
+
+  /** Gets the center brake.
+      @return the center brake setting. */
+  double GetCBrake(void) const {return CenterBrake;}
   //@}
 
   /** Loads the Flight Control System.
index 1ed71ab26eb6c051f60cfedfaa393476661769d2..a82a281a124372aefceb2ae368fae26d893d769f 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -142,26 +142,28 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter)
   std::ostringstream buf;
 
   for (unsigned int i=0;i<lGear.size();i++) {
-    string name = lGear[i].GetName();
-    buf << name << "_WOW" << delimeter
-        << name << "_stroke" << delimeter
-        << name << "_strokeVel" << delimeter
-        << name << "_CompressForce" << delimeter
-        << name << "_WhlSideForce" << delimeter
-        << name << "_WhlVelVecX" << delimeter
-        << name << "_WhlVelVecY" << delimeter
-        << name << "_WhlRollForce" << delimeter
-        << name << "_BodyXForce" << delimeter
-        << name << "_BodyYForce" << delimeter
-        << name << "_WhlSlipDegrees" << delimeter;
+    if (lGear[i].IsBogey()) {
+      string name = lGear[i].GetName();
+      buf << name << " WOW" << delimeter
+          << name << " stroke (ft)" << delimeter
+          << name << " stroke velocity (ft/sec)" << delimeter
+          << name << " compress force (lbs)" << delimeter
+          << name << " wheel side force (lbs)" << delimeter
+          << name << " wheel velocity vec X (ft/sec)" << delimeter
+          << name << " wheel velocity vec Y (ft/sec)" << delimeter
+          << name << " wheel roll force (lbs)" << delimeter
+          << name << " body X force (lbs)" << delimeter
+          << name << " body Y force (lbs)" << delimeter
+          << name << " wheel slip (deg)" << delimeter;
+    }
   }
 
-  buf << "TotalGearForce_X" << delimeter
-      << "TotalGearForce_Y" << delimeter
-      << "TotalGearForce_Z" << delimeter
-      << "TotalGearMoment_L" << delimeter
-      << "TotalGearMoment_M" << delimeter
-      << "TotalGearMoment_N";
+  buf << " Total Gear Force_X (lbs)" << delimeter
+      << " Total Gear Force_Y (lbs)" << delimeter
+      << " Total Gear Force_Z (lbs)" << delimeter
+      << " Total Gear Moment_L (ft-lbs)" << delimeter
+      << " Total Gear Moment_M (ft-lbs)" << delimeter
+      << " Total Gear Moment_N (ft-lbs)";
 
   return buf.str();
 }
@@ -173,18 +175,20 @@ string FGGroundReactions::GetGroundReactionValues(string delimeter)
   std::ostringstream buf;
 
   for (unsigned int i=0;i<lGear.size();i++) {
-    FGLGear& gear = lGear[i];
-    buf << (gear.GetWOW() ? "1, " : "0, ")
-        << setprecision(5) << gear.GetCompLen() << delimeter
-        << setprecision(6) << gear.GetCompVel() << delimeter
-        << setprecision(10) << gear.GetCompForce() << delimeter
-        << setprecision(6) << gear.GetWheelVel(eX) << delimeter
-        << gear.GetWheelVel(eY) << delimeter
-        << gear.GetWheelSideForce() << delimeter
-        << gear.GetWheelRollForce() << delimeter
-        << gear.GetBodyXForce() << delimeter
-        << gear.GetBodyYForce() << delimeter
-        << gear.GetWheelSlipAngle() << delimeter;
+    if (lGear[i].IsBogey()) {
+      FGLGear& gear = lGear[i];
+      buf << (gear.GetWOW() ? "1, " : "0, ")
+          << setprecision(5) << gear.GetCompLen() << delimeter
+          << setprecision(6) << gear.GetCompVel() << delimeter
+          << setprecision(10) << gear.GetCompForce() << delimeter
+          << setprecision(6) << gear.GetWheelVel(eX) << delimeter
+          << gear.GetWheelVel(eY) << delimeter
+          << gear.GetWheelSideForce() << delimeter
+          << gear.GetWheelRollForce() << delimeter
+          << gear.GetBodyXForce() << delimeter
+          << gear.GetBodyYForce() << delimeter
+          << gear.GetWheelSlipAngle() << delimeter;
+    }
   }
 
   buf << vForces(eX) << delimeter
index c67f546ebfc98f047d66ac6fdcebaf2d0db56c03..71d39e0e939b0d2f5ed7da1f3b4fbee43403191d 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -89,7 +89,7 @@ public:
   string GetGroundReactionValues(string delimeter);
   bool GetWOW(void);
 
-  inline int GetNumGearUnits(void) const { return lGear.size(); }
+  int GetNumGearUnits(void) const { return lGear.size(); }
 
   /** Gets a gear instance
       @param gear index of gear instance
@@ -103,8 +103,6 @@ private:
   vector <FGLGear> lGear;
   FGColumnVector3 vForces;
   FGColumnVector3 vMoments;
-  FGColumnVector3 vMaxStaticGrip;
-  FGColumnVector3 vMaxMomentResist;
 
   void Debug(int from);
 };
index c86ba673a06ab6b7709636ace759357842989a94..e18098a44aaa2396c3c1c523076dfac3d3ab9c44 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 9433af1a6e31b24d64c5ef519123fc19c2e81e01..72c7864c17dfb45b96b29552b0d449b6d2b349d7 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 363c34569bb8ea2011521b1beab7913d30159424..9f20531a303cf247478c0317b106a9b07235432e 100755 (executable)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -69,8 +69,7 @@ FGInput::FGInput(FGFDMExec* fdmex) : FGModel(fdmex)
 
 FGInput::~FGInput()
 {
-  if (socket) delete socket;
-
+  delete socket;
   Debug(1);
 }
 
@@ -89,7 +88,8 @@ bool FGInput::Run(void)
   FGPropertyManager* node=0;
 
   if (FGModel::Run()) return true; // fast exit if nothing to do
-  if (port == 0) return true; // Do nothing here if port not defined
+  if (port == 0) return false;      // Do nothing here if port not defined
+                                    // return false if no error
   // This model DOES execute if "Exec->Holding"
 
   data = socket->Receive(); // get socket transmission if present
index 071b48a01595e2c1a50f67d788a49f711d2cd818..4ef5dad11f27de57251e9fc53828b8262696ce88 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 6f3d6f2fadd5086c580d50bf1aac72d826450b58..dc0c1b98b8f00a907906905782d796ff955112d1 100644 (file)
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -135,6 +135,40 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
          << sSteerType << " is undefined." << endl;
   }
 
+  RFRV = 0.7;  // Rolling force relaxation velocity, default value
+  SFRV = 0.7;  // Side force relaxation velocity, default value
+
+  Element* relax_vel = el->FindElement("relaxation_velocity");
+  if (relax_vel) {
+    if (relax_vel->FindElement("rolling")) {
+      RFRV = relax_vel->FindElementValueAsNumberConvertTo("rolling", "FT/SEC");
+    }
+    if (relax_vel->FindElement("side")) {
+      SFRV = relax_vel->FindElementValueAsNumberConvertTo("side", "FT/SEC");
+    }
+  }
+
+  State = Exec->GetState();
+  LongForceLagFilterCoeff = 1/State->Getdt(); // default longitudinal force filter coefficient
+  LatForceLagFilterCoeff  = 1/State->Getdt(); // default lateral force filter coefficient
+
+  Element* force_lag_filter_elem = el->FindElement("force_lag_filter");
+  if (force_lag_filter_elem) {
+    if (force_lag_filter_elem->FindElement("rolling")) {
+      LongForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("rolling");
+    }
+    if (force_lag_filter_elem->FindElement("side")) {
+      LatForceLagFilterCoeff = force_lag_filter_elem->FindElementValueAsNumber("side");
+    }
+  }
+
+  WheelSlipLagFilterCoeff = 1/State->Getdt();
+
+  Element *wheel_slip_angle_lag_elem = el->FindElement("wheel_slip_filter");
+  if (wheel_slip_angle_lag_elem) {
+    WheelSlipLagFilterCoeff = wheel_slip_angle_lag_elem->GetDataAsNumber();
+  }
+  
   GearUp = false;
   GearDown = true;
   Servicable = true;
@@ -168,8 +202,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number) : Exec(fdmex),
   brakePct        = 0.0;
   maxCompLen      = 0.0;
 
-  WheelSlip = last_WheelSlip = 0.0;
-  slipIn = last_SlipIn = 0;
+  WheelSlip = 0.0;
   TirePressureNorm = 1.0;
 
   Debug(0);
@@ -237,12 +270,15 @@ FGLGear::FGLGear(const FGLGear& lgear)
   ForceY_Table    = lgear.ForceY_Table;
   CosWheel        = lgear.CosWheel;
   SinWheel        = lgear.SinWheel;
-  In              = lgear.In;
-  prevIn          = lgear.prevIn;
   prevOut         = lgear.prevOut;
-  slipIn          = lgear.slipIn;
-  last_SlipIn     = lgear.last_SlipIn;
-  last_WheelSlip  = lgear.last_WheelSlip;
+  prevIn          = lgear.prevIn;
+  prevSlipIn      = lgear.prevSlipIn;
+  prevSlipOut     = lgear.prevSlipOut;
+  RFRV            = lgear.RFRV;
+  SFRV            = lgear.SFRV;
+  LongForceLagFilterCoeff = lgear.LongForceLagFilterCoeff;
+  LatForceLagFilterCoeff = lgear.LatForceLagFilterCoeff;
+  WheelSlipLagFilterCoeff = lgear.WheelSlipLagFilterCoeff;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -259,6 +295,7 @@ FGColumnVector3& FGLGear::Force(void)
   FGColumnVector3 normal, cvel;
   FGLocation contact, gearLoc;
   double t = Exec->GetState()->Getsim_time();
+  dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
 
   vForce.InitMatrix();
   vMoment.InitMatrix();
@@ -308,20 +345,42 @@ FGColumnVector3& FGLGear::Force(void)
 
     vForce  = Propagate->GetTl2b() * vLocalForce;
 
-    // Lag and attenuate the XY-plane forces dependent on velocity
+// Start experimental section for gear jitter reduction
+//
+// Lag and attenuate the XY-plane forces dependent on velocity
+
+    double ca, cb, denom;
+    FGColumnVector3 Output;
+
+// This code implements a lag filter, C/(s + C) where
+// "C" is the filter coefficient. When "C" is chosen at the 
+// frame rate (in Hz), the jittering is significantly reduced. This is because
+// the jitter is present *at* the execution rate.
+// If a coefficient is set to something equal to or less than zero, the filter
+// is bypassed.
+
+    if (LongForceLagFilterCoeff > 0) { 
+      denom = 2.00 + dT*LongForceLagFilterCoeff;
+      ca = dT*LongForceLagFilterCoeff / denom;
+      cb = (2.00 - dT*LongForceLagFilterCoeff) / denom;
+      Output(eX) = vForce(eX) * ca + prevIn(eX) * ca + prevOut(eX) * cb;
+      vForce(eX) = Output(eX);
+    }
+    if (LatForceLagFilterCoeff > 0) { 
+      denom = 2.00 + dT*LatForceLagFilterCoeff;
+      ca = dT*LatForceLagFilterCoeff / denom;
+      cb = (2.00 - dT*LatForceLagFilterCoeff) / denom;
+      Output(eY) = vForce(eY) * ca + prevIn(eY) * ca + prevOut(eY) * cb;
+      vForce(eY) = Output(eY);
+    }
 
-    double RFRV = 0.015; // Rolling force relaxation velocity
-    double SFRV = 0.25;  // Side force relaxation velocity
-    double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
+    prevIn = vForce;
+    prevOut = Output;
 
-    In = vForce;
-    vForce(eX) = (0.25)*(In(eX) + prevIn(eX)) + (0.50)*prevOut(eX);
-    vForce(eY) = (0.15)*(In(eY) + prevIn(eY)) + (0.70)*prevOut(eY);
-    prevOut = vForce;
-    prevIn = In;
+    if ((fabs(RollingWhlVel) <= RFRV) && RFRV > 0) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
+    if ((fabs(SideWhlVel) <= SFRV) && SFRV > 0) vForce(eY) *= fabs(SideWhlVel)/SFRV;
 
-    if (fabs(RollingWhlVel) <= RFRV) vForce(eX) *= fabs(RollingWhlVel)/RFRV;
-    if (fabs(SideWhlVel) <= SFRV) vForce(eY) *= fabs(SideWhlVel)/SFRV;
+// End experimental section for attentuating gear jitter
 
     vMoment = vWhlBodyVec * vForce;
 
@@ -362,24 +421,31 @@ void FGLGear::ComputeRetractionState(void)
 
 void FGLGear::ComputeSlipAngle(void)
 {
-  double dT = State->Getdt()*Exec->GetGroundReactions()->GetRate();
-
   // Transform the wheel velocities from the local axis system to the wheel axis system.
-
   RollingWhlVel = vWhlVelVec(eX)*CosWheel + vWhlVelVec(eY)*SinWheel;
   SideWhlVel    = vWhlVelVec(eY)*CosWheel - vWhlVelVec(eX)*SinWheel;
 
   // Calculate tire slip angle.
-
-  if (fabs(RollingWhlVel) < 0.1 && fabs(SideWhlVel) < 0.01) {
+  if (fabs(RollingWhlVel) < 0.02 && fabs(SideWhlVel) < 0.02) {
     WheelSlip = -SteerAngle*radtodeg;
   } else {
     WheelSlip = atan2(SideWhlVel, fabs(RollingWhlVel))*radtodeg;
   }
-  slipIn = WheelSlip;
-  WheelSlip = (0.46)*(slipIn + last_SlipIn) + (0.08)*last_WheelSlip;
-  last_WheelSlip = WheelSlip;
-  last_SlipIn = slipIn;
+
+// Filter the wheel slip angle
+
+  double SlipOutput, ca, cb, denom;
+
+  if (WheelSlipLagFilterCoeff > 0) {
+    denom = 2.00 + dT*WheelSlipLagFilterCoeff;
+    ca = dT*WheelSlipLagFilterCoeff / denom;
+    cb = (2.00 - dT*WheelSlipLagFilterCoeff) / denom;
+
+    SlipOutput = ca * (WheelSlip + prevSlipIn) + cb * prevSlipOut;
+
+    prevSlipIn = WheelSlip;
+    WheelSlip = prevSlipOut = SlipOutput;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -484,10 +550,10 @@ void FGLGear::ReportTakeoffOrLanding(void)
 
 void FGLGear::CrashDetect(void)
 {
-  if (compressLength > 500.0 ||
+  if ( (compressLength > 500.0 ||
       vForce.Magnitude() > 100000000.0 ||
       vMoment.Magnitude() > 5000000000.0 ||
-      SinkRate > 1.4666*30)
+      SinkRate > 1.4666*30 ) && !State->IntegrationSuspended())
   {
     PutMessage("Crash Detected: Simulation FREEZE.");
     State->SuspendIntegration();
@@ -670,6 +736,9 @@ void FGLGear::Debug(int from)
         cout << "      Grouping:         " << sBrakeGroup   << endl;
         cout << "      Max Steer Angle:  " << maxSteerAngle << endl;
         cout << "      Retractable:      " << isRetractable  << endl;
+        cout << "      Relaxation Velocities:" << endl;
+        cout << "        Rolling:          " << RFRV << endl;
+        cout << "        Side:             " << SFRV << endl;
       }
     }
   }
index 95b1d11d27a351a642fb3cab9f43f704ca97dd32..e35d2b7c40fc78bdba0fe656b8bf7c5fe986d008 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -264,10 +264,9 @@ private:
   FGColumnVector3 last_vForce; // remove this
   FGColumnVector3 vLocalForce;
   FGColumnVector3 vWhlVelVec;     // Velocity of this wheel (Local)
-  FGColumnVector3 In;
-  FGColumnVector3 prevIn;
-  FGColumnVector3 prevOut;
+  FGColumnVector3 prevOut, prevIn;
   FGTable *ForceY_Table;
+  double dT;
   double SteerAngle;
   double kSpring;
   double bDamp;
@@ -288,9 +287,8 @@ private:
   double SideWhlVel, RollingWhlVel;
   double RollingForce, SideForce, FCoeff;
   double WheelSlip;
-  double last_WheelSlip;
-  double slipIn;
-  double last_SlipIn;
+  double prevSlipIn;
+  double prevSlipOut;
   double TirePressureNorm;
   double SinWheel, CosWheel;
   bool WOW;
@@ -312,6 +310,11 @@ private:
   BrakeGroup eBrakeGrp;
   SteerType  eSteerType;
   double  maxSteerAngle;
+  double RFRV;  // Rolling force relaxation velocity
+  double SFRV;  // Side force relaxation velocity
+  double LongForceLagFilterCoeff; // Longitudinal Force Lag Filter Coefficient
+  double LatForceLagFilterCoeff; // Lateral Force Lag Filter Coefficient
+  double WheelSlipLagFilterCoeff; // Wheel slip angle lag filter coefficient
 
   FGFDMExec*     Exec;
   FGState*       State;
index 73892ba614325f8d5ec4c233701d254e4dd78d6c..e5a868f8320d8737c11e476b6c8fb38c1a92025a 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -139,7 +139,6 @@ bool FGMassBalance::Run(void)
 
 // Calculate new CG
 
-//  printf("%s:%i\n", __FILE__, __LINE__);
   vXYZcg = (Propulsion->GetTanksMoment() + EmptyWeight*vbaseXYZcg
                                      + GetPointMassMoment() ) / Weight;
 
@@ -189,19 +188,14 @@ void FGMassBalance::AddPointMass(Element* el)
 {
   Element* loc_element = el->FindElement("location");
   string pointmass_name = el->GetAttributeValue("name");
-  if (!el) {
-    cerr << "Pointmass " << pointmass_name << "has no location." << endl;
+  if (!loc_element) {
+    cerr << "Pointmass " << pointmass_name << " has no location." << endl;
     exit(-1);
   }
-  string loc_unit = loc_element->GetAttributeValue("unit");
-  double w, x, y, z;
 
-  w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
-  x = loc_element->FindElementValueAsNumberConvertTo("x", loc_unit);
-  y = loc_element->FindElementValueAsNumberConvertTo("y", loc_unit);
-  z = loc_element->FindElementValueAsNumberConvertTo("z", loc_unit);
-
-  PointMasses.push_back(PointMass(w, x, y, z));
+  double w = el->FindElementValueAsNumberConvertTo("weight", "LBS");
+  FGColumnVector3 vXYZ = loc_element->FindElementTripletConvertTo("IN");
+  PointMasses.push_back(PointMass(w, vXYZ));
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index e1cfb4877b1a4cf7951e93729723bccf7ee6a33c..13f1aa9b370a003854e5efb120a29475c88e3010 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -146,9 +146,9 @@ private:
   FGMatrix33& CalculatePMInertias(void);
 
   struct PointMass {
-    PointMass(double w, double x, double y, double z) {
+    PointMass(double w, FGColumnVector3& vXYZ) {
       Weight = w;
-      Location.InitMatrix(x, y, z);
+      Location = vXYZ;
     }
     FGColumnVector3 Location;
     double Weight;
index 53f2500fcbcb5546e2f7fdfe788b9b7c7fa5fc14..778d2b3a37717d900eb61581d4ddaa8da704f31f 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -136,13 +136,10 @@ bool FGModel::Run()
 {
   if (debug_lvl & 4) cout << "Entering Run() for model " << Name << endl;
 
-  if (exe_ctr == 1) {
-    if (exe_ctr++ >= rate) exe_ctr = 1;
-    return false;
-  } else {
-    if (exe_ctr++ >= rate) exe_ctr = 1;
-    return true;
-  }
+  if (exe_ctr++ >= rate) exe_ctr = 1;
+
+  if (exe_ctr == 1) return false;
+  else              return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index d1907e3c20737de0d4e03dfea8ca73c6a8c29bf3..4d0f8b7f261f78515df373b1194dfce390abb55c 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 4f1e6694f4eedb677e7e4db7645cb3330ea07e27..39be607d5b62ca47ca7e3eeaa5789c29a15387cd 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -73,6 +73,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
   enabled = true;
   delimeter = ", ";
   Filename = "";
+  DirectivesFile = "";
 
   Debug(0);
 }
@@ -81,9 +82,8 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
 
 FGOutput::~FGOutput()
 {
-  if (socket) delete socket;
+  delete socket;
   OutputProperties.clear();
-
   Debug(1);
 }
 
@@ -152,70 +152,70 @@ void FGOutput::DelimitedOutput(string fname)
     }
     if (SubSystems & ssAerosurfaces) {
       outstream << delimeter;
-      outstream << "Aileron Cmd" + delimeter;
-      outstream << "Elevator Cmd" + delimeter;
-      outstream << "Rudder Cmd" + delimeter;
-      outstream << "Flap Cmd" + delimeter;
-      outstream << "Left Aileron Pos" + delimeter;
-      outstream << "Right Aileron Pos" + delimeter;
-      outstream << "Elevator Pos" + delimeter;
-      outstream << "Rudder Pos" + delimeter;
-      outstream << "Flap Pos";
+      outstream << "Aileron Command (norm)" + delimeter;
+      outstream << "Elevator Command (norm)" + delimeter;
+      outstream << "Rudder Command (norm)" + delimeter;
+      outstream << "Flap Command (norm)" + delimeter;
+      outstream << "Left Aileron Position (deg)" + delimeter;
+      outstream << "Right Aileron Position (deg)" + delimeter;
+      outstream << "Elevator Position (deg)" + delimeter;
+      outstream << "Rudder Position (deg)" + delimeter;
+      outstream << "Flap Position (deg)";
     }
     if (SubSystems & ssRates) {
       outstream << delimeter;
-      outstream << "P" + delimeter + "Q" + delimeter + "R" + delimeter;
-      outstream << "Pdot" + delimeter + "Qdot" + delimeter + "Rdot";
+      outstream << "P (deg/s)" + delimeter + "Q (deg/s)" + delimeter + "R (deg/s)" + delimeter;
+      outstream << "P dot (deg/s^2)" + delimeter + "Q dot (deg/s^2)" + delimeter + "R dot (deg/s^2)";
     }
     if (SubSystems & ssVelocities) {
       outstream << delimeter;
-      outstream << "QBar" + delimeter;
-      outstream << "Vtotal" + delimeter;
+      outstream << "q bar (psf)" + delimeter;
+      outstream << "V_{Total} (ft/s)" + delimeter;
       outstream << "UBody" + delimeter + "VBody" + delimeter + "WBody" + delimeter;
-      outstream << "UAero" + delimeter + "VAero" + delimeter + "WAero" + delimeter;
-      outstream << "Vn" + delimeter + "Ve" + delimeter + "Vd";
+      outstream << "Aero V_{X Body} (ft/s)" + delimeter + "Aero V_{Y Body} (ft/s)" + delimeter + "Aero V_{Z Body} (ft/s)" + delimeter;
+      outstream << "V_{North} (ft/s)" + delimeter + "V_{East} (ft/s)" + delimeter + "V_{Down} (ft/s)";
     }
     if (SubSystems & ssForces) {
       outstream << delimeter;
-      outstream << "Drag" + delimeter + "Side" + delimeter + "Lift" + delimeter;
+      outstream << "F_{Drag} (lbs)" + delimeter + "F_{Side} (lbs)" + delimeter + "F_{Lift} (lbs)" + delimeter;
       outstream << "L/D" + delimeter;
-      outstream << "Xforce" + delimeter + "Yforce" + delimeter + "Zforce";
+      outstream << "F_X (lbs)" + delimeter + "F_Y (lbs)" + delimeter + "F_Z (lbs)";
     }
     if (SubSystems & ssMoments) {
       outstream << delimeter;
-      outstream << "L" + delimeter + "M" + delimeter + "N";
+      outstream << "L (ft-lbs)" + delimeter + "M (ft-lbs)" + delimeter + "N (ft-lbs)";
     }
     if (SubSystems & ssAtmosphere) {
       outstream << delimeter;
-      outstream << "Rho" + delimeter;
-      outstream << "SL pressure" + delimeter;
-      outstream << "Ambient pressure" + delimeter;
-      outstream << "NWind" + delimeter + "EWind" + delimeter + "DWind";
+      outstream << "Rho (slugs/ft^3)" + delimeter;
+      outstream << "P_{SL} (psf)" + delimeter;
+      outstream << "P_{Ambient} (psf)" + delimeter;
+      outstream << "Wind V_{North} (ft/s)" + delimeter + "Wind V_{East} (ft/s)" + delimeter + "Wind V_{Down} (ft/s)";
     }
     if (SubSystems & ssMassProps) {
       outstream << delimeter;
-      outstream << "Ixx" + delimeter;
-      outstream << "Ixy" + delimeter;
-      outstream << "Ixz" + delimeter;
-      outstream << "Iyx" + delimeter;
-      outstream << "Iyy" + delimeter;
-      outstream << "Iyz" + delimeter;
-      outstream << "Izx" + delimeter;
-      outstream << "Izy" + delimeter;
-      outstream << "Izz" + delimeter;
+      outstream << "I_xx" + delimeter;
+      outstream << "I_xy" + delimeter;
+      outstream << "I_xz" + delimeter;
+      outstream << "I_yx" + delimeter;
+      outstream << "I_yy" + delimeter;
+      outstream << "I_yz" + delimeter;
+      outstream << "I_zx" + delimeter;
+      outstream << "I_zy" + delimeter;
+      outstream << "I_zz" + delimeter;
       outstream << "Mass" + delimeter;
-      outstream << "Xcg" + delimeter + "Ycg" + delimeter + "Zcg";
+      outstream << "X_cg" + delimeter + "Y_cg" + delimeter + "Z_cg";
     }
     if (SubSystems & ssPropagate) {
       outstream << delimeter;
-      outstream << "Altitude" + delimeter;
-      outstream << "Phi" + delimeter + "Tht" + delimeter + "Psi" + delimeter;
-      outstream << "Alpha" + delimeter;
-      outstream << "Beta" + delimeter;
-      outstream << "Latitude (Deg)" + delimeter;
-      outstream << "Longitude (Deg)" + delimeter;
-      outstream << "Distance AGL" + delimeter;
-      outstream << "Runway Radius";
+      outstream << "Altitude (ft)" + delimeter;
+      outstream << "Phi (deg)" + delimeter + "Theta (deg)" + delimeter + "Psi (deg)" + delimeter;
+      outstream << "Alpha (deg)" + delimeter;
+      outstream << "Beta (deg)" + delimeter;
+      outstream << "Latitude (deg)" + delimeter;
+      outstream << "Longitude (deg)" + delimeter;
+      outstream << "Distance AGL (ft)" + delimeter;
+      outstream << "Runway Radius (ft)";
     }
     if (SubSystems & ssCoefficients) {
       scratch = Aerodynamics->GetCoefficientStrings(delimeter);
@@ -252,11 +252,11 @@ void FGOutput::DelimitedOutput(string fname)
     outstream << FCS->GetDeCmd() << delimeter;
     outstream << FCS->GetDrCmd() << delimeter;
     outstream << FCS->GetDfCmd() << delimeter;
-    outstream << FCS->GetDaLPos() << delimeter;
-    outstream << FCS->GetDaRPos() << delimeter;
-    outstream << FCS->GetDePos() << delimeter;
-    outstream << FCS->GetDrPos() << delimeter;
-    outstream << FCS->GetDfPos();
+    outstream << FCS->GetDaLPos(ofDeg) << delimeter;
+    outstream << FCS->GetDaRPos(ofDeg) << delimeter;
+    outstream << FCS->GetDePos(ofDeg) << delimeter;
+    outstream << FCS->GetDrPos(ofDeg) << delimeter;
+    outstream << FCS->GetDfPos(ofDeg);
   }
   if (SubSystems & ssRates) {
     outstream << delimeter;
@@ -583,14 +583,28 @@ bool FGOutput::Load(Element* element)
   separator = ";";
 # endif
 
-  fname = element->GetAttributeValue("file");
-  if (!fname.empty()) {
-    output_file_name = FDMExec->GetAircraftPath() + separator
-                        + FDMExec->GetModelName() + separator + fname + ".xml";
+  if (!DirectivesFile.empty()) { // A directives filename from the command line overrides
+    fname = DirectivesFile;      // one found in the config file.
+  } else {
+    fname = element->GetAttributeValue("file");
+  }
 
+  if (!fname.empty()) {
+    int len = fname.size();
+    if (fname.find(".xml") != string::npos) {
+      output_file_name = fname; // Use supplied name if last four letters are ".xml"
+    } else {
+      output_file_name = FDMExec->GetFullAircraftPath() + separator + fname + ".xml";
+    }
     output_file->open(output_file_name.c_str());
-    readXML(*output_file, output_file_parser);
-    delete output_file;
+    if (output_file->is_open()) {
+      readXML(*output_file, output_file_parser);
+      delete output_file;
+    } else {
+      delete output_file;
+      cerr << "Could not open directives file: " << output_file_name << endl;
+      return false;
+    }
     document = output_file_parser.GetDocument();
   } else {
     document = element;
@@ -644,7 +658,7 @@ bool FGOutput::Load(Element* element)
     property_element = document->FindNextElement("property");
   }
 
-  OutRate = OutRate>120?120:(OutRate<0?0:OutRate);
+  OutRate = OutRate>1000?1000:(OutRate<0?0:OutRate);
   rate = (int)(0.5 + 1.0/(State->Getdt()*OutRate));
 
   Debug(2);
@@ -694,7 +708,7 @@ void FGOutput::Debug(int from)
       }
       switch (Type) {
       case otCSV:
-        cout << scratch << " in CSV format output at rate " << 120/rate << " Hz" << endl;
+        cout << scratch << " in CSV format output at rate " << 1/(State->Getdt()*rate) << " Hz" << endl;
         break;
       case otNone:
         cout << "  No log output" << endl;
index 35bc338d4e2b9323cdb387ed9c78f43c77f34a0f..7126624a24ba5e9fc84c75b024bd444e56d7126e 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -140,6 +140,9 @@ public:
   inline void Disable(void) { enabled = false; }
   inline bool Toggle(void) {enabled = !enabled; return enabled;}
   bool Load(Element* el);
+  void SetOutputFileName(string fname) {Filename = fname;}
+  void SetDirectivesFile(string fname) {DirectivesFile = fname;}
+  string GetOutputFileName(void) const {return Filename;}
 
   /// Subsystem types for specifying which will be output in the FDM data logging
   enum  eSubSystems {
@@ -159,13 +162,14 @@ public:
   } subsystems;
 
 private:
+  enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
   bool sFirstPass, dFirstPass, enabled;
   int SubSystems;
-  string output_file_name, delimeter, Filename;
-  enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
+  string output_file_name, delimeter, Filename, DirectivesFile;
   ofstream datafile;
   FGfdmSocket* socket;
   vector <FGPropertyManager*> OutputProperties;
+
   void Debug(int from);
 };
 }
index fcd7861bf31e3e3003bcc8365ccf9af6b8b6cf37..db2ff3f92589bf7c7424dd4325edf80eb57fa07e 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -96,6 +96,7 @@ CLASS IMPLEMENTATION
 FGPropagate::FGPropagate(FGFDMExec* fdmex) : FGModel(fdmex)
 {
   Name = "FGPropagate";
+//  vQtrndot.zero();
 
   bind();
   Debug(0);
@@ -231,22 +232,58 @@ bool FGPropagate::Run(void)
   vUVWdot += Tl2b*gAccel;
 
   // Compute vehicle velocity wrt EC frame, expressed in EC frame
-  FGColumnVector3 vLocationDot = Tl2ec * vVel;
+  vLocationDot = Tl2ec * vVel;
 
   FGColumnVector3 omegaLocal( rInv*vVel(eEast),
                               -rInv*vVel(eNorth),
                               -rInv*vVel(eEast)*VState.vLocation.GetTanLatitude() );
 
   // Compute quaternion orientation derivative on current body rates
-  FGQuaternion vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal );
+  vQtrndot = VState.vQtrn.GetQDot( VState.vPQR - Tl2b*omegaLocal );
 
-  // Propagate velocities
-  VState.vPQR += dt*vPQRdot;
-  VState.vUVW += dt*vUVWdot;
+  // Integrate to propagate the state
 
-  // Propagate positions
-  VState.vQtrn += dt*vQtrndot;
-  VState.vLocation += dt*vLocationDot;
+  // Propagate rotational velocity
+
+  // VState.vPQR += dt*(1.5*vPQRdot - 0.5*last_vPQRdot); // Adams-Bashforth
+  VState.vPQR += (1/12.0)*dt*(23.0*vPQRdot - 16.0*last_vPQRdot + 5.0*last2_vPQRdot); // Adams-Bashforth 3
+  // VState.vPQR += dt*vPQRdot;                          // Rectangular Euler
+  // VState.vPQR += 0.5*dt*(vPQRdot + last_vPQRdot);     // Trapezoidal
+
+  // Propagate translational velocity
+
+  // VState.vUVW += dt*(1.5*vUVWdot - 0.5*last_vUVWdot); // Adams Bashforth
+  VState.vUVW += (1/12.0)*dt*(23.0*vUVWdot - 16.0*last_vUVWdot + 5.0*last2_vUVWdot); // Adams-Bashforth 3
+  // VState.vUVW += dt*vUVWdot;                         // Rectangular Euler
+  // VState.vUVW += 0.5*dt*(vUVWdot + last_vUVWdot);    // Trapezoidal
+
+  // Propagate angular position
+
+  // VState.vQtrn += dt*(1.5*vQtrndot - 0.5*last_vQtrndot); // Adams Bashforth
+  VState.vQtrn += (1/12.0)*dt*(23.0*vQtrndot - 16.0*last_vQtrndot + 5.0*last2_vQtrndot); // Adams-Bashforth 3
+  // VState.vQtrn += dt*vQtrndot;                           // Rectangular Euler
+  // VState.vQtrn += 0.5*dt*(vQtrndot + last_vQtrndot);     // Trapezoidal
+
+  // Propagate translational position
+
+  // VState.vLocation += dt*(1.5*vLocationDot - 0.5*last_vLocationDot); // Adams Bashforth
+  VState.vLocation += (1/12.0)*dt*(23.0*vLocationDot - 16.0*last_vLocationDot + 5.0*last2_vLocationDot); // Adams-Bashforth 3
+  // VState.vLocation += dt*vLocationDot;                               // Rectangular Euler
+  // VState.vLocation += 0.5*dt*(vLocationDot + last_vLocationDot);     // Trapezoidal
+
+  // Set past values
+  
+  last2_vPQRdot = last_vPQRdot;
+  last_vPQRdot = vPQRdot;
+  
+  last2_vUVWdot = last_vUVWdot;
+  last_vUVWdot = vUVWdot;
+  
+  last2_vQtrndot = last_vQtrndot;
+  last_vQtrndot = vQtrndot;
+
+  last2_vLocationDot = last_vLocationDot;
+  last_vLocationDot = vLocationDot;
 
   return false;
 }
index 2c0fef1d47394cd6481c5a7875e49623493b2d93..a554a9cb2847b28db7eaaafd54c0df2682fc77e4 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -154,9 +154,11 @@ private:
   struct VehicleState VState;
 
   FGColumnVector3 vVel;
-  FGColumnVector3 vPQRdot;
-  FGColumnVector3 vUVWdot;
-
+  FGColumnVector3 vPQRdot, last_vPQRdot, last2_vPQRdot;
+  FGColumnVector3 vUVWdot, last_vUVWdot, last2_vUVWdot;
+  FGColumnVector3 vLocationDot, last_vLocationDot, last2_vLocationDot;
+  FGQuaternion vQtrndot, last_vQtrndot, last2_vQtrndot;
+  
   double RunwayRadius, SeaLevelRadius;
 
   void Debug(int from);
index 306126ccac78ad3aa6a11ae47d6ef799b54eb413..35f420a5bc38632fabb030ba44e32b9b186db615 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -124,7 +124,7 @@ bool FGPropulsion::Run(void)
     Tanks[i]->Calculate( dt * rate );
     if (Tanks[i]->GetType() == FGTank::ttFUEL) {
       TotalFuelQuantity += Tanks[i]->GetContents();
-    } 
+    }
   }
 
   if (refuel) DoRefuel( dt * rate );
@@ -282,7 +282,7 @@ string FGPropulsion::FindEngineFullPathname(string engine_filename)
 {
   string fullpath, localpath;
   string enginePath = FDMExec->GetEnginePath();
-  string aircraftPath = FDMExec->GetAircraftPath();
+  string aircraftPath = FDMExec->GetFullAircraftPath();
   ifstream* engine_file = new ifstream();
 
   string separator = "/";
@@ -313,7 +313,7 @@ ifstream* FGPropulsion::FindEngineFile(string engine_filename)
 {
   string fullpath, localpath;
   string enginePath = FDMExec->GetEnginePath();
-  string aircraftPath = FDMExec->GetAircraftPath();
+  string aircraftPath = FDMExec->GetFullAircraftPath();
   ifstream* engine_file = new ifstream();
 
   string separator = "/";
@@ -572,6 +572,8 @@ void FGPropulsion::bind(void)
 
 void FGPropulsion::unbind(void)
 {
+  if (!IsBound) return;
+
   if (HaveTurbineEngine) {
     PropertyManager->Untie("propulsion/starter_cmd");
     PropertyManager->Untie("propulsion/cutoff_cmd");
index 6ae3324ac011fdbc4feb9215ce021878b55b1709..e25f46fd13b503d2164b1984b895dd9cfc32e132 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -119,7 +119,7 @@ public:
   bool Load(Element* el);
 
   /// Retrieves the number of engines defined for the aircraft.
-  inline unsigned int GetNumEngines(void) const {return Engines.size();}
+  inline unsigned int GetNumEngines(void) const {return (unsigned int)Engines.size();}
 
   /** Retrieves an engine object pointer from the list of engines.
       @param index the engine index within the vector container
@@ -130,7 +130,7 @@ public:
                       else                           return 0L;      }
 
   /// Retrieves the number of tanks defined for the aircraft.
-  inline unsigned int GetNumTanks(void) const {return Tanks.size();}
+  inline unsigned int GetNumTanks(void) const {return (unsigned int)Tanks.size();}
 
   /** Retrieves a tank object pointer from the list of tanks.
       @param index the tank index within the vector container
index 38f7dd7bea33a236cac7793af9ceb307b4680716..7fe318209507206df7e02b622404b1ebf6663793 100755 (executable)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 2003  David P. Culp (davidculp2@comcast.net) ------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 8f2b65293da04e7bce9cc954427d6acfe10263da..f9ced1eaf17df3ca9e31ebce9d2fbd4180f9dec4 100755 (executable)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2003  David P. Culp (davidculp2@comcast.net) ------
  
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
  
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
  
 HISTORY
index 2f9eec4166a3024d05e1afa4b12b7722a20e81d2..414f1ef530e463d52733fc410e3d249441c74a7d 100755 (executable)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 2004  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 9ec3bb85603ed81d8605d14299e73c9989d1134d..279f771b0294140c14a30330d0afa66626fcba64 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2004  Jon S. Berndt (jsb@hal-pc.org) -------------
  
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
  
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
  
 HISTORY
diff --git a/src/FDM/JSBSim/models/flight_control/FGCondition.cpp b/src/FDM/JSBSim/models/flight_control/FGCondition.cpp
deleted file mode 100644 (file)
index 21adb3a..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Module:       FGCondition.cpp
- Author:       Jon S. Berndt
- Date started: 1/2/2003
-
- -------------- Copyright (C) 2003 Jon S. Berndt (jsb@hal-pc.org) --------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU 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 General Public License for more
- details.
-
- You should have received a copy of the GNU 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 General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES,  and NOTES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include "FGCondition.h"
-
-namespace JSBSim {
-
-static const char *IdSrc = "$Id$";
-static const char *IdHdr = ID_CONDITION;
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS IMPLEMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-string FGCondition::indent = "        ";
-
-
-FGCondition::FGCondition(Element* element, FGPropertyManager* PropertyManager) :
-  PropertyManager(PropertyManager), isGroup(true)
-{
-  string property1, property2, logic;
-  Element* condition_element;
-
-  InitializeConditionals();
-
-  TestParam1  = TestParam2 = 0L;
-  TestValue   = 0.0;
-  Comparison  = ecUndef;
-  Logic       = elUndef;
-  conditions.clear();
-
-  logic = element->GetAttributeValue("logic");
-  if (logic == "OR") Logic = eOR;
-  else if (logic == "AND") Logic = eAND;
-  else { // error
-    cerr << "Unrecognized LOGIC token " << logic << " in switch component: " << logic << endl;
-  }
-  condition_element = element->GetElement();
-  while (condition_element) {
-    conditions.push_back(FGCondition(condition_element, PropertyManager));
-    condition_element = element->GetNextElement();
-  }
-  for (int i=0; i<element->GetNumDataLines(); i++) {
-    conditions.push_back(FGCondition(element->GetDataLine(i), PropertyManager));
-  }
-
-  Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGCondition::FGCondition(string test, FGPropertyManager* PropertyManager) :
-  PropertyManager(PropertyManager), isGroup(false)
-{
-  string property1, property2, compare_string;
-  Element* condition_element;
-
-  InitializeConditionals();
-
-  TestParam1  = TestParam2 = 0L;
-  TestValue   = 0.0;
-  Comparison  = ecUndef;
-  Logic       = elUndef;
-  conditions.clear();
-
-  int start = 0, end = 0;
-  start = test.find_first_not_of(" ");
-  end = test.find_first_of(" ", start+1);
-  property1 = test.substr(start,end-start);
-  start = test.find_first_not_of(" ",end);
-  end = test.find_first_of(" ",start+1);
-  conditional = test.substr(start,end-start);
-  start = test.find_first_not_of(" ",end);
-  end = test.find_first_of(" ",start+1);
-  property2 = test.substr(start,end-start);
-
-  TestParam1 = PropertyManager->GetNode(property1, true);
-  Comparison = mComparison[conditional];
-  if (property2.find_first_not_of("-.0123456789eE") == string::npos) {
-    TestValue = atof(property2.c_str());
-  } else {
-    TestParam2 = PropertyManager->GetNode(property2, true);
-  }
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGCondition::InitializeConditionals(void)
-{
-  mComparison["EQ"] = eEQ;
-  mComparison["NE"] = eNE;
-  mComparison["GT"] = eGT;
-  mComparison["GE"] = eGE;
-  mComparison["LT"] = eLT;
-  mComparison["LE"] = eLE;
-  mComparison["eq"] = eEQ;
-  mComparison["ne"] = eNE;
-  mComparison["gt"] = eGT;
-  mComparison["ge"] = eGE;
-  mComparison["lt"] = eLT;
-  mComparison["le"] = eLE;
-  mComparison["=="] = eEQ;
-  mComparison["!="] = eNE;
-  mComparison[">"]  = eGT;
-  mComparison[">="] = eGE;
-  mComparison["<"]  = eLT;
-  mComparison["<="] = eLE;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGCondition::~FGCondition(void)
-{
-  Debug(1);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-bool FGCondition::Evaluate(void )
-{
-  vector <FGCondition>::iterator iConditions;
-  bool pass = false;
-  double compareValue;
-
-  if (Logic == eAND) {
-
-    iConditions = conditions.begin();
-    pass = true;
-    while (iConditions < conditions.end()) {
-      if (!iConditions->Evaluate()) pass = false;
-      *iConditions++;
-    }
-
-  } else if (Logic == eOR) {
-
-    pass = false;
-    while (iConditions < conditions.end()) {
-      if (iConditions->Evaluate()) pass = true;
-      *iConditions++;
-    }
-
-  } else {
-
-    if (TestParam2 != 0L) compareValue = TestParam2->getDoubleValue();
-    else compareValue = TestValue;
-
-    switch (Comparison) {
-    case ecUndef:
-      cerr << "Undefined comparison operator." << endl;
-      break;
-    case eEQ:
-      pass = TestParam1->getDoubleValue() == compareValue;
-      break;
-    case eNE:
-      pass = TestParam1->getDoubleValue() != compareValue;
-      break;
-    case eGT:
-      pass = TestParam1->getDoubleValue() > compareValue;
-      break;
-    case eGE:
-      pass = TestParam1->getDoubleValue() >= compareValue;
-      break;
-    case eLT:
-      pass = TestParam1->getDoubleValue() < compareValue;
-      break;
-    case eLE:
-      pass = TestParam1->getDoubleValue() <= compareValue;
-      break;
-    default:
-     cerr << "Unknown comparison operator." << endl;
-    }
-  }
-
-  return pass;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGCondition::PrintCondition(void )
-{
-  vector <FGCondition>::iterator iConditions;
-  string scratch;
-
-  if (isGroup) {
-    switch(Logic) {
-    case (elUndef):
-      scratch = " UNSET";
-      cerr << "unset logic for test condition" << endl;
-      break;
-    case (eAND):
-      scratch = " if all of the following are true";
-      break;
-    case (eOR):
-      scratch = " if any of the following are true:";
-      break;
-    default:
-      scratch = " UNKNOWN";
-      cerr << "Unknown logic for test condition" << endl;
-    }
-
-    iConditions = conditions.begin();
-    cout << scratch << endl;
-    while (iConditions < conditions.end()) {
-      iConditions->PrintCondition();
-      *iConditions++;
-    }
-  } else {
-    if (TestParam2 != 0L)
-      cout << TestParam1->GetName() << " " << conditional << " " << TestParam2->GetName();
-    else
-      cout << TestParam1->GetName() << " " << conditional << " " << TestValue;
-  }
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-//    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 FGCondition::Debug(int from)
-{
-  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: FGCondition" << endl;
-    if (from == 1) cout << "Destroyed:    FGCondition" << 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/FGCondition.h b/src/FDM/JSBSim/models/flight_control/FGCondition.h
deleted file mode 100644 (file)
index fbb643b..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- Header:       FGCondition.h
- Author:       Jon S. Berndt
- Date started: 1/02/2003
-
- ------------- Copyright (C)  -------------
-
- This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU 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 General Public License for more
- details.
-
- You should have received a copy of the GNU 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 General Public License can also be found on
- the world wide web at http://www.gnu.org.
-
-HISTORY
---------------------------------------------------------------------------------
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-SENTRY
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#ifndef FGCONDITION_H
-#define FGCONDITION_H
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INCLUDES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#include <map>
-#include <FGJSBBase.h>
-#include <input_output/FGXMLElement.h>
-#include <input_output/FGPropertyManager.h>
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-DEFINITIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-#define ID_CONDITION "$Id$"
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-FORWARD DECLARATIONS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-namespace JSBSim {
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS DOCUMENTATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-/** Encapsulates a condition, which is used in parts of JSBSim including switches
-*/
-
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS DECLARATION
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-class FGCondition : public FGJSBBase
-{
-public:
-  FGCondition(Element* element, FGPropertyManager* PropertyManager);
-  FGCondition(string test, FGPropertyManager* PropertyManager);
-  ~FGCondition(void);
-
-  bool Evaluate(void);
-  void PrintCondition(void);
-
-private:
-  enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
-  enum eLogic {elUndef=0, eAND, eOR};
-  map <string, eComparison> mComparison;
-  eLogic Logic;
-
-  FGPropertyManager *TestParam1, *TestParam2, *PropertyManager;
-  double TestValue;
-  eComparison Comparison;
-  bool isGroup;
-  string conditional;
-
-  static string indent;
-
-  vector <FGCondition> conditions;
-  void InitializeConditionals(void);
-
-  void Debug(int from);
-};
-}
-#endif
-
index bbd8f68f0c00137d2909941a66e0256d831aad06..4bdb8108eb151e0b1592e3274ff3993404e3b282 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index f94087c95bef17b51ef7c26de466f730ad1c7e20..471e5ab0d224263f9525b168613316ccd0b9f014 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2001 Jon S. Berndt -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -59,20 +59,25 @@ CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 /** Models a deadband object.
-    Here is the format of the deadband control specification:
-    <pre>
-    \<COMPONENT NAME="Deadbeat1" TYPE="DEADBAND">
-       INPUT {input}
-       WIDTH {deadband width}
-       MIN {minimum value}
-       MAX {maximum value}
-       [GAIN {optional deadband gain}]
-       [OUTPUT {optional output parameter to set}]
-    \</COMPONENT>
-    </pre>
-    The WIDTH value is the total deadband region within which an input will
-    produce no output. For example, say that the WIDTH value is 2.0.  If the
-    input is between -1.0 and +1.0, the output will be zero.
+    This is a component that allows for some \93play\94 in a control path, in the
+    form of a dead zone, or deadband. The form of the deadband component
+    specification is:
+
+    @code
+    <deadband name="Windup Trigger">
+      <input> [-]property </input>
+      <width> number </width>
+      [<clipto>
+        <min> {[-]property name | value} </min>
+        <max> {[-]property name | value} </max>
+      </clipto>]
+      [<output> {property} </output>]
+    </deadband>
+    @endcode
+
+    The width value is the total deadband region within which an input will
+    produce no output. For example, say that the width value is 2.0. If the
+    input is between \961.0 and +1.0, the output will be zero.
     @author Jon S. Berndt
     @version $Id$
 */
index b67ffaef821b05c68d745b5b4eaf2c842af82cf1..177055becc379d49b0ddb3387853f0225346fb92 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -59,43 +59,44 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
   string input, clip_string;
 
   PropertyManager = fcs->GetPropertyManager();
-  Type = element->GetAttributeValue("type"); // Old, deprecated format
-  if (Type.empty()) {
-    if        (element->GetName() == string("lag_filter")) {
-      Type = "LAG_FILTER";
-    } else if (element->GetName() == string("lead_lag_filter")) {
-      Type = "LEAD_LAG_FILTER";
-    } else if (element->GetName() == string("washout_filter")) {
-      Type = "WASHOUT_FILTER";
-    } else if (element->GetName() == string("second_order_filter")) {
-      Type = "SECOND_ORDER_FILTER";
-    } else if (element->GetName() == string("integrator")) {
-      Type = "INTEGRATOR";
-    } else if (element->GetName() == string("summer")) {
-      Type = "SUMMER";
-    } else if (element->GetName() == string("pure_gain")) {
-      Type = "PURE_GAIN";
-    } else if (element->GetName() == string("scheduled_gain")) {
-      Type = "SCHEDULED_GAIN";
-    } else if (element->GetName() == string("aerosurface_scale")) {
-      Type = "AEROSURFACE_SCALE";
-    } else if (element->GetName() == string("switch")) {
-      Type = "SWITCH";
-    } else if (element->GetName() == string("kinematic")) {
-      Type = "KINEMATIC";
-    } else if (element->GetName() == string("deadband")) {
-      Type = "DEADBAND";
-    } else if (element->GetName() == string("fcs_function")) {
-      Type = "FCS_FUNCTION";
-    } else if (element->GetName() == string("sensor")) {
-      Type = "SENSOR";
-    } else { // illegal component in this channel
-      Type = "UNKNOWN";
-    }
+  if        (element->GetName() == string("lag_filter")) {
+    Type = "LAG_FILTER";
+  } else if (element->GetName() == string("lead_lag_filter")) {
+    Type = "LEAD_LAG_FILTER";
+  } else if (element->GetName() == string("washout_filter")) {
+    Type = "WASHOUT_FILTER";
+  } else if (element->GetName() == string("second_order_filter")) {
+    Type = "SECOND_ORDER_FILTER";
+  } else if (element->GetName() == string("integrator")) {
+    Type = "INTEGRATOR";
+  } else if (element->GetName() == string("summer")) {
+    Type = "SUMMER";
+  } else if (element->GetName() == string("pure_gain")) {
+    Type = "PURE_GAIN";
+  } else if (element->GetName() == string("scheduled_gain")) {
+    Type = "SCHEDULED_GAIN";
+  } else if (element->GetName() == string("aerosurface_scale")) {
+    Type = "AEROSURFACE_SCALE";
+  } else if (element->GetName() == string("switch")) {
+    Type = "SWITCH";
+  } else if (element->GetName() == string("kinematic")) {
+    Type = "KINEMATIC";
+  } else if (element->GetName() == string("deadband")) {
+    Type = "DEADBAND";
+  } else if (element->GetName() == string("fcs_function")) {
+    Type = "FCS_FUNCTION";
+  } else if (element->GetName() == string("pid")) {
+    Type = "PID";
+  } else if (element->GetName() == string("sensor")) {
+    Type = "SENSOR";
+  } else { // illegal component in this channel
+    Type = "UNKNOWN";
   }
 
   Name = element->GetAttributeValue("name");
 
+  FGPropertyManager *tmp=0;
+
   input_element = element->FindElement("input");
   while (input_element) {
     input = input_element->GetDataLine();
@@ -105,7 +106,14 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
     } else {
       InputSigns.push_back( 1.0);
     }
-    InputNodes.push_back( resolveSymbol(input) );
+    tmp = PropertyManager->GetNode(input);
+    if (tmp) {
+      InputNodes.push_back( tmp );
+    } else {
+      cerr << fgred << "  In component: " << Name << " unknown property "
+           << input << " referenced. Aborting" << endl;
+      exit(-1);
+    }
     input_element = element->FindNextElement("input");
   }
 
@@ -144,9 +152,6 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
 
 FGFCSComponent::~FGFCSComponent()
 {
-//  string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
-//  PropertyManager->Untie( tmp);
-
   Debug(1);
 }
 
@@ -177,25 +182,21 @@ void FGFCSComponent::Clip(void)
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-FGPropertyManager* FGFCSComponent::resolveSymbol(string token)
-{
-  string prop;
-  FGPropertyManager* tmp = PropertyManager->GetNode(token,false);
-  if (!tmp) {
-    if (token.find("/") == token.npos) prop = "model/" + token;
-    cerr << "Creating new property " << prop << endl;
-    tmp = PropertyManager->GetNode(token,true);
-  }
-  return tmp;
-}
-
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//
+// The old way of naming FCS components allowed upper or lower case, spaces, etc.
+// but then the names were modified to fit into a property name heirarchy. This
+// was confusing (it wasn't done intentionally - it was a carryover from the early
+// design). We now support the direct naming of properties in the FCS component
+// name attribute. The old way is supported in code at this time, but deprecated.
 
 void FGFCSComponent::bind(void)
 {
-  string tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
+  string tmp;
+  if (Name.find("/") == string::npos) {
+    tmp = "fcs/" + PropertyManager->mkPropertyName(Name, true);
+  } else {
+    tmp = Name;
+  }
   PropertyManager->Tie( tmp, this, &FGFCSComponent::GetOutput);
 }
 
index 17beb089b375aa47fe679a8ded62a858de08cfab..8e0fa14f4b73e66177d42e94354f56e311b568b0 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C)  -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -78,7 +78,9 @@ CLASS DOCUMENTATION
     - FGFilter
     - FGDeadBand
     - FGSummer
-    - FGGradient
+    - FGSensor
+    - FGFCSFunction
+    - FGPID
 
     @author Jon S. Berndt
     @version $Id$
@@ -125,8 +127,6 @@ protected:
 
   void Clip(void);
   virtual void bind();
-  FGPropertyManager* resolveSymbol(string token);
-
   virtual void Debug(int from);
 };
 
index 4c19f4ef94a86abf6e8da6e753a0238d2bf1393d..cd6559b089bb1d48cecd0bc71e17d47c268371b1 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2005 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 9f1c5317e967d7aa555bf4ac566c406ed95158d6..c189ff64b72a84d4968b0155aeb3a172bf376d23 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2005 Jon S. Berndt -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -61,6 +61,48 @@ CLASS DOCUMENTATION
 
 /** Models a FCSFunction object.
     @author Jon S. Berndt
+
+One of the most recent additions to the FCS component set is the FCS Function
+component. This component allows a function to be created when no other component
+is suitable. The function component is defined as follows:
+
+@code
+<fcs_function name="Windup Trigger">
+  [<input> [-]property </input>]
+  <function>
+    \85
+  </function>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<output> {property} </output>]
+</ fcs_function >
+@endcode
+
+The function definition itself can include a nested series of products, sums,
+quotients, etc. as well as trig and other math functions. Here\92s an example of
+a function (from an aero specification):
+
+@code
+<function name="aero/coefficient/CDo">
+    <description>Drag_at_zero_lift</description>
+    <product>
+        <property>aero/qbar-psf</property>
+        <property>metrics/Sw-sqft</property>
+        <table>
+            <independentVar>velocities/mach</independentVar>
+            <tableData>
+                0.0000 0.0220
+                0.2000 0.0200
+                0.6500 0.0220
+                0.9000 0.0240
+                0.9700 0.0500
+            </tableData>
+        </table>
+    </product>
+</function>
+@endcode
     @version $Id$
 */
 
index 79ec7e1edb4fdba20ad7711aa9e8375a96d41884..c4437e41cd88c80057cc27fbfabf2a8b6aed9853 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -71,7 +71,7 @@ FGFilter::FGFilter(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
   if (element->FindElement("c5")) C5 = element->FindElementValueAsNumber("c5");
   if (element->FindElement("c6")) C6 = element->FindElementValueAsNumber("c6");
   if (element->FindElement("trigger")) {
-    Trigger =  resolveSymbol(element->FindElementValue("trigger"));
+    Trigger =  PropertyManager->GetNode(element->FindElementValue("trigger"));
   }
 
   Initialize = true;
index 5ff57e7cf215fcc39758ed97d0c4093276880389..483730b5d29120722849fc987fb8dd1c42a9ee0e 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 Jon S. Berndt jsb@hal-pc.org -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index b46e7721e2134f5980f70cbe6b8dd122fa658d32..484074901635e37ff90e449659bf078c0df05014 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -69,6 +69,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
 
   if ( element->FindElement("gain") ) {
     gain_string = element->FindElementValue("gain");
+    //ToDo allow for negative sign here for property
     if (gain_string.find_first_not_of("+-.0123456789") != string::npos) { // property
       GainPropertyNode = PropertyManager->GetNode(gain_string);
     } else {
@@ -98,6 +99,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
     }
     ZeroCentered = true;
     zero_centered = element->FindElement("zero_centered");
+    //ToDo if zero centered, then mins must be <0 and max's must be >0
     if (zero_centered) {
       sZeroCentered = zero_centered->FindElementValue("zero_centered");
       if (sZeroCentered == string("0") || sZeroCentered == string("false")) {
index ab20a31c18b1442ef705af227476c7f0368d05e5..e06382a99e17f22d56ced77a33298f71e02db3d7 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1998 by Jon S. Berndt, jsb@hal-pc.org -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index c42d9b97a1ae904604fd7a911e82b9610dbdac31..15af4c5f3517ee54a6d1054cf1dc50c8c165f4b6 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index b51dee519e93dab65de4ac98ef12aad18267ff2e..0d2ad21db0f7a2e16998292159c524e9dca962ae 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C)  -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index dffcce7463c593bb896b14fa20f6232db16384ac..ad2034b0b63f16279f08ba900bf0895c065bd063 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 Anthony K. Peden -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 43508dec83e4eaac9e0c9cc13627da6cadac737d..94c1e7d74e2fc6b6709557f47d94115942052c7d 100644 (file)
@@ -1,31 +1,31 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Header:       FGKinemat.h
  Author:       Tony Peden, for flight control system authored by Jon S. Berndt
- Date started: 12/02/01 
+ Date started: 12/02/01
+
  ------------- Copyright (C) Anthony K. Peden -------------
+
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
- You should have received a copy of the GNU General Public License along with
+
+ 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 General Public License can also be found on
+
+ 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
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -68,7 +68,52 @@ namespace JSBSim {
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-/** Encapsulates a kinematic component for the flight control system.
+/** Encapsulates a kinematic (mechanical) component for the flight control system.
+This component models the action of a moving effector, such as an aerosurface or
+other mechanized entity such as a landing gear strut for the purpose of effecting
+vehicle control or configuration. The form of the component specification is:
+
+@code
+<kinematic name="Gear Control">
+  <input> [-]property </input>
+  <traverse>
+    <setting>
+      <position> number </position>
+      <time> number </time>
+    </setting>
+    \85
+  </traverse>
+  [<clipto>
+    <min> {[-]property name | value} </min>
+    <max> {[-]property name | value} </max>
+  </clipto>]
+  [<gain> {property name | value} </gain>]
+  [<output> {property} </output>]
+</kinematic>
+@endcode
+
+The detent is the position that the component takes, and the lag is the time it
+takes to get to that position from an adjacent setting. For example:
+
+@code
+<kinematic name="Gear Control">
+  <input>gear/gear-cmd-norm</input>
+  <traverse>
+    <setting>
+      <position>0</position>
+      <time>0</time>
+    </setting>
+    <setting>
+      <position>1</position>
+      <time>5</time>
+    </setting>
+  </traverse>
+  <output>gear/gear-pos-norm</output>
+</kinematic>
+@endcode
+
+In this case, it takes 5 seconds to get to a 1 setting. As this is a software
+mechanization of a servo-actuator, there should be an output specified.
   */
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -77,31 +122,28 @@ CLASS DECLARATION
 
 class FGKinemat  : public FGFCSComponent {
 public:
-  /** Initializer.
+  /** Constructor.
       @param fcs A reference to the ccurrent flightcontrolsystem.
       @param AC_cfg reference to the current aircraft configuration file.
       Initializes the FGKinemat object from the given configuration
       file. The Configuration file is expected to be at the stream
-      position where the KINEMAT object starts. Also it is expected to
-      be past the end of the current KINEMAT configuration on exit.
+      position where the kinematic object starts. Also it is expected to
+      be past the end of the current kinematic configuration on exit.
    */
   FGKinemat(FGFCS* fcs, Element* element);
 
-  /** Destructor.
-   */
+  /// Destructor.
   ~FGKinemat();
-  
-  /** Kinemat output value.
-      @return the current output of the kinemat object on the range of [0,1].
-   */
+
+  /** Kinematic component output value.
+      @return the current output of the kinematic object on the range of [0,1]. */
   double GetOutputPct() const { return OutputPct; }
-    
-  /** Run method, overwrites FGModel::Run().
+
+  /** Run method, overrides FGModel::Run().
       @return false on success, true on failure.
-      The routine doing the work.
-   */
+      The routine doing the work.  */
   bool Run (void);
-  
+
 private:
   vector<double> Detents;
   vector<double> TransitionTimes;
diff --git a/src/FDM/JSBSim/models/flight_control/FGPID.cpp b/src/FDM/JSBSim/models/flight_control/FGPID.cpp
new file mode 100755 (executable)
index 0000000..3b60b1a
--- /dev/null
@@ -0,0 +1,155 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Module:       FGPID.cpp
+ Author:       Jon S. Berndt
+ Date started: 6/17/2006
+
+ ------------- Copyright (C) 2006 Jon S. Berndt (jsb@hal-pc.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
+--------------------------------------------------------------------------------
+Initial code 6/17/2006 JSB
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES,  and NOTES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#include "FGPID.h"
+
+namespace JSBSim {
+
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_PID;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+FGPID::FGPID(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
+{
+  dt = fcs->GetState()->Getdt();
+
+  Kp = Ki = Kd = 0.0;
+  P_out = D_out = I_out = 0.0;
+  Input_prev = Input_prev2 = 0.0;
+  Trigger = 0;
+
+  if (element->FindElement("kp")) Kp = element->FindElementValueAsNumber("kp");
+  if (element->FindElement("ki")) Ki = element->FindElementValueAsNumber("ki");
+  if (element->FindElement("kd")) Kd = element->FindElementValueAsNumber("kd");
+  if (element->FindElement("trigger")) {
+    Trigger =  PropertyManager->GetNode(element->FindElementValue("trigger"));
+  }
+
+  FGFCSComponent::bind();
+
+  Debug(0);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+FGPID::~FGPID()
+{
+  Debug(1);
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGPID::Run(void )
+{
+  Input = InputNodes[0]->getDoubleValue() * InputSigns[0];
+
+  P_out = Kp * (Input - Input_prev);
+  I_out = Ki * dt * Input;
+  D_out = (Kd / dt) * (Input - 2*Input_prev + Input_prev2);
+
+  if (Trigger != 0) {
+    double test = Trigger->getDoubleValue();
+    if (fabs(test) > 0.000001) {
+      I_out = 0.0;
+    }
+  }
+
+  Input_prev = Input;
+  Input_prev2 = Input_prev;
+
+  Output += P_out + I_out + D_out;
+
+  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 FGPID::Debug(int from)
+{
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+    if (from == 0) { // Constructor
+      if (InputSigns[0] < 0)
+        cout << "      INPUT: -" << InputNodes[0]->getName() << endl;
+      else
+        cout << "      INPUT: " << InputNodes[0]->getName() << endl;
+
+      if (IsOutput) cout << "      OUTPUT: " << OutputNode->getName() << endl;
+    }
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGPID" << endl;
+    if (from == 1) cout << "Destroyed:    FGPID" << 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;
+    }
+  }
+}
+}
diff --git a/src/FDM/JSBSim/models/flight_control/FGPID.h b/src/FDM/JSBSim/models/flight_control/FGPID.h
new file mode 100755 (executable)
index 0000000..7f69f2e
--- /dev/null
@@ -0,0 +1,98 @@
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+ Header:       FGPID.h
+ Author:       Jon Berndt
+ Date started: 6/17/2006
+
+ ------------- Copyright (C) 2006 by Jon S. Berndt, jsb@hal-pc.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
+--------------------------------------------------------------------------------
+Initial Code 6/17/2006 JSB
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+SENTRY
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifndef FGPID_H
+#define FGPID_H
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+INCLUDES
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#ifdef FGFS
+#  include <simgear/compiler.h>
+#  include STL_STRING
+   SG_USING_STD(string);
+#else
+#  include <string>
+#endif
+
+#include "FGFCSComponent.h"
+#include <input_output/FGXMLElement.h>
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_PID "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+class FGFCS;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Encapsulates a PID control component for the flight control system.
+
+    @author Jon S. Berndt
+    @version $Revision$
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DECLARATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+class FGPID  : public FGFCSComponent
+{
+public:
+  FGPID(FGFCS* fcs, Element* element);
+  ~FGPID();
+
+  bool Run (void);
+
+private:
+  double dt;
+  FGPropertyManager *Trigger;
+  double Kp, Ki, Kd;
+  double P_out, D_out, I_out;
+  double Input_prev, Input_prev2;
+
+  void Debug(int from);
+};
+}
+#endif
index b2d541d3263a9083cec5ccbbfe99f19cf910a324..f0055616cdb8e97fe8b999759ca298ef65b47d29 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2005 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 37205ba0790967527f44da1b08f8464190b44a3a..267258336554dc1ccd2e9d27be50bade954c76ba 100755 (executable)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2005 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -62,6 +62,7 @@ CLASS DOCUMENTATION
 
 Syntax:
 
+@code
 <sensor name=\94name\94 rate_group=\94name\94>
   <input> property </input>
   <lag> number </lag>
@@ -74,9 +75,11 @@ Syntax:
   <drift_rate> number </drift_rate>
   <bias> number </bias>
 </sensor>
+@endcode
 
 Example:
 
+@code
 <sensor name=\94aero/sensor/qbar\94 rate_group=\94HFCS\94>
   <input> aero/qbar </input>
   <lag> 0.5 </lag>
@@ -88,6 +91,7 @@ Example:
   </quantization>
   <bias> 0.5 </bias>
 </sensor>
+@endcode
 
 The only required element in the sensor definition is the input element. In that
 case, no degradation would be modeled, and the output would simply be the input.
@@ -101,7 +105,7 @@ time.
 
 @author Jon S. Berndt
 @version $Revision$
-  */
+*/
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
index 06b575f4c87715212cb6813ccf155db72e1737bc..0503f04a820e104dd4de9d8719ff8384f925eff5 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index ede4b261fc783c7f3b450107e218bfd6921aa256..8bf5fbbdfb78f2e611e8a1b88e22aafd21ae46d2 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C)  -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 1c36fd2fcc8272cfc35fde1e5b60a0688aeb974e..a28aeddddd8a9dcfdd56d112a56a9baf5ad72d6b 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000 -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -33,24 +33,27 @@ HISTORY
 COMMENTS, REFERENCES,  and NOTES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-The SWITCH component is defined as follows (see the API documentation for more
+The switch component is defined as follows (see the API documentation for more
 information):
 
-<COMPONENT NAME="switch1" TYPE="SWITCH">
-  <TEST LOGIC="{AND|OR|DEFAULT}" OUTPUT="{property|value}">
+@code
+<switch name="switch1">
+  <default value="{property|value}"/>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
-    <CONDITION_GROUP LOGIC="{AND|OR}">
+    <test logic="{AND|OR}">
       {property} {conditional} {property|value}
       ...
-    </CONDITION_GROUP>
+    </test>
     ...
-  </TEST>
-  <TEST LOGIC="{AND|OR}" OUTPUT="{property|value}">
+  </test>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
     ...
-  </TEST>
+  </test>
   ...
-</COMPONENT>
+</switch>
+@endcode
 
 Also, see the header file (FGSwitch.h) for further details.
 
index a6ef0db171caf17f03494ef5e69ba8124796202c..cca569c0e303516237efdd5b03e173ce4fd9f586 100644 (file)
@@ -4,23 +4,23 @@
  Author:       Jon S. Berndt
  Date started: 12/23/2002
 
- ------------- Copyright (C)  -------------
+ ------------- Copyright (C) 2002 jsb@hal-pc.org  -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -39,7 +39,7 @@ INCLUDES
 
 #include "FGFCSComponent.h"
 #include <input_output/FGXMLElement.h>
-#include "FGCondition.h"
+#include <math/FGCondition.h>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -59,60 +59,64 @@ CLASS DOCUMENTATION
 
 /** Encapsulates a switch for the flight control system.
 
-The SWITCH component models a switch - either on/off or a multi-choice rotary
+The switch component models a switch - either on/off or a multi-choice rotary
 switch. The switch can represent a physical cockpit switch, or can represent a
 logical switch, where several conditions might need to be satisfied before a
-particular state is reached. The VALUE of the switch - the output value for the
+particular state is reached. The value of the switch - the output value for the
 component - is chosen depending on the state of the switch. Each switch is
-comprised of two or more TESTs. Each TEST has a VALUE associated with it. The
-first TEST that evaluates to TRUE will set the output value of the switch
-according to the VALUE parameter belonging to that TEST. Each TEST contains one
-or more CONDITIONS, which each must be logically related (if there are more than
-one) given the value of the LOGIC parameter, and which takes the form:
+comprised of one or more tests. Each test has a value associated with it. The
+first test that evaluates to true will set the output value of the switch
+according to the value parameter belonging to that test. Each test contains one
+or more conditions, which each must be logically related (if there are more than
+one) given the value of the logic attribute, and which takes the form:
 
   property conditional property|value
 
 e.g.
 
-  qbar GE 21.0
+  qbar ge 21.0
 
 or,
 
-  roll_rate < pitch_rate
+  roll_rate == pitch_rate
 
-Within a TEST, a CONDITION_GROUP can be specified. A CONDITION_GROUP allows for
-complex groupings of logical comparisons. Each CONDITION_GROUP contains
-additional conditions, as well as possibly additional CONDITION_GROUPs.
+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.
 
-<pre>
-\<COMPONENT NAME="switch1" TYPE="SWITCH"\>
-  \<TEST LOGIC="{AND|OR|DEFAULT}" VALUE="{property|value}"\>
+@code
+<switch name="switch1">
+  <default value="{property|value}"/>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
-    \<CONDITION_GROUP LOGIC="{AND|OR}"\>
+    <test logic="{AND|OR}">
       {property} {conditional} {property|value}
       ...
-    \</CONDITION_GROUP\>
+    </test>
     ...
-  \</TEST>
-  \<TEST LOGIC="{AND|OR}" VALUE="{property|value}"\>
+  </test>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
     ...
-  \</TEST\>
+  </test>
   ...
-  [OUTPUT \<property>]
-\</COMPONENT\>
-</pre>
+  [<output> {property} </output>]
+</switch>
+@endcode
 
 Here's an example:
-<pre>
-\<COMPONENT NAME="Roll A/P Autoswitch" TYPE="SWITCH">
-  \<TEST LOGIC="DEFAULT" VALUE="0.0">
-  \</TEST>
-  \<TEST LOGIC="AND" VALUE="fcs/roll-ap-error-summer">
+
+@code
+<switch name="roll a/p autoswitch">
+  <default value="0.0"/>
+  <test value="fcs/roll-ap-error-summer">
     ap/attitude_hold == 1
-  \</TEST>
-\</COMPONENT>
-</pre>
+  </test>
+</switch>
+@endcode
+
+Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.
+
 The above example specifies that the default value of the component (i.e. the
 output property of the component, addressed by the property, ap/roll-ap-autoswitch)
 is 0.0.  If or when the attitude hold switch is selected (property
@@ -129,16 +133,23 @@ CLASS DECLARATION
 class FGSwitch  : 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 switch component */
   FGSwitch(FGFCS* fcs, Element* element);
+
+  /// Destructor
   ~FGSwitch();
 
+  /** Executes the switch logic.
+      @return true - always*/
   bool Run(void);
 
   enum eLogic {elUndef=0, eAND, eOR, eDefault};
   enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
 
 private:
-  FGFCS* fcs;
 
   struct test {
     vector <FGCondition> conditions;
index 4ae764df0e3a778c27289ae7f5d3064efba6aa3a..e81ce1480cd2a04bab6613f7a3bfd0261b67ee21 100644 (file)
@@ -1,10 +1,10 @@
 noinst_LIBRARIES = libFlightControl.a 
 
-libFlightControl_a_SOURCES = FGCondition.cpp FGDeadBand.cpp FGFCSComponent.cpp \
+libFlightControl_a_SOURCES = FGPID.cpp FGDeadBand.cpp FGFCSComponent.cpp \
                             FGFilter.cpp FGGain.cpp FGGradient.cpp FGKinemat.cpp \
                             FGSummer.cpp FGSwitch.cpp FGFCSFunction.cpp FGSensor.cpp
 
-noinst_HEADERS = FGCondition.h FGDeadBand.h FGFCSComponent.h FGFilter.h \
+noinst_HEADERS = FGPID.h FGDeadBand.h FGFCSComponent.h FGFilter.h \
                  FGGain.h FGGradient.h FGKinemat.h FGSummer.h FGSwitch.h FGFCSFunction.h \
                  FGSensor.h
 
index 3740ed911d5a90ee688bd31cc6d6094167657847..0835c857eafb4d0549fdd32c70efa26d75e23973 100644 (file)
@@ -8,20 +8,20 @@
  --------- Copyright (C) 2004  David Culp (davidculp2@comcast.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 84aa378374d441d377b804dfb8f86969a1c0f9cd..20e5692304f30c56896364fa81e25584ce9337ca 100644 (file)
@@ -7,20 +7,20 @@
  ----- Copyright (C) 2004  David P. Culp (davidculp2@comcast.net) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 27390de7be700f8723ef4a90b7091d51e43afdac..ac55b0aed123bb697f98f5b93b4d9aac695e8860 100644 (file)
@@ -8,19 +8,19 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more details.
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -144,7 +144,7 @@ FGEngine::FGEngine(FGFDMExec* exec, Element* engine_element, int engine_number)
 
 FGEngine::~FGEngine()
 {
-  if (Thruster) delete Thruster;
+  delete Thruster;
   Debug(1);
 }
 
@@ -250,16 +250,15 @@ bool FGEngine::LoadThruster(Element *thruster_element)
   double xLoc, yLoc, zLoc, Pitch, Yaw;
   double P_Factor = 0, Sense = 0.0;
   string enginePath = FDMExec->GetEnginePath();
-  string aircraftPath = FDMExec->GetAircraftPath();
+  string aircraftPath = FDMExec->GetFullAircraftPath();
   FGXMLParse thruster_file_parser;
   Element *document, *element;
   ifstream thruster_file;
   FGColumnVector3 location, orientation;
-
-# ifndef macintosh
   string separator = "/";
-# else
-  string separator = ";";
+
+# ifdef macintosh
+    separator = ";";
 # endif
 
   fullpath = enginePath + separator;
index a6e820aaaf69c21db530b32f1d7e7192fbc4ed72..07c4c60e1a0201e438375f62207432fb420b349c 100644 (file)
@@ -7,19 +7,19 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more details.
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index f54ac9996a21d646a2a08046c6bdbf795de478f7..1dffff82d0b1698f62ca24fb0446e8134bb9c9fc 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -62,6 +62,7 @@ FGForce::FGForce(FGFDMExec *FDMExec) :
   mT(2,2) = 1;
   mT(3,3) = 1;
   vSense.InitMatrix(1);
+
   Debug(0);
 }
 
index 0f69897af164cbf80b620999f2e33f8c7d301cff..767e269417b968f04ff91f1456f56bde4464eade 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Anthony K. Peden (apeden@earthlink.net) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 
@@ -305,6 +305,12 @@ public:
     SetAnglesToBody(vv(eRoll), vv(ePitch), vv(eYaw));
   }
 
+  void SetPitch(double pitch) {vOrient(ePitch) = pitch;}
+  void SetYaw(double yaw) {vOrient(eYaw) = yaw;}
+
+  double GetPitch(void) const {return vOrient(ePitch);}
+  double GetYaw(void) const {return vOrient(eYaw);}
+
   inline void SetSense(double x, double y, double z) { vSense(eX)=x, vSense(eY)=y, vSense(eZ)=z; }
   inline void SetSense(FGColumnVector3 vv) { vSense=vv; }
 
index bb5d91955a9e016c1a850a313210c3b3159cccc4..5b0b58a20d29fcf8a3e8b7c814d1929e236b19d5 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -50,7 +50,8 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThruster(FDMExec)
+FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num)
+                    : FGThruster(FDMExec, nozzle_element, num)
 {
 
   if (nozzle_element->FindElement("pe"))
@@ -79,15 +80,10 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThr
   }
 
   Thrust = 0;
-  ReverserAngle = 0.0;
   Type = ttNozzle;
   Area2 = (Diameter*Diameter/4.0)*M_PI;
   AreaT = Area2/ExpR;
 
-//  char property_name[80];
-//  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-//  PropertyManager->Tie( property_name, &ThrustCoeff );
-
   Debug(0);
 }
 
@@ -95,10 +91,6 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) : FGThr
 
 FGNozzle::~FGNozzle()
 {
-//  char property_name[80];
-//  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-//  PropertyManager->Untie( property_name );
-
   Debug(1);
 }
 
index 4b7f3085d5db435097d0c91968199974b1934205..f2aaf358a84cf684814e92ff78978b57565f3306 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -79,7 +79,6 @@ public:
   string GetThrusterValues(int id, string delimeter);
 
 private:
-  double ReverserAngle;
   double PE;
   double ExpR;
   double nzlEff;
index 4ad410459796764b4379fcd0214239d3d9b49f77..94b54c35d6ce6b24495a6560fd773a5ac4a3476f 100644 (file)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -80,15 +80,15 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
   // These are internal program variables
 
   crank_counter = 0;
-  OilTemp_degK = 298;
+  OilTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
   ManifoldPressure_inHg = Atmosphere->GetPressure() * psftoinhg; // psf to in Hg
   minMAP = 21950;
   maxMAP = 96250;
   MAP = Atmosphere->GetPressure() * psftopa;
-  CylinderHeadTemp_degK = 0.0;
+  CylinderHeadTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
   Magnetos = 0;
-  ExhaustGasTemp_degK = 0.0;
-  EGT_degC = 0.0;
+  ExhaustGasTemp_degK = RankineToKelvin(Atmosphere->GetTemperature());
+  EGT_degC = ExhaustGasTemp_degK - 273;
 
   dt = State->Getdt();
 
@@ -198,6 +198,7 @@ FGPiston::FGPiston(FGFDMExec* exec, Element* el, int engine_number)
   }
   minMAP = MinManifoldPressure_inHg * 3386.38;  // inHg to Pa
   maxMAP = MaxManifoldPressure_inHg * 3386.38;
+  StarterHP = sqrt(MaxHP) * 0.2;
 
   // Set up and sanity-check the turbo/supercharging configuration based on the input values.
   if (TakeoffBoost > RatedBoost[0]) bTakeoffBoost = true;
@@ -271,7 +272,7 @@ double FGPiston::Calculate(void)
 
   p_amb = Atmosphere->GetPressure() * psftopa;
   p_amb_sea_level = Atmosphere->GetPressureSL() * psftopa;
-  T_amb = Atmosphere->GetTemperature() * (5.0 / 9.0);  // convert from Rankine to Kelvin
+  T_amb = RankineToKelvin(Atmosphere->GetTemperature());
 
   RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
 
@@ -555,7 +556,8 @@ void FGPiston::doEnginePower(void)
     } else {
       ManXRPM = ManifoldPressure_inHg * RPM; // Note that inHg must be used for the following correlation.
       Percentage_Power = (6e-9 * ManXRPM * ManXRPM) + (8e-4 * ManXRPM) - 1.0;
-      Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
+//      Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 /120);
+      Percentage_Power += ((T_amb_sea_lev_degF - T_amb_degF) * 7 * dt);
       if (Percentage_Power < 0.0) Percentage_Power = 0.0;
       else if (Percentage_Power > 100.0) Percentage_Power = 100.0;
     }
@@ -576,14 +578,12 @@ void FGPiston::doEnginePower(void)
     // Power output when the engine is not running
     if (Cranking) {
       if (RPM < 10) {
-        HP = 3.0;   // This is a hack to prevent overshooting the idle rpm in
-                    // the first time step. It may possibly need to be changed
-                    // if the prop model is changed.
+        HP = StarterHP;
       } else if (RPM < 480) {
-        HP = 3.0 + ((480 - RPM) / 10.0);
+        HP = StarterHP + ((480 - RPM) / 10.0);
         // This is a guess - would be nice to find a proper starter moter torque curve
       } else {
-        HP = 3.0;
+        HP = StarterHP;
       }
     } else {
       // Quick hack until we port the FMEP stuff
@@ -622,7 +622,8 @@ void FGPiston::doEGT(void)
     ExhaustGasTemp_degK = T_amb + delta_T_exhaust;
     ExhaustGasTemp_degK *= 0.444 + ((0.544 - 0.444) * Percentage_Power / 100.0);
   } else {  // Drop towards ambient - guess an appropriate time constant for now
-    dEGTdt = (298.0 - ExhaustGasTemp_degK) / 100.0;
+    combustion_efficiency = 0;
+    dEGTdt = (RankineToKelvin(Atmosphere->GetTemperature()) - ExhaustGasTemp_degK) / 100.0;
     delta_T_exhaust = dEGTdt * dt;
     ExhaustGasTemp_degK += delta_T_exhaust;
   }
@@ -687,7 +688,7 @@ void FGPiston::doOilTemperature(void)
       time_constant /= ((Percentage_Power / idle_percentage_power) / 10.0); // adjust for power
     }
   } else {
-    target_oil_temp = 298;
+    target_oil_temp = RankineToKelvin(Atmosphere->GetTemperature());
     time_constant = 1000;  // Time constant for engine-off; reflects the fact
                            // that oil is no longer getting circulated
   }
index 3bb09ede7faf3c18733652778045db9287ce9bc7..cb4e503ba76275893c2f4840906fc3c0c94c381c 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -210,6 +210,7 @@ private:
   double MaxHP;                    // horsepower
   double Cycles;                   // cycles/power stroke
   double IdleRPM;                  // revolutions per minute
+  double StarterHP;                // initial horsepower of starter motor 
   int BoostSpeeds;     // Number of super/turbocharger boost speeds - zero implies no turbo/supercharging.
   int BoostSpeed;      // The current boost-speed (zero-based).
   bool Boosted;                // Set true for boosted engine.
index fa706b6c331dedb7fcf126b7894fcf7d5f3facbd..ea5ad91b209d6fd60489fc175b594763adc99534 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -137,8 +137,8 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
 
 FGPropeller::~FGPropeller()
 {
-  if (cThrust)    delete cThrust;
-  if (cPower)     delete cPower;
+  delete cThrust;
+  delete cPower;
 
   char property_name[80];
   snprintf(property_name, 80, "propulsion/engine[%d]/advance-ratio", EngineNum);
index a268b583d225a7d76924390036987b1da351b3b0..3da9e2546c0788e2a3c0e16d0a242fc1deb8fda3 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -161,7 +161,7 @@ public:
   bool   GetReverse (void) { return Reversed; }
   void   SetFeather (bool f) { Feathered = f; }
   bool   GetFeather (void) { return Feathered; }
-  double GetThrustCoefficient(void) const {return ThrustCoeff;}  
+  double GetThrustCoefficient(void) const {return ThrustCoeff;}
 
 private:
   int   numBlades;
index 2bcbcca20719d18c2e164bd460d539fa22206875..d4c0fa0e13fc4f8f6766351f5d63a8448f8babbc 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index d21ad4c89cbe9e35510a523dac62261dc6631fe6..eac74251c3b077bec252226377a52c34aeb23674 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) --------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index b1efdde7653daa78d365c6e7a25747ef0b5e6501..e8d47ee177271b33bf1ac08af5ab5ed0759eca08 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -47,7 +47,8 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGRotor::FGRotor(FGFDMExec *FDMExec) : FGThruster(FDMExec)
+FGRotor::FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num)
+                    : FGThruster(FDMExec, rotor_element, num)
 {
   Debug(0);
 }
index 2e4b3b34d87119a2922778781e135d26880695f4..c876abaac435cf24121f567797d0de82129817dd 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -66,7 +66,9 @@ CLASS DECLARATION
 class FGRotor : public FGThruster {
 
 public:
-  FGRotor(FGFDMExec *FDMExec);
+  /// Constructor
+  FGRotor(FGFDMExec *FDMExec, Element* rotor_element, int num);
+  /// Destructor
   ~FGRotor();
 
   double Calculate(double);
index 57bebd7dc2a8ba141ffe5422e522178af6b6ecdc..29c5e528411b4731434120c3e28bd1280007e56e 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 33e3430d05b7dd4bf7a5a1c8389b8c6a91ba1b1e..a19899ce49dd1a30520be519bc8bbff979d92215 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index 9d1dc336a45d2191aeeac526ff0e793c50ffaae1..8cf4bf894c09951d798e2e49cd2ce89a6d42c7d0 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -49,19 +49,6 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGThruster::FGThruster(FGFDMExec *FDMExec) : FGForce(FDMExec)
-{
-  Type = ttDirect;
-  SetTransformType(FGForce::tCustom);
-
-  EngineNum = 0;
-  PropertyManager = FDMExec->GetPropertyManager();
-
-  Debug(0);
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMExec)
 {
   Element* thruster_element = el->GetParent();
@@ -74,9 +61,8 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
   Name = el->GetName();
 
   GearRatio = 1.0;
-
+  ReverserAngle = 0.0;
   EngineNum = num;
-  ThrustCoeff = 0.0;
   PropertyManager = FDMExec->GetPropertyManager();
 
 // Determine the initial location and orientation of this thruster and load the
@@ -93,9 +79,19 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
   SetLocation(location);
   SetAnglesToBody(orientation);
 
-//  char property_name[80];
-//  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-//  PropertyManager->Tie( property_name, &ThrustCoeff );
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
+  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetPitch, &FGForce::SetPitch);
+  snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
+  PropertyManager->Tie( property_name, (FGForce *)this, &FGForce::GetYaw, &FGForce::SetYaw);
+
+  if (el->GetName() == "direct") // this is a direct thruster. At this time
+                                      // only a direct thruster can be reversed.
+  {
+    snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
+    PropertyManager->Tie( property_name, (FGThruster *)this, &FGThruster::GetReverserAngle,
+                                                          &FGThruster::SetReverserAngle);
+  }
 
   Debug(0);
 }
@@ -104,9 +100,18 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx
 
 FGThruster::~FGThruster()
 {
-//  char property_name[80];
-//  snprintf(property_name, 80, "propulsion/c-thrust[%u]", EngineNum);
-//  PropertyManager->Untie( property_name );
+  char property_name[80];
+  snprintf(property_name, 80, "propulsion/engine[%d]/pitch-angle-rad", EngineNum);
+  PropertyManager->Untie( property_name);
+  snprintf(property_name, 80, "propulsion/engine[%d]/yaw-angle-rad", EngineNum);
+  PropertyManager->Untie( property_name);
+
+  if (Type == ttDirect) // this is a direct thruster. At this time
+                                      // only a direct thruster can be reversed.
+  {
+    snprintf(property_name, 80, "propulsion/engine[%d]/reverser-angle-rad", EngineNum);
+    PropertyManager->Untie( property_name);
+  }
 
   Debug(1);
 }
index 776ab17127ffd5dcb16afa3f8700f23b654ee4c4..7ab74a8758c18cdfe9ff10745b1645a57178424a 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2000  Jon S. Berndt (jsb@hal-pc.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -73,7 +73,6 @@ class FGThruster : public FGForce {
 
 public:
   /// Constructor
-  FGThruster(FGFDMExec *FDMExec);
   FGThruster(FGFDMExec *FDMExec, Element *el, int num );
   /// Destructor
   virtual ~FGThruster();
@@ -81,7 +80,8 @@ public:
   enum eType {ttNozzle, ttRotor, ttPropeller, ttDirect};
 
   virtual double Calculate(double tt) {
-       Thrust = tt; vFn(1) = Thrust;
+       Thrust = cos(ReverserAngle)*tt;
+       vFn(1) = Thrust;
        return Thrust;
   }
   void SetName(string name) {Name = name;}
@@ -91,6 +91,8 @@ public:
   double GetThrust(void) {return Thrust;}
   eType GetType(void) {return Type;}
   string GetName(void) {return Name;}
+  void SetReverserAngle(double angle) {ReverserAngle = angle;}
+  double GetReverserAngle(void) const {return ReverserAngle;}
   virtual double GetRPM(void) { return 0.0; };
   double GetGearRatio(void) {return GearRatio; }
   virtual string GetThrusterLabels(int id, string delimeter);
@@ -104,6 +106,7 @@ protected:
   double deltaT;
   double GearRatio;
   double ThrustCoeff;
+  double ReverserAngle;
   int EngineNum;
   FGPropertyManager* PropertyManager;
   virtual void Debug(int from);
index 9554e553faf072f105130b55a04126bd250a8b21..09fda02577f2a803639e4df328edcd4a40029445 100644 (file)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2003  David Culp (davidculp2@comcast.net) ---------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
@@ -67,10 +67,10 @@ FGTurbine::FGTurbine(FGFDMExec* exec, Element *el, int engine_number)
 
 FGTurbine::~FGTurbine()
 {
-  if (IdleThrustLookup) delete IdleThrustLookup;
-  if (MilThrustLookup) delete MilThrustLookup;
-  if (MaxThrustLookup) delete MaxThrustLookup;
-  if (InjectionLookup) delete InjectionLookup;
+  delete IdleThrustLookup;
+  delete MilThrustLookup;
+  delete MaxThrustLookup;
+  delete InjectionLookup;
   unbind();
   Debug(1);
 }
index 0b2740ddfe78bcb45500a722e395a8ce1579fe22..059f63153d69d0841ebe5037ffa14a9bb01629cc 100644 (file)
@@ -7,20 +7,20 @@
  ------------- Copyright (C) 2003  David Culp (davidculp2@comcast.net)----------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
index 12a8f36e7d37cab9324d1501f6cfcd7d21d9e6fd..057d961f009dc7428e8db251fd6e255c63ba1983 100755 (executable)
@@ -9,20 +9,20 @@
  ------------- Copyright (C) 2004  (javky@email.cz) ---------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ 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
index d1ac945d9ff8fa431dd368fd3fe9d7d6b49df7c7..6ee080500f6e6950125dfc6ca6ace812e3729562 100755 (executable)
@@ -8,20 +8,20 @@
  ------------- Copyright (C) 2004  (javky@email.cz)----------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ 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 General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ 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 General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY