| 1 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 | |
| 3 | Header: FGModelFunctions.h |
| 4 | Author: Jon Berndt |
| 5 | Date started: August 2010 |
| 6 | |
| 7 | ------------- Copyright (C) 2010 Jon S. Berndt ([email protected]) ------------- |
| 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 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 | SENTRY |
| 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 29 | |
| 30 | #ifndef FGMODELFUNCTIONS_H |
| 31 | #define FGMODELFUNCTIONS_H |
| 32 | |
| 33 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 34 | INCLUDES |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 36 | |
| 37 | #include "FGJSBBase.h" |
| 38 | #include "input_output/FGPropertyReader.h" |
| 39 | |
| 40 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 41 | FORWARD DECLARATIONS |
| 42 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 43 | |
| 44 | namespace JSBSim { |
| 45 | |
| 46 | class FGFunction; |
| 47 | class Element; |
| 48 | class FGPropertyManager; |
| 49 | class FGFDMExec; |
| 50 | |
| 51 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 52 | CLASS DOCUMENTATION |
| 53 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 54 | |
| 55 | /** The model functions class provides the capability for loading, storing, and |
| 56 | executing arbitrary functions. |
| 57 | For certain classes, such as the engine, aerodynamics, ground reactions, |
| 58 | mass balance, etc., it can be useful to incorporate special functions that |
| 59 | can operate on the local model parameters before and/or after the model |
| 60 | executes. For example, there is no inherent chamber pressure calculation |
| 61 | done in the rocket engine model. However, an arbitrary function can be added |
| 62 | to a specific rocket engine XML configuration file. It would be tagged with |
| 63 | a "pre" or "post" type attribute to denote whether the function is to be |
| 64 | executed before or after the standard model algorithm. |
| 65 | @author Jon Berndt |
| 66 | */ |
| 67 | |
| 68 | /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 | DECLARATION: FGModelFunctions |
| 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ |
| 71 | |
| 72 | class FGModelFunctions : public FGJSBBase |
| 73 | { |
| 74 | public: |
| 75 | virtual ~FGModelFunctions(); |
| 76 | void RunPreFunctions(void); |
| 77 | void RunPostFunctions(void); |
| 78 | bool Load(Element* el, FGFDMExec* fdmex, std::string prefix=""); |
| 79 | void PreLoad(Element* el, FGFDMExec* fdmex, std::string prefix=""); |
| 80 | void PostLoad(Element* el, FGFDMExec* fdmex, std::string prefix=""); |
| 81 | |
| 82 | /** Gets the strings for the current set of functions. |
| 83 | @param delimeter either a tab or comma string depending on output type |
| 84 | @return a string containing the descriptive names for all functions */ |
| 85 | std::string GetFunctionStrings(const std::string& delimeter) const; |
| 86 | |
| 87 | /** Gets the function values. |
| 88 | @param delimeter either a tab or comma string depending on output type |
| 89 | @return a string containing the numeric values for the current set of |
| 90 | functions */ |
| 91 | std::string GetFunctionValues(const std::string& delimeter) const; |
| 92 | |
| 93 | /** Get one of the "pre" function |
| 94 | @param name the name of the requested function. |
| 95 | @return a pointer to the function (NULL if not found) |
| 96 | */ |
| 97 | FGFunction* GetPreFunction(const std::string& name); |
| 98 | |
| 99 | protected: |
| 100 | std::vector <FGFunction*> PreFunctions; |
| 101 | std::vector <FGFunction*> PostFunctions; |
| 102 | FGPropertyReader LocalProperties; |
| 103 | |
| 104 | virtual bool InitModel(void); |
| 105 | }; |
| 106 | |
| 107 | } // namespace JSBSim |
| 108 | |
| 109 | #endif |