]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGTrim.h
Latest JSBSim changes, including some gear tweaking from Jon and some
[flightgear.git] / src / FDM / JSBSim / FGTrim.h
index de1b02cf0201a79ee733a1d90b4c29e0fffa6d0f..0e6019efc0dabefd9bd7150ce1c27c756248f8a3 100644 (file)
@@ -49,6 +49,7 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGFDMExec.h"
+#include "FGJSBBase.h"
 #include "FGRotation.h"
 #include "FGAtmosphere.h"
 #include "FGState.h"
@@ -69,12 +70,18 @@ DEFINITIONS
 
 #define ID_TRIM "$Id$"
 
+typedef enum { tLongitudinal, tFull, tGround, tPullup, 
+               tCustom, tNone, tTurn 
+             } TrimMode;
+
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-typedef enum { tLongitudinal, tFull, tGround, tCustom, tNone } TrimMode;
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -135,19 +142,20 @@ CLASS DOCUMENTATION
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGTrim {
+class FGTrim : public FGJSBBase
+{
 private:
 
   vector<FGTrimAxis*> TrimAxes;
-  int current_axis;
+  unsigned int current_axis;
   int N, Nsub;
   TrimMode mode;
-  int Debug;
-  float Tolerance, A_Tolerance;
-  float wdot,udot,qdot;
-  float dth;
-  float *sub_iterations;
-  float *successful;
+  int DebugLevel, Debug;
+  double Tolerance, A_Tolerance;
+  double wdot,udot,qdot;
+  double dth;
+  double *sub_iterations;
+  double *successful;
   bool *solution;
   int max_sub_iterations;
   int max_iterations;
@@ -155,9 +163,13 @@ private:
   bool trimudot;
   bool gamma_fallback;
   bool trim_failed;
-  int axis_count;
+  unsigned int axis_count;
   int solutionDomain;
-  float xlo,xhi,alo,ahi;
+  double xlo,xhi,alo,ahi;
+  double targetNlf;
+  int debug_axis;
+  
+  double psidot,thetadot;
 
   FGFDMExec* fdmex;
   FGInitialCondition* fgic;
@@ -174,6 +186,13 @@ private:
   bool findInterval(void);
 
   bool checkLimits(void);
+  
+  void setupPullup(void);
+  void setupTurn(void);
+  
+  void updateRates(void);
+
+  void setDebug(void);
 
 public:
   /** Initializes the trimming class
@@ -197,11 +216,6 @@ public:
   */     
   void Report(void);
   
-  /** Prints a summary of simulator state (speed, altitude, 
-      configuration, etc.)
-  */
-  void ReportState(void);
-  
   /** Iteration statistics
   */
   void TrimStats();
@@ -264,15 +278,26 @@ public:
       held to a tolerance of 1/10th of the given.  The default is 
       0.001 for the recti-linear accelerations and 0.0001 for the angular.
   */         
-  inline void SetTolerance(float tt) {
+  inline void SetTolerance(double tt) {
     Tolerance = tt;
     A_Tolerance = tt / 10;
   }
   
-  //Debug level 1 shows results of each top-level iteration
-  //Debug level 2 shows level 1 & results of each per-axis iteration
-  inline void SetDebug(int level) { Debug = level; }
-  inline void ClearDebug(void) { Debug = 0; }
+  /** 
+    Debug level 1 shows results of each top-level iteration
+    Debug level 2 shows level 1 & results of each per-axis iteration
+  */  
+  inline void SetDebug(int level) { DebugLevel = level; }
+  inline void ClearDebug(void) { DebugLevel = 0; }
+  
+  /**
+    Output debug data for one of the axes
+    The State enum is defined in FGTrimAxis.h
+  */  
+  inline void DebugState(State state) { debug_axis=state; }
+  
+  inline void SetTargetNlf(float nlf) { targetNlf=nlf; }
+  inline double GetTargetNlf(void) { return targetNlf; }
 
 };