JSBSim Flight Dynamics Model  1.1.11 (13 Feb 2022)
An Open Source Flight Dynamics and Control Software Library in C++
FGSwitch.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGSwitch.h
4  Author: Jon S. Berndt
5  Date started: 12/23/2002
6 
7  ------------- Copyright (C) 2002 jon@jsbsim.org -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free
11  Software Foundation; either version 2 of the License, or (at your option) any
12  later version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along
20  with this program; if not, write to the Free Software Foundation, Inc., 59
21  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be
24  found on the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 SENTRY
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
32 
33 #ifndef FGSWITCH_H
34 #define FGSWITCH_H
35 
36 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 INCLUDES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39 
40 #include "FGFCSComponent.h"
41 #include "math/FGParameterValue.h"
42 
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 FORWARD DECLARATIONS
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46 
47 namespace JSBSim {
48 
49 class FGCondition;
50 
51 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 CLASS DOCUMENTATION
53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
54 
126 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 CLASS DECLARATION
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
129 
130 class FGSwitch : public FGFCSComponent
131 {
132 public:
137  FGSwitch(FGFCS* fcs, Element* element);
138 
140  ~FGSwitch();
141 
144  bool Run(void) override;
145 
146 private:
147 
148  struct Test {
149  FGCondition* condition;
150  bool Default;
151  FGParameter_ptr OutputValue;
152 
153  // constructor for the test structure
154  Test(void) : condition(nullptr), Default(false) {}
155 
156  void setTestValue(const std::string &value, const std::string &Name,
157  FGPropertyManager* pm)
158  {
159  if (value.empty()) {
160  std::cerr << "No VALUE supplied for switch component: " << Name
161  << std::endl;
162  } else
163  OutputValue = new FGParameterValue(value, pm);
164  }
165 
166  std::string GetOutputName(void) const {return OutputValue->GetName();}
167  };
168 
169  std::vector <Test*> tests;
170  bool initialized = false;
171 
172  void VerifyProperties(void);
173  void Debug(int from) override;
174 };
175 }
176 #endif
JSBSim::FGSwitch::Run
bool Run(void) override
Executes the switch logic.
Definition: FGSwitch.cpp:123
JSBSim::FGFCSComponent
Base class for JSBSim Flight Control System Components.
Definition: FGFCSComponent.h:84
JSBSim::FGSwitch::~FGSwitch
~FGSwitch()
Destructor.
Definition: FGSwitch.cpp:111
JSBSim::FGParameterValue
Represents a either a real value or a property value.
Definition: FGParameterValue.h:63
JSBSim::FGFCS
Encapsulates the Flight Control System (FCS) functionality.
Definition: FGFCS.h:187
JSBSim::FGSwitch::FGSwitch
FGSwitch(FGFCS *fcs, Element *element)
Constructor.
Definition: FGSwitch.cpp:75
JSBSim::FGSwitch
Encapsulates a switch for the flight control system.
Definition: FGSwitch.h:130
JSBSim::FGCondition
Encapsulates a condition, which is used in parts of JSBSim including switches.
Definition: FGCondition.h:66
JSBSim::FGPropertyManager
Definition: FGPropertyManager.h:373
JSBSim::Element
Definition: FGXMLElement.h:143