]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGState.h
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGState.h
index 9311cba4bf6eb138f9330d5893b6486b26e036b3..8709b00b35d7418f2ea4b1252f28784eda92bd6d 100644 (file)
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  Header:       FGState.h
  Author:       Jon S. Berndt
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
 
-Based on Flightgear code, which is based on LaRCSim. This class wraps all
-global state variables (such as velocity, position, orientation, etc.).
-
 HISTORY
 --------------------------------------------------------------------------------
 11/17/98   JSB   Created
 
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifndef FGSTATE_H
 #define FGSTATE_H
 
-/*******************************************************************************
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  include STL_STRING
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <fstream>
 #  else
 #    include <fstream.h>
 #  endif
-   FG_USING_STD(string);
 #else
-#  include <string>
-#  include <fstream>
+#  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
+#    include <fstream.h>
+#  else
+#    include <fstream>
+#  endif
 #endif
 
-#include "FGDefs.h"
+#include <string>
+#include <map>
+#include "FGJSBBase.h"
 #include "FGInitialCondition.h"
-
-/*******************************************************************************
-DEFINES
-*******************************************************************************/
-
-using namespace std;
-
-/*******************************************************************************
+#include "FGMatrix33.h"
+#include "FGColumnVector3.h"
+#include "FGQuaternion.h"
+#include "FGFDMExec.h"
+#include "FGAtmosphere.h"
+#include "FGFCS.h"
+#include "FGPropagate.h"
+#include "FGAuxiliary.h"
+#include "FGAerodynamics.h"
+#include "FGOutput.h"
+#include "FGAircraft.h"
+#include "FGGroundReactions.h"
+#include "FGPropulsion.h"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+#define ID_STATE "$Id$"
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+namespace JSBSim {
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Encapsulates the calculation of aircraft state.
+    @author Jon S. Berndt
+    @version $Id$
+*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
-*******************************************************************************/
-
-class FGFDMExec;
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGState
+class FGState : public FGJSBBase
 {
 public:
-   FGState(FGFDMExec*);
-  ~FGState(void);
-
-  bool Reset(string, string);
-  void Initialize(float, float, float, float, float, float, float, float, float);
+  /** Constructor
+      @param Executive a pointer to the parent executive object */
+  FGState(FGFDMExec*);
+  /// Destructor
+  ~FGState();
+
+  /** Initializes the simulation state based on parameters from an Initial Conditions object.
+      @param FGIC pointer to an initial conditions object.
+      @see FGInitialConditions.
+      */
   void Initialize(FGInitialCondition *FGIC);
-  bool StoreData(string);
-  bool DumpData(string);
-  bool DisplayData(void);
-
-  inline float GetVt(void) {return Vt;}
-
-  inline float Getlatitude(void) {return latitude;}
-  inline float Getlongitude(void) {return longitude;}
-  inline float GetGeodeticLat(void) {return GeodeticLat;}
-
-  inline float Getadot(void) {return adot;}
-  inline float Getbdot(void) {return bdot;}
-
-  inline float GetLocalAltitudeOverRunway(void) {return LocalAltitudeOverRunway;}
-  inline float Geth(void) {return h;}
-  inline float Geta(void) {return a;}
-  inline float GetMach(void) {return Mach;}
-
-  inline float Getsim_time(void) {return sim_time;}
-  inline float Getdt(void) {return dt;}
-
-  inline float Getqbar(void) {return qbar;}
-
-  inline void SetVt(float tt) {Vt = tt;}
-
-  inline void Setlatitude(float tt) {latitude = tt;}
-  inline void Setlongitude(float tt) {longitude = tt;}
-  inline void SetGeodeticLat(float tt) {GeodeticLat = tt;}
-
-  inline void Setadot(float tt) {adot = tt;}
-  inline void Setbdot(float tt) {bdot = tt;}
-
-  inline void Setqbar(float tt) {qbar = tt;}
-
-  inline void SetLocalAltitudeOverRunway(float tt) {LocalAltitudeOverRunway = tt;}
-  inline void Seth(float tt) {h = tt;}
-  inline void Seta(float tt) {a = tt;}
-  inline void SetMach(float tt) {Mach = tt;}
-
-  inline float Setsim_time(float tt) {sim_time = tt; return sim_time;}
-  inline void  Setdt(float tt) {dt = tt;}
-
-  inline float IncrTime(void) {sim_time+=dt;return sim_time;}
 
+  /// Returns the simulation time in seconds.
+  inline double Getsim_time(void) const { return sim_time; }
+  /// Returns the simulation delta T.
+  inline double Getdt(void) { return dt; }
+
+  /// Suspends the simulation and sets the delta T to zero.
+  inline void Suspend(void) {saved_dt = dt; dt = 0.0;}
+  /// Resumes the simulation by resetting delta T to the correct value.
+  inline void Resume(void)  {dt = saved_dt;}
+
+  /** Sets the current sim time.
+      @param cur_time the current time
+      @return the current time.
+      */
+  inline double Setsim_time(double cur_time) {
+    sim_time = cur_time;
+    return sim_time;
+  }
+
+  /** Sets the integration time step for the simulation executive.
+      @param delta_t the time step in seconds.
+      */
+  inline void  Setdt(double delta_t) { dt = delta_t; }
+
+  /** Increments the simulation time.
+      @return the new simulation time.
+      */
+  inline double IncrTime(void) {
+    sim_time+=dt;
+    return sim_time;
+  }
+
+  /** Calculates and returns the stability-to-body axis transformation matrix.
+      @return a reference to the stability-to-body transformation matrix.
+      */
+  FGMatrix33& GetTs2b(void);
+
+  /** Calculates and returns the body-to-stability axis transformation matrix.
+      @return a reference to the stability-to-body transformation matrix.
+      */
+  FGMatrix33& GetTb2s(void);
+
+  /** Prints a summary of simulator state (speed, altitude,
+      configuration, etc.)
+  */
+  void ReportState(void);
+
+  void bind();
+  void unbind();
 
 private:
-
-  float Vt;                         // Total velocity
-  float latitude, longitude;        // position
-  float GeodeticLat;                // Geodetic Latitude
-  float adot, bdot;                 // alpha dot and beta dot
-  float h, a;                       // altitude above sea level, speed of sound
-  float qbar;                       // dynamic pressure
-  float sim_time, dt;
-  float Mach;                       // Mach number
+  double sim_time, dt;
+  double saved_dt;
 
   FGFDMExec* FDMExec;
-  float LocalAltitudeOverRunway;
-
-protected:
-
+  FGMatrix33 mTs2b;
+  FGMatrix33 mTb2s;
+
+  FGAircraft* Aircraft;
+  FGPropagate* Propagate;
+  FGOutput* Output;
+  FGAtmosphere* Atmosphere;
+  FGFCS* FCS;
+  FGAerodynamics* Aerodynamics;
+  FGGroundReactions* GroundReactions;
+  FGPropulsion* Propulsion;
+  FGAuxiliary* Auxiliary;
+  FGPropertyManager* PropertyManager;
+
+  void Debug(int from);
 };
+}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 
-/******************************************************************************/
 #endif
+