1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header:       FGModel.h
4  Author:       Jon Berndt
5  Date started: 11/21/98
6 
7  ------------- Copyright (C) 1999  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
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 11/22/98   JSB   Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGMODEL_H
35 #define FGMODEL_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include <string>
42 
43 #include "math/FGModelFunctions.h"
44 #include "simgear/misc/sg_path.hxx"
45 
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 FORWARD DECLARATIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 
50 namespace JSBSim {
51 
52 class FGFDMExec;
53 class Element;
54 class FGPropertyManager;
55 
56 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59 
60 /** Base class for all scheduled JSBSim models
61     @author Jon S. Berndt
62   */
63 
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 CLASS DECLARATION
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67 
68 class FGModel : public FGModelFunctions
69 {
70 public:
71 
72   /// Constructor
73   explicit FGModel(FGFDMExec*);
74   /// Destructor
75   ~FGModel() override;
76 
77   /** Runs the model; called by the Executive.
78       Can pass in a value indicating if the executive is directing the simulation to Hold.
79       @param Holding if true, the executive has been directed to hold the sim from
80                      advancing time. Some models may ignore this flag, such as the Input
81                      model, which may need to be active to listen on a socket for the
82                      "Resume" command to be given. The Holding flag is not used in the base
83                      FGModel class.
84       @see JSBSim.cpp documentation
85       @return false if no error */
86   virtual bool Run(bool Holding);
87 
88   bool InitModel(void) override;
89   /// Set the ouput rate for the model in frames
SetRate(unsigned int tt)90   void SetRate(unsigned int tt) {rate = tt;}
91   /// Get the output rate for the model in frames
GetRate(void)92   unsigned int GetRate(void)   {return rate;}
GetExec(void)93   FGFDMExec* GetExec(void)     {return FDMExec;}
94 
SetPropertyManager(FGPropertyManager * fgpm)95   void SetPropertyManager(FGPropertyManager *fgpm) { PropertyManager=fgpm;}
96   virtual SGPath FindFullPathName(const SGPath& path) const;
GetName(void)97   const std::string& GetName(void) { return Name; }
98 
99 protected:
100   unsigned int exe_ctr;
101   unsigned int rate;
102   std::string Name;
103 
104   /** Loads this model.
105       @param el      a pointer to the element
106       @param preLoad true if model functions and local properties must be
107                      preloaded.
108       @return true if model is successfully loaded*/
109   virtual bool Load(Element* el, bool preLoad);
110 
111   virtual void Debug(int from);
112 
113   FGFDMExec*         FDMExec;
114   FGPropertyManager* PropertyManager;
115 };
116 }
117 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 #endif
119