#ifdef FGFS
# include <simgear/compiler.h>
-# ifdef FG_HAVE_STD_INCLUDES
+# ifdef SG_HAVE_STD_INCLUDES
# include <vector>
# else
# include <vector.h>
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_FCS "$Header"
+#define ID_FCS "$Id$"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
@see FGSwitch
@see FGGradient
@see FGFilter
- @see FGFlaps
@see FGDeadBand
*/
@param Executive a pointer to the parent executive object */
FGFCS(FGFDMExec*);
/// Destructor
- ~FGFCS(void);
+ ~FGFCS();
/** Runs the Flight Controls model; called by the Executive
@return false if no error */
/// @name Pilot input command retrieval
//@{
/** Gets the aileron command.
- @return aileron command in radians */
- inline float GetDaCmd(void) { return DaCmd; }
+ @return aileron command in percent */
+ inline double GetDaCmd(void) { return DaCmd; }
+
/** Gets the elevator command.
- @return elevator command in radians */
- inline float GetDeCmd(void) { return DeCmd; }
+ @return elevator command in percent */
+ inline double GetDeCmd(void) { return DeCmd; }
+
/** Gets the rudder command.
- @return rudder command in radians */
- inline float GetDrCmd(void) { return DrCmd; }
+ @return rudder command in percent */
+ inline double GetDrCmd(void) { return DrCmd; }
+
/** Gets the flaps command.
- @return flaps command in radians */
- inline float GetDfCmd(void) { return DfCmd; }
+ @return flaps command in percent */
+ inline double GetDfCmd(void) { return DfCmd; }
+
/** Gets the speedbrake command.
- @return speedbrake command in radians */
- inline float GetDsbCmd(void) { return DsbCmd; }
+ @return speedbrake command in percent */
+ inline double GetDsbCmd(void) { return DsbCmd; }
+
/** Gets the spoiler command.
- @return spoiler command in radians */
- inline float GetDspCmd(void) { return DspCmd; }
+ @return spoiler command in percent */
+ inline double GetDspCmd(void) { return DspCmd; }
+
/** Gets the throttle command.
@param engine engine ID number
@return throttle command in percent ( 0 - 100) for the given engine */
- inline float GetThrottleCmd(int engine) { return ThrottleCmd[engine]; }
+ double GetThrottleCmd(int engine);
+
+ /** Gets the mixture command.
+ @param engine engine ID number
+ @return mixture command in percent ( 0 - 100) for the given engine */
+ inline double GetMixtureCmd(int engine) { return MixtureCmd[engine]; }
+
+ /** Gets the prop pitch command.
+ @param engine engine ID number
+ @return pitch command in percent ( 0.0 - 1.0) for the given engine */
+ inline double GetPropAdvanceCmd(int engine) { return PropAdvanceCmd[engine]; }
+
/** Gets the pitch trim command.
- @return pitch trim command in radians */
- inline float GetPitchTrimCmd(void) { return PTrimCmd; }
- //@}
+ @return pitch trim command in percent */
+ inline double GetPitchTrimCmd(void) { return PTrimCmd; }
+
+ /** Gets the rudder trim command.
+ @return rudder trim command in percent */
+ inline double GetYawTrimCmd(void) { return YTrimCmd; }
+ /** Gets the aileron trim command.
+ @return aileron trim command in percent */
+ inline double GetRollTrimCmd(void) { return RTrimCmd; }
+
+ /** Get the gear extend/retract command. 0 commands gear up, 1 down.
+ defaults to down.
+ @return the current value of the gear extend/retract command*/
+ inline double GetGearCmd(void) { return GearCmd; }
+ //@}
+
/// @name Aerosurface position retrieval
//@{
/** Gets the aileron position.
@return aileron position in radians */
- inline float GetDaPos(void) { return DaPos; }
+ inline double GetDaPos(void) { return DaPos; }
+
/** Gets the elevator position.
@return elevator position in radians */
- inline float GetDePos(void) { return DePos; }
+ inline double GetDePos(void) { return DePos; }
+
/** Gets the rudder position.
@return rudder position in radians */
- inline float GetDrPos(void) { return DrPos; }
+ inline double GetDrPos(void) { return DrPos; }
+
/** Gets the flaps position.
@return flaps position in radians */
- inline float GetDfPos(void) { return DfPos; }
+ inline double GetDfPos(void) { return DfPos; }
+
/** Gets the speedbrake position.
@return speedbrake position in radians */
- inline float GetDsbPos(void) { return DsbPos; }
+ inline double GetDsbPos(void) { return DsbPos; }
+
/** Gets the spoiler position.
@return spoiler position in radians */
- inline float GetDspPos(void) { return DspPos; }
+ inline double GetDspPos(void) { return DspPos; }
+
/** Gets the throttle position.
@param engine engine ID number
@return throttle position for the given engine in percent ( 0 - 100)*/
- inline float GetThrottlePos(int engine) { return ThrottlePos[engine]; }
+ double GetThrottlePos(int engine);
+
+ /** Gets the mixture position.
+ @param engine engine ID number
+ @return mixture position for the given engine in percent ( 0 - 100)*/
+ inline double GetMixturePos(int engine) { return MixturePos[engine]; }
+
+ /** Gets the gear position (0 up, 1 down), defaults to down
+ @return gear position (0 up, 1 down) */
+ inline double GetGearPos(void) { return GearPos; }
+
+ /** Gets the prop pitch position.
+ @param engine engine ID number
+ @return prop pitch position for the given engine in percent ( 0.0-1.0)*/
+ inline double GetPropAdvance(int engine) { return PropAdvance[engine]; }
//@}
/** Retrieves the State object pointer.
This is used by the FGFCS-owned components.
@return pointer to the State object */
inline FGState* GetState(void) { return State; }
+
/** Retrieves a components output value
@param idx the index of the component (the component ID)
@return output value from the component */
- float GetComponentOutput(eParam idx);
+ double GetComponentOutput(eParam idx);
+
/** Retrieves the component name
@param idx the index of the component (the component ID)
@return name of the component */
string GetComponentName(int idx);
+ /** Retrieves all component names for inclusion in output stream */
+ string GetComponentStrings(void);
+
+ /** Retrieves all component outputs for inclusion in output stream */
+ string GetComponentValues(void);
+
/// @name Pilot input command setting
//@{
/** Sets the aileron command
- @param cmd aileron command in radians*/
- inline void SetDaCmd(float cmd) { DaCmd = cmd; }
+ @param cmd aileron command in percent*/
+ inline void SetDaCmd(double cmd) { DaCmd = cmd; }
+
/** Sets the elevator command
- @param cmd elevator command in radians*/
- inline void SetDeCmd(float cmd) { DeCmd = cmd; }
+ @param cmd elevator command in percent*/
+ inline void SetDeCmd(double cmd) { DeCmd = cmd; }
+
/** Sets the rudder command
- @param cmd rudder command in radians*/
- inline void SetDrCmd(float cmd) { DrCmd = cmd; }
+ @param cmd rudder command in percent*/
+ inline void SetDrCmd(double cmd) { DrCmd = cmd; }
+
/** Sets the flaps command
- @param cmd flaps command in radians*/
- inline void SetDfCmd(float cmd) { DfCmd = cmd; }
+ @param cmd flaps command in percent*/
+ inline void SetDfCmd(double cmd) { DfCmd = cmd; }
+
/** Sets the speedbrake command
- @param cmd speedbrake command in radians*/
- inline void SetDsbCmd(float cmd) { DsbCmd = cmd; }
+ @param cmd speedbrake command in percent*/
+ inline void SetDsbCmd(double cmd) { DsbCmd = cmd; }
+
/** Sets the spoilers command
- @param cmd spoilers command in radians*/
- inline void SetDspCmd(float cmd) { DspCmd = cmd; }
+ @param cmd spoilers command in percent*/
+ inline void SetDspCmd(double cmd) { DspCmd = cmd; }
+
/** Sets the pitch trim command
- @param cmd pitch trim command in radians*/
- inline void SetPitchTrimCmd(float cmd) { PTrimCmd = cmd; }
+ @param cmd pitch trim command in percent*/
+ inline void SetPitchTrimCmd(double cmd) { PTrimCmd = cmd; }
+
+ /** Sets the rudder trim command
+ @param cmd rudder trim command in percent*/
+ inline void SetYawTrimCmd(double cmd) { YTrimCmd = cmd; }
+
+ /** Sets the aileron trim command
+ @param cmd aileron trim command in percent*/
+ inline void SetRollTrimCmd(double cmd) { RTrimCmd = cmd; }
+
/** Sets the throttle command for the specified engine
- @param engine engine ID number
+ @param engine engine ID number
@param cmd throttle command in percent (0 - 100)*/
- inline void SetThrottleCmd(int engine, float cmd);
+ 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)*/
+ void SetMixtureCmd(int engine, double cmd);
+
+ /** Set the gear extend/retract command, defaults to down
+ @param gear command 0 for up, 1 for down */
+ void SetGearCmd(double gearcmd) { GearCmd = gearcmd; }
+
+ /** Sets the propeller pitch command for the specified engine
+ @param engine engine ID number
+ @param cmd mixture command in percent (0.0 - 1.0)*/
+ void SetPropAdvanceCmd(int engine, double cmd);
//@}
/// @name Aerosurface position setting
//@{
/** Sets the aileron position
@param cmd aileron position in radians*/
- inline void SetDaPos(float cmd) { DaPos = cmd; }
+ inline void SetDaPos(double cmd) { DaPos = cmd; }
+
/** Sets the elevator position
@param cmd elevator position in radians*/
- inline void SetDePos(float cmd) { DePos = cmd; }
+ inline void SetDePos(double cmd) { DePos = cmd; }
+
/** Sets the rudder position
@param cmd rudder position in radians*/
- inline void SetDrPos(float cmd) { DrPos = cmd; }
+ inline void SetDrPos(double cmd) { DrPos = cmd; }
+
/** Sets the flaps position
@param cmd flaps position in radians*/
- inline void SetDfPos(float cmd) { DfPos = cmd; }
+ inline void SetDfPos(double cmd) { DfPos = cmd; }
+
/** Sets the speedbrake position
@param cmd speedbrake position in radians*/
- inline void SetDsbPos(float cmd) { DsbPos = cmd; }
+ inline void SetDsbPos(double cmd) { DsbPos = cmd; }
+
/** Sets the spoiler position
@param cmd spoiler position in radians*/
- inline void SetDspPos(float cmd) { DspPos = cmd; }
+ inline void SetDspPos(double cmd) { DspPos = cmd; }
+
/** Sets the actual throttle setting for the specified engine
- @param engine engine ID number
+ @param engine engine ID number
@param cmd throttle setting in percent (0 - 100)*/
- inline void SetThrottlePos(int engine, float cmd);
+ 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)*/
+ void SetMixturePos(int engine, double cmd);
+
+ /** Set the gear extend/retract position, defaults to down
+ @param gear position 0 up, 1 down */
+ void SetGearPos(double gearpos) { GearPos = gearpos; }
+
+
+ /** Sets the actual prop pitch setting for the specified engine
+ @param engine engine ID number
+ @param cmd prop pitch setting in percent (0.0 - 1.0)*/
+ void SetPropAdvance(int engine, double cmd);
//@}
/// @name Landing Gear brakes
//@{
/** Sets the left brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetLBrake(float cmd) {LeftBrake = cmd;}
+ void SetLBrake(double cmd) {LeftBrake = cmd;}
+
/** Sets the right brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetRBrake(float cmd) {RightBrake = cmd;}
+ void SetRBrake(double cmd) {RightBrake = cmd;}
+
/** Sets the center brake group
@param cmd brake setting in percent (0.0 - 1.0) */
- void SetCBrake(float cmd) {CenterBrake = cmd;}
+ void SetCBrake(double cmd) {CenterBrake = 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 */
- float GetBrake(FGLGear::eBrakeGroup bg);
+ double GetBrake(FGLGear::BrakeGroup bg);
//@}
/** Loads the Flight Control System.
the config file instance pointer. LoadFCS() is called from FGAircraft.
@param AC_cfg pointer to the config file instance
@return true if succesful */
- bool LoadFCS(FGConfigFile* AC_cfg);
-
- /** The name of the flight control laws for this aircraft.
- This is given in the config file, and is not used for anything currently.*/
- string FCSName;
-
+ bool Load(FGConfigFile* AC_cfg);
+
+ void AddThrottle(void);
+
private:
- float DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
- float DaPos, DePos, DrPos, DfPos, DsbPos, DspPos;
- float PTrimCmd;
- float ThrottleCmd[MAX_ENGINES]; // Needs to be changed: s/b no limit
- float ThrottlePos[MAX_ENGINES]; // Needs to be changed: s/b no limit
- float LeftBrake, RightBrake, CenterBrake; // Brake settings
+ double DaCmd, DeCmd, DrCmd, DfCmd, DsbCmd, DspCmd;
+ double DaPos, DePos, DrPos, DfPos, DsbPos, DspPos;
+ double PTrimCmd, YTrimCmd, RTrimCmd;
+ vector <double> ThrottleCmd;
+ vector <double> ThrottlePos;
+ vector <double> MixtureCmd;
+ vector <double> MixturePos;
+ vector <double> PropAdvanceCmd;
+ vector <double> PropAdvance;
+ double LeftBrake, RightBrake, CenterBrake; // Brake settings
+ double GearCmd,GearPos;
vector <FGFCSComponent*> Components;
-
+ void Debug(int from);
};
#include "FGState.h"
#endif
+