FGSwitch Class Reference

#include <FGSwitch.h>

Inherits FGFCSComponent.

List of all members.


Detailed Description

The switch component models a switch - either on/off or a multi-choice rotary switch. The switch can represent a physical cockpit switch, or can represent a logical switch, where several conditions might need to be satisfied before a particular state is reached. The value of the switch - the output value for the component - is chosen depending on the state of the switch. Each switch is comprised of one or more tests. Each test has a value associated with it. The first test that evaluates to true will set the output value of the switch according to the value parameter belonging to that test. Each test contains one or more conditions, which each must be logically related (if there are more than one) given the value of the logic attribute, and which takes the form:

property conditional property|value

e.g.

qbar ge 21.0

or,

roll_rate == pitch_rate

Within a test, additional tests can be specified, which allows for complex groupings of logical comparisons. Each test contains additional conditions, as well as possibly additional tests.

<switch name="switch1">
  <default value="{property|value}"/>
  <test logic="{AND|OR}" value="{property|value}">
    {property} {conditional} {property|value}
    <test logic="{AND|OR}">
      {property} {conditional} {property|value}
      ...
    </test>
    ...
  </test>
  <test logic="{AND|OR}" value="{property|value}">
    {property} {conditional} {property|value}
    ...
  </test>
  ...
  [<output> {property} </output>]
</switch>

Here's an example:

<switch name="roll a/p autoswitch">
  <default value="0.0"/>
  <test value="fcs/roll-ap-error-summer">
    ap/attitude_hold == 1
  </test>
</switch>

Note: In the "logic" attribute, "AND" is the default logic, if none is supplied.

The above example specifies that the default value of the component (i.e. the output property of the component, addressed by the property, ap/roll-ap-autoswitch) is 0.0. If or when the attitude hold switch is selected (property ap/attitude_hold takes the value 1), the value of the switch component will be whatever value fcs/roll-ap-error-summer is.

Author:
Jon S. Berndt
Version:
Id
FGSwitch.h,v 1.11 2008/05/01 01:03:14 dpculp Exp

Definition at line 134 of file FGSwitch.h.


Public Types

enum  eComparison {
  ecUndef = 0, eEQ, eNE, eGT,
  eGE, eLT, eLE
}
enum  eLogic { elUndef = 0, eAND, eOR, eDefault }

Public Member Functions

 FGSwitch (FGFCS *fcs, Element *element)
 Constructor.
bool Run (void)
 Executes the switch logic.
 ~FGSwitch ()
 Destructor.

Classes

struct  test

Constructor & Destructor Documentation

FGSwitch ( FGFCS fcs,
Element element 
)

Parameters:
fcs a pointer to the parent FGFCS class
element a pointer to the Element (from the config file XML tree) that represents this switch component

Definition at line 75 of file FGSwitch.cpp.


Member Function Documentation

bool Run ( void   )  [virtual]

Returns:
true - always

Reimplemented from FGFCSComponent.

Definition at line 153 of file FGSwitch.cpp.


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

Generated on Tue May 26 00:55:13 2009 for JSBSim Flight Dynamics Model by  doxygen 1.5.5