]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGCoefficient.h
Curt Olson:
[flightgear.git] / src / FDM / JSBSim / FGCoefficient.h
index a3c49466753a65810ae2259ee6a4835dbc1ab2ad..01c6abb806337bc84401ecb1efc53a833606ca82 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  Header:       FGCoefficient.h
  Author:       Jon Berndt
@@ -27,60 +27,42 @@ HISTORY
 --------------------------------------------------------------------------------
 12/28/98   JSB   Created
 
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifndef FGCOEFFICIENT_H
 #define FGCOEFFICIENT_H
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  include STL_STRING
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <fstream>
-#  else
-#    include <fstream.h>
-#  endif
-   FG_USING_STD(string);
-#else
-#  include <string>
-#  include <fstream>
 #endif
 
-#include <map>
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-#define FG_QBAR         1
-#define FG_WINGAREA     2
-#define FG_WINGSPAN     4
-#define FG_CBAR         8
-#define FG_ALPHA       16
-#define FG_ALPHADOT    32
-#define FG_BETA        64
-#define FG_BETADOT    128
-#define FG_PITCHRATE  256
-#define FG_ROLLRATE   512
-#define FG_YAWRATE   1024
-#define FG_ELEVATOR  2048
-#define FG_AILERON   4096
-#define FG_RUDDER    8192
-#define FG_MACH     16384
-#define FG_ALTITUDE 32768L
-#define FG_BI2VEL   65536L
-#define FG_CI2VEL  131072L
-
-/*******************************************************************************
+#include <vector>
+#include <string>
+#include "FGConfigFile.h"
+#include "FGTable.h"
+#include "FGJSBBase.h"
+#include "FGPropertyManager.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_COEFFICIENT "$Id$"
+
+using std::vector;
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
 class FGFDMExec;
 class FGState;
 class FGAtmosphere;
@@ -92,75 +74,113 @@ class FGPosition;
 class FGAuxiliary;
 class FGOutput;
 
-/*******************************************************************************
-COMMENTS, REFERENCES,  and NOTES
-********************************************************************************
-
-This class models the stability derivative coefficient lookup tables or 
-equations. Note that the coefficients need not be calculated each delta-t.
-
-FG_QBAR         1
-FG_WINGAREA     2
-FG_WINGSPAN     4
-FG_CBAR         8
-FG_ALPHA       16
-FG_ALPHADOT    32
-FG_BETA        64
-FG_BETADOT    128
-FG_PITCHRATE  256
-FG_ROLLRATE   512
-FG_YAWRATE   1024
-FG_ELEVATOR  2048
-FG_AILERON   4096
-FG_RUDDER    8192
-FG_MACH     16384
-FG_ALTITUDE 32768L
-FG_BI2VEL   65536L
-FG_CI2VEL  131072L
-
-********************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** This class models the aero coefficient and stability derivative coefficient
+    lookup table, value, vector, or equation (equation not modeled, yet).
+    Each coefficient for an axis is stored in that axes' vector of coefficients.
+    Each FDM execution frame the Run() method of the FGAerodynamics model
+    is called and the coefficient values are calculated.
+    @author Jon S. Berndt
+    @version $Id$
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGCoefficient
+class FGCoefficient : public FGJSBBase
 {
 public:
-  FGCoefficient(FGFDMExec*, ifstream&);
-  ~FGCoefficient(void);
-  bool Allocate(int);
-  bool Allocate(int, int);
-  float Value(float, float);
-  float Value(float);
-  float Value(void);
-  float TotalValue(void);
-  inline float GetSDValue(void) {return SD;}
-  inline void SetSDValue(float tt) {SD = tt;}
-  void DumpSD(void);
+  /** Constructor.
+      @param exec a pointer to the FGFDMExec instance. */
+  FGCoefficient(FGFDMExec* exec);
+  /// Destructor.
+  virtual ~FGCoefficient();
+  
+  /** Loads the stability derivative/aero coefficient data from the config file
+      as directed by the FGAerodynamics instance.
+      @param AC_cfg a pointer to the current config file instance. */
+  virtual bool Load(FGConfigFile* AC_cfg);
+  
+  typedef vector <FGPropertyManager*> MultVec;
+
   enum Type {UNKNOWN, VALUE, VECTOR, TABLE, EQUATION};
 
+  /** Returns the value for this coefficient.
+      Each instance of FGCoefficient stores a value for the "type" of coefficient
+      it is, one of: VALUE, VECTOR, TABLE, or EQUATION. This TotalValue function 
+      is called when the value for a coefficient needs to be known. When it is called,
+      depending on what type of coefficient is represented by the FGCoefficient
+      instance, TotalValue() directs the appropriate Value() function to be called.
+      The type of coefficient represented is determined when the config file is read.
+      The coefficient definition includes the "type" specifier.
+      @return the current value of the coefficient represented by this instance of
+      FGCoefficient. */
+  virtual double TotalValue(void);
+
+  /** Returns the value for this coefficient.
+      TotalValue is stored each time TotalValue() is called. This function returns
+      the stored value but does not calculate it anew. This is valuable for merely
+      printing out the value.
+      @return the most recently calculated and stored value of the coefficient
+      represented by this instance of FGCoefficient. */
+  virtual inline double GetValue(void) const { return totalValue; }
+
+  /// Returns the name of this coefficient.
+  virtual inline string Getname(void) const {return name;}
+
+  /// Returns the value of the coefficient only - before it is re-dimensionalized.
+  virtual inline double GetSD(void) const { return SD;}
+
+  /** Outputs coefficient information.
+      Non-dimensionalizing parameter descriptions are output
+      for each aero coefficient defined. */
+  virtual void DisplayCoeffFactors(void);
+
+  /// Returns the name of the coefficient.
+  virtual inline string GetCoefficientName(void) { return name; }
+  /// Returns the stability derivative or coefficient value as a string.
+  virtual string GetSDstring(void);
+
+  inline void setBias(double b) { bias=b; }
+  inline void setGain(double g) { gain=g; };
+  inline double getBias(void) const { return bias; }
+  inline double getGain(void) const { return gain; }
+  
+  virtual void bind(FGPropertyManager *parent);
+  virtual void unbind(void);
+
 protected:
+  FGFDMExec* FDMExec;
 
 private:
-  typedef map<string, long> CoeffMap;
-  CoeffMap coeffdef;
-  string filename;
+  int numInstances;
   string description;
   string name;
+  string filename;
   string method;
-  float StaticValue;
-  float *Table2D;
-  float **Table3D;
-  float LookupR, LookupC;
-  long int mult_idx[10];
+  string multparms;
+  string multparmsRow;
+  string multparmsCol;
+  double Value(double, double);
+  double Value(double);
+  double Value(void);
+  double StaticValue;
+  double totalValue;
+  double bias,gain;
+  FGPropertyManager *LookupR, *LookupC;
+  
+  FGPropertyManager *node; // must be private!!
+  
+  MultVec multipliers;
   int rows, columns;
   Type type;
-  int multipliers;
-  int mult_count;
-  float SD; // Actual stability derivative (or other coefficient) value
+  double SD; // Actual stability derivative (or other coefficient) value
+  FGTable *Table;
 
-  float GetCoeffVal(int);
-
-  FGFDMExec*      FDMExec;
   FGState*        State;
   FGAtmosphere*   Atmosphere;
   FGFCS*          FCS;
@@ -170,7 +190,15 @@ private:
   FGPosition*     Position;
   FGAuxiliary*    Auxiliary;
   FGOutput*       Output;
+  FGPropertyManager* PropertyManager;
+  
+  FGPropertyManager* resolveSymbol(string name);
+
+  virtual void Debug(int from);
 };
 
-/******************************************************************************/
+} // using namespace JSBSim
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 #endif
+