JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGFunction.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3 Header: FGFunction.h
4 Author: Jon Berndt
5 Date started: August 25 2004
6 
7  ------------- Copyright (C) 2001 Jon S. Berndt (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 Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  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 with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27 SENTRY
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
29 
30 #ifndef FGFUNCTION_H
31 #define FGFUNCTION_H
32 
33 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 INCLUDES
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
36 
37 #include <vector>
38 #include <string>
39 #include "FGParameter.h"
40 #include "input_output/FGPropertyManager.h"
41 
42 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 DEFINITIONS
44 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
45 
46 #define ID_FUNCTION "$Id: FGFunction.h,v 1.32 2015/07/12 13:03:23 bcoconni Exp $"
47 
48 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 FORWARD DECLARATIONS
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
51 
52 namespace JSBSim {
53 
54 class Element;
55 
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 
693 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694 DECLARATION: FGFunction
695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
696 
697 // Todo: Does this class need a copy constructor, like FGLGear?
698 
699 class FGFunction : public FGParameter
700 {
701 public:
702 
718  FGFunction(FGPropertyManager* PropertyManager, Element* element, const std::string& prefix="");
720  virtual ~FGFunction();
721 
724  double GetValue(void) const;
725 
728  std::string GetValueAsString(void) const;
729 
731  std::string GetName(void) const {return Name;}
732 
739  void cacheValue(bool shouldCache);
740 
741 private:
742  std::vector <FGParameter*> Parameters;
743  FGPropertyManager* const PropertyManager;
744  bool cached;
745  double invlog2val;
746  std::string Prefix;
747  static const std::string description_string;
748  static const std::string property_string;
749  static const std::string value_string;
750  static const std::string table_string;
751  static const std::string p_string;
752  static const std::string v_string;
753  static const std::string t_string;
754  static const std::string function_string;
755  static const std::string sum_string;
756  static const std::string difference_string;
757  static const std::string product_string;
758  static const std::string quotient_string;
759  static const std::string pow_string;
760  static const std::string sqrt_string;
761  static const std::string toradians_string;
762  static const std::string todegrees_string;
763  static const std::string exp_string;
764  static const std::string log2_string;
765  static const std::string ln_string;
766  static const std::string log10_string;
767  static const std::string abs_string;
768  static const std::string sign_string;
769  static const std::string sin_string;
770  static const std::string cos_string;
771  static const std::string tan_string;
772  static const std::string asin_string;
773  static const std::string acos_string;
774  static const std::string atan_string;
775  static const std::string atan2_string;
776  static const std::string pi_string;
777  static const std::string min_string;
778  static const std::string max_string;
779  static const std::string avg_string;
780  static const std::string fraction_string;
781  static const std::string mod_string;
782  static const std::string random_string;
783  static const std::string urandom_string;
784  static const std::string integer_string;
785  static const std::string rotation_alpha_local_string;
786  static const std::string rotation_beta_local_string;
787  static const std::string rotation_gamma_local_string;
788  static const std::string rotation_bf_to_wf_string;
789  static const std::string rotation_wf_to_bf_string;
790  static const std::string lessthan_string;
791  static const std::string lessequal_string;
792  static const std::string greatthan_string;
793  static const std::string greatequal_string;
794  static const std::string equal_string;
795  static const std::string notequal_string;
796  static const std::string and_string;
797  static const std::string or_string;
798  static const std::string not_string;
799  static const std::string ifthen_string;
800  static const std::string switch_string;
801  static const std::string interpolate1d_string;
802  double cachedValue;
803  enum functionType {eTopLevel=0, eProduct, eDifference, eSum, eQuotient, ePow, eSqrt, eToRadians,
804  eToDegrees, eExp, eAbs, eSign, eSin, eCos, eTan, eASin, eACos, eATan, eATan2,
805  eMin, eMax, eAvg, eFrac, eInteger, eMod, eRandom, eUrandom, ePi,
806  eLog2, eLn, eLog10, eLT, eLE, eGE, eGT, eEQ, eNE, eAND, eOR, eNOT,
807  eIfThen, eSwitch, eInterpolate1D, eRotation_alpha_local,
808  eRotation_beta_local, eRotation_gamma_local, eRotation_bf_to_wf,
809  eRotation_wf_to_bf} Type;
810  std::string Name;
811  std::string sCopyTo; // Property name to copy function value to
812  FGPropertyNode_ptr pCopyTo; // Property node for CopyTo property string
813 
814  unsigned int GetBinary(double) const;
815  void bind(void);
816  void Debug(int from);
817 };
818 
819 } // namespace JSBSim
820 
821 #endif
virtual ~FGFunction()
Destructor.
Definition: FGFunction.cpp:333
std::string GetValueAsString(void) const
The value that the function evaluates to, as a string.
Definition: FGFunction.cpp:777
Represents various types of parameters.
Definition: FGParameter.h:63
std::string GetName(void) const
Retrieves the name of the function.
Definition: FGFunction.h:731
double GetValue(void) const
Retrieves the value of the function object.
Definition: FGFunction.cpp:364
void cacheValue(bool shouldCache)
Specifies whether to cache the value of the function, so it is calculated only once per frame...
Definition: FGFunction.cpp:340
Represents a mathematical function.
Definition: FGFunction.h:699
FGFunction(FGPropertyManager *PropertyManager, Element *element, const std::string &prefix="")
Constructor.
Definition: FGFunction.cpp:111