JSBSim Flight Dynamics Model 1.3.0 (09 Apr 2026)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGSummer.cpp
1/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3 Module: FGSummer.cpp
4 Author: Jon S. Berndt
5 Date started: 4/2000
6
7 ------------- Copyright (C) 2000 -------------
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
26FUNCTIONAL DESCRIPTION
27--------------------------------------------------------------------------------
28
29HISTORY
30--------------------------------------------------------------------------------
31
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33COMMENTS, REFERENCES, and NOTES
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37INCLUDES
38%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
39
40#include "FGSummer.h"
41#include "models/FGFCS.h"
42#include "input_output/FGXMLElement.h"
43#include "input_output/FGLog.h"
44
45using namespace std;
46
47namespace JSBSim {
48
49/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
50CLASS IMPLEMENTATION
51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
52
53FGSummer::FGSummer(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element)
54{
55 Bias = 0.0;
56
57 if (element->FindElement("bias"))
58 Bias = element->FindElementValueAsNumber("bias");
59
60 bind(element, fcs->GetPropertyManager().get());
61 Debug(0);
62}
63
64//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65
67{
68 Debug(1);
69}
70
71//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72
73bool FGSummer::Run(void)
74{
75 Output = 0.0;
76
77 for (auto node: InputNodes)
78 Output += node->getDoubleValue();
79
80 Output += Bias;
81
82 Clip();
83 SetOutput();
84
85 return true;
86}
87
88//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89// The bitmasked value choices are as follows:
90// unset: In this case (the default) JSBSim would only print
91// out the normally expected messages, essentially echoing
92// the config files as they are read. If the environment
93// variable is not set, debug_lvl is set to 1 internally
94// 0: This requests JSBSim not to output any messages
95// whatsoever.
96// 1: This value explicitly requests the normal JSBSim
97// startup messages
98// 2: This value asks for a message to be printed out when
99// a class is instantiated
100// 4: When this value is set, a message is displayed when a
101// FGModel object executes its Run() method
102// 8: When this value is set, various runtime state variables
103// are printed out periodically
104// 16: When set various parameters are sanity checked and
105// a message is printed out when they go out of bounds
106
107void FGSummer::Debug(int from)
108{
109 if (debug_lvl <= 0) return;
110
111 if (debug_lvl & 1) { // Standard console startup message output
112 FGLogging log(LogLevel::DEBUG);
113 if (from == 0) { // Constructor
114 log << " INPUTS: " << fixed << "\n";
115 for (auto node: InputNodes)
116 log << " " << node->GetNameWithSign() << "\n";
117 if (Bias != 0.0) log << " Bias: " << Bias << "\n";
118 for (auto node: OutputNodes)
119 log << " OUTPUT: " << node->getNameString() << "\n";
120 }
121 }
122 if (debug_lvl & 2 ) { // Instantiation/Destruction notification
123 FGLogging log(LogLevel::DEBUG);
124 if (from == 0) log << "Instantiated: FGSummer\n";
125 if (from == 1) log << "Destroyed: FGSummer\n";
126 }
127 if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
128 }
129 if (debug_lvl & 8 ) { // Runtime state variables
130 }
131 if (debug_lvl & 16) { // Sanity checking
132 }
133 if (debug_lvl & 64) {
134 if (from == 0) { // Constructor
135 }
136 }
137}
138
139} //namespace JSBSim
Element * FindElement(const std::string &el="")
Searches for a specified element.
double FindElementValueAsNumber(const std::string &el="")
Searches for the named element and returns the data belonging to it as a number.
Base class for JSBSim Flight Control System Components.
Encapsulates the Flight Control System (FCS) functionality.
Definition FGFCS.h:189
FGSummer(FGFCS *fcs, Element *element)
Constructor.
Definition FGSummer.cpp:53
~FGSummer()
Destructor.
Definition FGSummer.cpp:66
bool Run(void) override
The execution method for this FCS component.
Definition FGSummer.cpp:73
Main namespace for the JSBSim Flight Dynamics Model.
Definition FGFDMExec.cpp:71