]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGExternalReactions.h
sync with JSB JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGExternalReactions.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGExternalReactions.h
4  Author:       David P. Culp
5  Date started: 17/11/06
6
7  ------------- Copyright (C) 2006  David P. Culp (davidculp2@comcast.net) -------------
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 HISTORY
27 --------------------------------------------------------------------------------
28 17/11/06   DPC   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGEXTERNALREACTIONS_H
35 #define FGEXTERNALREACTIONS_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include <vector>
42 #include "FGModel.h"
43 #include "FGExternalForce.h"
44 #include "input_output/FGXMLFileRead.h"
45
46
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 DEFINITIONS
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51 #define ID_EXTERNALREACTIONS "$Id: FGExternalReactions.h,v 1.14 2011/10/31 14:54:41 bcoconni Exp $"
52
53 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54 FORWARD DECLARATIONS
55 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
56
57 namespace JSBSim {
58
59 class Element;
60
61 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 CLASS DOCUMENTATION
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
64
65 /** Manages the external and/or arbitrary forces.
66     The external reactions capability in JSBSim really should be named
67     "arbitrary forces", because this feature can be used to model a wide
68     variety of forces that act on a vehicle. Some examples include: parachutes,
69     catapult, arresting hook, and tow line.
70     
71     This class acts similarly to the other "manager classes" (FGPropulsion, 
72     FGFCS, FGGroundReactions, FGAerodynamics) because it manages collections
73     of constituent forces. The individual forces are implemented with the
74     FGExternalForce class.
75     
76     The format of the <em>optional</em> external reactions section in the config
77     file is as follows:
78     
79     @code
80 <external_reactions>
81
82   <!-- Interface properties, a.k.a. property declarations -->
83   <property> ... </property>
84     
85   <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
86     ...
87   </force>
88
89   <!-- Additional force definitions may follow -->
90   <force name="name" frame="BODY | LOCAL | WIND" unit="unit">
91     ...
92   </force>
93
94 </external_reactions>
95     @endcode
96
97     See the FGExternalForce class for more information on the format of the
98     force specification itself.
99     
100     When force elements are encountered in the configuration file, a new instance
101     of the FGExternalForce class is created and a pointer to the class is pushed
102     onto the Forces vector.
103     
104     This class is one of a few of the manager classes that allows properties
105     to be "declared". In code, these are represented by the
106     <em>interface_properties</em> vector. Properties that have not yet been
107     created in an already parsed section of the configuration file and that are
108     used in the definition of an external force should be declared in the
109     external_reactions section because they will not be created automatically,
110     and so would cause an error, since the property cannot be found to exist.
111         
112     See the FGExternalForce documentation for details on how forces are
113     actually calculated.
114   */
115
116 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 CLASS DECLARATION
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
119
120 class FGExternalReactions : public FGModel, public FGXMLFileRead
121 {
122 public:
123   /** Constructor.
124       @param fdmex pointer to the main executive class.
125   */
126   FGExternalReactions(FGFDMExec* fdmex);
127   
128   /** Destructor.
129       Within the destructor the Forces and interface_properties vectors are
130       cleared out and the items pointed to are deleted.
131   */
132   ~FGExternalReactions(void);
133
134   bool InitModel(void);
135
136   /** Sum all the constituent forces for this cycle.
137       Can pass in a value indicating if the executive is directing the simulation to Hold.
138       @param Holding if true, the executive has been directed to hold the sim from 
139                      advancing time. Some models may ignore this flag, such as the Input
140                      model, which may need to be active to listen on a socket for the
141                      "Resume" command to be given.
142       @return true always.  */
143   bool Run(bool Holding);
144   
145   /** Loads the external forces from the XML configuration file.
146       If the external_reactions section is encountered in the vehicle configuration
147       file, this Load() method is called. All external forces will be parsed, and 
148       a FGExternalForce object will be instantiated for each force definition.
149       @param el a pointer to the XML element holding the external reactions definition.
150   */
151   bool Load(Element* el);
152
153   /** Retrieves the total forces defined in the external reactions.
154       @return the total force in pounds.
155   */
156   const FGColumnVector3& GetForces(void) const {return vTotalForces;}
157   double GetForces(int idx) const {return vTotalForces(idx);}
158
159   /** Retrieves the total moment resulting from the forces defined in the external reactions.
160       @return the total moment in foot-pounds.
161   */
162   const FGColumnVector3& GetMoments(void) const {return vTotalMoments;}
163   double GetMoments(int idx) const {return vTotalMoments(idx);}
164
165 private:
166
167   std::vector <FGExternalForce*> Forces;
168   unsigned int numForces;
169   FGColumnVector3 vTotalForces;
170   FGColumnVector3 vTotalMoments;
171
172   bool NoneDefined;
173
174   void bind(void);
175   void Debug(int from);
176 };
177 }
178 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 #endif
180