JSBSim Flight Dynamics Model 1.0 (23 February 2013)
An Open Source Flight Dynamics and Control Software Library in C++

FGFCS Class Reference

Encapsulates the Flight Control System (FCS) functionality. More...

#include <FGFCS.h>

Inheritance diagram for FGFCS:
Collaboration diagram for FGFCS:

List of all members.

Classes

struct  Inputs

Public Types

enum  SystemType { stFCS, stSystem, stAutoPilot }

Public Member Functions

 FGFCS (FGFDMExec *)
 Constructor.
 ~FGFCS ()
 Destructor.
void AddGear (unsigned int NumGear)
void AddThrottle (void)
std::ifstream * FindSystemFile (const std::string &system_filename)
std::string FindSystemFullPathname (const std::string &system_filename)
std::string GetComponentStrings (const std::string &delimiter) const
 Retrieves all component names for inclusion in output stream.
std::string GetComponentValues (const std::string &delimiter) const
 Retrieves all component outputs for inclusion in output stream.
double GetDt (void)
FGPropertyManagerGetPropertyManager (void)
bool GetTrimStatus (void) const
bool InitModel (void)
bool Load (Element *el, SystemType systype)
 Loads the Flight Control System.
bool Run (bool Holding)
 Runs the Flight Controls model; called by the Executive Can pass in a value indicating if the executive is directing the simulation to Hold.
Pilot input command retrieval
double GetDaCmd (void) const
 Gets the aileron command.
double GetDeCmd (void) const
 Gets the elevator command.
double GetDrCmd (void) const
 Gets the rudder command.
double GetDsCmd (void) const
 Gets the steering command.
double GetDfCmd (void) const
 Gets the flaps command.
double GetDsbCmd (void) const
 Gets the speedbrake command.
double GetDspCmd (void) const
 Gets the spoiler command.
double GetThrottleCmd (int engine) const
 Gets the throttle command.
const vector< double > & GetThrottleCmd () const
double GetMixtureCmd (int engine) const
 Gets the mixture command.
const vector< double > & GetMixtureCmd () const
double GetPropAdvanceCmd (int engine) const
 Gets the prop pitch command.
bool GetFeatherCmd (int engine) const
 Gets the prop feather command.
double GetPitchTrimCmd (void) const
 Gets the pitch trim command.
double GetYawTrimCmd (void) const
 Gets the rudder trim command.
double GetRollTrimCmd (void) const
 Gets the aileron trim command.
double GetGearCmd (void) const
 Get the gear extend/retract command.
Aerosurface position retrieval
double GetDaLPos (int form=ofRad) const
 Gets the left aileron position.
double GetDaRPos (int form=ofRad) const
 Gets the right aileron position.
double GetDePos (int form=ofRad) const
 Gets the elevator position.
double GetDrPos (int form=ofRad) const
 Gets the rudder position.
double GetDsbPos (int form=ofRad) const
 Gets the speedbrake position.
double GetDspPos (int form=ofRad) const
 Gets the spoiler position.
double GetDfPos (int form=ofRad) const
 Gets the flaps position.
double GetThrottlePos (int engine) const
 Gets the throttle position.
const vector< double > & GetThrottlePos () const
double GetMixturePos (int engine) const
 Gets the mixture position.
const vector< double > & GetMixturePos () const
double GetSteerPosDeg (int gear) const
 Gets the steering position.
const vector< double > & GetSteerPosDeg () const
double GetGearPos (void) const
 Gets the gear position (0 up, 1 down), defaults to down.
double GetTailhookPos (void) const
 Gets the tailhook position (0 up, 1 down)
double GetWingFoldPos (void) const
 Gets the wing fold position (0 unfolded, 1 folded)
double GetPropAdvance (int engine) const
 Gets the prop pitch position.
const vector< double > & GetPropAdvance () const
bool GetPropFeather (int engine) const
 Gets the prop feather position.
const vector< bool > & GetPropFeather () const
Pilot input command setting
void SetDaCmd (double cmd)
 Sets the aileron command.
void SetDeCmd (double cmd)
 Sets the elevator command.
void SetDrCmd (double cmd)
 Sets the rudder command.
void SetDsCmd (double cmd)
 Sets the steering command.
void SetDfCmd (double cmd)
 Sets the flaps command.
void SetDsbCmd (double cmd)
 Sets the speedbrake command.
void SetDspCmd (double cmd)
 Sets the spoilers command.
void SetPitchTrimCmd (double cmd)
 Sets the pitch trim command.
void SetYawTrimCmd (double cmd)
 Sets the rudder trim command.
void SetRollTrimCmd (double cmd)
 Sets the aileron trim command.
void SetThrottleCmd (int engine, double cmd)
 Sets the throttle command for the specified engine.
void SetMixtureCmd (int engine, double cmd)
 Sets the mixture command for the specified engine.
void SetGearCmd (double gearcmd)
 Set the gear extend/retract command, defaults to down.
void SetPropAdvanceCmd (int engine, double cmd)
 Sets the propeller pitch command for the specified engine.
void SetFeatherCmd (int engine, bool cmd)
 Sets the propeller feather command for the specified engine.
Aerosurface position setting
void SetDaLPos (int form, double pos)
 Sets the left aileron position.
void SetDaRPos (int form, double pos)
 Sets the right aileron position.
void SetDePos (int form, double pos)
 Sets the elevator position.
void SetDrPos (int form, double pos)
 Sets the rudder position.
void SetDfPos (int form, double pos)
 Sets the flaps position.
void SetDsbPos (int form, double pos)
 Sets the speedbrake position.
void SetDspPos (int form, double pos)
 Sets the spoiler position.
void SetThrottlePos (int engine, double cmd)
 Sets the actual throttle setting for the specified engine.
void SetMixturePos (int engine, double cmd)
 Sets the actual mixture setting for the specified engine.
void SetSteerPosDeg (int gear, double pos)
 Sets the steering position.
void SetGearPos (double gearpos)
 Set the gear extend/retract position, defaults to down.
void SetTailhookPos (double hookpos)
 Set the tailhook position.
void SetWingFoldPos (double foldpos)
 Set the wing fold position.
void SetPropAdvance (int engine, double cmd)
 Sets the actual prop pitch setting for the specified engine.
void SetPropFeather (int engine, bool cmd)
 Sets the actual prop feather setting for the specified engine.
Landing Gear brakes
void SetLBrake (double cmd)
 Sets the left brake group.
void SetRBrake (double cmd)
 Sets the right brake group.
void SetCBrake (double cmd)
 Sets the center brake group.
double GetBrake (FGLGear::BrakeGroup bg)
 Gets the brake for a specified group.
const vector< double > & GetBrakePos () const
double GetLBrake (void) const
 Gets the left brake.
double GetRBrake (void) const
 Gets the right brake.
double GetCBrake (void) const
 Gets the center brake.

Public Attributes

struct JSBSim::FGFCS::Inputs in

Detailed Description

This class also encapsulates the identical "system" and "autopilot" capability. FGFCS owns and contains the list of FGFCSComponents that define a system or systems for the modeled aircraft. The config file for the aircraft contains a description of the control path that starts at an input or command and ends at an effector, e.g. an aerosurface. The FCS components which comprise the control laws for an axis are defined sequentially in the configuration file. For instance, for the X-15:

    <flight_control name="X-15 SAS">
      <channel>
        <summer name="Pitch Trim Sum">
           <input> fcs/elevator-cmd-norm </input>
           <input> fcs/pitch-trim-cmd-norm </input>
           <clipto>
             <min>-1</min>
             <max>1</max>
           </clipto>
        </summer>

        <aerosurface_scale name="Pitch Command Scale">
          <input> fcs/pitch-trim-sum </input>
          <range>
            <min> -50 </min>
            <max>  50 </max>
          </range>
        </aerosurface_scale>

        ... etc.

In the above case we can see the first few components of the pitch channel defined. The input to the first component (a summer), as can be seen in the "Pitch trim sum" component, is really the sum of two parameters: elevator command (from the stick - a pilot input), and pitch trim. The next component created is an aerosurface scale component - a type of gain (see the LoadFCS() method for insight on how the various types of components map into the actual component classes). This continues until the final component for an axis when the <output> element is usually used to specify where the output is supposed to go. See the individual components for more information on how they are mechanized.

Another option for the flight controls portion of the config file is that in addition to using the "NAME" attribute in,

    <flight_control name="X-15 SAS">

one can also supply a filename:

    <flight_control name="X-15 SAS" file="X15.xml">
    </flight_control>

In this case, the FCS would be read in from another file.

Properties

  • fcs/aileron-cmd-norm normalized aileron command
  • fcs/elevator-cmd-norm normalized elevator command
  • fcs/rudder-cmd-norm
  • fcs/steer-cmd-norm
  • fcs/flap-cmd-norm
  • fcs/speedbrake-cmd-norm
  • fcs/spoiler-cmd-norm
  • fcs/pitch-trim-cmd-norm
  • fcs/roll-trim-cmd-norm
  • fcs/yaw-trim-cmd-norm
  • gear/gear-cmd-norm
  • fcs/left-aileron-pos-rad
  • fcs/left-aileron-pos-deg
  • fcs/left-aileron-pos-norm
  • fcs/mag-left-aileron-pos-rad
  • fcs/right-aileron-pos-rad
  • fcs/right-aileron-pos-deg
  • fcs/right-aileron-pos-norm
  • fcs/mag-right-aileron-pos-rad
  • fcs/elevator-pos-rad
  • fcs/elevator-pos-deg
  • fcs/elevator-pos-norm
  • fcs/mag-elevator-pos-rad
  • fcs/rudder-pos-rad
  • fcs/rudder-pos-deg
  • fcs/rudder-pos-norm
  • fcs/mag-rudder-pos-rad
  • fcs/flap-pos-rad
  • fcs/flap-pos-deg
  • fcs/flap-pos-norm
  • fcs/speedbrake-pos-rad
  • fcs/speedbrake-pos-deg
  • fcs/speedbrake-pos-norm
  • fcs/mag-speedbrake-pos-rad
  • fcs/spoiler-pos-rad
  • fcs/spoiler-pos-deg
  • fcs/spoiler-pos-norm
  • fcs/mag-spoiler-pos-rad
  • fcs/wing-fold-pos-norm
  • gear/gear-pos-norm
  • gear/tailhook-pos-norm
Author:
Jon S. Berndt
Version:
Revision:
1.41
See also:
FGActuator
FGDeadBand
FGFCSFunction
FGFilter
FGGain
FGKinemat
FGPID
FGSensor
FGSummer
FGSwitch
FGFCSComponent
Element

Definition at line 191 of file FGFCS.h.


Constructor & Destructor Documentation

FGFCS ( FGFDMExec fdmex)
Parameters:
Executivea pointer to the parent executive object

Definition at line 76 of file FGFCS.cpp.

                             : FGModel(fdmex)
{
  int i;
  Name = "FGFCS";

  DaCmd = DeCmd = DrCmd = DsCmd = DfCmd = DsbCmd = DspCmd = 0;
  PTrimCmd = YTrimCmd = RTrimCmd = 0.0;
  GearCmd = GearPos = 1; // default to gear down
  BrakePos.resize(FGLGear::bgNumBrakeGroups);
  TailhookPos = WingFoldPos = 0.0; 

  bind();
  for (i=0;i<NForms;i++) {
    DePos[i] = DaLPos[i] = DaRPos[i] = DrPos[i] = 0.0;
    DfPos[i] = DsbPos[i] = DspPos[i] = 0.0;
  }

  Debug(0);
}

Member Function Documentation

double GetBrake ( FGLGear::BrakeGroup  bg)
Parameters:
bgwhich brakegroup to retrieve the command for
Returns:
the brake setting for the supplied brake group argument

Definition at line 648 of file FGFCS.cpp.

{
  return BrakePos[bg];
}
double GetCBrake ( void  ) const [inline]
Returns:
the center brake setting.

Definition at line 544 of file FGFCS.h.

{return BrakePos[FGLGear::bgCenter];}
string GetComponentStrings ( const std::string &  delimiter) const
Parameters:
delimitereither a tab or comma string depending on output type
Returns:
a string containing the descriptive names for all components

Definition at line 721 of file FGFCS.cpp.

{
  string CompStrings = "";
  bool firstime = true;
  int total_count=0;

  for (unsigned int i=0; i<SystemChannels.size(); i++)
  {
    for (unsigned int c=0; c<SystemChannels[i]->GetNumComponents(); c++)
    {
      if (firstime) firstime = false;
      else          CompStrings += delimiter;

      CompStrings += SystemChannels[i]->GetComponent(c)->GetName();
      total_count++;
    }
  }

  return CompStrings;
}
string GetComponentValues ( const std::string &  delimiter) const
Parameters:
delimitereither a tab or comma string depending on output type
Returns:
a string containing the numeric values for the current set of component outputs

Definition at line 744 of file FGFCS.cpp.

Referenced by FGOutputSocket::Print().

{
  std::ostringstream buf;

  bool firstime = true;
  int total_count=0;

  for (unsigned int i=0; i<SystemChannels.size(); i++)
  {
    for (unsigned int c=0; c<SystemChannels[i]->GetNumComponents(); c++)
    {
      if (firstime) firstime = false;
      else          buf << delimiter;

      buf << setprecision(9) << SystemChannels[i]->GetComponent(c)->GetOutput();
      total_count++;
    }
  }

  return buf.str();
}

Here is the caller graph for this function:

double GetDaCmd ( void  ) const [inline]
Returns:
aileron command in range from -1.0 - 1.0

Definition at line 216 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

{ return DaCmd; }

Here is the caller graph for this function:

double GetDaLPos ( int  form = ofRad) const [inline]
Returns:
aileron position in radians

Definition at line 288 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

                               { return DaLPos[form]; }

Here is the caller graph for this function:

double GetDaRPos ( int  form = ofRad) const [inline]
Returns:
aileron position in radians

Definition at line 293 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

                               { return DaRPos[form]; }

Here is the caller graph for this function:

double GetDeCmd ( void  ) const [inline]
Returns:
elevator command in range from -1.0 - 1.0

Definition at line 220 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

{ return DeCmd; }

Here is the caller graph for this function:

double GetDePos ( int  form = ofRad) const [inline]
Returns:
elevator position in radians

Definition at line 298 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

                               { return DePos[form]; }

Here is the caller graph for this function:

double GetDfCmd ( void  ) const [inline]
Returns:
flaps command in range from 0 to 1.0

Definition at line 232 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

{ return DfCmd; }

Here is the caller graph for this function:

double GetDfPos ( int  form = ofRad) const [inline]
Returns:
flaps position in radians

Definition at line 318 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

                               { return DfPos[form]; }

Here is the caller graph for this function:

double GetDrCmd ( void  ) const [inline]
Returns:
rudder command in range from -1.0 - 1.0

Definition at line 224 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

{ return DrCmd; }

Here is the caller graph for this function:

double GetDrPos ( int  form = ofRad) const [inline]
Returns:
rudder position in radians

Definition at line 303 of file FGFCS.h.

Referenced by FGOutputSocket::Print().

                               { return DrPos[form]; }

Here is the caller graph for this function:

double GetDsbCmd ( void  ) const [inline]
Returns:
speedbrake command in range from 0 to 1.0

Definition at line 236 of file FGFCS.h.

{ return DsbCmd; }
double GetDsbPos ( int  form = ofRad) const [inline]
Returns:
speedbrake position in radians

Definition at line 308 of file FGFCS.h.

                               { return DsbPos[form]; }
double GetDsCmd ( void  ) const [inline]
Returns:
steering command in range from -1.0 - 1.0

Definition at line 228 of file FGFCS.h.

Referenced by FGFCS::Run().

{ return DsCmd; }

Here is the caller graph for this function:

double GetDspCmd ( void  ) const [inline]
Returns:
spoiler command in range from 0 to 1.0

Definition at line 240 of file FGFCS.h.

{ return DspCmd; }
double GetDspPos ( int  form = ofRad) const [inline]
Returns:
spoiler position in radians

Definition at line 313 of file FGFCS.h.

                               { return DspPos[form]; }
bool GetFeatherCmd ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
feather command for the given engine (on / off)

Definition at line 264 of file FGFCS.h.

{ return PropFeatherCmd[engine]; }
double GetGearCmd ( void  ) const [inline]

0 commands gear up, 1 down. defaults to down.

Returns:
the current value of the gear extend/retract command

Definition at line 281 of file FGFCS.h.

{ return GearCmd; }
double GetGearPos ( void  ) const [inline]
Returns:
gear position (0 up, 1 down)

Definition at line 343 of file FGFCS.h.

{ return GearPos; }
double GetLBrake ( void  ) const [inline]
Returns:
the left brake setting.

Definition at line 536 of file FGFCS.h.

{return BrakePos[FGLGear::bgLeft];}
double GetMixtureCmd ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
mixture command in range from 0 - 1.0 for the given engine

Definition at line 252 of file FGFCS.h.

{ return MixtureCmd[engine]; }
double GetMixturePos ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
mixture position for the given engine in range from 0 - 1.0

Definition at line 331 of file FGFCS.h.

{ return MixturePos[engine]; }
double GetPitchTrimCmd ( void  ) const [inline]
Returns:
pitch trim command in range from -1.0 to 1.0

Definition at line 268 of file FGFCS.h.

{ return PTrimCmd; }
double GetPropAdvance ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
prop pitch position for the given engine in range from 0 - 1.0

Definition at line 356 of file FGFCS.h.

{ return PropAdvance[engine]; }
double GetPropAdvanceCmd ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
pitch command in range from 0.0 - 1.0 for the given engine

Definition at line 259 of file FGFCS.h.

{ return PropAdvanceCmd[engine]; }
bool GetPropFeather ( int  engine) const [inline]
Parameters:
engineengine ID number
Returns:
prop fether for the given engine (on / off)

Definition at line 363 of file FGFCS.h.

{ return PropFeather[engine]; }
double GetRBrake ( void  ) const [inline]
Returns:
the right brake setting.

Definition at line 540 of file FGFCS.h.

{return BrakePos[FGLGear::bgRight];}
double GetRollTrimCmd ( void  ) const [inline]
Returns:
aileron trim command in range from -1.0 - 1.0

Definition at line 276 of file FGFCS.h.

{ return RTrimCmd; }
double GetSteerPosDeg ( int  gear) const [inline]
Returns:
steering position in degrees

Definition at line 337 of file FGFCS.h.

{ return SteerPosDeg[gear]; }
double GetTailhookPos ( void  ) const [inline]
Returns:
tailhook position (0 up, 1 down)

Definition at line 347 of file FGFCS.h.

{ return TailhookPos; }
double GetThrottleCmd ( int  engine) const
Parameters:
engineengine ID number
Returns:
throttle command in range from 0 - 1.0 for the given engine

Definition at line 355 of file FGFCS.cpp.

{
  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
       cerr << "Cannot get throttle value for ALL engines" << endl;
    } else {
      return ThrottleCmd[engineNum];
    }
  } else {
    cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
         << " engines exist, but throttle setting for engine " << engineNum
         << " is selected" << endl;
  }
  return 0.0;
}
double GetThrottlePos ( int  engine) const
Parameters:
engineengine ID number
Returns:
throttle position for the given engine in range from 0 - 1.0

Definition at line 373 of file FGFCS.cpp.

{
  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
       cerr << "Cannot get throttle value for ALL engines" << endl;
    } else {
      return ThrottlePos[engineNum];
    }
  } else {
    cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
         << " engines exist, but attempted throttle position setting is for engine "
         << engineNum << endl;
  }
  return 0.0;
}
double GetWingFoldPos ( void  ) const [inline]
Returns:
wing fold position (0 unfolded, 1 folded)

Definition at line 351 of file FGFCS.h.

{ return WingFoldPos; }
double GetYawTrimCmd ( void  ) const [inline]
Returns:
rudder trim command in range from -1.0 - 1.0

Definition at line 272 of file FGFCS.h.

{ return YTrimCmd; }
bool Load ( Element el,
SystemType  systype 
)

Load() is called from FGFDMExec.

Parameters:
elpointer to the Element instance
systypetype of system (FCS, Autopilot, System)
Returns:
true if succesful

Definition at line 481 of file FGFCS.cpp.

References FGFCSChannel::Add(), FGJSBBase::fgblue, FGJSBBase::fgred, Element::FindElement(), Element::FindNextElement(), Element::GetAttributeValue(), Element::GetAttributeValueAsNumber(), Element::GetDataLine(), Element::GetElement(), FGFDMExec::GetFullAircraftPath(), Element::GetName(), Element::GetNextElement(), FGJSBBase::highint, FGJSBBase::normint, FGJSBBase::reset, and FGPropertyManager::Tie().

{
  string name, file, fname="", interface_property_string, parent_name;
  Element *component_element;
  Element *channel_element;
  
// ToDo: The handling of name and file attributes could be improved, here,
//       considering that a name can be in the external file, as well.

  name = el->GetAttributeValue("name");

  if (name.empty() || !el->GetAttributeValue("file").empty()) {
    fname = el->GetAttributeValue("file");
    if (systype == stSystem) {
      file = FindSystemFullPathname(fname);
    } else { 
      file = FDMExec->GetFullAircraftPath() + "/" + fname + ".xml";
    }
    if (fname.empty()) {
      cerr << "FCS, Autopilot, or system does not appear to be defined inline nor in a file" << endl;
      return false;
    } else {
      document = LoadXMLDocument(file);
      if (!document) {
        cerr << "Error loading file " << file << endl;
        return false;
      }
      name = document->GetAttributeValue("name");
    }
  } else {
    document = el;
  }

  if (document->GetName() == "autopilot") {
    Name = "Autopilot: " + document->GetAttributeValue("name");
  } else if (document->GetName() == "flight_control") {
    Name = "FCS: " + document->GetAttributeValue("name");
  } else if (document->GetName() == "system") {
    Name = "System: " + document->GetAttributeValue("name");
  }
  Debug(2);

  if (document->GetName() == "flight_control") bindModel();

  FGModel::Load(document); // Load interface properties from document

  // After reading interface properties in a file, read properties in the local
  // flight_control, autopilot, or system element. This allows general-purpose
  // systems to be defined in a file, with overrides or initial loaded constants
  // supplied in the relevant element of the aircraft configuration file.

  Element* property_element = 0;

  if (!fname.empty()) {
    property_element = el->FindElement("property");
    if (property_element && debug_lvl > 0) cout << endl << "    Overriding properties" << endl << endl;
    while (property_element) {
      double value=0.0;
      if ( ! property_element->GetAttributeValue("value").empty())
        value = property_element->GetAttributeValueAsNumber("value");

      interface_property_string = property_element->GetDataLine();
      if (PropertyManager->HasNode(interface_property_string)) {
        FGPropertyNode* node = PropertyManager->GetNode(interface_property_string);
        if (debug_lvl > 0)
          cout << "      " << "Overriding value for property " << interface_property_string
               << " (old value: " << node->getDoubleValue() << "  new value: " << value << ")" << endl;
        node->setDoubleValue(value);
      } else {
        interface_properties.push_back(new double(value));
        PropertyManager->Tie(interface_property_string, interface_properties.back());
        if (debug_lvl > 0)
          cout << "      " << interface_property_string << " (initial value: " << value << ")" << endl;
      }
      
      property_element = el->FindNextElement("property");
    }
  }

  channel_element = document->FindElement("channel");
  
  while (channel_element) {
  
    FGFCSChannel* newChannel = 0;

    string sOnOffProperty = channel_element->GetAttributeValue("execute");
    FGPropertyNode* OnOffPropertyNode = 0;
    if (sOnOffProperty.length() > 0) {
      OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty);
      if (OnOffPropertyNode == 0) {
        cerr << highint << fgred
             << "The On/Off property, " << sOnOffProperty << " specified for channel "
             << channel_element->GetAttributeValue("name") << " is undefined or not "
             << "understood. The simulation will abort" << reset << endl;
        throw("Bad system definition");
      } else {
        newChannel = new FGFCSChannel(OnOffPropertyNode);
      }
    } else {
      newChannel = new FGFCSChannel();
    }

    SystemChannels.push_back(newChannel);

    if (debug_lvl > 0)
      cout << endl << highint << fgblue << "    Channel " 
         << normint << channel_element->GetAttributeValue("name") << reset << endl;
  
    component_element = channel_element->GetElement();
    while (component_element) {
      try {
        if ((component_element->GetName() == string("lag_filter")) ||
            (component_element->GetName() == string("lead_lag_filter")) ||
            (component_element->GetName() == string("washout_filter")) ||
            (component_element->GetName() == string("second_order_filter")) ||
            (component_element->GetName() == string("integrator")) )
        {
          newChannel->Add(new FGFilter(this, component_element));
        } else if ((component_element->GetName() == string("pure_gain")) ||
                   (component_element->GetName() == string("scheduled_gain")) ||
                   (component_element->GetName() == string("aerosurface_scale")))
        {
          newChannel->Add(new FGGain(this, component_element));
        } else if (component_element->GetName() == string("summer")) {
          newChannel->Add(new FGSummer(this, component_element));
        } else if (component_element->GetName() == string("deadband")) {
          newChannel->Add(new FGDeadBand(this, component_element));
        } else if (component_element->GetName() == string("switch")) {
          newChannel->Add(new FGSwitch(this, component_element));
        } else if (component_element->GetName() == string("kinematic")) {
          newChannel->Add(new FGKinemat(this, component_element));
        } else if (component_element->GetName() == string("fcs_function")) {
          newChannel->Add(new FGFCSFunction(this, component_element));
        } else if (component_element->GetName() == string("pid")) {
          newChannel->Add(new FGPID(this, component_element));
        } else if (component_element->GetName() == string("actuator")) {
          newChannel->Add(new FGActuator(this, component_element));
        } else if (component_element->GetName() == string("sensor")) {
          newChannel->Add(new FGSensor(this, component_element));
        } else if (component_element->GetName() == string("accelerometer")) {
          newChannel->Add(new FGAccelerometer(this, component_element));
        } else if (component_element->GetName() == string("magnetometer")) {
          newChannel->Add(new FGMagnetometer(this, component_element));
        } else if (component_element->GetName() == string("gyro")) {
          newChannel->Add(new FGGyro(this, component_element));
        } else {
          cerr << "Unknown FCS component: " << component_element->GetName() << endl;
        }
      } catch(string s) {
        cerr << highint << fgred << endl << "  " << s << endl;
        cerr << reset << endl;
        return false;
      }
      component_element = channel_element->GetNextElement();
    }
    channel_element = document->FindNextElement("channel");
  }

  PostLoad(document, PropertyManager);

  ResetParser();

  return true;
}

Here is the call graph for this function:

bool Run ( bool  Holding) [virtual]
Parameters:
Holdingif 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.
Returns:
false if no error

Reimplemented from FGModel.

Definition at line 154 of file FGFCS.cpp.

References FGFCS::GetDsCmd(), FGGroundReactions::GetGearUnit(), FGFDMExec::GetGroundReactions(), and FGModel::Run().

{
  unsigned int i;

  if (FGModel::Run(Holding)) return true; // fast exit if nothing to do
  if (Holding) return false;

  RunPreFunctions();

  for (i=0; i<ThrottlePos.size(); i++) ThrottlePos[i] = ThrottleCmd[i];
  for (i=0; i<MixturePos.size(); i++) MixturePos[i] = MixtureCmd[i];
  for (i=0; i<PropAdvance.size(); i++) PropAdvance[i] = PropAdvanceCmd[i];
  for (i=0; i<PropFeather.size(); i++) PropFeather[i] = PropFeatherCmd[i];

  // Set the default steering angle
  for (i=0; i<SteerPosDeg.size(); i++) {
    FGLGear* gear = FDMExec->GetGroundReactions()->GetGearUnit(i);
    SteerPosDeg[i] = gear->GetDefaultSteerAngle( GetDsCmd() );
  }

  // Execute system channels in order
  for (i=0; i<SystemChannels.size(); i++) SystemChannels[i]->Execute();

  RunPostFunctions();

  return false;
}

Here is the call graph for this function:

void SetCBrake ( double  cmd) [inline]
Parameters:
cmdbrake setting in percent (0.0 - 1.0)

Definition at line 525 of file FGFCS.h.

{BrakePos[FGLGear::bgCenter] = cmd;}
void SetDaCmd ( double  cmd) [inline]
Parameters:
cmdaileron command

Definition at line 383 of file FGFCS.h.

{ DaCmd = cmd; }
void SetDaLPos ( int  form,
double  pos 
)
Parameters:
cmdleft aileron position in radians

Definition at line 184 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DaLPos[ofRad] = pos;
    DaLPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DaLPos[ofRad] = pos*degtorad;
    DaLPos[ofDeg] = pos;
    break;
  case ofNorm:
    DaLPos[ofNorm] = pos;
  }
  DaLPos[ofMag] = fabs(DaLPos[ofRad]);
}
void SetDaRPos ( int  form,
double  pos 
)
Parameters:
cmdright aileron position in radians

Definition at line 203 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DaRPos[ofRad] = pos;
    DaRPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DaRPos[ofRad] = pos*degtorad;
    DaRPos[ofDeg] = pos;
    break;
  case ofNorm:
    DaRPos[ofNorm] = pos;
  }
  DaRPos[ofMag] = fabs(DaRPos[ofRad]);
}
void SetDeCmd ( double  cmd) [inline]
Parameters:
cmdelevator command in percent

Definition at line 387 of file FGFCS.h.

{ DeCmd = cmd; }
void SetDePos ( int  form,
double  pos 
)
Parameters:
cmdelevator position in radians

Definition at line 222 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DePos[ofRad] = pos;
    DePos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DePos[ofRad] = pos*degtorad;
    DePos[ofDeg] = pos;
    break;
  case ofNorm:
    DePos[ofNorm] = pos;
  }
  DePos[ofMag] = fabs(DePos[ofRad]);
}
void SetDfCmd ( double  cmd) [inline]
Parameters:
cmdflaps command in percent

Definition at line 399 of file FGFCS.h.

{ DfCmd = cmd; }
void SetDfPos ( int  form,
double  pos 
)
Parameters:
cmdflaps position in radians

Definition at line 260 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DfPos[ofRad] = pos;
    DfPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DfPos[ofRad] = pos*degtorad;
    DfPos[ofDeg] = pos;
    break;
  case ofNorm:
    DfPos[ofNorm] = pos;
  }
  DfPos[ofMag] = fabs(DfPos[ofRad]);
}
void SetDrCmd ( double  cmd) [inline]
Parameters:
cmdrudder command in percent

Definition at line 391 of file FGFCS.h.

{ DrCmd = cmd; }
void SetDrPos ( int  form,
double  pos 
)
Parameters:
cmdrudder position in radians

Definition at line 241 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DrPos[ofRad] = pos;
    DrPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DrPos[ofRad] = pos*degtorad;
    DrPos[ofDeg] = pos;
    break;
  case ofNorm:
    DrPos[ofNorm] = pos;
  }
  DrPos[ofMag] = fabs(DrPos[ofRad]);
}
void SetDsbCmd ( double  cmd) [inline]
Parameters:
cmdspeedbrake command in percent

Definition at line 403 of file FGFCS.h.

{ DsbCmd = cmd; }
void SetDsbPos ( int  form,
double  pos 
)
Parameters:
cmdspeedbrake position in radians

Definition at line 279 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DsbPos[ofRad] = pos;
    DsbPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DsbPos[ofRad] = pos*degtorad;
    DsbPos[ofDeg] = pos;
    break;
  case ofNorm:
    DsbPos[ofNorm] = pos;
  }
  DsbPos[ofMag] = fabs(DsbPos[ofRad]);
}
void SetDsCmd ( double  cmd) [inline]
Parameters:
cmdsteering command in percent

Definition at line 395 of file FGFCS.h.

{ DsCmd = cmd; }
void SetDspCmd ( double  cmd) [inline]
Parameters:
cmdspoilers command in percent

Definition at line 407 of file FGFCS.h.

{ DspCmd = cmd; }
void SetDspPos ( int  form,
double  pos 
)
Parameters:
cmdspoiler position in radians

Definition at line 298 of file FGFCS.cpp.

{
  switch(form) {
  case ofRad:
    DspPos[ofRad] = pos;
    DspPos[ofDeg] = pos*radtodeg;
    break;
  case ofDeg:
    DspPos[ofRad] = pos*degtorad;
    DspPos[ofDeg] = pos;
    break;
  case ofNorm:
    DspPos[ofNorm] = pos;
  }
  DspPos[ofMag] = fabs(DspPos[ofRad]);
}
void SetFeatherCmd ( int  engine,
bool  cmd 
)
Parameters:
engineengine ID number
cmdfeather (bool)

Definition at line 451 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<PropFeatherCmd.size();ctr++) PropFeatherCmd[ctr] = setting;
    } else {
      PropFeatherCmd[engineNum] = setting;
    }
  }
}
void SetGearCmd ( double  gearcmd) [inline]
Parameters:
gearcommand 0 for up, 1 for down

Definition at line 433 of file FGFCS.h.

{ GearCmd = gearcmd; }
void SetGearPos ( double  gearpos) [inline]
Parameters:
gearposition 0 up, 1 down

Definition at line 492 of file FGFCS.h.

{ GearPos = gearpos; }
void SetLBrake ( double  cmd) [inline]
Parameters:
cmdbrake setting in percent (0.0 - 1.0)

Definition at line 517 of file FGFCS.h.

{BrakePos[FGLGear::bgLeft] = cmd;}
void SetMixtureCmd ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdnormalized mixture command (0.0 - 1.0)

Definition at line 391 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<MixtureCmd.size();ctr++) MixtureCmd[ctr] = setting;
    } else {
      MixtureCmd[engineNum] = setting;
    }
  }
}
void SetMixturePos ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdnormalized mixture setting (0.0 - 1.0)

Definition at line 406 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<MixtureCmd.size();ctr++) MixturePos[ctr] = MixtureCmd[ctr];
    } else {
      MixturePos[engineNum] = setting;
    }
  }
}
void SetPitchTrimCmd ( double  cmd) [inline]
Parameters:
cmdpitch trim command in percent

Definition at line 411 of file FGFCS.h.

{ PTrimCmd = cmd; }
void SetPropAdvance ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdprop pitch setting in percent (0.0 - 1.0)

Definition at line 436 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvance[ctr] = PropAdvanceCmd[ctr];
    } else {
      PropAdvance[engineNum] = setting;
    }
  }
}
void SetPropAdvanceCmd ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdmixture command in percent (0.0 - 1.0)

Definition at line 421 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<PropAdvanceCmd.size();ctr++) PropAdvanceCmd[ctr] = setting;
    } else {
      PropAdvanceCmd[engineNum] = setting;
    }
  }
}
void SetPropFeather ( int  engine,
bool  cmd 
)
Parameters:
engineengine ID number
cmdprop fether setting (bool)

Definition at line 466 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<PropFeatherCmd.size();ctr++) PropFeather[ctr] = PropFeatherCmd[ctr];
    } else {
      PropFeather[engineNum] = setting;
    }
  }
}
void SetRBrake ( double  cmd) [inline]
Parameters:
cmdbrake setting in percent (0.0 - 1.0)

Definition at line 521 of file FGFCS.h.

{BrakePos[FGLGear::bgRight] = cmd;}
void SetRollTrimCmd ( double  cmd) [inline]
Parameters:
cmdaileron trim command in percent

Definition at line 419 of file FGFCS.h.

{ RTrimCmd = cmd; }
void SetSteerPosDeg ( int  gear,
double  pos 
) [inline]
Parameters:
cmdsteering position in degrees

Definition at line 488 of file FGFCS.h.

{ SteerPosDeg[gear] = pos; }
void SetTailhookPos ( double  hookpos) [inline]
Parameters:
tailhookposition 0 up, 1 down

Definition at line 496 of file FGFCS.h.

{ TailhookPos = hookpos; }
void SetThrottleCmd ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdnormalized throttle command (0.0 - 1.0)

Definition at line 317 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<ThrottleCmd.size();ctr++) ThrottleCmd[ctr] = setting;
    } else {
      ThrottleCmd[engineNum] = setting;
    }
  } else {
    cerr << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size()
         << " engines exist, but attempted throttle command is for engine "
         << engineNum << endl;
  }
}
void SetThrottlePos ( int  engine,
double  cmd 
)
Parameters:
engineengine ID number
cmdnormalized throttle setting (0.0 - 1.0)

Definition at line 336 of file FGFCS.cpp.

{
  unsigned int ctr;

  if (engineNum < (int)ThrottlePos.size()) {
    if (engineNum < 0) {
      for (ctr=0;ctr<ThrottlePos.size();ctr++) ThrottlePos[ctr] = setting;
    } else {
      ThrottlePos[engineNum] = setting;
    }
  } else {
    cerr << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size()
         << " engines exist, but attempted throttle position setting is for engine "
         << engineNum << endl;
  }
}
void SetWingFoldPos ( double  foldpos) [inline]
Parameters:
wingfold position 0 unfolded, 1 folded

Definition at line 500 of file FGFCS.h.

{ WingFoldPos = foldpos; }
void SetYawTrimCmd ( double  cmd) [inline]
Parameters:
cmdrudder trim command in percent

Definition at line 415 of file FGFCS.h.

{ YTrimCmd = cmd; }

The documentation for this class was generated from the following files: