1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 Author: Bertrand Coconnier
7 ------------- Copyright (C) 2011 Bertrand Coconnier -------------
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
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
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.
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.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
34 #ifndef FGOUTPUTTYPE_H
35 #define FGOUTPUTTYPE_H
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
41 #include "models/FGModel.h"
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
47 #define ID_OUTPUTTYPE "$Id: FGOutputType.h,v 1.5 2013/01/26 17:06:49 bcoconni Exp $"
49 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
65 class FGAccelerations;
67 class FGGroundReactions;
68 class FGExternalReactions;
69 class FGBuoyantForces;
71 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75 /** Abstract class to provide functions generic to all the output directives.
76 This class is used by the output manager FGOutput to manage a list of
77 different output classes without needing to know the details of each one of
78 them. It also provides the functions that are common to all the output
81 The class inherits from FGModelFunctions so it is possible to define
82 functions that execute before or after the output is generated. Such
83 functions need to be tagged with a "pre" or "post" type attribute to denote
84 the sequence in which they should be executed.
86 The class mimics some functionalities of FGModel (methods InitModel(),
87 Run() and SetRate()). However it does not inherit from FGModel since it is
88 conceptually different from the model paradigm.
91 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
95 class FGOutputType : public FGModel
98 /** Constructor (implement the FGModel interface).
99 @param fdmex a pointer to the parent executive object
101 FGOutputType(FGFDMExec* fdmex);
104 virtual ~FGOutputType();
106 /** Set the idx for this output instance
107 @param idx ID of the output instance that is constructed
109 void SetIdx(int idx);
111 /** Set the output rate for this output instances.
112 @param rtHz new output rate in Hz */
113 void SetRate(double rtHz);
115 /** Set the activated subsystems for this output instance.
116 @param subSystems bitfield that describes the activated subsystems
117 @param outputProperties list of properties that should be output
119 void SetSubSystems(int subSystems) { SubSystems = subSystems; }
121 /** Set the list of properties that should be output for this output instance.
122 @param outputProperties list of properties that should be output
124 void SetOutputProperties(std::vector<FGPropertyNode_ptr> & outputProperties)
126 OutputProperties = outputProperties;
129 /** Overwrites the name identifier under which the output will be logged.
130 This method is taken into account if it is called before
131 FGFDMExec::RunIC() otherwise it is ignored until the next call to
133 @param name new name */
134 virtual void SetOutputName(const std::string& name) { Name = name; }
136 /** Get the name identifier to which the output will be directed.
137 @result the name identifier.*/
138 virtual const std::string& GetOutputName(void) const { return Name; }
140 /** Init the output directives from an XML file (implement the FGModel interface).
141 @param element XML Element that is pointing to the output directives
143 virtual bool Load(Element* el);
145 /// Init the output model according to its configitation.
146 virtual bool InitModel(void);
148 /** Executes the output directives (implement the FGModel interface).
149 This method checks that the current time step matches the output
150 rate and calls the registered "pre" functions, the output
151 generation and finally the "post" functions.
152 @result false if no error.
154 bool Run(bool Holding);
156 /** Generate the output. This is a pure method so it must be implemented by
157 the classes that inherits from FGOutputType. The Print name may not be
158 relevant to all outputs but it has been kept for backward compatibility.
160 virtual void Print(void) = 0;
162 /** Reset the output prior to a restart of the simulation. This method should
163 be called when the simulation is restarted with, for example, new initial
164 conditions. When this method is executed the output instance can take
165 special actions such as closing the current output file and open a new
166 one with a different name. */
168 virtual void SetStartNewOutput(void) {}
170 /// Enables the output generation.
171 void Enable(void) { enabled = true; }
172 /// Disables the output generation.
173 void Disable(void) { enabled = false; }
174 /** Toggles the output generation.
175 @result the output generation status i.e. true if the output has been
176 enabled, false if the output has been disabled. */
177 bool Toggle(void) {enabled = !enabled; return enabled;}
179 /// Subsystem types for specifying which will be output in the FDM data logging
181 /** Subsystem: Simulation (= 1) */ ssSimulation = 1,
182 /** Subsystem: Aerosurfaces (= 2) */ ssAerosurfaces = 2,
183 /** Subsystem: Body rates (= 4) */ ssRates = 4,
184 /** Subsystem: Velocities (= 8) */ ssVelocities = 8,
185 /** Subsystem: Forces (= 16) */ ssForces = 16,
186 /** Subsystem: Moments (= 32) */ ssMoments = 32,
187 /** Subsystem: Atmosphere (= 64) */ ssAtmosphere = 64,
188 /** Subsystem: Mass Properties (= 128) */ ssMassProps = 128,
189 /** Subsystem: Coefficients (= 256) */ ssAeroFunctions = 256,
190 /** Subsystem: Propagate (= 512) */ ssPropagate = 512,
191 /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
192 /** Subsystem: FCS (= 2048) */ ssFCS = 2048,
193 /** Subsystem: Propulsion (= 4096) */ ssPropulsion = 4096
199 std::vector <FGPropertyNode_ptr> OutputProperties;
200 std::vector <std::string> OutputCaptions;
203 FGAerodynamics* Aerodynamics;
204 FGAuxiliary* Auxiliary;
205 FGAircraft* Aircraft;
206 FGAtmosphere* Atmosphere;
208 FGPropulsion* Propulsion;
209 FGMassBalance* MassBalance;
210 FGPropagate* Propagate;
211 FGAccelerations* Accelerations;
213 FGGroundReactions* GroundReactions;
214 FGExternalReactions* ExternalReactions;
215 FGBuoyantForces* BuoyantForces;
217 void Debug(int from);
220 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%