]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGFCS.h
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / FGFCS.h
index 8aa9ca9ffc750ce63083663079a29b293bf9d84b..5c485c2bd01af1849d07c2c9289da3857b43bc96 100644 (file)
@@ -4,7 +4,7 @@
  Author:       Jon S. Berndt
  Date started: 12/12/98
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
 
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free Software
@@ -38,19 +38,20 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <iosfwd>
 #include <vector>
 
 #include <string>
-#include <models/flight_control/FGFCSComponent.h>
-#include <models/FGModel.h>
-#include <models/FGLGear.h>
-#include <input_output/FGXMLFileRead.h>
+#include "models/flight_control/FGFCSComponent.h"
+#include "models/FGModel.h"
+#include "models/FGLGear.h"
+#include "input_output/FGXMLFileRead.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#define ID_FCS "$Id$"
+#define ID_FCS "$Id: FGFCS.h,v 1.40 2011/10/31 14:54:41 bcoconni Exp $"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -167,7 +168,7 @@ CLASS DOCUMENTATION
     @property gear/tailhook-pos-norm
 
     @author Jon S. Berndt
-    @version $Revision$
+    @version $Revision: 1.40 $
     @see FGActuator
     @see FGDeadBand
     @see FGFCSFunction
@@ -199,8 +200,13 @@ public:
   bool InitModel(void);
 
   /** Runs the Flight Controls model; called by the Executive
+      Can pass in a value indicating if the executive is directing the simulation to Hold.
+      @param Holding if true, the executive has been directed to hold the sim from 
+                     advancing time. Some models may ignore this flag, such as the Input
+                     model, which may need to be active to listen on a socket for the
+                     "Resume" command to be given.
       @return false if no error */
-  bool Run(void);
+  bool Run(bool Holding);
 
   /// @name Pilot input command retrieval
   //@{
@@ -237,11 +243,15 @@ public:
       @return throttle command in range from 0 - 1.0 for the given engine */
   double GetThrottleCmd(int engine) const;
 
+  const vector<double>& GetThrottleCmd() const {return ThrottleCmd;}
+
   /** Gets the mixture command.
       @param engine engine ID number
       @return mixture command in range from 0 - 1.0 for the given engine */
   double GetMixtureCmd(int engine) const { return MixtureCmd[engine]; }
 
+  const vector<double>& GetMixtureCmd() const {return MixtureCmd;}
+
   /** Gets the prop pitch command.
       @param engine engine ID number
       @return pitch command in range from 0.0 - 1.0 for the given engine */
@@ -277,8 +287,6 @@ public:
   double GetDaLPos( int form = ofRad )
                          const { return DaLPos[form]; }
 
-  /// @name Aerosurface position retrieval
-  //@{
   /** Gets the right aileron position.
       @return aileron position in radians */
   double GetDaRPos( int form = ofRad )
@@ -314,15 +322,21 @@ public:
       @return throttle position for the given engine in range from 0 - 1.0 */
   double GetThrottlePos(int engine) const;
 
+  const vector<double>& GetThrottlePos() const {return ThrottlePos;}
+
   /** Gets the mixture position.
       @param engine engine ID number
       @return mixture position for the given engine in range from 0 - 1.0 */
   double GetMixturePos(int engine) const { return MixturePos[engine]; }
 
+  const vector<double>& GetMixturePos() const {return MixturePos;}
+
   /** Gets the steering position.
       @return steering position in degrees */
   double GetSteerPosDeg(int gear) const { return SteerPosDeg[gear]; }
 
+  const vector<double>& GetSteerPosDeg() const {return SteerPosDeg;}
+
   /** Gets the gear position (0 up, 1 down), defaults to down
       @return gear position (0 up, 1 down) */
   double GetGearPos(void) const { return GearPos; }
@@ -340,27 +354,26 @@ public:
       @return prop pitch position for the given engine in range from 0 - 1.0 */
   double GetPropAdvance(int engine) const { return PropAdvance[engine]; }
 
+  const vector<double>& GetPropAdvance() const { return PropAdvance; }
+
   /** Gets the prop feather position.
       @param engine engine ID number
       @return prop fether for the given engine (on / off)*/
   bool GetPropFeather(int engine) const { return PropFeather[engine]; }
-  //@}
 
-  /** Retrieves the State object pointer.
-      This is used by the FGFCS-owned components.
-      @return pointer to the State object */
-  FGState* GetState(void) { return State; }
+  const vector<bool>& GetPropFeather() const { return PropFeather; }
+  //@}
 
   /** Retrieves all component names for inclusion in output stream
-      @param delimeter either a tab or comma string depending on output type
+      @param delimiter either a tab or comma string depending on output type
       @return a string containing the descriptive names for all components */
-  string GetComponentStrings(string delimeter);
+  std::string GetComponentStrings(const std::string& delimiter) const;
 
   /** Retrieves all component outputs for inclusion in output stream
-      @param delimeter either a tab or comma string depending on output type
+      @param delimiter either a tab or comma string depending on output type
       @return a string containing the numeric values for the current set of
       component outputs */
-  string GetComponentValues(string delimeter);
+  std::string GetComponentValues(const std::string& delimiter) const;
 
   /// @name Pilot input command setting
   //@{
@@ -406,12 +419,12 @@ public:
 
   /** Sets the throttle command for the specified engine
       @param engine engine ID number
-      @param cmd throttle command in percent (0 - 100)*/
+      @param cmd normalized throttle command (0.0 - 1.0)*/
   void SetThrottleCmd(int engine, double cmd);
 
   /** Sets the mixture command for the specified engine
       @param engine engine ID number
-      @param cmd mixture command in percent (0 - 100)*/
+      @param cmd normalized mixture command (0.0 - 1.0)*/
   void SetMixtureCmd(int engine, double cmd);
 
   /** Set the gear extend/retract command, defaults to down
@@ -461,12 +474,12 @@ public:
 
   /** Sets the actual throttle setting for the specified engine
       @param engine engine ID number
-      @param cmd throttle setting in percent (0 - 100)*/
+      @param cmd normalized throttle setting (0.0 - 1.0)*/
   void SetThrottlePos(int engine, double cmd);
 
   /** Sets the actual mixture setting for the specified engine
       @param engine engine ID number
-      @param cmd mixture setting in percent (0 - 100)*/
+      @param cmd normalized mixture setting (0.0 - 1.0)*/
   void SetMixturePos(int engine, double cmd);
 
   /** Sets the steering position
@@ -500,32 +513,34 @@ public:
   //@{
   /** Sets the left brake group
       @param cmd brake setting in percent (0.0 - 1.0) */
-  void SetLBrake(double cmd) {LeftBrake = cmd;}
+  void SetLBrake(double cmd) {BrakePos[FGLGear::bgLeft] = cmd;}
 
   /** Sets the right brake group
       @param cmd brake setting in percent (0.0 - 1.0) */
-  void SetRBrake(double cmd) {RightBrake = cmd;}
+  void SetRBrake(double cmd) {BrakePos[FGLGear::bgRight] = cmd;}
 
   /** Sets the center brake group
       @param cmd brake setting in percent (0.0 - 1.0) */
-  void SetCBrake(double cmd) {CenterBrake = cmd;}
+  void SetCBrake(double cmd) {BrakePos[FGLGear::bgCenter] = cmd;}
 
   /** Gets the brake for a specified group.
       @param bg which brakegroup to retrieve the command for
       @return the brake setting for the supplied brake group argument */
   double GetBrake(FGLGear::BrakeGroup bg);
 
+  const vector<double>& GetBrakePos() const {return BrakePos;}
+
   /** Gets the left brake.
       @return the left brake setting. */
-  double GetLBrake(void) const {return LeftBrake;}
+  double GetLBrake(void) const {return BrakePos[FGLGear::bgLeft];}
 
   /** Gets the right brake.
       @return the right brake setting. */
-  double GetRBrake(void) const {return RightBrake;}
+  double GetRBrake(void) const {return BrakePos[FGLGear::bgRight];}
 
   /** Gets the center brake.
       @return the center brake setting. */
-  double GetCBrake(void) const {return CenterBrake;}
+  double GetCBrake(void) const {return BrakePos[FGLGear::bgCenter];}
   //@}
 
   enum SystemType { stFCS, stSystem, stAutoPilot }; 
@@ -537,39 +552,44 @@ public:
       @return true if succesful */
   bool Load(Element* el, SystemType systype);
 
-  ifstream* FindSystemFile(string system_filename);
-  string FindSystemFullPathname(string system_filename);
+  std::ifstream* FindSystemFile(const std::string& system_filename);
+  std::string FindSystemFullPathname(const std::string& system_filename);
 
   void AddThrottle(void);
-  void AddGear(void);
+  void AddGear(unsigned int NumGear);
   double GetDt(void);
 
   FGPropertyManager* GetPropertyManager(void) { return PropertyManager; }
 
+  bool GetTrimStatus(void) const { return FDMExec->GetTrimStatus(); }
+
+  struct Inputs {
+    unsigned int NumGear;
+  } in;
+
 private:
   double DaCmd, DeCmd, DrCmd, DsCmd, DfCmd, DsbCmd, DspCmd;
   double DePos[NForms], DaLPos[NForms], DaRPos[NForms], DrPos[NForms];
   double DfPos[NForms], DsbPos[NForms], DspPos[NForms];
   double PTrimCmd, YTrimCmd, RTrimCmd;
-  vector <double> ThrottleCmd;
-  vector <double> ThrottlePos;
-  vector <double> MixtureCmd;
-  vector <double> MixturePos;
-  vector <double> PropAdvanceCmd;
-  vector <double> PropAdvance;
-  vector <bool> PropFeatherCmd;
-  vector <bool> PropFeather;
-  vector <double> SteerPosDeg;
+  std::vector <double> ThrottleCmd;
+  std::vector <double> ThrottlePos;
+  std::vector <double> MixtureCmd;
+  std::vector <double> MixturePos;
+  std::vector <double> PropAdvanceCmd;
+  std::vector <double> PropAdvance;
+  std::vector <bool> PropFeatherCmd;
+  std::vector <bool> PropFeather;
+  std::vector <double> SteerPosDeg;
   double LeftBrake, RightBrake, CenterBrake; // Brake settings
+  vector <double> BrakePos; // left, center, right - defined by FGLGear:: enum
   double GearCmd,GearPos;
   double TailhookPos, WingFoldPos;
 
-  typedef vector <FGFCSComponent*> FCSCompVec;
+  typedef std::vector <FGFCSComponent*> FCSCompVec;
   FCSCompVec Systems;
   FCSCompVec FCSComponents;
   FCSCompVec APComponents;
-  FCSCompVec sensors;
-  vector <double*> interface_properties;
   void bind(void);
   void bindModel(void);
   void bindThrottle(unsigned int);