]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGOutput.h
Clean up header file use of iostream and "using" declarations
[flightgear.git] / src / FDM / JSBSim / models / FGOutput.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGOutput.h
4  Author:       Jon Berndt
5  Date started: 12/2/98
6
7  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.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 HISTORY
27 --------------------------------------------------------------------------------
28 12/02/98   JSB   Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGOUTPUT_H
35 #define FGOUTPUT_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #include "FGModel.h"
42
43 #ifdef FGFS
44 #  include <simgear/compiler.h>
45 #  include STL_FSTREAM
46 #else
47 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
48 #    include <fstream.h>
49 #  else
50 #    include <fstream>
51 #  endif
52 #endif
53
54 #include <string>
55 #include <vector>
56
57 #include <input_output/FGfdmSocket.h>
58 #include <input_output/FGXMLFileRead.h>
59
60 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 DEFINITIONS
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
63
64 #define ID_OUTPUT "$Id$"
65
66 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 FORWARD DECLARATIONS
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
69
70 namespace JSBSim {
71
72 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 CLASS DOCUMENTATION
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
75
76 /** Handles simulation output.
77     OUTPUT section definition
78
79     The following specifies the way that JSBSim writes out data.
80
81     NAME is the filename you want the output to go to
82
83     TYPE can be:
84       CSV       Comma separated data. If a filename is supplied then the data
85                 goes to that file. If COUT or cout is specified, the data goes
86                 to stdout. If the filename is a null filename the data goes to
87                 stdout, as well.
88       SOCKET    Will eventually send data to a socket output, where NAME
89                 would then be the IP address of the machine the data should be
90                 sent to. DON'T USE THIS YET!
91       TABULAR   Columnar data. NOT IMPLEMENTED YET!
92       TERMINAL  Output to terminal. NOT IMPLEMENTED YET!
93       NONE      Specifies to do nothing. THis setting makes it easy to turn on and
94                 off the data output without having to mess with anything else.
95
96     The arguments that can be supplied, currently, are
97
98     RATE_IN_HZ  An integer rate in times-per-second that the data is output. This
99                 value may not be *exactly* what you want, due to the dependence
100                 on dt, the cycle rate for the FDM.
101
102     The following parameters tell which subsystems of data to output:
103
104     SIMULATION       ON|OFF
105     ATMOSPHERE       ON|OFF
106     MASSPROPS        ON|OFF
107     AEROSURFACES     ON|OFF
108     RATES            ON|OFF
109     VELOCITIES       ON|OFF
110     FORCES           ON|OFF
111     MOMENTS          ON|OFF
112     POSITION         ON|OFF
113     COEFFICIENTS     ON|OFF
114     GROUND_REACTIONS ON|OFF
115     FCS              ON|OFF
116     PROPULSION       ON|OFF
117
118     NOTE that Time is always output with the data.
119     @version $Id$
120  */
121
122 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
123 CLASS DECLARATION
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
125
126 class FGOutput : public FGModel, public FGXMLFileRead
127 {
128 public:
129   FGOutput(FGFDMExec*);
130   ~FGOutput();
131
132   bool Run(void);
133
134   void DelimitedOutput(string);
135   void SocketOutput(void);
136   void SocketStatusOutput(string);
137   void SetType(string);
138   void SetSubsystems(int tt) {SubSystems = tt;}
139   inline void Enable(void) { enabled = true; }
140   inline void Disable(void) { enabled = false; }
141   inline bool Toggle(void) {enabled = !enabled; return enabled;}
142   bool Load(Element* el);
143   void SetOutputFileName(string fname) {Filename = fname;}
144   void SetDirectivesFile(string fname) {DirectivesFile = fname;}
145   string GetOutputFileName(void) const {return Filename;}
146
147   /// Subsystem types for specifying which will be output in the FDM data logging
148   enum  eSubSystems {
149     /** Subsystem: Simulation (= 1)          */ ssSimulation      = 1,
150     /** Subsystem: Aerosurfaces (= 2)        */ ssAerosurfaces    = 2,
151     /** Subsystem: Body rates (= 4)          */ ssRates           = 4,
152     /** Subsystem: Velocities (= 8)          */ ssVelocities      = 8,
153     /** Subsystem: Forces (= 16)             */ ssForces          = 16,
154     /** Subsystem: Moments (= 32)            */ ssMoments         = 32,
155     /** Subsystem: Atmosphere (= 64)         */ ssAtmosphere      = 64,
156     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
157     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
158     /** Subsystem: Propagate (= 512)         */ ssPropagate       = 512,
159     /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
160     /** Subsystem: FCS (= 2048)              */ ssFCS             = 2048,
161     /** Subsystem: Propulsion (= 4096)       */ ssPropulsion      = 4096
162   } subsystems;
163
164 private:
165   enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
166   bool sFirstPass, dFirstPass, enabled;
167   int SubSystems;
168   std::string output_file_name, delimeter, Filename, DirectivesFile;
169   std::ofstream datafile;
170   FGfdmSocket* socket;
171   std::vector <FGPropertyManager*> OutputProperties;
172
173   void Debug(int from);
174 };
175 }
176 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 #endif
178