]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/flight_control/FGSwitch.h
Sync. with JSBSim (CVS) again
[flightgear.git] / src / FDM / JSBSim / models / flight_control / FGSwitch.h
index a6ef0db171caf17f03494ef5e69ba8124796202c..4efec9dfbf141a29aa15a09042fa77af353bc7cd 100644 (file)
@@ -4,23 +4,23 @@
  Author:       Jon S. Berndt
  Date started: 12/23/2002
 
- ------------- Copyright (C)  -------------
+ ------------- Copyright (C) 2002 jon@jsbsim.org  -------------
 
  This program is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free Software
+ the terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
 
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  details.
 
- You should have received a copy of the GNU General Public License along with
+ You should have received a copy of the GNU Lesser General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
- Further information about the GNU General Public License can also be found on
+ Further information about the GNU Lesser General Public License can also be found on
  the world wide web at http://www.gnu.org.
 
 HISTORY
@@ -39,7 +39,7 @@ INCLUDES
 
 #include "FGFCSComponent.h"
 #include <input_output/FGXMLElement.h>
-#include "FGCondition.h"
+#include <math/FGCondition.h>
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -59,65 +59,70 @@ CLASS DOCUMENTATION
 
 /** Encapsulates a switch for the flight control system.
 
-The SWITCH component models a switch - either on/off or a multi-choice rotary
+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
+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 two 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 parameter, and which takes the form:
+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
+  qbar ge 21.0
 
 or,
 
-  roll_rate < pitch_rate
+  roll_rate == pitch_rate
 
-Within a TEST, a CONDITION_GROUP can be specified. A CONDITION_GROUP allows for
-complex groupings of logical comparisons. Each CONDITION_GROUP contains
-additional conditions, as well as possibly additional CONDITION_GROUPs.
+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.
 
-<pre>
-\<COMPONENT NAME="switch1" TYPE="SWITCH"\>
-  \<TEST LOGIC="{AND|OR|DEFAULT}" VALUE="{property|value}"\>
+@code
+<switch name="switch1">
+  <default value="{property|value}"/>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
-    \<CONDITION_GROUP LOGIC="{AND|OR}"\>
+    <test logic="{AND|OR}">
       {property} {conditional} {property|value}
       ...
-    \</CONDITION_GROUP\>
+    </test>
     ...
-  \</TEST>
-  \<TEST LOGIC="{AND|OR}" VALUE="{property|value}"\>
+  </test>
+  <test logic="{AND|OR}" value="{property|value}">
     {property} {conditional} {property|value}
     ...
-  \</TEST\>
+  </test>
   ...
-  [OUTPUT \<property>]
-\</COMPONENT\>
-</pre>
+  [<output> {property} </output>]
+</switch>
+@endcode
 
 Here's an example:
-<pre>
-\<COMPONENT NAME="Roll A/P Autoswitch" TYPE="SWITCH">
-  \<TEST LOGIC="DEFAULT" VALUE="0.0">
-  \</TEST>
-  \<TEST LOGIC="AND" VALUE="fcs/roll-ap-error-summer">
+
+@code
+<switch name="roll a/p autoswitch">
+  <default value="0.0"/>
+  <test value="fcs/roll-ap-error-summer">
     ap/attitude_hold == 1
-  \</TEST>
-\</COMPONENT>
-</pre>
+  </test>
+</switch>
+@endcode
+
+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$
 */
@@ -129,19 +134,26 @@ CLASS DECLARATION
 class FGSwitch  : public FGFCSComponent
 {
 public:
+  /** Constructor
+      @param fcs a pointer to the parent FGFCS class
+      @param element a pointer to the Element (from the config file XML tree)
+             that represents this switch component */
   FGSwitch(FGFCS* fcs, Element* element);
+
+  /// Destructor
   ~FGSwitch();
 
+  /** Executes the switch logic.
+      @return true - always*/
   bool Run(void);
 
   enum eLogic {elUndef=0, eAND, eOR, eDefault};
   enum eComparison {ecUndef=0, eEQ, eNE, eGT, eGE, eLT, eLE};
 
 private:
-  FGFCS* fcs;
 
   struct test {
-    vector <FGCondition> conditions;
+    vector <FGCondition*> conditions;
     eLogic Logic;
     double OutputVal;
     FGPropertyManager *OutputProp;
@@ -161,7 +173,7 @@ private:
 
   };
 
-  vector <test> tests;
+  vector <test*> tests;
 
   void Debug(int from);
 };