| 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 | |
| 26 | FUNCTIONAL DESCRIPTION |
| 27 | -------------------------------------------------------------------------------- |
| 28 | |
| 29 | HISTORY |
| 30 | -------------------------------------------------------------------------------- |
| 31 | |
| 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 33 | COMMENTS, REFERENCES, and NOTES |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | |
| 36 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 37 | INCLUDES |
| 38 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 39 | |
| 40 | #include "FGSummer.h" |
| 41 | #include "input_output/FGXMLElement.h" |
| 42 | |
| 43 | using namespace std; |
| 44 | |
| 45 | namespace JSBSim { |
| 46 | |
| 47 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 48 | CLASS IMPLEMENTATION |
| 49 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 50 | |
| 51 | FGSummer::FGSummer(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) |
| 52 | { |
| 53 | Bias = 0.0; |
| 54 | |
| 55 | if (element->FindElement("bias")) |
| 56 | Bias = element->FindElementValueAsNumber("bias"); |
| 57 | |
| 58 | bind(element); |
| 59 | Debug(0); |
| 60 | } |
| 61 | |
| 62 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 63 | |
| 64 | FGSummer::~FGSummer() |
| 65 | { |
| 66 | Debug(1); |
| 67 | } |
| 68 | |
| 69 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 70 | |
| 71 | bool FGSummer::Run(void) |
| 72 | { |
| 73 | Output = 0.0; |
| 74 | |
| 75 | for (auto node: InputNodes) |
| 76 | Output += node->getDoubleValue(); |
| 77 | |
| 78 | Output += Bias; |
| 79 | |
| 80 | Clip(); |
| 81 | SetOutput(); |
| 82 | |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 87 | // The bitmasked value choices are as follows: |
| 88 | // unset: In this case (the default) JSBSim would only print |
| 89 | // out the normally expected messages, essentially echoing |
| 90 | // the config files as they are read. If the environment |
| 91 | // variable is not set, debug_lvl is set to 1 internally |
| 92 | // 0: This requests JSBSim not to output any messages |
| 93 | // whatsoever. |
| 94 | // 1: This value explicity requests the normal JSBSim |
| 95 | // startup messages |
| 96 | // 2: This value asks for a message to be printed out when |
| 97 | // a class is instantiated |
| 98 | // 4: When this value is set, a message is displayed when a |
| 99 | // FGModel object executes its Run() method |
| 100 | // 8: When this value is set, various runtime state variables |
| 101 | // are printed out periodically |
| 102 | // 16: When set various parameters are sanity checked and |
| 103 | // a message is printed out when they go out of bounds |
| 104 | |
| 105 | void FGSummer::Debug(int from) |
| 106 | { |
| 107 | if (debug_lvl <= 0) return; |
| 108 | |
| 109 | if (debug_lvl & 1) { // Standard console startup message output |
| 110 | if (from == 0) { // Constructor |
| 111 | cout << " INPUTS: " << endl; |
| 112 | for (auto node: InputNodes) |
| 113 | cout << " " << node->GetNameWithSign() << endl; |
| 114 | if (Bias != 0.0) cout << " Bias: " << Bias << endl; |
| 115 | for (auto node: OutputNodes) |
| 116 | cout << " OUTPUT: " << node->GetName() << endl; |
| 117 | } |
| 118 | } |
| 119 | if (debug_lvl & 2 ) { // Instantiation/Destruction notification |
| 120 | if (from == 0) cout << "Instantiated: FGSummer" << endl; |
| 121 | if (from == 1) cout << "Destroyed: FGSummer" << endl; |
| 122 | } |
| 123 | if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects |
| 124 | } |
| 125 | if (debug_lvl & 8 ) { // Runtime state variables |
| 126 | } |
| 127 | if (debug_lvl & 16) { // Sanity checking |
| 128 | } |
| 129 | if (debug_lvl & 64) { |
| 130 | if (from == 0) { // Constructor |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | } //namespace JSBSim |
| 136 |