]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGOutput.h
Sync. w. JSBSim CVS.
[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 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 General Public License for more
17  details.
18
19  You should have received a copy of the GNU 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 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_IOSTREAM
46 #  include STL_FSTREAM
47 #else
48 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
49 #    include <iostream.h>
50 #    include <fstream.h>
51 #  else
52 #    include <iostream>
53 #    include <fstream>
54 #  endif
55 #endif
56
57 #include <input_output/FGfdmSocket.h>
58 #include <input_output/FGXMLElement.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
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
144   /// Subsystem types for specifying which will be output in the FDM data logging
145   enum  eSubSystems {
146     /** Subsystem: Simulation (= 1)          */ ssSimulation      = 1,
147     /** Subsystem: Aerosurfaces (= 2)        */ ssAerosurfaces    = 2,
148     /** Subsystem: Body rates (= 4)          */ ssRates           = 4,
149     /** Subsystem: Velocities (= 8)          */ ssVelocities      = 8,
150     /** Subsystem: Forces (= 16)             */ ssForces          = 16,
151     /** Subsystem: Moments (= 32)            */ ssMoments         = 32,
152     /** Subsystem: Atmosphere (= 64)         */ ssAtmosphere      = 64,
153     /** Subsystem: Mass Properties (= 128)   */ ssMassProps       = 128,
154     /** Subsystem: Coefficients (= 256)      */ ssCoefficients    = 256,
155     /** Subsystem: Propagate (= 512)         */ ssPropagate       = 512,
156     /** Subsystem: Ground Reactions (= 1024) */ ssGroundReactions = 1024,
157     /** Subsystem: FCS (= 2048)              */ ssFCS             = 2048,
158     /** Subsystem: Propulsion (= 4096)       */ ssPropulsion      = 4096
159   } subsystems;
160
161 private:
162   bool sFirstPass, dFirstPass, enabled;
163   int SubSystems;
164   string output_file_name, delimeter, Filename;
165   enum {otNone, otCSV, otTab, otSocket, otTerminal, otUnknown} Type;
166   ofstream datafile;
167   FGfdmSocket* socket;
168   vector <FGPropertyManager*> OutputProperties;
169   void Debug(int from);
170 };
171 }
172 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 #endif
174